]> git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/drivers/crypto/kasumi/rte_kasumi_pmd.c
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / dpdk / drivers / crypto / kasumi / rte_kasumi_pmd.c
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright(c) 2016 Intel Corporation. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include <rte_common.h>
34 #include <rte_config.h>
35 #include <rte_hexdump.h>
36 #include <rte_cryptodev.h>
37 #include <rte_cryptodev_pmd.h>
38 #include <rte_vdev.h>
39 #include <rte_malloc.h>
40 #include <rte_cpuflags.h>
41
42 #include "rte_kasumi_pmd_private.h"
43
44 #define KASUMI_KEY_LENGTH 16
45 #define KASUMI_IV_LENGTH 8
46 #define KASUMI_DIGEST_LENGTH 4
47 #define KASUMI_MAX_BURST 4
48 #define BYTE_LEN 8
49
50 /**
51 * Global static parameter used to create a unique name for each KASUMI
52 * crypto device.
53 */
54 static unsigned unique_name_id;
55
56 static inline int
57 create_unique_device_name(char *name, size_t size)
58 {
59 int ret;
60
61 if (name == NULL)
62 return -EINVAL;
63
64 ret = snprintf(name, size, "%s_%u", RTE_STR(CRYPTODEV_NAME_KASUMI_PMD),
65 unique_name_id++);
66 if (ret < 0)
67 return ret;
68 return 0;
69 }
70
71 /** Get xform chain order. */
72 static enum kasumi_operation
73 kasumi_get_mode(const struct rte_crypto_sym_xform *xform)
74 {
75 if (xform == NULL)
76 return KASUMI_OP_NOT_SUPPORTED;
77
78 if (xform->next)
79 if (xform->next->next != NULL)
80 return KASUMI_OP_NOT_SUPPORTED;
81
82 if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH) {
83 if (xform->next == NULL)
84 return KASUMI_OP_ONLY_AUTH;
85 else if (xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER)
86 return KASUMI_OP_AUTH_CIPHER;
87 else
88 return KASUMI_OP_NOT_SUPPORTED;
89 }
90
91 if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER) {
92 if (xform->next == NULL)
93 return KASUMI_OP_ONLY_CIPHER;
94 else if (xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH)
95 return KASUMI_OP_CIPHER_AUTH;
96 else
97 return KASUMI_OP_NOT_SUPPORTED;
98 }
99
100 return KASUMI_OP_NOT_SUPPORTED;
101 }
102
103
104 /** Parse crypto xform chain and set private session parameters. */
105 int
106 kasumi_set_session_parameters(struct kasumi_session *sess,
107 const struct rte_crypto_sym_xform *xform)
108 {
109 const struct rte_crypto_sym_xform *auth_xform = NULL;
110 const struct rte_crypto_sym_xform *cipher_xform = NULL;
111 enum kasumi_operation mode;
112
113 /* Select Crypto operation - hash then cipher / cipher then hash */
114 mode = kasumi_get_mode(xform);
115
116 switch (mode) {
117 case KASUMI_OP_CIPHER_AUTH:
118 auth_xform = xform->next;
119 /* Fall-through */
120 case KASUMI_OP_ONLY_CIPHER:
121 cipher_xform = xform;
122 break;
123 case KASUMI_OP_AUTH_CIPHER:
124 cipher_xform = xform->next;
125 /* Fall-through */
126 case KASUMI_OP_ONLY_AUTH:
127 auth_xform = xform;
128 break;
129 case KASUMI_OP_NOT_SUPPORTED:
130 default:
131 KASUMI_LOG_ERR("Unsupported operation chain order parameter");
132 return -EINVAL;
133 }
134
135 if (cipher_xform) {
136 /* Only KASUMI F8 supported */
137 if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_KASUMI_F8)
138 return -EINVAL;
139 /* Initialize key */
140 sso_kasumi_init_f8_key_sched(xform->cipher.key.data,
141 &sess->pKeySched_cipher);
142 }
143
144 if (auth_xform) {
145 /* Only KASUMI F9 supported */
146 if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_KASUMI_F9)
147 return -EINVAL;
148 sess->auth_op = auth_xform->auth.op;
149 /* Initialize key */
150 sso_kasumi_init_f9_key_sched(xform->auth.key.data,
151 &sess->pKeySched_hash);
152 }
153
154
155 sess->op = mode;
156
157 return 0;
158 }
159
160 /** Get KASUMI session. */
161 static struct kasumi_session *
162 kasumi_get_session(struct kasumi_qp *qp, struct rte_crypto_op *op)
163 {
164 struct kasumi_session *sess;
165
166 if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
167 if (unlikely(op->sym->session->dev_type !=
168 RTE_CRYPTODEV_KASUMI_PMD))
169 return NULL;
170
171 sess = (struct kasumi_session *)op->sym->session->_private;
172 } else {
173 struct rte_cryptodev_session *c_sess = NULL;
174
175 if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
176 return NULL;
177
178 sess = (struct kasumi_session *)c_sess->_private;
179
180 if (unlikely(kasumi_set_session_parameters(sess,
181 op->sym->xform) != 0))
182 return NULL;
183 }
184
185 return sess;
186 }
187
188 /** Encrypt/decrypt mbufs with same cipher key. */
189 static uint8_t
190 process_kasumi_cipher_op(struct rte_crypto_op **ops,
191 struct kasumi_session *session,
192 uint8_t num_ops)
193 {
194 unsigned i;
195 uint8_t processed_ops = 0;
196 uint8_t *src[num_ops], *dst[num_ops];
197 uint64_t IV[num_ops];
198 uint32_t num_bytes[num_ops];
199
200 for (i = 0; i < num_ops; i++) {
201 /* Sanity checks. */
202 if (ops[i]->sym->cipher.iv.length != KASUMI_IV_LENGTH) {
203 ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
204 KASUMI_LOG_ERR("iv");
205 break;
206 }
207
208 src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
209 (ops[i]->sym->cipher.data.offset >> 3);
210 dst[i] = ops[i]->sym->m_dst ?
211 rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *) +
212 (ops[i]->sym->cipher.data.offset >> 3) :
213 rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
214 (ops[i]->sym->cipher.data.offset >> 3);
215 IV[i] = *((uint64_t *)(ops[i]->sym->cipher.iv.data));
216 num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
217
218 processed_ops++;
219 }
220
221 if (processed_ops != 0)
222 sso_kasumi_f8_n_buffer(&session->pKeySched_cipher, IV,
223 src, dst, num_bytes, processed_ops);
224
225 return processed_ops;
226 }
227
228 /** Encrypt/decrypt mbuf (bit level function). */
229 static uint8_t
230 process_kasumi_cipher_op_bit(struct rte_crypto_op *op,
231 struct kasumi_session *session)
232 {
233 uint8_t *src, *dst;
234 uint64_t IV;
235 uint32_t length_in_bits, offset_in_bits;
236
237 /* Sanity checks. */
238 if (unlikely(op->sym->cipher.iv.length != KASUMI_IV_LENGTH)) {
239 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
240 KASUMI_LOG_ERR("iv");
241 return 0;
242 }
243
244 offset_in_bits = op->sym->cipher.data.offset;
245 src = rte_pktmbuf_mtod(op->sym->m_src, uint8_t *);
246 if (op->sym->m_dst == NULL) {
247 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
248 KASUMI_LOG_ERR("bit-level in-place not supported\n");
249 return 0;
250 }
251 dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *);
252 IV = *((uint64_t *)(op->sym->cipher.iv.data));
253 length_in_bits = op->sym->cipher.data.length;
254
255 sso_kasumi_f8_1_buffer_bit(&session->pKeySched_cipher, IV,
256 src, dst, length_in_bits, offset_in_bits);
257
258 return 1;
259 }
260
261 /** Generate/verify hash from mbufs with same hash key. */
262 static int
263 process_kasumi_hash_op(struct rte_crypto_op **ops,
264 struct kasumi_session *session,
265 uint8_t num_ops)
266 {
267 unsigned i;
268 uint8_t processed_ops = 0;
269 uint8_t *src, *dst;
270 uint32_t length_in_bits;
271 uint32_t num_bytes;
272 uint32_t shift_bits;
273 uint64_t IV;
274 uint8_t direction;
275
276 for (i = 0; i < num_ops; i++) {
277 if (unlikely(ops[i]->sym->auth.aad.length != KASUMI_IV_LENGTH)) {
278 ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
279 KASUMI_LOG_ERR("aad");
280 break;
281 }
282
283 if (unlikely(ops[i]->sym->auth.digest.length != KASUMI_DIGEST_LENGTH)) {
284 ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
285 KASUMI_LOG_ERR("digest");
286 break;
287 }
288
289 /* Data must be byte aligned */
290 if ((ops[i]->sym->auth.data.offset % BYTE_LEN) != 0) {
291 ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
292 KASUMI_LOG_ERR("offset");
293 break;
294 }
295
296 length_in_bits = ops[i]->sym->auth.data.length;
297
298 src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
299 (ops[i]->sym->auth.data.offset >> 3);
300 /* IV from AAD */
301 IV = *((uint64_t *)(ops[i]->sym->auth.aad.data));
302 /* Direction from next bit after end of message */
303 num_bytes = (length_in_bits >> 3) + 1;
304 shift_bits = (BYTE_LEN - 1 - length_in_bits) % BYTE_LEN;
305 direction = (src[num_bytes - 1] >> shift_bits) & 0x01;
306
307 if (session->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) {
308 dst = (uint8_t *)rte_pktmbuf_append(ops[i]->sym->m_src,
309 ops[i]->sym->auth.digest.length);
310
311 sso_kasumi_f9_1_buffer_user(&session->pKeySched_hash,
312 IV, src,
313 length_in_bits, dst, direction);
314 /* Verify digest. */
315 if (memcmp(dst, ops[i]->sym->auth.digest.data,
316 ops[i]->sym->auth.digest.length) != 0)
317 ops[i]->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
318
319 /* Trim area used for digest from mbuf. */
320 rte_pktmbuf_trim(ops[i]->sym->m_src,
321 ops[i]->sym->auth.digest.length);
322 } else {
323 dst = ops[i]->sym->auth.digest.data;
324
325 sso_kasumi_f9_1_buffer_user(&session->pKeySched_hash,
326 IV, src,
327 length_in_bits, dst, direction);
328 }
329 processed_ops++;
330 }
331
332 return processed_ops;
333 }
334
335 /** Process a batch of crypto ops which shares the same session. */
336 static int
337 process_ops(struct rte_crypto_op **ops, struct kasumi_session *session,
338 struct kasumi_qp *qp, uint8_t num_ops,
339 uint16_t *accumulated_enqueued_ops)
340 {
341 unsigned i;
342 unsigned enqueued_ops, processed_ops;
343
344 switch (session->op) {
345 case KASUMI_OP_ONLY_CIPHER:
346 processed_ops = process_kasumi_cipher_op(ops,
347 session, num_ops);
348 break;
349 case KASUMI_OP_ONLY_AUTH:
350 processed_ops = process_kasumi_hash_op(ops, session,
351 num_ops);
352 break;
353 case KASUMI_OP_CIPHER_AUTH:
354 processed_ops = process_kasumi_cipher_op(ops, session,
355 num_ops);
356 process_kasumi_hash_op(ops, session, processed_ops);
357 break;
358 case KASUMI_OP_AUTH_CIPHER:
359 processed_ops = process_kasumi_hash_op(ops, session,
360 num_ops);
361 process_kasumi_cipher_op(ops, session, processed_ops);
362 break;
363 default:
364 /* Operation not supported. */
365 processed_ops = 0;
366 }
367
368 for (i = 0; i < num_ops; i++) {
369 /*
370 * If there was no error/authentication failure,
371 * change status to successful.
372 */
373 if (ops[i]->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
374 ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
375 /* Free session if a session-less crypto op. */
376 if (ops[i]->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
377 rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
378 ops[i]->sym->session = NULL;
379 }
380 }
381
382 enqueued_ops = rte_ring_enqueue_burst(qp->processed_ops,
383 (void **)ops, processed_ops);
384 qp->qp_stats.enqueued_count += enqueued_ops;
385 *accumulated_enqueued_ops += enqueued_ops;
386
387 return enqueued_ops;
388 }
389
390 /** Process a crypto op with length/offset in bits. */
391 static int
392 process_op_bit(struct rte_crypto_op *op, struct kasumi_session *session,
393 struct kasumi_qp *qp, uint16_t *accumulated_enqueued_ops)
394 {
395 unsigned enqueued_op, processed_op;
396
397 switch (session->op) {
398 case KASUMI_OP_ONLY_CIPHER:
399 processed_op = process_kasumi_cipher_op_bit(op,
400 session);
401 break;
402 case KASUMI_OP_ONLY_AUTH:
403 processed_op = process_kasumi_hash_op(&op, session, 1);
404 break;
405 case KASUMI_OP_CIPHER_AUTH:
406 processed_op = process_kasumi_cipher_op_bit(op, session);
407 if (processed_op == 1)
408 process_kasumi_hash_op(&op, session, 1);
409 break;
410 case KASUMI_OP_AUTH_CIPHER:
411 processed_op = process_kasumi_hash_op(&op, session, 1);
412 if (processed_op == 1)
413 process_kasumi_cipher_op_bit(op, session);
414 break;
415 default:
416 /* Operation not supported. */
417 processed_op = 0;
418 }
419
420 /*
421 * If there was no error/authentication failure,
422 * change status to successful.
423 */
424 if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
425 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
426
427 /* Free session if a session-less crypto op. */
428 if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
429 rte_mempool_put(qp->sess_mp, op->sym->session);
430 op->sym->session = NULL;
431 }
432
433 enqueued_op = rte_ring_enqueue_burst(qp->processed_ops, (void **)&op,
434 processed_op);
435 qp->qp_stats.enqueued_count += enqueued_op;
436 *accumulated_enqueued_ops += enqueued_op;
437
438 return enqueued_op;
439 }
440
441 static uint16_t
442 kasumi_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
443 uint16_t nb_ops)
444 {
445 struct rte_crypto_op *c_ops[nb_ops];
446 struct rte_crypto_op *curr_c_op;
447
448 struct kasumi_session *prev_sess = NULL, *curr_sess = NULL;
449 struct kasumi_qp *qp = queue_pair;
450 unsigned i;
451 uint8_t burst_size = 0;
452 uint16_t enqueued_ops = 0;
453 uint8_t processed_ops;
454
455 for (i = 0; i < nb_ops; i++) {
456 curr_c_op = ops[i];
457
458 /* Set status as enqueued (not processed yet) by default. */
459 curr_c_op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
460
461 curr_sess = kasumi_get_session(qp, curr_c_op);
462 if (unlikely(curr_sess == NULL ||
463 curr_sess->op == KASUMI_OP_NOT_SUPPORTED)) {
464 curr_c_op->status =
465 RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
466 break;
467 }
468
469 /* If length/offset is at bit-level, process this buffer alone. */
470 if (((curr_c_op->sym->cipher.data.length % BYTE_LEN) != 0)
471 || ((ops[i]->sym->cipher.data.offset
472 % BYTE_LEN) != 0)) {
473 /* Process the ops of the previous session. */
474 if (prev_sess != NULL) {
475 processed_ops = process_ops(c_ops, prev_sess,
476 qp, burst_size, &enqueued_ops);
477 if (processed_ops < burst_size) {
478 burst_size = 0;
479 break;
480 }
481
482 burst_size = 0;
483 prev_sess = NULL;
484 }
485
486 processed_ops = process_op_bit(curr_c_op, curr_sess,
487 qp, &enqueued_ops);
488 if (processed_ops != 1)
489 break;
490
491 continue;
492 }
493
494 /* Batch ops that share the same session. */
495 if (prev_sess == NULL) {
496 prev_sess = curr_sess;
497 c_ops[burst_size++] = curr_c_op;
498 } else if (curr_sess == prev_sess) {
499 c_ops[burst_size++] = curr_c_op;
500 /*
501 * When there are enough ops to process in a batch,
502 * process them, and start a new batch.
503 */
504 if (burst_size == KASUMI_MAX_BURST) {
505 processed_ops = process_ops(c_ops, prev_sess,
506 qp, burst_size, &enqueued_ops);
507 if (processed_ops < burst_size) {
508 burst_size = 0;
509 break;
510 }
511
512 burst_size = 0;
513 prev_sess = NULL;
514 }
515 } else {
516 /*
517 * Different session, process the ops
518 * of the previous session.
519 */
520 processed_ops = process_ops(c_ops, prev_sess,
521 qp, burst_size, &enqueued_ops);
522 if (processed_ops < burst_size) {
523 burst_size = 0;
524 break;
525 }
526
527 burst_size = 0;
528 prev_sess = curr_sess;
529
530 c_ops[burst_size++] = curr_c_op;
531 }
532 }
533
534 if (burst_size != 0) {
535 /* Process the crypto ops of the last session. */
536 processed_ops = process_ops(c_ops, prev_sess,
537 qp, burst_size, &enqueued_ops);
538 }
539
540 qp->qp_stats.enqueue_err_count += nb_ops - enqueued_ops;
541 return enqueued_ops;
542 }
543
544 static uint16_t
545 kasumi_pmd_dequeue_burst(void *queue_pair,
546 struct rte_crypto_op **c_ops, uint16_t nb_ops)
547 {
548 struct kasumi_qp *qp = queue_pair;
549
550 unsigned nb_dequeued;
551
552 nb_dequeued = rte_ring_dequeue_burst(qp->processed_ops,
553 (void **)c_ops, nb_ops);
554 qp->qp_stats.dequeued_count += nb_dequeued;
555
556 return nb_dequeued;
557 }
558
559 static int cryptodev_kasumi_remove(const char *name);
560
561 static int
562 cryptodev_kasumi_create(const char *name,
563 struct rte_crypto_vdev_init_params *init_params)
564 {
565 struct rte_cryptodev *dev;
566 char crypto_dev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
567 struct kasumi_private *internals;
568 uint64_t cpu_flags = 0;
569
570 /* Check CPU for supported vector instruction set */
571 if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX))
572 cpu_flags |= RTE_CRYPTODEV_FF_CPU_AVX;
573 else if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SSE4_1))
574 cpu_flags |= RTE_CRYPTODEV_FF_CPU_SSE;
575 else {
576 KASUMI_LOG_ERR("Vector instructions are not supported by CPU");
577 return -EFAULT;
578 }
579
580 /* Create a unique device name. */
581 if (create_unique_device_name(crypto_dev_name,
582 RTE_CRYPTODEV_NAME_MAX_LEN) != 0) {
583 KASUMI_LOG_ERR("failed to create unique cryptodev name");
584 return -EINVAL;
585 }
586
587 dev = rte_cryptodev_pmd_virtual_dev_init(crypto_dev_name,
588 sizeof(struct kasumi_private), init_params->socket_id);
589 if (dev == NULL) {
590 KASUMI_LOG_ERR("failed to create cryptodev vdev");
591 goto init_error;
592 }
593
594 dev->dev_type = RTE_CRYPTODEV_KASUMI_PMD;
595 dev->dev_ops = rte_kasumi_pmd_ops;
596
597 /* Register RX/TX burst functions for data path. */
598 dev->dequeue_burst = kasumi_pmd_dequeue_burst;
599 dev->enqueue_burst = kasumi_pmd_enqueue_burst;
600
601 dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
602 RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
603 cpu_flags;
604
605 internals = dev->data->dev_private;
606
607 internals->max_nb_queue_pairs = init_params->max_nb_queue_pairs;
608 internals->max_nb_sessions = init_params->max_nb_sessions;
609
610 return 0;
611 init_error:
612 KASUMI_LOG_ERR("driver %s: cryptodev_kasumi_create failed", name);
613
614 cryptodev_kasumi_remove(crypto_dev_name);
615 return -EFAULT;
616 }
617
618 static int
619 cryptodev_kasumi_probe(const char *name,
620 const char *input_args)
621 {
622 struct rte_crypto_vdev_init_params init_params = {
623 RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS,
624 RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_SESSIONS,
625 rte_socket_id()
626 };
627
628 rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
629
630 RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name,
631 init_params.socket_id);
632 RTE_LOG(INFO, PMD, " Max number of queue pairs = %d\n",
633 init_params.max_nb_queue_pairs);
634 RTE_LOG(INFO, PMD, " Max number of sessions = %d\n",
635 init_params.max_nb_sessions);
636
637 return cryptodev_kasumi_create(name, &init_params);
638 }
639
640 static int
641 cryptodev_kasumi_remove(const char *name)
642 {
643 if (name == NULL)
644 return -EINVAL;
645
646 RTE_LOG(INFO, PMD, "Closing KASUMI crypto device %s"
647 " on numa socket %u\n",
648 name, rte_socket_id());
649
650 return 0;
651 }
652
653 static struct rte_vdev_driver cryptodev_kasumi_pmd_drv = {
654 .probe = cryptodev_kasumi_probe,
655 .remove = cryptodev_kasumi_remove
656 };
657
658 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_KASUMI_PMD, cryptodev_kasumi_pmd_drv);
659 RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_KASUMI_PMD, cryptodev_kasumi_pmd);
660 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_KASUMI_PMD,
661 "max_nb_queue_pairs=<int> "
662 "max_nb_sessions=<int> "
663 "socket_id=<int>");