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 : RTE_ALIGN_CEIL(test_vector->aead_iv.length, 16);
726 : :
727 : 0 : for (i = 0; i < nb_ops; i++) {
728 : 0 : struct rte_crypto_sym_op *sym_op = ops[i]->sym;
729 : :
730 : 0 : ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
731 : : rte_crypto_op_attach_sym_session(ops[i], sess);
732 : :
733 : 0 : sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] +
734 : : src_buf_offset);
735 : :
736 : : /* Set dest mbuf to NULL if out-of-place (dst_buf_offset = 0) */
737 : 0 : if (dst_buf_offset == 0)
738 : 0 : sym_op->m_dst = NULL;
739 : : else
740 : 0 : sym_op->m_dst = (struct rte_mbuf *)((uint8_t *)ops[i] +
741 : : dst_buf_offset);
742 : :
743 : : /* AEAD parameters */
744 : 0 : if (options->imix_distribution_count) {
745 : 0 : sym_op->aead.data.length =
746 : 0 : options->imix_buffer_sizes[*imix_idx];
747 : 0 : *imix_idx = (*imix_idx + 1) % options->pool_sz;
748 : : } else
749 : 0 : sym_op->aead.data.length = options->test_buffer_size;
750 : 0 : sym_op->aead.data.offset = 0;
751 : :
752 : 0 : sym_op->aead.aad.data = rte_crypto_op_ctod_offset(ops[i],
753 : : uint8_t *, aad_offset);
754 : 0 : sym_op->aead.aad.phys_addr = rte_crypto_op_ctophys_offset(ops[i],
755 : : aad_offset);
756 : :
757 : 0 : if (options->aead_op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
758 : 0 : sym_op->aead.digest.data = test_vector->digest.data;
759 : 0 : sym_op->aead.digest.phys_addr =
760 : 0 : test_vector->digest.phys_addr;
761 : : } else {
762 : :
763 : 0 : uint32_t offset = sym_op->aead.data.length +
764 : : sym_op->aead.data.offset;
765 : : struct rte_mbuf *buf, *tbuf;
766 : :
767 : 0 : if (options->out_of_place) {
768 : 0 : buf = sym_op->m_dst;
769 : : } else {
770 : : tbuf = sym_op->m_src;
771 : 0 : while ((tbuf->next != NULL) &&
772 : 0 : (offset >= tbuf->data_len)) {
773 : 0 : offset -= tbuf->data_len;
774 : : tbuf = tbuf->next;
775 : : }
776 : : /*
777 : : * If there is not enough room in segment,
778 : : * place the digest in the next segment
779 : : */
780 : 0 : if ((tbuf->data_len - offset) < options->digest_sz) {
781 : : tbuf = tbuf->next;
782 : : offset = 0;
783 : : }
784 : : buf = tbuf;
785 : : }
786 : :
787 : 0 : sym_op->aead.digest.data = rte_pktmbuf_mtod_offset(buf,
788 : : uint8_t *, offset);
789 : 0 : sym_op->aead.digest.phys_addr =
790 : 0 : rte_pktmbuf_iova_offset(buf, offset);
791 : : }
792 : : }
793 : :
794 : 0 : if ((options->test == CPERF_TEST_TYPE_VERIFY) ||
795 : 0 : (options->test == CPERF_TEST_TYPE_LATENCY) ||
796 : 0 : (options->test == CPERF_TEST_TYPE_THROUGHPUT &&
797 : 0 : (options->aead_op == RTE_CRYPTO_AEAD_OP_DECRYPT ||
798 : 0 : options->cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT))) {
799 : 0 : for (i = 0; i < nb_ops; i++) {
800 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ops[i],
801 : : uint8_t *, iv_offset);
802 : :
803 : : /*
804 : : * If doing AES-CCM, nonce is copied one byte
805 : : * after the start of IV field, and AAD is copied
806 : : * 18 bytes after the start of the AAD field.
807 : : */
808 : 0 : if (options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) {
809 : 0 : memcpy(iv_ptr + 1, test_vector->aead_iv.data,
810 : 0 : test_vector->aead_iv.length);
811 : :
812 : 0 : memcpy(ops[i]->sym->aead.aad.data + 18,
813 : 0 : test_vector->aad.data,
814 : 0 : test_vector->aad.length);
815 : : } else {
816 : 0 : memcpy(iv_ptr, test_vector->aead_iv.data,
817 : 0 : test_vector->aead_iv.length);
818 : :
819 : 0 : memcpy(ops[i]->sym->aead.aad.data,
820 : 0 : test_vector->aad.data,
821 : 0 : test_vector->aad.length);
822 : : }
823 : : }
824 : : }
825 : 0 : }
826 : :
827 : : static void *
828 : 0 : create_ipsec_session(struct rte_mempool *sess_mp,
829 : : uint8_t dev_id,
830 : : const struct cperf_options *options,
831 : : const struct cperf_test_vector *test_vector,
832 : : uint16_t iv_offset)
833 : : {
834 : 0 : struct rte_crypto_sym_xform auth_xform = {0};
835 : : struct rte_crypto_sym_xform *crypto_xform;
836 : 0 : struct rte_crypto_sym_xform xform = {0};
837 : :
838 : 0 : if (options->aead_algo != 0) {
839 : : /* Setup AEAD Parameters */
840 : 0 : xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
841 : : xform.next = NULL;
842 : 0 : xform.aead.algo = options->aead_algo;
843 : 0 : xform.aead.op = options->aead_op;
844 : 0 : xform.aead.iv.offset = iv_offset;
845 : 0 : xform.aead.key.data = test_vector->aead_key.data;
846 : 0 : xform.aead.key.length = test_vector->aead_key.length;
847 : 0 : xform.aead.iv.length = test_vector->aead_iv.length;
848 : 0 : xform.aead.digest_length = options->digest_sz;
849 : 0 : xform.aead.aad_length = options->aead_aad_sz;
850 : : crypto_xform = &xform;
851 : 0 : } else if (options->cipher_algo != 0 && options->auth_algo != 0) {
852 : : /* Setup Cipher Parameters */
853 : 0 : xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
854 : 0 : xform.cipher.algo = options->cipher_algo;
855 : 0 : xform.cipher.op = options->cipher_op;
856 : 0 : xform.cipher.iv.offset = iv_offset;
857 : 0 : xform.cipher.iv.length = test_vector->cipher_iv.length;
858 : : /* cipher different than null */
859 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
860 : 0 : xform.cipher.key.data = test_vector->cipher_key.data;
861 : 0 : xform.cipher.key.length =
862 : 0 : test_vector->cipher_key.length;
863 : : } else {
864 : : xform.cipher.key.data = NULL;
865 : : xform.cipher.key.length = 0;
866 : : }
867 : :
868 : : /* Setup Auth Parameters */
869 : 0 : auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
870 : 0 : auth_xform.auth.algo = options->auth_algo;
871 : 0 : auth_xform.auth.op = options->auth_op;
872 : 0 : auth_xform.auth.iv.offset = iv_offset +
873 : : xform.cipher.iv.length;
874 : : /* auth different than null */
875 : 0 : if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
876 : 0 : auth_xform.auth.digest_length = options->digest_sz;
877 : 0 : auth_xform.auth.key.length =
878 : 0 : test_vector->auth_key.length;
879 : 0 : auth_xform.auth.key.data = test_vector->auth_key.data;
880 : 0 : auth_xform.auth.iv.length = test_vector->auth_iv.length;
881 : : } else {
882 : : auth_xform.auth.digest_length = 0;
883 : : auth_xform.auth.key.length = 0;
884 : : auth_xform.auth.key.data = NULL;
885 : : auth_xform.auth.iv.length = 0;
886 : : }
887 : :
888 : 0 : if (options->is_outbound) {
889 : : crypto_xform = &xform;
890 : 0 : xform.next = &auth_xform;
891 : : auth_xform.next = NULL;
892 : : } else {
893 : : crypto_xform = &auth_xform;
894 : 0 : auth_xform.next = &xform;
895 : : xform.next = NULL;
896 : : }
897 : : } else {
898 : : return NULL;
899 : : }
900 : :
901 : : #define CPERF_IPSEC_SRC_IP 0x01010101
902 : : #define CPERF_IPSEC_DST_IP 0x02020202
903 : : #define CPERF_IPSEC_SALT 0x0
904 : : #define CPERF_IPSEC_DEFTTL 64
905 : 0 : struct rte_security_ipsec_tunnel_param tunnel = {
906 : : .type = RTE_SECURITY_IPSEC_TUNNEL_IPV4,
907 : : {.ipv4 = {
908 : : .src_ip = { .s_addr = CPERF_IPSEC_SRC_IP},
909 : : .dst_ip = { .s_addr = CPERF_IPSEC_DST_IP},
910 : : .dscp = 0,
911 : : .df = 0,
912 : : .ttl = CPERF_IPSEC_DEFTTL,
913 : : } },
914 : : };
915 : 0 : struct rte_security_session_conf sess_conf = {
916 : : .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
917 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
918 : : {.ipsec = {
919 : 0 : .spi = rte_lcore_id() + 1,
920 : : /**< For testing sake, lcore_id is taken as SPI so that
921 : : * for every core a different session is created.
922 : : */
923 : : .salt = CPERF_IPSEC_SALT,
924 : : .options = { 0 },
925 : : .replay_win_sz = 0,
926 : : .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
927 : : .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
928 : : .tunnel = tunnel,
929 : : } },
930 : : .userdata = NULL,
931 : : .crypto_xform = crypto_xform,
932 : : };
933 : :
934 : 0 : if (options->is_outbound)
935 : : sess_conf.ipsec.direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS;
936 : : else
937 : 0 : sess_conf.ipsec.direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS;
938 : :
939 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(dev_id);
940 : :
941 : : /* Create security session */
942 : 0 : return (void *)rte_security_session_create(ctx, &sess_conf, sess_mp);
943 : : }
944 : :
945 : : static void *
946 : 0 : create_tls_session(struct rte_mempool *sess_mp,
947 : : uint8_t dev_id,
948 : : const struct cperf_options *options,
949 : : const struct cperf_test_vector *test_vector,
950 : : uint16_t iv_offset)
951 : : {
952 : 0 : struct rte_crypto_sym_xform auth_xform = {0};
953 : : struct rte_crypto_sym_xform *crypto_xform;
954 : 0 : struct rte_crypto_sym_xform xform = {0};
955 : :
956 : 0 : if (options->aead_algo != 0) {
957 : : /* Setup AEAD Parameters */
958 : 0 : xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
959 : : xform.next = NULL;
960 : 0 : xform.aead.algo = options->aead_algo;
961 : 0 : xform.aead.op = options->aead_op;
962 : 0 : xform.aead.iv.offset = iv_offset;
963 : 0 : xform.aead.key.data = test_vector->aead_key.data;
964 : 0 : xform.aead.key.length = test_vector->aead_key.length;
965 : 0 : xform.aead.iv.length = test_vector->aead_iv.length;
966 : 0 : xform.aead.digest_length = options->digest_sz;
967 : 0 : xform.aead.aad_length = options->aead_aad_sz;
968 : : crypto_xform = &xform;
969 : 0 : } else if (options->cipher_algo != 0 && options->auth_algo != 0) {
970 : : /* Setup Cipher Parameters */
971 : 0 : xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
972 : 0 : xform.cipher.algo = options->cipher_algo;
973 : 0 : xform.cipher.op = options->cipher_op;
974 : 0 : xform.cipher.iv.offset = iv_offset;
975 : 0 : xform.cipher.iv.length = test_vector->cipher_iv.length;
976 : : /* cipher different than null */
977 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
978 : 0 : xform.cipher.key.data = test_vector->cipher_key.data;
979 : 0 : xform.cipher.key.length = test_vector->cipher_key.length;
980 : : } else {
981 : : xform.cipher.key.data = NULL;
982 : : xform.cipher.key.length = 0;
983 : : }
984 : :
985 : : /* Setup Auth Parameters */
986 : 0 : auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
987 : 0 : auth_xform.auth.algo = options->auth_algo;
988 : 0 : auth_xform.auth.op = options->auth_op;
989 : 0 : auth_xform.auth.iv.offset = iv_offset + xform.cipher.iv.length;
990 : : /* auth different than null */
991 : 0 : if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
992 : 0 : auth_xform.auth.digest_length = options->digest_sz;
993 : 0 : auth_xform.auth.key.length = test_vector->auth_key.length;
994 : 0 : auth_xform.auth.key.data = test_vector->auth_key.data;
995 : 0 : auth_xform.auth.iv.length = test_vector->auth_iv.length;
996 : : } else {
997 : : auth_xform.auth.digest_length = 0;
998 : : auth_xform.auth.key.length = 0;
999 : : auth_xform.auth.key.data = NULL;
1000 : : auth_xform.auth.iv.length = 0;
1001 : : }
1002 : :
1003 : 0 : if (options->is_outbound) {
1004 : : /* Currently supporting AUTH then Encrypt mode only for TLS. */
1005 : : crypto_xform = &auth_xform;
1006 : 0 : auth_xform.next = &xform;
1007 : : xform.next = NULL;
1008 : : } else {
1009 : : crypto_xform = &xform;
1010 : 0 : xform.next = &auth_xform;
1011 : : auth_xform.next = NULL;
1012 : : }
1013 : : } else {
1014 : : return NULL;
1015 : : }
1016 : :
1017 : : struct rte_security_tls_record_sess_options opts = {
1018 : : .iv_gen_disable = 0,
1019 : : .extra_padding_enable = 0,
1020 : : };
1021 : 0 : struct rte_security_session_conf sess_conf = {
1022 : : .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1023 : : .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
1024 : : {.tls_record = {
1025 : : .ver = RTE_SECURITY_VERSION_TLS_1_2,
1026 : : .options = opts,
1027 : : } },
1028 : : .userdata = NULL,
1029 : : .crypto_xform = crypto_xform,
1030 : : };
1031 : 0 : if (options->tls_version)
1032 : 0 : sess_conf.tls_record.ver = options->tls_version;
1033 : :
1034 : 0 : if (options->is_outbound)
1035 : 0 : sess_conf.tls_record.type = RTE_SECURITY_TLS_SESS_TYPE_WRITE;
1036 : : else
1037 : : sess_conf.tls_record.type = RTE_SECURITY_TLS_SESS_TYPE_READ;
1038 : :
1039 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(dev_id);
1040 : :
1041 : : /* Create security session */
1042 : 0 : return (void *)rte_security_session_create(ctx, &sess_conf, sess_mp);
1043 : : }
1044 : :
1045 : : static void *
1046 : 0 : cperf_create_session(struct rte_mempool *sess_mp,
1047 : : uint8_t dev_id,
1048 : : const struct cperf_options *options,
1049 : : const struct cperf_test_vector *test_vector,
1050 : : uint16_t iv_offset)
1051 : : {
1052 : : struct rte_crypto_sym_xform cipher_xform;
1053 : : struct rte_crypto_sym_xform auth_xform;
1054 : : struct rte_crypto_sym_xform aead_xform;
1055 : : void *sess = NULL;
1056 : 0 : void *asym_sess = NULL;
1057 : 0 : struct rte_crypto_asym_xform xform = {0};
1058 : : int ret;
1059 : :
1060 : 0 : if (options->op_type == CPERF_ASYM_MODEX) {
1061 : : xform.next = NULL;
1062 : 0 : xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
1063 : 0 : xform.modex.modulus.data = options->modex_data->modulus.data;
1064 : 0 : xform.modex.modulus.length = options->modex_data->modulus.len;
1065 : 0 : xform.modex.exponent.data = options->modex_data->exponent.data;
1066 : 0 : xform.modex.exponent.length = options->modex_data->exponent.len;
1067 : :
1068 : 0 : ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1069 : : sess_mp, &asym_sess);
1070 : 0 : if (ret < 0) {
1071 : 0 : RTE_LOG(ERR, USER1, "Asym session create failed\n");
1072 : 0 : return NULL;
1073 : : }
1074 : 0 : return asym_sess;
1075 : : }
1076 : :
1077 : : if (options->op_type == CPERF_ASYM_RSA) {
1078 : : xform.next = NULL;
1079 : 0 : xform.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA;
1080 : 0 : xform.rsa.padding.type = options->rsa_data->padding;
1081 : 0 : xform.rsa.n.data = options->rsa_data->n.data;
1082 : 0 : xform.rsa.n.length = options->rsa_data->n.length;
1083 : 0 : xform.rsa.e.data = options->rsa_data->e.data;
1084 : 0 : xform.rsa.e.length = options->rsa_data->e.length;
1085 : 0 : xform.rsa.d.data = options->rsa_data->d.data;
1086 : 0 : xform.rsa.d.length = options->rsa_data->d.length;
1087 : 0 : xform.rsa.key_type = options->rsa_data->key_type;
1088 : 0 : if (xform.rsa.key_type == RTE_RSA_KEY_TYPE_QT) {
1089 : 0 : xform.rsa.qt.p.data = options->rsa_data->p.data;
1090 : 0 : xform.rsa.qt.p.length = options->rsa_data->p.length;
1091 : 0 : xform.rsa.qt.q.data = options->rsa_data->q.data;
1092 : 0 : xform.rsa.qt.q.length = options->rsa_data->q.length;
1093 : 0 : xform.rsa.qt.dP.data = options->rsa_data->dp.data;
1094 : 0 : xform.rsa.qt.dP.length = options->rsa_data->dp.length;
1095 : 0 : xform.rsa.qt.dQ.data = options->rsa_data->dq.data;
1096 : 0 : xform.rsa.qt.dQ.length = options->rsa_data->dq.length;
1097 : 0 : xform.rsa.qt.qInv.data = options->rsa_data->qinv.data;
1098 : 0 : xform.rsa.qt.qInv.length = options->rsa_data->qinv.length;
1099 : : }
1100 : 0 : ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1101 : : sess_mp, &asym_sess);
1102 : 0 : if (ret < 0) {
1103 : 0 : RTE_LOG(ERR, USER1, "Asym session create failed\n");
1104 : 0 : return NULL;
1105 : : }
1106 : 0 : return asym_sess;
1107 : : }
1108 : :
1109 : : if (options->op_type == CPERF_ASYM_SECP256R1) {
1110 : : xform.next = NULL;
1111 : 0 : xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDSA;
1112 : 0 : xform.ec.curve_id = options->secp256r1_data->curve;
1113 : 0 : xform.ec.pkey.data = options->secp256r1_data->pkey.data;
1114 : 0 : xform.ec.pkey.length = options->secp256r1_data->pkey.length;
1115 : 0 : xform.ec.q.x.data = options->secp256r1_data->pubkey_qx.data;
1116 : 0 : xform.ec.q.x.length = options->secp256r1_data->pubkey_qx.length;
1117 : 0 : xform.ec.q.y.data = options->secp256r1_data->pubkey_qy.data;
1118 : 0 : xform.ec.q.y.length = options->secp256r1_data->pubkey_qy.length;
1119 : :
1120 : 0 : ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1121 : : sess_mp, &asym_sess);
1122 : 0 : if (ret < 0) {
1123 : 0 : RTE_LOG(ERR, USER1, "ECDSA Asym session create failed\n");
1124 : 0 : return NULL;
1125 : : }
1126 : :
1127 : 0 : return asym_sess;
1128 : : }
1129 : :
1130 : : if (options->op_type == CPERF_ASYM_ED25519) {
1131 : : xform.next = NULL;
1132 : 0 : xform.xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA;
1133 : 0 : xform.ec.curve_id = options->eddsa_data->curve;
1134 : 0 : xform.ec.pkey.data = options->eddsa_data->pkey.data;
1135 : 0 : xform.ec.pkey.length = options->eddsa_data->pkey.length;
1136 : 0 : xform.ec.q.x.data = options->eddsa_data->pubkey.data;
1137 : 0 : xform.ec.q.x.length = options->eddsa_data->pubkey.length;
1138 : :
1139 : 0 : ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1140 : : sess_mp, &asym_sess);
1141 : 0 : if (ret < 0) {
1142 : 0 : RTE_LOG(ERR, USER1, "EdDSA Asym session create failed\n");
1143 : 0 : return NULL;
1144 : : }
1145 : :
1146 : 0 : return asym_sess;
1147 : : }
1148 : :
1149 : : if (options->op_type == CPERF_ASYM_SM2) {
1150 : : xform.next = NULL;
1151 : 0 : xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
1152 : 0 : xform.ec.curve_id = options->sm2_data->curve;
1153 : 0 : xform.ec.pkey.data = options->sm2_data->pkey.data;
1154 : 0 : xform.ec.pkey.length = options->sm2_data->pkey.length;
1155 : 0 : xform.ec.q.x.data = options->sm2_data->pubkey_qx.data;
1156 : 0 : xform.ec.q.x.length = options->sm2_data->pubkey_qx.length;
1157 : 0 : xform.ec.q.y.data = options->sm2_data->pubkey_qy.data;
1158 : 0 : xform.ec.q.y.length = options->sm2_data->pubkey_qy.length;
1159 : :
1160 : 0 : ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1161 : : sess_mp, &asym_sess);
1162 : 0 : if (ret < 0) {
1163 : 0 : RTE_LOG(ERR, USER1, "SM2 Asym session create failed\n");
1164 : 0 : return NULL;
1165 : : }
1166 : :
1167 : 0 : return asym_sess;
1168 : : }
1169 : : #ifdef RTE_LIB_SECURITY
1170 : : /*
1171 : : * security only
1172 : : */
1173 : : if (options->op_type == CPERF_PDCP) {
1174 : : /* Setup Cipher Parameters */
1175 : 0 : cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1176 : 0 : cipher_xform.next = NULL;
1177 : 0 : cipher_xform.cipher.algo = options->cipher_algo;
1178 : 0 : cipher_xform.cipher.op = options->cipher_op;
1179 : 0 : cipher_xform.cipher.iv.offset = iv_offset;
1180 : 0 : cipher_xform.cipher.iv.length = 4;
1181 : :
1182 : : /* cipher different than null */
1183 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
1184 : 0 : cipher_xform.cipher.key.data = test_vector->cipher_key.data;
1185 : 0 : cipher_xform.cipher.key.length = test_vector->cipher_key.length;
1186 : : } else {
1187 : 0 : cipher_xform.cipher.key.data = NULL;
1188 : 0 : cipher_xform.cipher.key.length = 0;
1189 : : }
1190 : :
1191 : : /* Setup Auth Parameters */
1192 : 0 : if (options->auth_algo != 0) {
1193 : 0 : auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1194 : 0 : auth_xform.next = NULL;
1195 : 0 : auth_xform.auth.algo = options->auth_algo;
1196 : 0 : auth_xform.auth.op = options->auth_op;
1197 : 0 : auth_xform.auth.iv.offset = iv_offset +
1198 : : cipher_xform.cipher.iv.length;
1199 : :
1200 : : /* auth different than null */
1201 : 0 : if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
1202 : 0 : auth_xform.auth.digest_length = options->digest_sz;
1203 : 0 : auth_xform.auth.key.length = test_vector->auth_key.length;
1204 : 0 : auth_xform.auth.key.data = test_vector->auth_key.data;
1205 : 0 : auth_xform.auth.iv.length = test_vector->auth_iv.length;
1206 : : } else {
1207 : 0 : auth_xform.auth.digest_length = 0;
1208 : 0 : auth_xform.auth.key.length = 0;
1209 : 0 : auth_xform.auth.key.data = NULL;
1210 : 0 : auth_xform.auth.iv.length = 0;
1211 : : }
1212 : :
1213 : 0 : cipher_xform.next = &auth_xform;
1214 : : } else {
1215 : : cipher_xform.next = NULL;
1216 : : }
1217 : :
1218 : 0 : struct rte_security_session_conf sess_conf = {
1219 : : .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1220 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
1221 : : {.pdcp = {
1222 : : .bearer = 0x16,
1223 : 0 : .domain = options->pdcp_domain,
1224 : : .pkt_dir = 0,
1225 : 0 : .sn_size = options->pdcp_sn_sz,
1226 : 0 : .hfn = options->pdcp_ses_hfn_en ?
1227 : 0 : PDCP_DEFAULT_HFN : 0,
1228 : : .hfn_threshold = 0x70C0A,
1229 : 0 : .sdap_enabled = options->pdcp_sdap,
1230 : 0 : .hfn_ovrd = !(options->pdcp_ses_hfn_en),
1231 : : } },
1232 : : .crypto_xform = &cipher_xform
1233 : : };
1234 : :
1235 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(dev_id);
1236 : :
1237 : : /* Create security session */
1238 : 0 : return (void *)rte_security_session_create(ctx, &sess_conf, sess_mp);
1239 : : }
1240 : :
1241 : : if (options->op_type == CPERF_IPSEC) {
1242 : 0 : return create_ipsec_session(sess_mp, dev_id,
1243 : : options, test_vector, iv_offset);
1244 : : }
1245 : :
1246 : : if (options->op_type == CPERF_TLS) {
1247 : 0 : return create_tls_session(sess_mp, dev_id,
1248 : : options, test_vector, iv_offset);
1249 : : }
1250 : :
1251 : : if (options->op_type == CPERF_DOCSIS) {
1252 : : enum rte_security_docsis_direction direction;
1253 : :
1254 : 0 : cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1255 : 0 : cipher_xform.next = NULL;
1256 : 0 : cipher_xform.cipher.algo = options->cipher_algo;
1257 : 0 : cipher_xform.cipher.op = options->cipher_op;
1258 : 0 : cipher_xform.cipher.iv.offset = iv_offset;
1259 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
1260 : 0 : cipher_xform.cipher.key.data =
1261 : 0 : test_vector->cipher_key.data;
1262 : 0 : cipher_xform.cipher.key.length =
1263 : 0 : test_vector->cipher_key.length;
1264 : 0 : cipher_xform.cipher.iv.length =
1265 : 0 : test_vector->cipher_iv.length;
1266 : : } else {
1267 : 0 : cipher_xform.cipher.key.data = NULL;
1268 : 0 : cipher_xform.cipher.key.length = 0;
1269 : 0 : cipher_xform.cipher.iv.length = 0;
1270 : : }
1271 : : cipher_xform.next = NULL;
1272 : :
1273 : 0 : if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
1274 : : direction = RTE_SECURITY_DOCSIS_DOWNLINK;
1275 : : else
1276 : : direction = RTE_SECURITY_DOCSIS_UPLINK;
1277 : :
1278 : 0 : struct rte_security_session_conf sess_conf = {
1279 : : .action_type =
1280 : : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
1281 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
1282 : : {.docsis = {
1283 : : .direction = direction,
1284 : : } },
1285 : : .crypto_xform = &cipher_xform
1286 : : };
1287 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(dev_id);
1288 : :
1289 : : /* Create security session */
1290 : 0 : return (void *)rte_security_session_create(ctx, &sess_conf, sess_mp);
1291 : : }
1292 : : #endif
1293 : : /*
1294 : : * cipher only
1295 : : */
1296 : : if (options->op_type == CPERF_CIPHER_ONLY) {
1297 : 0 : cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1298 : 0 : cipher_xform.next = NULL;
1299 : 0 : cipher_xform.cipher.algo = options->cipher_algo;
1300 : 0 : cipher_xform.cipher.op = options->cipher_op;
1301 : 0 : cipher_xform.cipher.iv.offset = iv_offset;
1302 : :
1303 : : /* cipher different than null */
1304 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
1305 : 0 : cipher_xform.cipher.key.data =
1306 : 0 : test_vector->cipher_key.data;
1307 : 0 : cipher_xform.cipher.key.length =
1308 : 0 : test_vector->cipher_key.length;
1309 : 0 : cipher_xform.cipher.iv.length =
1310 : 0 : test_vector->cipher_iv.length;
1311 : : } else {
1312 : 0 : cipher_xform.cipher.key.data = NULL;
1313 : 0 : cipher_xform.cipher.key.length = 0;
1314 : 0 : cipher_xform.cipher.iv.length = 0;
1315 : : }
1316 : : /* create crypto session */
1317 : 0 : sess = rte_cryptodev_sym_session_create(dev_id, &cipher_xform,
1318 : : sess_mp);
1319 : : /*
1320 : : * auth only
1321 : : */
1322 : : } else if (options->op_type == CPERF_AUTH_ONLY) {
1323 : 0 : auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1324 : 0 : auth_xform.next = NULL;
1325 : 0 : auth_xform.auth.algo = options->auth_algo;
1326 : 0 : auth_xform.auth.op = options->auth_op;
1327 : 0 : auth_xform.auth.iv.offset = iv_offset;
1328 : :
1329 : : /* auth different than null */
1330 : 0 : if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
1331 : 0 : auth_xform.auth.digest_length =
1332 : 0 : options->digest_sz;
1333 : 0 : auth_xform.auth.key.length =
1334 : 0 : test_vector->auth_key.length;
1335 : 0 : auth_xform.auth.key.data = test_vector->auth_key.data;
1336 : 0 : auth_xform.auth.iv.length =
1337 : 0 : test_vector->auth_iv.length;
1338 : : } else {
1339 : 0 : auth_xform.auth.digest_length = 0;
1340 : 0 : auth_xform.auth.key.length = 0;
1341 : 0 : auth_xform.auth.key.data = NULL;
1342 : 0 : auth_xform.auth.iv.length = 0;
1343 : : }
1344 : : /* create crypto session */
1345 : 0 : sess = rte_cryptodev_sym_session_create(dev_id, &auth_xform,
1346 : : sess_mp);
1347 : : /*
1348 : : * cipher and auth
1349 : : */
1350 : : } else if (options->op_type == CPERF_CIPHER_THEN_AUTH
1351 : : || options->op_type == CPERF_AUTH_THEN_CIPHER) {
1352 : : /*
1353 : : * cipher
1354 : : */
1355 : 0 : cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1356 : 0 : cipher_xform.next = NULL;
1357 : 0 : cipher_xform.cipher.algo = options->cipher_algo;
1358 : 0 : cipher_xform.cipher.op = options->cipher_op;
1359 : 0 : cipher_xform.cipher.iv.offset = iv_offset;
1360 : :
1361 : : /* cipher different than null */
1362 : 0 : if (options->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
1363 : 0 : cipher_xform.cipher.key.data =
1364 : 0 : test_vector->cipher_key.data;
1365 : 0 : cipher_xform.cipher.key.length =
1366 : 0 : test_vector->cipher_key.length;
1367 : 0 : cipher_xform.cipher.iv.length =
1368 : 0 : test_vector->cipher_iv.length;
1369 : : } else {
1370 : 0 : cipher_xform.cipher.key.data = NULL;
1371 : 0 : cipher_xform.cipher.key.length = 0;
1372 : 0 : cipher_xform.cipher.iv.length = 0;
1373 : : }
1374 : :
1375 : : /*
1376 : : * auth
1377 : : */
1378 : 0 : auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1379 : 0 : auth_xform.next = NULL;
1380 : 0 : auth_xform.auth.algo = options->auth_algo;
1381 : 0 : auth_xform.auth.op = options->auth_op;
1382 : 0 : auth_xform.auth.iv.offset = iv_offset +
1383 : 0 : cipher_xform.cipher.iv.length;
1384 : :
1385 : : /* auth different than null */
1386 : 0 : if (options->auth_algo != RTE_CRYPTO_AUTH_NULL) {
1387 : 0 : auth_xform.auth.digest_length = options->digest_sz;
1388 : 0 : auth_xform.auth.iv.length = test_vector->auth_iv.length;
1389 : 0 : auth_xform.auth.key.length =
1390 : 0 : test_vector->auth_key.length;
1391 : 0 : auth_xform.auth.key.data =
1392 : 0 : test_vector->auth_key.data;
1393 : : } else {
1394 : 0 : auth_xform.auth.digest_length = 0;
1395 : 0 : auth_xform.auth.key.length = 0;
1396 : 0 : auth_xform.auth.key.data = NULL;
1397 : 0 : auth_xform.auth.iv.length = 0;
1398 : : }
1399 : :
1400 : : /* cipher then auth */
1401 : 0 : if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
1402 : 0 : cipher_xform.next = &auth_xform;
1403 : : /* create crypto session */
1404 : 0 : sess = rte_cryptodev_sym_session_create(dev_id,
1405 : : &cipher_xform, sess_mp);
1406 : : } else { /* auth then cipher */
1407 : 0 : auth_xform.next = &cipher_xform;
1408 : : /* create crypto session */
1409 : 0 : sess = rte_cryptodev_sym_session_create(dev_id,
1410 : : &auth_xform, sess_mp);
1411 : : }
1412 : : } else { /* options->op_type == CPERF_AEAD */
1413 : 0 : aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
1414 : 0 : aead_xform.next = NULL;
1415 : 0 : aead_xform.aead.algo = options->aead_algo;
1416 : 0 : aead_xform.aead.op = options->aead_op;
1417 : 0 : aead_xform.aead.iv.offset = iv_offset;
1418 : :
1419 : 0 : aead_xform.aead.key.data =
1420 : 0 : test_vector->aead_key.data;
1421 : 0 : aead_xform.aead.key.length =
1422 : 0 : test_vector->aead_key.length;
1423 : 0 : aead_xform.aead.iv.length = test_vector->aead_iv.length;
1424 : :
1425 : 0 : aead_xform.aead.digest_length = options->digest_sz;
1426 : 0 : aead_xform.aead.aad_length =
1427 : 0 : options->aead_aad_sz;
1428 : :
1429 : : /* Create crypto session */
1430 : 0 : sess = rte_cryptodev_sym_session_create(dev_id, &aead_xform,
1431 : : sess_mp);
1432 : : }
1433 : :
1434 : : return sess;
1435 : : }
1436 : :
1437 : : int
1438 : 0 : cperf_get_op_functions(const struct cperf_options *options,
1439 : : struct cperf_op_fns *op_fns)
1440 : : {
1441 : : memset(op_fns, 0, sizeof(struct cperf_op_fns));
1442 : :
1443 : 0 : op_fns->sess_create = cperf_create_session;
1444 : :
1445 : 0 : switch (options->op_type) {
1446 : 0 : case CPERF_AEAD:
1447 : 0 : op_fns->populate_ops = cperf_set_ops_aead;
1448 : 0 : break;
1449 : :
1450 : 0 : case CPERF_AUTH_THEN_CIPHER:
1451 : : case CPERF_CIPHER_THEN_AUTH:
1452 : 0 : op_fns->populate_ops = cperf_set_ops_cipher_auth;
1453 : 0 : break;
1454 : 0 : case CPERF_AUTH_ONLY:
1455 : 0 : if (options->auth_algo == RTE_CRYPTO_AUTH_NULL)
1456 : 0 : op_fns->populate_ops = cperf_set_ops_null_auth;
1457 : : else
1458 : 0 : op_fns->populate_ops = cperf_set_ops_auth;
1459 : : break;
1460 : 0 : case CPERF_CIPHER_ONLY:
1461 : 0 : if (options->cipher_algo == RTE_CRYPTO_CIPHER_NULL)
1462 : 0 : op_fns->populate_ops = cperf_set_ops_null_cipher;
1463 : : else
1464 : 0 : op_fns->populate_ops = cperf_set_ops_cipher;
1465 : : break;
1466 : 0 : case CPERF_ASYM_MODEX:
1467 : 0 : op_fns->populate_ops = cperf_set_ops_asym_modex;
1468 : 0 : break;
1469 : 0 : case CPERF_ASYM_RSA:
1470 : 0 : op_fns->populate_ops = cperf_set_ops_asym_rsa;
1471 : 0 : break;
1472 : 0 : case CPERF_ASYM_SECP256R1:
1473 : 0 : op_fns->populate_ops = cperf_set_ops_asym_ecdsa;
1474 : 0 : break;
1475 : 0 : case CPERF_ASYM_ED25519:
1476 : 0 : op_fns->populate_ops = cperf_set_ops_asym_eddsa;
1477 : 0 : break;
1478 : 0 : case CPERF_ASYM_SM2:
1479 : 0 : op_fns->populate_ops = cperf_set_ops_asym_sm2;
1480 : 0 : break;
1481 : : #ifdef RTE_LIB_SECURITY
1482 : 0 : case CPERF_PDCP:
1483 : : case CPERF_DOCSIS:
1484 : 0 : op_fns->populate_ops = cperf_set_ops_security;
1485 : 0 : break;
1486 : 0 : case CPERF_IPSEC:
1487 : 0 : op_fns->populate_ops = cperf_set_ops_security_ipsec;
1488 : 0 : break;
1489 : 0 : case CPERF_TLS:
1490 : 0 : op_fns->populate_ops = cperf_set_ops_security_tls;
1491 : 0 : break;
1492 : : #endif
1493 : : default:
1494 : : return -1;
1495 : : }
1496 : :
1497 : : return 0;
1498 : : }
|