Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2016-2017 Intel Corporation
3 : : */
4 : :
5 : : #include <rte_cryptodev.h>
6 : : #include <rte_ether.h>
7 : : #include <rte_ip.h>
8 : :
9 : : #include "cperf_ops.h"
10 : : #include "cperf_test_vectors.h"
11 : :
12 : : static void
13 : 0 : cperf_set_ops_asym_modex(struct rte_crypto_op **ops,
14 : : uint32_t src_buf_offset __rte_unused,
15 : : uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops,
16 : : void *sess,
17 : : const struct cperf_options *options,
18 : : const struct cperf_test_vector *test_vector __rte_unused,
19 : : uint16_t iv_offset __rte_unused,
20 : : uint32_t *imix_idx __rte_unused,
21 : : uint64_t *tsc_start __rte_unused)
22 : : {
23 : : uint16_t i;
24 : :
25 : 0 : for (i = 0; i < nb_ops; i++) {
26 : 0 : struct rte_crypto_asym_op *asym_op = ops[i]->asym;
27 : :
28 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
29 : 0 : asym_op->modex.base.data = options->modex_data->base.data;
30 : 0 : asym_op->modex.base.length = options->modex_data->base.len;
31 : 0 : asym_op->modex.result.data = options->modex_data->result.data;
32 : 0 : asym_op->modex.result.length = options->modex_data->result.len;
33 : : rte_crypto_op_attach_asym_session(ops[i], sess);
34 : : }
35 : 0 : }
36 : :
37 : : static void
38 : 0 : cperf_set_ops_asym_rsa(struct rte_crypto_op **ops,
39 : : uint32_t src_buf_offset __rte_unused,
40 : : uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops,
41 : : void *sess,
42 : : const struct cperf_options *options,
43 : : const struct cperf_test_vector *test_vector __rte_unused,
44 : : uint16_t iv_offset __rte_unused,
45 : : uint32_t *imix_idx __rte_unused,
46 : : uint64_t *tsc_start __rte_unused)
47 : : {
48 : 0 : uint8_t cipher_buf[4096] = {0};
49 : : uint16_t i;
50 : :
51 : 0 : for (i = 0; i < nb_ops; i++) {
52 : 0 : struct rte_crypto_asym_op *asym_op = ops[i]->asym;
53 : :
54 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
55 : 0 : asym_op->rsa.op_type = options->asym_op_type;
56 : 0 : asym_op->rsa.message.data = rsa_plaintext.data;
57 : 0 : asym_op->rsa.message.length = rsa_plaintext.len;
58 : 0 : if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
59 : 0 : asym_op->rsa.sign.data = cipher_buf;
60 : 0 : asym_op->rsa.sign.length = options->rsa_data->n.length;
61 : 0 : } else if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
62 : 0 : asym_op->rsa.cipher.data = cipher_buf;
63 : 0 : asym_op->rsa.cipher.length = options->rsa_data->n.length;
64 : : } else {
65 : : printf("RSA DECRYPT/VERIFY not supported");
66 : : }
67 : 0 : rte_crypto_op_attach_asym_session(ops[i], sess);
68 : : }
69 : 0 : }
70 : :
71 : : static void
72 : 0 : cperf_set_ops_asym_ecdsa(struct rte_crypto_op **ops,
73 : : uint32_t src_buf_offset __rte_unused,
74 : : uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops,
75 : : void *sess,
76 : : const struct cperf_options *options,
77 : : const struct cperf_test_vector *test_vector __rte_unused,
78 : : uint16_t iv_offset __rte_unused,
79 : : uint32_t *imix_idx __rte_unused,
80 : : uint64_t *tsc_start __rte_unused)
81 : : {
82 : : uint16_t i;
83 : :
84 : 0 : for (i = 0; i < nb_ops; i++) {
85 : 0 : struct rte_crypto_asym_op *asym_op = ops[i]->asym;
86 : :
87 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
88 : : rte_crypto_op_attach_asym_session(ops[i], sess);
89 : :
90 : 0 : asym_op->ecdsa.op_type = options->asym_op_type;
91 : 0 : asym_op->ecdsa.message.data = options->secp256r1_data->message.data;
92 : 0 : asym_op->ecdsa.message.length = options->secp256r1_data->message.length;
93 : :
94 : 0 : asym_op->ecdsa.k.data = options->secp256r1_data->k.data;
95 : 0 : asym_op->ecdsa.k.length = options->secp256r1_data->k.length;
96 : :
97 : 0 : asym_op->ecdsa.r.data = options->secp256r1_data->sign_r.data;
98 : 0 : asym_op->ecdsa.r.length = options->secp256r1_data->sign_r.length;
99 : 0 : asym_op->ecdsa.s.data = options->secp256r1_data->sign_s.data;
100 : 0 : asym_op->ecdsa.s.length = options->secp256r1_data->sign_s.length;
101 : : }
102 : 0 : }
103 : :
104 : : static void
105 : 0 : cperf_set_ops_asym_eddsa(struct rte_crypto_op **ops,
106 : : uint32_t src_buf_offset __rte_unused,
107 : : uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops,
108 : : void *sess,
109 : : const struct cperf_options *options,
110 : : const struct cperf_test_vector *test_vector __rte_unused,
111 : : uint16_t iv_offset __rte_unused,
112 : : uint32_t *imix_idx __rte_unused,
113 : : uint64_t *tsc_start __rte_unused)
114 : : {
115 : : uint16_t i;
116 : :
117 : 0 : for (i = 0; i < nb_ops; i++) {
118 : 0 : struct rte_crypto_asym_op *asym_op = ops[i]->asym;
119 : :
120 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
121 : : rte_crypto_op_attach_asym_session(ops[i], sess);
122 : :
123 : 0 : asym_op->eddsa.op_type = options->asym_op_type;
124 : 0 : asym_op->eddsa.message.data = options->eddsa_data->message.data;
125 : 0 : asym_op->eddsa.message.length = options->eddsa_data->message.length;
126 : :
127 : 0 : asym_op->eddsa.instance = options->eddsa_data->instance;
128 : :
129 : 0 : asym_op->eddsa.sign.data = options->eddsa_data->sign.data;
130 : 0 : asym_op->eddsa.sign.length = options->eddsa_data->sign.length;
131 : : }
132 : 0 : }
133 : :
134 : : static void
135 : 0 : cperf_set_ops_asym_sm2(struct rte_crypto_op **ops,
136 : : uint32_t src_buf_offset __rte_unused,
137 : : uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops,
138 : : void *sess,
139 : : const struct cperf_options *options,
140 : : const struct cperf_test_vector *test_vector __rte_unused,
141 : : uint16_t iv_offset __rte_unused,
142 : : uint32_t *imix_idx __rte_unused,
143 : : uint64_t *tsc_start __rte_unused)
144 : : {
145 : : uint16_t i;
146 : :
147 : 0 : for (i = 0; i < nb_ops; i++) {
148 : 0 : struct rte_crypto_asym_op *asym_op = ops[i]->asym;
149 : :
150 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
151 : : rte_crypto_op_attach_asym_session(ops[i], sess);
152 : :
153 : : /* Populate op with operational details */
154 : 0 : asym_op->sm2.hash = options->asym_hash_alg;
155 : :
156 : 0 : asym_op->sm2.op_type = options->asym_op_type;
157 : 0 : asym_op->sm2.message.data = options->sm2_data->message.data;
158 : 0 : asym_op->sm2.message.length = options->sm2_data->message.length;
159 : 0 : asym_op->sm2.cipher.data = options->sm2_data->cipher.data;
160 : 0 : asym_op->sm2.cipher.length = options->sm2_data->cipher.length;
161 : 0 : asym_op->sm2.id.data = options->sm2_data->id.data;
162 : 0 : asym_op->sm2.id.length = options->sm2_data->id.length;
163 : :
164 : 0 : asym_op->sm2.k.data = options->sm2_data->k.data;
165 : 0 : asym_op->sm2.k.length = options->sm2_data->k.length;
166 : :
167 : 0 : asym_op->sm2.r.data = options->sm2_data->sign_r.data;
168 : 0 : asym_op->sm2.r.length = options->sm2_data->sign_r.length;
169 : 0 : asym_op->sm2.s.data = options->sm2_data->sign_s.data;
170 : 0 : asym_op->sm2.s.length = options->sm2_data->sign_s.length;
171 : : }
172 : 0 : }
173 : :
174 : :
175 : : #ifdef RTE_LIB_SECURITY
176 : : static void
177 : 0 : test_ipsec_vec_populate(struct rte_mbuf *m, const struct cperf_options *options,
178 : : const struct cperf_test_vector *test_vector)
179 : : {
180 : 0 : struct rte_ipv4_hdr *ip = rte_pktmbuf_mtod(m, struct rte_ipv4_hdr *);
181 : :
182 : 0 : if (options->is_outbound) {
183 : 0 : memcpy(ip, test_vector->plaintext.data, sizeof(struct rte_ipv4_hdr));
184 : 0 : ip->total_length = rte_cpu_to_be_16(m->pkt_len);
185 : : }
186 : 0 : }
187 : :
188 : : static void
189 : 0 : cperf_set_ops_security(struct rte_crypto_op **ops,
190 : : uint32_t src_buf_offset __rte_unused,
191 : : uint32_t dst_buf_offset __rte_unused,
192 : : uint16_t nb_ops, void *sess,
193 : : const struct cperf_options *options,
194 : : const struct cperf_test_vector *test_vector,
195 : : uint16_t iv_offset __rte_unused, uint32_t *imix_idx,
196 : : uint64_t *tsc_start)
197 : : {
198 : : uint16_t i;
199 : :
200 : 0 : for (i = 0; i < nb_ops; i++) {
201 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
202 : : uint32_t buf_sz;
203 : :
204 : 0 : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ops[i],
205 : : uint32_t *, iv_offset);
206 : 0 : *per_pkt_hfn = options->pdcp_ses_hfn_en ? 0 : PDCP_DEFAULT_HFN;
207 : :
208 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
209 : : rte_security_attach_session(ops[i], sess);
210 : 0 : sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] +
211 : : src_buf_offset);
212 : :
213 : 0 : if (options->op_type == CPERF_PDCP) {
214 : 0 : sym_op->m_src->buf_len = options->segment_sz;
215 : 0 : sym_op->m_src->data_len = options->test_buffer_size;
216 : 0 : sym_op->m_src->pkt_len = sym_op->m_src->data_len;
217 : : }
218 : :
219 : 0 : if (options->op_type == CPERF_DOCSIS) {
220 : 0 : if (options->imix_distribution_count) {
221 : 0 : buf_sz = options->imix_buffer_sizes[*imix_idx];
222 : 0 : *imix_idx = (*imix_idx + 1) % options->pool_sz;
223 : : } else
224 : 0 : buf_sz = options->test_buffer_size;
225 : :
226 : 0 : sym_op->m_src->buf_len = options->segment_sz;
227 : 0 : sym_op->m_src->data_len = buf_sz;
228 : 0 : sym_op->m_src->pkt_len = buf_sz;
229 : :
230 : : /* DOCSIS header is not CRC'ed */
231 : 0 : sym_op->auth.data.offset = options->docsis_hdr_sz;
232 : 0 : sym_op->auth.data.length = buf_sz -
233 : 0 : sym_op->auth.data.offset - RTE_ETHER_CRC_LEN;
234 : : /*
235 : : * DOCSIS header and SRC and DST MAC addresses are not
236 : : * ciphered
237 : : */
238 : 0 : sym_op->cipher.data.offset = sym_op->auth.data.offset +
239 : 0 : RTE_ETHER_HDR_LEN - RTE_ETHER_TYPE_LEN;
240 : 0 : sym_op->cipher.data.length = buf_sz -
241 : : sym_op->cipher.data.offset;
242 : : }
243 : :
244 : : /* Set dest mbuf to NULL if out-of-place (dst_buf_offset = 0) */
245 : 0 : if (dst_buf_offset == 0)
246 : 0 : sym_op->m_dst = NULL;
247 : : else
248 : 0 : sym_op->m_dst = (struct rte_mbuf *)((uint8_t *)ops[i] +
249 : : dst_buf_offset);
250 : : }
251 : :
252 : : RTE_SET_USED(tsc_start);
253 : : RTE_SET_USED(test_vector);
254 : 0 : }
255 : :
256 : : static void
257 : 0 : cperf_set_ops_security_ipsec(struct rte_crypto_op **ops,
258 : : uint32_t src_buf_offset __rte_unused,
259 : : uint32_t dst_buf_offset __rte_unused,
260 : : uint16_t nb_ops, void *sess,
261 : : const struct cperf_options *options,
262 : : const struct cperf_test_vector *test_vector,
263 : : uint16_t iv_offset __rte_unused, uint32_t *imix_idx,
264 : : uint64_t *tsc_start)
265 : : {
266 : 0 : const uint32_t test_buffer_size = options->test_buffer_size;
267 : : uint64_t tsc_start_temp, tsc_end_temp;
268 : : uint16_t i = 0;
269 : :
270 : : RTE_SET_USED(imix_idx);
271 : :
272 : 0 : for (i = 0; i < nb_ops; i++) {
273 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
274 : 0 : struct rte_mbuf *m = sym_op->m_src;
275 : : uint32_t offset = test_buffer_size;
276 : :
277 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
278 : : rte_security_attach_session(ops[i], sess);
279 : 0 : sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] + src_buf_offset);
280 : 0 : sym_op->m_src->pkt_len = test_buffer_size;
281 : :
282 : 0 : while ((m->next != NULL) && (offset >= m->data_len)) {
283 : 0 : offset -= m->data_len;
284 : : m = m->next;
285 : : }
286 : 0 : m->data_len = offset;
287 : : /*
288 : : * If there is not enough room in segment,
289 : : * place the digest in the next segment
290 : : */
291 : 0 : if (rte_pktmbuf_tailroom(m) < options->digest_sz) {
292 : : m = m->next;
293 : : offset = 0;
294 : : }
295 : 0 : m->next = NULL;
296 : :
297 : 0 : sym_op->m_dst = NULL;
298 : : }
299 : :
300 : 0 : if (options->test_file != NULL)
301 : : return;
302 : :
303 : : tsc_start_temp = rte_rdtsc_precise();
304 : :
305 : 0 : for (i = 0; i < nb_ops; i++) {
306 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
307 : 0 : struct rte_mbuf *m = sym_op->m_src;
308 : :
309 : 0 : test_ipsec_vec_populate(m, options, test_vector);
310 : : }
311 : :
312 : : tsc_end_temp = rte_rdtsc_precise();
313 : 0 : *tsc_start += tsc_end_temp - tsc_start_temp;
314 : : }
315 : :
316 : : static void
317 : 0 : cperf_set_ops_security_tls(struct rte_crypto_op **ops,
318 : : uint32_t src_buf_offset __rte_unused,
319 : : uint32_t dst_buf_offset __rte_unused,
320 : : uint16_t nb_ops, void *sess,
321 : : const struct cperf_options *options,
322 : : const struct cperf_test_vector *test_vector,
323 : : uint16_t iv_offset __rte_unused, uint32_t *imix_idx,
324 : : uint64_t *tsc_start)
325 : : {
326 : 0 : const uint32_t test_buffer_size = options->test_buffer_size;
327 : : uint16_t i = 0;
328 : :
329 : : RTE_SET_USED(imix_idx);
330 : : RTE_SET_USED(tsc_start);
331 : : RTE_SET_USED(test_vector);
332 : :
333 : 0 : for (i = 0; i < nb_ops; i++) {
334 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
335 : 0 : struct rte_mbuf *m = sym_op->m_src;
336 : : uint32_t offset = test_buffer_size;
337 : :
338 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
339 : 0 : ops[i]->param1.tls_record.content_type = 0x17;
340 : : rte_security_attach_session(ops[i], sess);
341 : 0 : sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] + src_buf_offset);
342 : 0 : sym_op->m_src->pkt_len = test_buffer_size;
343 : :
344 : 0 : while ((m->next != NULL) && (offset >= m->data_len)) {
345 : 0 : offset -= m->data_len;
346 : : m = m->next;
347 : : }
348 : 0 : m->data_len = offset;
349 : : /*
350 : : * If there is not enough room in segment,
351 : : * place the digest in the next segment
352 : : */
353 : 0 : if ((rte_pktmbuf_tailroom(m)) < options->digest_sz) {
354 : : m = m->next;
355 : 0 : m->data_len = 0;
356 : : }
357 : 0 : m->next = NULL;
358 : :
359 : 0 : sym_op->m_dst = NULL;
360 : : }
361 : 0 : }
362 : : #endif
363 : :
364 : : static void
365 : 0 : cperf_set_ops_null_cipher(struct rte_crypto_op **ops,
366 : : uint32_t src_buf_offset, uint32_t dst_buf_offset,
367 : : uint16_t nb_ops, void *sess,
368 : : const struct cperf_options *options,
369 : : const struct cperf_test_vector *test_vector __rte_unused,
370 : : uint16_t iv_offset __rte_unused, uint32_t *imix_idx,
371 : : uint64_t *tsc_start __rte_unused)
372 : : {
373 : : uint16_t i;
374 : :
375 : 0 : for (i = 0; i < nb_ops; i++) {
376 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
377 : :
378 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
379 : : rte_crypto_op_attach_sym_session(ops[i], sess);
380 : :
381 : 0 : sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] +
382 : : src_buf_offset);
383 : :
384 : : /* Set dest mbuf to NULL if out-of-place (dst_buf_offset = 0) */
385 : 0 : if (dst_buf_offset == 0)
386 : 0 : sym_op->m_dst = NULL;
387 : : else
388 : 0 : sym_op->m_dst = (struct rte_mbuf *)((uint8_t *)ops[i] +
389 : : dst_buf_offset);
390 : :
391 : : /* cipher parameters */
392 : 0 : if (options->imix_distribution_count) {
393 : 0 : sym_op->cipher.data.length =
394 : 0 : options->imix_buffer_sizes[*imix_idx];
395 : 0 : *imix_idx = (*imix_idx + 1) % options->pool_sz;
396 : : } else
397 : 0 : sym_op->cipher.data.length = options->test_buffer_size;
398 : 0 : sym_op->cipher.data.offset = 0;
399 : : }
400 : 0 : }
401 : :
402 : : static void
403 : 0 : cperf_set_ops_null_auth(struct rte_crypto_op **ops,
404 : : uint32_t src_buf_offset, uint32_t dst_buf_offset,
405 : : uint16_t nb_ops, void *sess,
406 : : const struct cperf_options *options,
407 : : const struct cperf_test_vector *test_vector __rte_unused,
408 : : uint16_t iv_offset __rte_unused, uint32_t *imix_idx,
409 : : uint64_t *tsc_start __rte_unused)
410 : : {
411 : : uint16_t i;
412 : :
413 : 0 : for (i = 0; i < nb_ops; i++) {
414 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
415 : :
416 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
417 : : rte_crypto_op_attach_sym_session(ops[i], sess);
418 : :
419 : 0 : sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] +
420 : : src_buf_offset);
421 : :
422 : : /* Set dest mbuf to NULL if out-of-place (dst_buf_offset = 0) */
423 : 0 : if (dst_buf_offset == 0)
424 : 0 : sym_op->m_dst = NULL;
425 : : else
426 : 0 : sym_op->m_dst = (struct rte_mbuf *)((uint8_t *)ops[i] +
427 : : dst_buf_offset);
428 : :
429 : : /* auth parameters */
430 : 0 : if (options->imix_distribution_count) {
431 : 0 : sym_op->auth.data.length =
432 : 0 : options->imix_buffer_sizes[*imix_idx];
433 : 0 : *imix_idx = (*imix_idx + 1) % options->pool_sz;
434 : : } else
435 : 0 : sym_op->auth.data.length = options->test_buffer_size;
436 : 0 : sym_op->auth.data.offset = 0;
437 : : }
438 : 0 : }
439 : :
440 : : static void
441 : 0 : cperf_set_ops_cipher(struct rte_crypto_op **ops,
442 : : uint32_t src_buf_offset, uint32_t dst_buf_offset,
443 : : uint16_t nb_ops, void *sess,
444 : : const struct cperf_options *options,
445 : : const struct cperf_test_vector *test_vector,
446 : : uint16_t iv_offset, uint32_t *imix_idx,
447 : : uint64_t *tsc_start __rte_unused)
448 : : {
449 : : uint16_t i;
450 : :
451 : 0 : for (i = 0; i < nb_ops; i++) {
452 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
453 : :
454 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
455 : : rte_crypto_op_attach_sym_session(ops[i], sess);
456 : :
457 : 0 : sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] +
458 : : src_buf_offset);
459 : :
460 : : /* Set dest mbuf to NULL if out-of-place (dst_buf_offset = 0) */
461 : 0 : if (dst_buf_offset == 0)
462 : 0 : sym_op->m_dst = NULL;
463 : : else
464 : 0 : sym_op->m_dst = (struct rte_mbuf *)((uint8_t *)ops[i] +
465 : : dst_buf_offset);
466 : :
467 : : /* cipher parameters */
468 : 0 : if (options->imix_distribution_count) {
469 : 0 : sym_op->cipher.data.length =
470 : 0 : options->imix_buffer_sizes[*imix_idx];
471 : 0 : *imix_idx = (*imix_idx + 1) % options->pool_sz;
472 : : } else
473 : 0 : sym_op->cipher.data.length = options->test_buffer_size;
474 : :
475 : 0 : if (options->cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
476 : 0 : options->cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
477 : : options->cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3)
478 : 0 : sym_op->cipher.data.length <<= 3;
479 : :
480 : 0 : sym_op->cipher.data.offset = 0;
481 : : }
482 : :
483 : 0 : if (options->test == CPERF_TEST_TYPE_VERIFY) {
484 : 0 : for (i = 0; i < nb_ops; i++) {
485 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ops[i],
486 : : uint8_t *, iv_offset);
487 : :
488 : 0 : memcpy(iv_ptr, test_vector->cipher_iv.data,
489 : 0 : test_vector->cipher_iv.length);
490 : :
491 : : }
492 : : }
493 : 0 : }
494 : :
495 : : static void
496 : 0 : cperf_set_ops_auth(struct rte_crypto_op **ops,
497 : : uint32_t src_buf_offset, uint32_t dst_buf_offset,
498 : : uint16_t nb_ops, void *sess,
499 : : const struct cperf_options *options,
500 : : const struct cperf_test_vector *test_vector,
501 : : uint16_t iv_offset, uint32_t *imix_idx,
502 : : uint64_t *tsc_start __rte_unused)
503 : : {
504 : : uint16_t i;
505 : :
506 : 0 : for (i = 0; i < nb_ops; i++) {
507 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
508 : :
509 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
510 : : rte_crypto_op_attach_sym_session(ops[i], sess);
511 : :
512 : 0 : sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] +
513 : : src_buf_offset);
514 : :
515 : : /* Set dest mbuf to NULL if out-of-place (dst_buf_offset = 0) */
516 : 0 : if (dst_buf_offset == 0)
517 : 0 : sym_op->m_dst = NULL;
518 : : else
519 : 0 : sym_op->m_dst = (struct rte_mbuf *)((uint8_t *)ops[i] +
520 : : dst_buf_offset);
521 : :
522 : 0 : if (test_vector->auth_iv.length) {
523 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ops[i],
524 : : uint8_t *,
525 : : iv_offset);
526 : 0 : memcpy(iv_ptr, test_vector->auth_iv.data,
527 : : test_vector->auth_iv.length);
528 : : }
529 : :
530 : : /* authentication parameters */
531 : 0 : if (options->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) {
532 : 0 : sym_op->auth.digest.data = test_vector->digest.data;
533 : 0 : sym_op->auth.digest.phys_addr =
534 : 0 : test_vector->digest.phys_addr;
535 : : } else {
536 : :
537 : 0 : uint32_t offset = options->test_buffer_size;
538 : : struct rte_mbuf *buf, *tbuf;
539 : :
540 : 0 : if (options->out_of_place) {
541 : 0 : buf = sym_op->m_dst;
542 : : } else {
543 : 0 : tbuf = sym_op->m_src;
544 : 0 : while ((tbuf->next != NULL) &&
545 : 0 : (offset >= tbuf->data_len)) {
546 : 0 : offset -= tbuf->data_len;
547 : : tbuf = tbuf->next;
548 : : }
549 : : /*
550 : : * If there is not enough room in segment,
551 : : * place the digest in the next segment
552 : : */
553 : 0 : if ((tbuf->data_len - offset) < options->digest_sz) {
554 : : tbuf = tbuf->next;
555 : : offset = 0;
556 : : }
557 : : buf = tbuf;
558 : : }
559 : :
560 : 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(buf,
561 : : uint8_t *, offset);
562 : 0 : sym_op->auth.digest.phys_addr =
563 : 0 : rte_pktmbuf_iova_offset(buf, offset);
564 : :
565 : : }
566 : :
567 : 0 : if (options->imix_distribution_count) {
568 : 0 : sym_op->auth.data.length =
569 : 0 : options->imix_buffer_sizes[*imix_idx];
570 : 0 : *imix_idx = (*imix_idx + 1) % options->pool_sz;
571 : : } else
572 : 0 : sym_op->auth.data.length = options->test_buffer_size;
573 : :
574 : 0 : if (options->auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
575 : 0 : options->auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
576 : : options->auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3)
577 : 0 : sym_op->auth.data.length <<= 3;
578 : :
579 : 0 : sym_op->auth.data.offset = 0;
580 : : }
581 : :
582 : 0 : if (options->test == CPERF_TEST_TYPE_VERIFY) {
583 : 0 : if (test_vector->auth_iv.length) {
584 : 0 : for (i = 0; i < nb_ops; i++) {
585 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ops[i],
586 : : uint8_t *, iv_offset);
587 : :
588 : 0 : memcpy(iv_ptr, test_vector->auth_iv.data,
589 : 0 : test_vector->auth_iv.length);
590 : : }
591 : : }
592 : : }
593 : 0 : }
594 : :
595 : : static void
596 : 0 : cperf_set_ops_cipher_auth(struct rte_crypto_op **ops,
597 : : uint32_t src_buf_offset, uint32_t dst_buf_offset,
598 : : uint16_t nb_ops, void *sess,
599 : : const struct cperf_options *options,
600 : : const struct cperf_test_vector *test_vector,
601 : : uint16_t iv_offset, uint32_t *imix_idx,
602 : : uint64_t *tsc_start __rte_unused)
603 : : {
604 : : uint16_t i;
605 : :
606 : 0 : for (i = 0; i < nb_ops; i++) {
607 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
608 : :
609 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
610 : : rte_crypto_op_attach_sym_session(ops[i], sess);
611 : :
612 : 0 : sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] +
613 : : src_buf_offset);
614 : :
615 : : /* Set dest mbuf to NULL if out-of-place (dst_buf_offset = 0) */
616 : 0 : if (dst_buf_offset == 0)
617 : 0 : sym_op->m_dst = NULL;
618 : : else
619 : 0 : sym_op->m_dst = (struct rte_mbuf *)((uint8_t *)ops[i] +
620 : : dst_buf_offset);
621 : :
622 : : /* cipher parameters */
623 : 0 : if (options->imix_distribution_count) {
624 : 0 : sym_op->cipher.data.length =
625 : 0 : options->imix_buffer_sizes[*imix_idx];
626 : 0 : *imix_idx = (*imix_idx + 1) % options->pool_sz;
627 : : } else
628 : 0 : sym_op->cipher.data.length = options->test_buffer_size;
629 : :
630 : 0 : if ((options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE) &&
631 : 0 : (options->op_type == CPERF_AUTH_THEN_CIPHER))
632 : 0 : sym_op->cipher.data.length += options->digest_sz;
633 : :
634 : 0 : if (options->cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
635 : 0 : options->cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
636 : : options->cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3)
637 : 0 : sym_op->cipher.data.length <<= 3;
638 : :
639 : 0 : sym_op->cipher.data.offset = 0;
640 : :
641 : : /* authentication parameters */
642 : 0 : if (options->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) {
643 : 0 : sym_op->auth.digest.data = test_vector->digest.data;
644 : 0 : sym_op->auth.digest.phys_addr =
645 : 0 : test_vector->digest.phys_addr;
646 : : } else {
647 : :
648 : 0 : uint32_t offset = options->test_buffer_size;
649 : : struct rte_mbuf *buf, *tbuf;
650 : :
651 : 0 : if (options->out_of_place) {
652 : 0 : buf = sym_op->m_dst;
653 : : } else {
654 : : tbuf = sym_op->m_src;
655 : 0 : while ((tbuf->next != NULL) &&
656 : 0 : (offset >= tbuf->data_len)) {
657 : 0 : offset -= tbuf->data_len;
658 : : tbuf = tbuf->next;
659 : : }
660 : : /*
661 : : * If there is not enough room in segment,
662 : : * place the digest in the next segment
663 : : */
664 : 0 : if ((tbuf->data_len - offset) < options->digest_sz) {
665 : : tbuf = tbuf->next;
666 : : offset = 0;
667 : : }
668 : : buf = tbuf;
669 : : }
670 : :
671 : 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(buf,
672 : : uint8_t *, offset);
673 : 0 : sym_op->auth.digest.phys_addr =
674 : 0 : rte_pktmbuf_iova_offset(buf, offset);
675 : : }
676 : :
677 : 0 : if (options->imix_distribution_count) {
678 : 0 : sym_op->auth.data.length =
679 : 0 : options->imix_buffer_sizes[*imix_idx];
680 : 0 : *imix_idx = (*imix_idx + 1) % options->pool_sz;
681 : : } else
682 : 0 : sym_op->auth.data.length = options->test_buffer_size;
683 : :
684 : 0 : if (options->auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
685 : 0 : options->auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
686 : : options->auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3)
687 : 0 : sym_op->auth.data.length <<= 3;
688 : :
689 : 0 : sym_op->auth.data.offset = 0;
690 : : }
691 : :
692 : 0 : if (options->test == CPERF_TEST_TYPE_VERIFY) {
693 : 0 : for (i = 0; i < nb_ops; i++) {
694 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ops[i],
695 : : uint8_t *, iv_offset);
696 : :
697 : 0 : memcpy(iv_ptr, test_vector->cipher_iv.data,
698 : 0 : test_vector->cipher_iv.length);
699 : 0 : if (test_vector->auth_iv.length) {
700 : : /*
701 : : * Copy IV after the crypto operation and
702 : : * the cipher IV
703 : : */
704 : 0 : iv_ptr += test_vector->cipher_iv.length;
705 : 0 : memcpy(iv_ptr, test_vector->auth_iv.data,
706 : : test_vector->auth_iv.length);
707 : : }
708 : : }
709 : :
710 : : }
711 : 0 : }
712 : :
713 : : static void
714 : 0 : cperf_set_ops_aead(struct rte_crypto_op **ops,
715 : : uint32_t src_buf_offset, uint32_t dst_buf_offset,
716 : : uint16_t nb_ops, void *sess,
717 : : const struct cperf_options *options,
718 : : const struct cperf_test_vector *test_vector,
719 : : uint16_t iv_offset, uint32_t *imix_idx,
720 : : uint64_t *tsc_start __rte_unused)
721 : : {
722 : : uint16_t i;
723 : : /* AAD is placed after the IV */
724 : 0 : uint16_t aad_offset = iv_offset +
725 : 0 : ((options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) ?
726 : 0 : RTE_ALIGN_CEIL(test_vector->aead_iv.length, 16) :
727 : : test_vector->aead_iv.length);
728 : :
729 : 0 : for (i = 0; i < nb_ops; i++) {
730 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
731 : :
732 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
733 : : rte_crypto_op_attach_sym_session(ops[i], sess);
734 : :
735 : 0 : sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] +
736 : : src_buf_offset);
737 : :
738 : : /* Set dest mbuf to NULL if out-of-place (dst_buf_offset = 0) */
739 : 0 : if (dst_buf_offset == 0)
740 : 0 : sym_op->m_dst = NULL;
741 : : else
742 : 0 : sym_op->m_dst = (struct rte_mbuf *)((uint8_t *)ops[i] +
743 : : dst_buf_offset);
744 : :
745 : : /* AEAD parameters */
746 : 0 : if (options->imix_distribution_count) {
747 : 0 : sym_op->aead.data.length =
748 : 0 : options->imix_buffer_sizes[*imix_idx];
749 : 0 : *imix_idx = (*imix_idx + 1) % options->pool_sz;
750 : : } else
751 : 0 : sym_op->aead.data.length = options->test_buffer_size;
752 : 0 : sym_op->aead.data.offset = 0;
753 : :
754 : 0 : sym_op->aead.aad.data = rte_crypto_op_ctod_offset(ops[i],
755 : : uint8_t *, aad_offset);
756 : 0 : sym_op->aead.aad.phys_addr = rte_crypto_op_ctophys_offset(ops[i],
757 : : aad_offset);
758 : :
759 : 0 : if (options->aead_op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
760 : 0 : sym_op->aead.digest.data = test_vector->digest.data;
761 : 0 : sym_op->aead.digest.phys_addr =
762 : 0 : test_vector->digest.phys_addr;
763 : : } else {
764 : :
765 : 0 : uint32_t offset = sym_op->aead.data.length +
766 : : sym_op->aead.data.offset;
767 : : struct rte_mbuf *buf, *tbuf;
768 : :
769 : 0 : if (options->out_of_place) {
770 : 0 : buf = sym_op->m_dst;
771 : : } else {
772 : : tbuf = sym_op->m_src;
773 : 0 : while ((tbuf->next != NULL) &&
774 : 0 : (offset >= tbuf->data_len)) {
775 : 0 : offset -= tbuf->data_len;
776 : : tbuf = tbuf->next;
777 : : }
778 : : /*
779 : : * If there is not enough room in segment,
780 : : * place the digest in the next segment
781 : : */
782 : 0 : if ((tbuf->data_len - offset) < options->digest_sz) {
783 : : tbuf = tbuf->next;
784 : : offset = 0;
785 : : }
786 : : buf = tbuf;
787 : : }
788 : :
789 : 0 : sym_op->aead.digest.data = rte_pktmbuf_mtod_offset(buf,
790 : : uint8_t *, offset);
791 : 0 : sym_op->aead.digest.phys_addr =
792 : 0 : rte_pktmbuf_iova_offset(buf, offset);
793 : : }
794 : : }
795 : :
796 : 0 : if ((options->test == CPERF_TEST_TYPE_VERIFY) ||
797 : 0 : (options->test == CPERF_TEST_TYPE_LATENCY) ||
798 : 0 : (options->test == CPERF_TEST_TYPE_THROUGHPUT &&
799 : 0 : (options->aead_op == RTE_CRYPTO_AEAD_OP_DECRYPT ||
800 : 0 : options->cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT))) {
801 : 0 : for (i = 0; i < nb_ops; i++) {
802 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ops[i],
803 : : uint8_t *, iv_offset);
804 : :
805 : : /*
806 : : * If doing AES-CCM, nonce is copied one byte
807 : : * after the start of IV field, and AAD is copied
808 : : * 18 bytes after the start of the AAD field.
809 : : */
810 : 0 : if (options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) {
811 : 0 : memcpy(iv_ptr + 1, test_vector->aead_iv.data,
812 : 0 : test_vector->aead_iv.length);
813 : :
814 : 0 : memcpy(ops[i]->sym->aead.aad.data + 18,
815 : 0 : test_vector->aad.data,
816 : 0 : test_vector->aad.length);
817 : : } else {
818 : 0 : memcpy(iv_ptr, test_vector->aead_iv.data,
819 : 0 : test_vector->aead_iv.length);
820 : :
821 : 0 : memcpy(ops[i]->sym->aead.aad.data,
822 : 0 : test_vector->aad.data,
823 : 0 : test_vector->aad.length);
824 : : }
825 : : }
826 : : }
827 : 0 : }
828 : :
829 : : static void *
830 : 0 : create_ipsec_session(struct rte_mempool *sess_mp,
831 : : uint8_t dev_id,
832 : : const struct cperf_options *options,
833 : : const struct cperf_test_vector *test_vector,
834 : : uint16_t iv_offset)
835 : : {
836 : 0 : struct rte_crypto_sym_xform auth_xform = {0};
837 : : struct rte_crypto_sym_xform *crypto_xform;
838 : 0 : struct rte_crypto_sym_xform xform = {0};
839 : :
840 : 0 : if (options->aead_algo != 0) {
841 : : /* Setup AEAD Parameters */
842 : 0 : xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
843 : : xform.next = NULL;
844 : 0 : xform.aead.algo = options->aead_algo;
845 : 0 : xform.aead.op = options->aead_op;
846 : 0 : xform.aead.iv.offset = iv_offset;
847 : 0 : xform.aead.key.data = test_vector->aead_key.data;
848 : 0 : xform.aead.key.length = test_vector->aead_key.length;
849 : 0 : xform.aead.iv.length = test_vector->aead_iv.length;
850 : 0 : xform.aead.digest_length = options->digest_sz;
851 : 0 : xform.aead.aad_length = options->aead_aad_sz;
852 : : crypto_xform = &xform;
853 : 0 : } else if (options->cipher_algo != 0 && options->auth_algo != 0) {
854 : : /* Setup Cipher Parameters */
855 : 0 : xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
856 : 0 : xform.cipher.algo = options->cipher_algo;
857 : 0 : xform.cipher.op = options->cipher_op;
858 : 0 : xform.cipher.iv.offset = iv_offset;
859 : 0 : xform.cipher.iv.length = test_vector->cipher_iv.length;
860 : : /* cipher different than null */
861 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
862 : 0 : xform.cipher.key.data = test_vector->cipher_key.data;
863 : 0 : xform.cipher.key.length =
864 : 0 : test_vector->cipher_key.length;
865 : : } else {
866 : : xform.cipher.key.data = NULL;
867 : : xform.cipher.key.length = 0;
868 : : }
869 : :
870 : : /* Setup Auth Parameters */
871 : 0 : auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
872 : 0 : auth_xform.auth.algo = options->auth_algo;
873 : 0 : auth_xform.auth.op = options->auth_op;
874 : 0 : auth_xform.auth.iv.offset = iv_offset +
875 : : xform.cipher.iv.length;
876 : : /* auth different than null */
877 : 0 : if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
878 : 0 : auth_xform.auth.digest_length = options->digest_sz;
879 : 0 : auth_xform.auth.key.length =
880 : 0 : test_vector->auth_key.length;
881 : 0 : auth_xform.auth.key.data = test_vector->auth_key.data;
882 : 0 : auth_xform.auth.iv.length = test_vector->auth_iv.length;
883 : : } else {
884 : : auth_xform.auth.digest_length = 0;
885 : : auth_xform.auth.key.length = 0;
886 : : auth_xform.auth.key.data = NULL;
887 : : auth_xform.auth.iv.length = 0;
888 : : }
889 : :
890 : 0 : if (options->is_outbound) {
891 : : crypto_xform = &xform;
892 : 0 : xform.next = &auth_xform;
893 : : auth_xform.next = NULL;
894 : : } else {
895 : : crypto_xform = &auth_xform;
896 : 0 : auth_xform.next = &xform;
897 : : xform.next = NULL;
898 : : }
899 : : } else {
900 : : return NULL;
901 : : }
902 : :
903 : : #define CPERF_IPSEC_SRC_IP 0x01010101
904 : : #define CPERF_IPSEC_DST_IP 0x02020202
905 : : #define CPERF_IPSEC_SALT 0x0
906 : : #define CPERF_IPSEC_DEFTTL 64
907 : 0 : struct rte_security_ipsec_tunnel_param tunnel = {
908 : : .type = RTE_SECURITY_IPSEC_TUNNEL_IPV4,
909 : : {.ipv4 = {
910 : : .src_ip = { .s_addr = CPERF_IPSEC_SRC_IP},
911 : : .dst_ip = { .s_addr = CPERF_IPSEC_DST_IP},
912 : : .dscp = 0,
913 : : .df = 0,
914 : : .ttl = CPERF_IPSEC_DEFTTL,
915 : : } },
916 : : };
917 : 0 : struct rte_security_session_conf sess_conf = {
918 : : .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
919 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
920 : : {.ipsec = {
921 : 0 : .spi = rte_lcore_id() + 1,
922 : : /**< For testing sake, lcore_id is taken as SPI so that
923 : : * for every core a different session is created.
924 : : */
925 : : .salt = CPERF_IPSEC_SALT,
926 : : .options = { 0 },
927 : : .replay_win_sz = 0,
928 : : .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
929 : : .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
930 : : .tunnel = tunnel,
931 : : } },
932 : : .userdata = NULL,
933 : : .crypto_xform = crypto_xform,
934 : : };
935 : :
936 : 0 : if (options->is_outbound)
937 : : sess_conf.ipsec.direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS;
938 : : else
939 : 0 : sess_conf.ipsec.direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS;
940 : :
941 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(dev_id);
942 : :
943 : : /* Create security session */
944 : 0 : return (void *)rte_security_session_create(ctx, &sess_conf, sess_mp);
945 : : }
946 : :
947 : : static void *
948 : 0 : create_tls_session(struct rte_mempool *sess_mp,
949 : : uint8_t dev_id,
950 : : const struct cperf_options *options,
951 : : const struct cperf_test_vector *test_vector,
952 : : uint16_t iv_offset)
953 : : {
954 : 0 : struct rte_crypto_sym_xform auth_xform = {0};
955 : : struct rte_crypto_sym_xform *crypto_xform;
956 : 0 : struct rte_crypto_sym_xform xform = {0};
957 : :
958 : 0 : if (options->aead_algo != 0) {
959 : : /* Setup AEAD Parameters */
960 : 0 : xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
961 : : xform.next = NULL;
962 : 0 : xform.aead.algo = options->aead_algo;
963 : 0 : xform.aead.op = options->aead_op;
964 : 0 : xform.aead.iv.offset = iv_offset;
965 : 0 : xform.aead.key.data = test_vector->aead_key.data;
966 : 0 : xform.aead.key.length = test_vector->aead_key.length;
967 : 0 : xform.aead.iv.length = test_vector->aead_iv.length;
968 : 0 : xform.aead.digest_length = options->digest_sz;
969 : 0 : xform.aead.aad_length = options->aead_aad_sz;
970 : : crypto_xform = &xform;
971 : 0 : } else if (options->cipher_algo != 0 && options->auth_algo != 0) {
972 : : /* Setup Cipher Parameters */
973 : 0 : xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
974 : 0 : xform.cipher.algo = options->cipher_algo;
975 : 0 : xform.cipher.op = options->cipher_op;
976 : 0 : xform.cipher.iv.offset = iv_offset;
977 : 0 : xform.cipher.iv.length = test_vector->cipher_iv.length;
978 : : /* cipher different than null */
979 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
980 : 0 : xform.cipher.key.data = test_vector->cipher_key.data;
981 : 0 : xform.cipher.key.length = test_vector->cipher_key.length;
982 : : } else {
983 : : xform.cipher.key.data = NULL;
984 : : xform.cipher.key.length = 0;
985 : : }
986 : :
987 : : /* Setup Auth Parameters */
988 : 0 : auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
989 : 0 : auth_xform.auth.algo = options->auth_algo;
990 : 0 : auth_xform.auth.op = options->auth_op;
991 : 0 : auth_xform.auth.iv.offset = iv_offset + xform.cipher.iv.length;
992 : : /* auth different than null */
993 : 0 : if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
994 : 0 : auth_xform.auth.digest_length = options->digest_sz;
995 : 0 : auth_xform.auth.key.length = test_vector->auth_key.length;
996 : 0 : auth_xform.auth.key.data = test_vector->auth_key.data;
997 : 0 : auth_xform.auth.iv.length = test_vector->auth_iv.length;
998 : : } else {
999 : : auth_xform.auth.digest_length = 0;
1000 : : auth_xform.auth.key.length = 0;
1001 : : auth_xform.auth.key.data = NULL;
1002 : : auth_xform.auth.iv.length = 0;
1003 : : }
1004 : :
1005 : 0 : if (options->is_outbound) {
1006 : : /* Currently supporting AUTH then Encrypt mode only for TLS. */
1007 : : crypto_xform = &auth_xform;
1008 : 0 : auth_xform.next = &xform;
1009 : : xform.next = NULL;
1010 : : } else {
1011 : : crypto_xform = &xform;
1012 : 0 : xform.next = &auth_xform;
1013 : : auth_xform.next = NULL;
1014 : : }
1015 : : } else {
1016 : : return NULL;
1017 : : }
1018 : :
1019 : : struct rte_security_tls_record_sess_options opts = {
1020 : : .iv_gen_disable = 0,
1021 : : .extra_padding_enable = 0,
1022 : : };
1023 : 0 : struct rte_security_session_conf sess_conf = {
1024 : : .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1025 : : .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
1026 : : {.tls_record = {
1027 : : .ver = RTE_SECURITY_VERSION_TLS_1_2,
1028 : : .options = opts,
1029 : : } },
1030 : : .userdata = NULL,
1031 : : .crypto_xform = crypto_xform,
1032 : : };
1033 : 0 : if (options->tls_version)
1034 : 0 : sess_conf.tls_record.ver = options->tls_version;
1035 : :
1036 : 0 : if (options->is_outbound)
1037 : 0 : sess_conf.tls_record.type = RTE_SECURITY_TLS_SESS_TYPE_WRITE;
1038 : : else
1039 : : sess_conf.tls_record.type = RTE_SECURITY_TLS_SESS_TYPE_READ;
1040 : :
1041 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(dev_id);
1042 : :
1043 : : /* Create security session */
1044 : 0 : return (void *)rte_security_session_create(ctx, &sess_conf, sess_mp);
1045 : : }
1046 : :
1047 : : static void *
1048 : 0 : cperf_create_session(struct rte_mempool *sess_mp,
1049 : : uint8_t dev_id,
1050 : : const struct cperf_options *options,
1051 : : const struct cperf_test_vector *test_vector,
1052 : : uint16_t iv_offset)
1053 : : {
1054 : : struct rte_crypto_sym_xform cipher_xform;
1055 : : struct rte_crypto_sym_xform auth_xform;
1056 : : struct rte_crypto_sym_xform aead_xform;
1057 : : void *sess = NULL;
1058 : 0 : void *asym_sess = NULL;
1059 : 0 : struct rte_crypto_asym_xform xform = {0};
1060 : : int ret;
1061 : :
1062 : 0 : if (options->op_type == CPERF_ASYM_MODEX) {
1063 : : xform.next = NULL;
1064 : 0 : xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
1065 : 0 : xform.modex.modulus.data = options->modex_data->modulus.data;
1066 : 0 : xform.modex.modulus.length = options->modex_data->modulus.len;
1067 : 0 : xform.modex.exponent.data = options->modex_data->exponent.data;
1068 : 0 : xform.modex.exponent.length = options->modex_data->exponent.len;
1069 : :
1070 : 0 : ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1071 : : sess_mp, &asym_sess);
1072 : 0 : if (ret < 0) {
1073 : 0 : RTE_LOG(ERR, USER1, "Asym session create failed\n");
1074 : 0 : return NULL;
1075 : : }
1076 : 0 : return asym_sess;
1077 : : }
1078 : :
1079 : : if (options->op_type == CPERF_ASYM_RSA) {
1080 : : xform.next = NULL;
1081 : 0 : xform.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
1082 : 0 : xform.rsa.padding.type = options->rsa_data->padding;
1083 : 0 : xform.rsa.n.data = options->rsa_data->n.data;
1084 : 0 : xform.rsa.n.length = options->rsa_data->n.length;
1085 : 0 : xform.rsa.e.data = options->rsa_data->e.data;
1086 : 0 : xform.rsa.e.length = options->rsa_data->e.length;
1087 : 0 : xform.rsa.d.data = options->rsa_data->d.data;
1088 : 0 : xform.rsa.d.length = options->rsa_data->d.length;
1089 : 0 : xform.rsa.key_type = options->rsa_data->key_type;
1090 : 0 : if (xform.rsa.key_type == RTE_RSA_KEY_TYPE_QT) {
1091 : 0 : xform.rsa.qt.p.data = options->rsa_data->p.data;
1092 : 0 : xform.rsa.qt.p.length = options->rsa_data->p.length;
1093 : 0 : xform.rsa.qt.q.data = options->rsa_data->q.data;
1094 : 0 : xform.rsa.qt.q.length = options->rsa_data->q.length;
1095 : 0 : xform.rsa.qt.dP.data = options->rsa_data->dp.data;
1096 : 0 : xform.rsa.qt.dP.length = options->rsa_data->dp.length;
1097 : 0 : xform.rsa.qt.dQ.data = options->rsa_data->dq.data;
1098 : 0 : xform.rsa.qt.dQ.length = options->rsa_data->dq.length;
1099 : 0 : xform.rsa.qt.qInv.data = options->rsa_data->qinv.data;
1100 : 0 : xform.rsa.qt.qInv.length = options->rsa_data->qinv.length;
1101 : : }
1102 : 0 : ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1103 : : sess_mp, &asym_sess);
1104 : 0 : if (ret < 0) {
1105 : 0 : RTE_LOG(ERR, USER1, "Asym session create failed\n");
1106 : 0 : return NULL;
1107 : : }
1108 : 0 : return asym_sess;
1109 : : }
1110 : :
1111 : : if (options->op_type == CPERF_ASYM_SECP256R1) {
1112 : : xform.next = NULL;
1113 : 0 : xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDSA;
1114 : 0 : xform.ec.curve_id = options->secp256r1_data->curve;
1115 : 0 : xform.ec.pkey.data = options->secp256r1_data->pkey.data;
1116 : 0 : xform.ec.pkey.length = options->secp256r1_data->pkey.length;
1117 : 0 : xform.ec.q.x.data = options->secp256r1_data->pubkey_qx.data;
1118 : 0 : xform.ec.q.x.length = options->secp256r1_data->pubkey_qx.length;
1119 : 0 : xform.ec.q.y.data = options->secp256r1_data->pubkey_qy.data;
1120 : 0 : xform.ec.q.y.length = options->secp256r1_data->pubkey_qy.length;
1121 : :
1122 : 0 : ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1123 : : sess_mp, &asym_sess);
1124 : 0 : if (ret < 0) {
1125 : 0 : RTE_LOG(ERR, USER1, "ECDSA Asym session create failed\n");
1126 : 0 : return NULL;
1127 : : }
1128 : :
1129 : 0 : return asym_sess;
1130 : : }
1131 : :
1132 : : if (options->op_type == CPERF_ASYM_ED25519) {
1133 : : xform.next = NULL;
1134 : 0 : xform.xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA;
1135 : 0 : xform.ec.curve_id = options->eddsa_data->curve;
1136 : 0 : xform.ec.pkey.data = options->eddsa_data->pkey.data;
1137 : 0 : xform.ec.pkey.length = options->eddsa_data->pkey.length;
1138 : 0 : xform.ec.q.x.data = options->eddsa_data->pubkey.data;
1139 : 0 : xform.ec.q.x.length = options->eddsa_data->pubkey.length;
1140 : :
1141 : 0 : ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1142 : : sess_mp, &asym_sess);
1143 : 0 : if (ret < 0) {
1144 : 0 : RTE_LOG(ERR, USER1, "EdDSA Asym session create failed\n");
1145 : 0 : return NULL;
1146 : : }
1147 : :
1148 : 0 : return asym_sess;
1149 : : }
1150 : :
1151 : : if (options->op_type == CPERF_ASYM_SM2) {
1152 : : xform.next = NULL;
1153 : 0 : xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
1154 : 0 : xform.ec.curve_id = options->sm2_data->curve;
1155 : 0 : xform.ec.pkey.data = options->sm2_data->pkey.data;
1156 : 0 : xform.ec.pkey.length = options->sm2_data->pkey.length;
1157 : 0 : xform.ec.q.x.data = options->sm2_data->pubkey_qx.data;
1158 : 0 : xform.ec.q.x.length = options->sm2_data->pubkey_qx.length;
1159 : 0 : xform.ec.q.y.data = options->sm2_data->pubkey_qy.data;
1160 : 0 : xform.ec.q.y.length = options->sm2_data->pubkey_qy.length;
1161 : :
1162 : 0 : ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1163 : : sess_mp, &asym_sess);
1164 : 0 : if (ret < 0) {
1165 : 0 : RTE_LOG(ERR, USER1, "SM2 Asym session create failed\n");
1166 : 0 : return NULL;
1167 : : }
1168 : :
1169 : 0 : return asym_sess;
1170 : : }
1171 : : #ifdef RTE_LIB_SECURITY
1172 : : /*
1173 : : * security only
1174 : : */
1175 : : if (options->op_type == CPERF_PDCP) {
1176 : : /* Setup Cipher Parameters */
1177 : 0 : cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1178 : 0 : cipher_xform.next = NULL;
1179 : 0 : cipher_xform.cipher.algo = options->cipher_algo;
1180 : 0 : cipher_xform.cipher.op = options->cipher_op;
1181 : 0 : cipher_xform.cipher.iv.offset = iv_offset;
1182 : 0 : cipher_xform.cipher.iv.length = 4;
1183 : :
1184 : : /* cipher different than null */
1185 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
1186 : 0 : cipher_xform.cipher.key.data = test_vector->cipher_key.data;
1187 : 0 : cipher_xform.cipher.key.length = test_vector->cipher_key.length;
1188 : : } else {
1189 : 0 : cipher_xform.cipher.key.data = NULL;
1190 : 0 : cipher_xform.cipher.key.length = 0;
1191 : : }
1192 : :
1193 : : /* Setup Auth Parameters */
1194 : 0 : if (options->auth_algo != 0) {
1195 : 0 : auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1196 : 0 : auth_xform.next = NULL;
1197 : 0 : auth_xform.auth.algo = options->auth_algo;
1198 : 0 : auth_xform.auth.op = options->auth_op;
1199 : 0 : auth_xform.auth.iv.offset = iv_offset +
1200 : : cipher_xform.cipher.iv.length;
1201 : :
1202 : : /* auth different than null */
1203 : 0 : if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
1204 : 0 : auth_xform.auth.digest_length = options->digest_sz;
1205 : 0 : auth_xform.auth.key.length = test_vector->auth_key.length;
1206 : 0 : auth_xform.auth.key.data = test_vector->auth_key.data;
1207 : 0 : auth_xform.auth.iv.length = test_vector->auth_iv.length;
1208 : : } else {
1209 : 0 : auth_xform.auth.digest_length = 0;
1210 : 0 : auth_xform.auth.key.length = 0;
1211 : 0 : auth_xform.auth.key.data = NULL;
1212 : 0 : auth_xform.auth.iv.length = 0;
1213 : : }
1214 : :
1215 : 0 : cipher_xform.next = &auth_xform;
1216 : : } else {
1217 : : cipher_xform.next = NULL;
1218 : : }
1219 : :
1220 : 0 : struct rte_security_session_conf sess_conf = {
1221 : : .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1222 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
1223 : : {.pdcp = {
1224 : : .bearer = 0x16,
1225 : 0 : .domain = options->pdcp_domain,
1226 : : .pkt_dir = 0,
1227 : 0 : .sn_size = options->pdcp_sn_sz,
1228 : 0 : .hfn = options->pdcp_ses_hfn_en ?
1229 : 0 : PDCP_DEFAULT_HFN : 0,
1230 : : .hfn_threshold = 0x70C0A,
1231 : 0 : .sdap_enabled = options->pdcp_sdap,
1232 : 0 : .hfn_ovrd = !(options->pdcp_ses_hfn_en),
1233 : : } },
1234 : : .crypto_xform = &cipher_xform
1235 : : };
1236 : :
1237 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(dev_id);
1238 : :
1239 : : /* Create security session */
1240 : 0 : return (void *)rte_security_session_create(ctx, &sess_conf, sess_mp);
1241 : : }
1242 : :
1243 : : if (options->op_type == CPERF_IPSEC) {
1244 : 0 : return create_ipsec_session(sess_mp, dev_id,
1245 : : options, test_vector, iv_offset);
1246 : : }
1247 : :
1248 : : if (options->op_type == CPERF_TLS) {
1249 : 0 : return create_tls_session(sess_mp, dev_id,
1250 : : options, test_vector, iv_offset);
1251 : : }
1252 : :
1253 : : if (options->op_type == CPERF_DOCSIS) {
1254 : : enum rte_security_docsis_direction direction;
1255 : :
1256 : 0 : cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1257 : 0 : cipher_xform.next = NULL;
1258 : 0 : cipher_xform.cipher.algo = options->cipher_algo;
1259 : 0 : cipher_xform.cipher.op = options->cipher_op;
1260 : 0 : cipher_xform.cipher.iv.offset = iv_offset;
1261 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
1262 : 0 : cipher_xform.cipher.key.data =
1263 : 0 : test_vector->cipher_key.data;
1264 : 0 : cipher_xform.cipher.key.length =
1265 : 0 : test_vector->cipher_key.length;
1266 : 0 : cipher_xform.cipher.iv.length =
1267 : 0 : test_vector->cipher_iv.length;
1268 : : } else {
1269 : 0 : cipher_xform.cipher.key.data = NULL;
1270 : 0 : cipher_xform.cipher.key.length = 0;
1271 : 0 : cipher_xform.cipher.iv.length = 0;
1272 : : }
1273 : : cipher_xform.next = NULL;
1274 : :
1275 : 0 : if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
1276 : : direction = RTE_SECURITY_DOCSIS_DOWNLINK;
1277 : : else
1278 : : direction = RTE_SECURITY_DOCSIS_UPLINK;
1279 : :
1280 : 0 : struct rte_security_session_conf sess_conf = {
1281 : : .action_type =
1282 : : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1283 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
1284 : : {.docsis = {
1285 : : .direction = direction,
1286 : : } },
1287 : : .crypto_xform = &cipher_xform
1288 : : };
1289 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(dev_id);
1290 : :
1291 : : /* Create security session */
1292 : 0 : return (void *)rte_security_session_create(ctx, &sess_conf, sess_mp);
1293 : : }
1294 : : #endif
1295 : : /*
1296 : : * cipher only
1297 : : */
1298 : : if (options->op_type == CPERF_CIPHER_ONLY) {
1299 : 0 : cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1300 : 0 : cipher_xform.next = NULL;
1301 : 0 : cipher_xform.cipher.algo = options->cipher_algo;
1302 : 0 : cipher_xform.cipher.op = options->cipher_op;
1303 : 0 : cipher_xform.cipher.iv.offset = iv_offset;
1304 : :
1305 : : /* cipher different than null */
1306 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
1307 : 0 : cipher_xform.cipher.key.data =
1308 : 0 : test_vector->cipher_key.data;
1309 : 0 : cipher_xform.cipher.key.length =
1310 : 0 : test_vector->cipher_key.length;
1311 : 0 : cipher_xform.cipher.iv.length =
1312 : 0 : test_vector->cipher_iv.length;
1313 : : } else {
1314 : 0 : cipher_xform.cipher.key.data = NULL;
1315 : 0 : cipher_xform.cipher.key.length = 0;
1316 : 0 : cipher_xform.cipher.iv.length = 0;
1317 : : }
1318 : : /* create crypto session */
1319 : 0 : sess = rte_cryptodev_sym_session_create(dev_id, &cipher_xform,
1320 : : sess_mp);
1321 : : /*
1322 : : * auth only
1323 : : */
1324 : : } else if (options->op_type == CPERF_AUTH_ONLY) {
1325 : 0 : auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1326 : 0 : auth_xform.next = NULL;
1327 : 0 : auth_xform.auth.algo = options->auth_algo;
1328 : 0 : auth_xform.auth.op = options->auth_op;
1329 : 0 : auth_xform.auth.iv.offset = iv_offset;
1330 : :
1331 : : /* auth different than null */
1332 : 0 : if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
1333 : 0 : auth_xform.auth.digest_length =
1334 : 0 : options->digest_sz;
1335 : 0 : auth_xform.auth.key.length =
1336 : 0 : test_vector->auth_key.length;
1337 : 0 : auth_xform.auth.key.data = test_vector->auth_key.data;
1338 : 0 : auth_xform.auth.iv.length =
1339 : 0 : test_vector->auth_iv.length;
1340 : : } else {
1341 : 0 : auth_xform.auth.digest_length = 0;
1342 : 0 : auth_xform.auth.key.length = 0;
1343 : 0 : auth_xform.auth.key.data = NULL;
1344 : 0 : auth_xform.auth.iv.length = 0;
1345 : : }
1346 : : /* create crypto session */
1347 : 0 : sess = rte_cryptodev_sym_session_create(dev_id, &auth_xform,
1348 : : sess_mp);
1349 : : /*
1350 : : * cipher and auth
1351 : : */
1352 : : } else if (options->op_type == CPERF_CIPHER_THEN_AUTH
1353 : : || options->op_type == CPERF_AUTH_THEN_CIPHER) {
1354 : : /*
1355 : : * cipher
1356 : : */
1357 : 0 : cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1358 : 0 : cipher_xform.next = NULL;
1359 : 0 : cipher_xform.cipher.algo = options->cipher_algo;
1360 : 0 : cipher_xform.cipher.op = options->cipher_op;
1361 : 0 : cipher_xform.cipher.iv.offset = iv_offset;
1362 : :
1363 : : /* cipher different than null */
1364 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
1365 : 0 : cipher_xform.cipher.key.data =
1366 : 0 : test_vector->cipher_key.data;
1367 : 0 : cipher_xform.cipher.key.length =
1368 : 0 : test_vector->cipher_key.length;
1369 : 0 : cipher_xform.cipher.iv.length =
1370 : 0 : test_vector->cipher_iv.length;
1371 : : } else {
1372 : 0 : cipher_xform.cipher.key.data = NULL;
1373 : 0 : cipher_xform.cipher.key.length = 0;
1374 : 0 : cipher_xform.cipher.iv.length = 0;
1375 : : }
1376 : :
1377 : : /*
1378 : : * auth
1379 : : */
1380 : 0 : auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1381 : 0 : auth_xform.next = NULL;
1382 : 0 : auth_xform.auth.algo = options->auth_algo;
1383 : 0 : auth_xform.auth.op = options->auth_op;
1384 : 0 : auth_xform.auth.iv.offset = iv_offset +
1385 : 0 : cipher_xform.cipher.iv.length;
1386 : :
1387 : : /* auth different than null */
1388 : 0 : if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
1389 : 0 : auth_xform.auth.digest_length = options->digest_sz;
1390 : 0 : auth_xform.auth.iv.length = test_vector->auth_iv.length;
1391 : 0 : auth_xform.auth.key.length =
1392 : 0 : test_vector->auth_key.length;
1393 : 0 : auth_xform.auth.key.data =
1394 : 0 : test_vector->auth_key.data;
1395 : : } else {
1396 : 0 : auth_xform.auth.digest_length = 0;
1397 : 0 : auth_xform.auth.key.length = 0;
1398 : 0 : auth_xform.auth.key.data = NULL;
1399 : 0 : auth_xform.auth.iv.length = 0;
1400 : : }
1401 : :
1402 : : /* cipher then auth */
1403 : 0 : if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
1404 : 0 : cipher_xform.next = &auth_xform;
1405 : : /* create crypto session */
1406 : 0 : sess = rte_cryptodev_sym_session_create(dev_id,
1407 : : &cipher_xform, sess_mp);
1408 : : } else { /* auth then cipher */
1409 : 0 : auth_xform.next = &cipher_xform;
1410 : : /* create crypto session */
1411 : 0 : sess = rte_cryptodev_sym_session_create(dev_id,
1412 : : &auth_xform, sess_mp);
1413 : : }
1414 : : } else { /* options->op_type == CPERF_AEAD */
1415 : 0 : aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
1416 : 0 : aead_xform.next = NULL;
1417 : 0 : aead_xform.aead.algo = options->aead_algo;
1418 : 0 : aead_xform.aead.op = options->aead_op;
1419 : 0 : aead_xform.aead.iv.offset = iv_offset;
1420 : :
1421 : 0 : aead_xform.aead.key.data =
1422 : 0 : test_vector->aead_key.data;
1423 : 0 : aead_xform.aead.key.length =
1424 : 0 : test_vector->aead_key.length;
1425 : 0 : aead_xform.aead.iv.length = test_vector->aead_iv.length;
1426 : :
1427 : 0 : aead_xform.aead.digest_length = options->digest_sz;
1428 : 0 : aead_xform.aead.aad_length =
1429 : 0 : options->aead_aad_sz;
1430 : :
1431 : : /* Create crypto session */
1432 : 0 : sess = rte_cryptodev_sym_session_create(dev_id, &aead_xform,
1433 : : sess_mp);
1434 : : }
1435 : :
1436 : : return sess;
1437 : : }
1438 : :
1439 : : int
1440 : 0 : cperf_get_op_functions(const struct cperf_options *options,
1441 : : struct cperf_op_fns *op_fns)
1442 : : {
1443 : : memset(op_fns, 0, sizeof(struct cperf_op_fns));
1444 : :
1445 : 0 : op_fns->sess_create = cperf_create_session;
1446 : :
1447 : 0 : switch (options->op_type) {
1448 : 0 : case CPERF_AEAD:
1449 : 0 : op_fns->populate_ops = cperf_set_ops_aead;
1450 : 0 : break;
1451 : :
1452 : 0 : case CPERF_AUTH_THEN_CIPHER:
1453 : : case CPERF_CIPHER_THEN_AUTH:
1454 : 0 : op_fns->populate_ops = cperf_set_ops_cipher_auth;
1455 : 0 : break;
1456 : 0 : case CPERF_AUTH_ONLY:
1457 : 0 : if (options->auth_algo == RTE_CRYPTO_AUTH_NULL)
1458 : 0 : op_fns->populate_ops = cperf_set_ops_null_auth;
1459 : : else
1460 : 0 : op_fns->populate_ops = cperf_set_ops_auth;
1461 : : break;
1462 : 0 : case CPERF_CIPHER_ONLY:
1463 : 0 : if (options->cipher_algo == RTE_CRYPTO_CIPHER_NULL)
1464 : 0 : op_fns->populate_ops = cperf_set_ops_null_cipher;
1465 : : else
1466 : 0 : op_fns->populate_ops = cperf_set_ops_cipher;
1467 : : break;
1468 : 0 : case CPERF_ASYM_MODEX:
1469 : 0 : op_fns->populate_ops = cperf_set_ops_asym_modex;
1470 : 0 : break;
1471 : 0 : case CPERF_ASYM_RSA:
1472 : 0 : op_fns->populate_ops = cperf_set_ops_asym_rsa;
1473 : 0 : break;
1474 : 0 : case CPERF_ASYM_SECP256R1:
1475 : 0 : op_fns->populate_ops = cperf_set_ops_asym_ecdsa;
1476 : 0 : break;
1477 : 0 : case CPERF_ASYM_ED25519:
1478 : 0 : op_fns->populate_ops = cperf_set_ops_asym_eddsa;
1479 : 0 : break;
1480 : 0 : case CPERF_ASYM_SM2:
1481 : 0 : op_fns->populate_ops = cperf_set_ops_asym_sm2;
1482 : 0 : break;
1483 : : #ifdef RTE_LIB_SECURITY
1484 : 0 : case CPERF_PDCP:
1485 : : case CPERF_DOCSIS:
1486 : 0 : op_fns->populate_ops = cperf_set_ops_security;
1487 : 0 : break;
1488 : 0 : case CPERF_IPSEC:
1489 : 0 : op_fns->populate_ops = cperf_set_ops_security_ipsec;
1490 : 0 : break;
1491 : 0 : case CPERF_TLS:
1492 : 0 : op_fns->populate_ops = cperf_set_ops_security_tls;
1493 : 0 : break;
1494 : : #endif
1495 : : default:
1496 : : return -1;
1497 : : }
1498 : :
1499 : : return 0;
1500 : : }
|