crypto/snow3g: support bit-level operations
[dpdk.git] / drivers / crypto / snow3g / rte_snow3g_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_dev.h>
39 #include <rte_malloc.h>
40 #include <rte_cpuflags.h>
41 #include <rte_kvargs.h>
42
43 #include "rte_snow3g_pmd_private.h"
44
45 #define SNOW3G_IV_LENGTH 16
46 #define SNOW3G_DIGEST_LENGTH 4
47 #define SNOW3G_MAX_BURST 8
48 #define BYTE_LEN 8
49
50 /**
51  * Global static parameter used to create a unique name for each SNOW 3G
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", CRYPTODEV_NAME_SNOW3G_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 snow3g_operation
73 snow3g_get_mode(const struct rte_crypto_sym_xform *xform)
74 {
75         if (xform == NULL)
76                 return SNOW3G_OP_NOT_SUPPORTED;
77
78         if (xform->next)
79                 if (xform->next->next != NULL)
80                         return SNOW3G_OP_NOT_SUPPORTED;
81
82         if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH) {
83                 if (xform->next == NULL)
84                         return SNOW3G_OP_ONLY_AUTH;
85                 else if (xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER)
86                         return SNOW3G_OP_AUTH_CIPHER;
87                 else
88                         return SNOW3G_OP_NOT_SUPPORTED;
89         }
90
91         if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER) {
92                 if (xform->next == NULL)
93                         return SNOW3G_OP_ONLY_CIPHER;
94                 else if (xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH)
95                         return SNOW3G_OP_CIPHER_AUTH;
96                 else
97                         return SNOW3G_OP_NOT_SUPPORTED;
98         }
99
100         return SNOW3G_OP_NOT_SUPPORTED;
101 }
102
103
104 /** Parse crypto xform chain and set private session parameters. */
105 int
106 snow3g_set_session_parameters(struct snow3g_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         int mode;
112
113         /* Select Crypto operation - hash then cipher / cipher then hash */
114         mode = snow3g_get_mode(xform);
115
116         switch (mode) {
117         case SNOW3G_OP_CIPHER_AUTH:
118                 auth_xform = xform->next;
119
120                 /* Fall-through */
121         case SNOW3G_OP_ONLY_CIPHER:
122                 cipher_xform = xform;
123                 break;
124         case SNOW3G_OP_AUTH_CIPHER:
125                 cipher_xform = xform->next;
126                 /* Fall-through */
127         case SNOW3G_OP_ONLY_AUTH:
128                 auth_xform = xform;
129         }
130
131         if (mode == SNOW3G_OP_NOT_SUPPORTED) {
132                 SNOW3G_LOG_ERR("Unsupported operation chain order parameter");
133                 return -EINVAL;
134         }
135
136         if (cipher_xform) {
137                 /* Only SNOW 3G UEA2 supported */
138                 if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_SNOW3G_UEA2)
139                         return -EINVAL;
140                 /* Initialize key */
141                 sso_snow3g_init_key_sched(xform->cipher.key.data,
142                                 &sess->pKeySched_cipher);
143         }
144
145         if (auth_xform) {
146                 /* Only SNOW 3G UIA2 supported */
147                 if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_SNOW3G_UIA2)
148                         return -EINVAL;
149                 sess->auth_op = auth_xform->auth.op;
150                 /* Initialize key */
151                 sso_snow3g_init_key_sched(xform->auth.key.data,
152                                 &sess->pKeySched_hash);
153         }
154
155
156         sess->op = mode;
157
158         return 0;
159 }
160
161 /** Get SNOW 3G session. */
162 static struct snow3g_session *
163 snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
164 {
165         struct snow3g_session *sess;
166
167         if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_WITH_SESSION) {
168                 if (unlikely(op->sym->session->dev_type !=
169                                 RTE_CRYPTODEV_SNOW3G_PMD))
170                         return NULL;
171
172                 sess = (struct snow3g_session *)op->sym->session->_private;
173         } else  {
174                 struct rte_cryptodev_session *c_sess = NULL;
175
176                 if (rte_mempool_get(qp->sess_mp, (void **)&c_sess))
177                         return NULL;
178
179                 sess = (struct snow3g_session *)c_sess->_private;
180
181                 if (unlikely(snow3g_set_session_parameters(sess,
182                                 op->sym->xform) != 0))
183                         return NULL;
184         }
185
186         return sess;
187 }
188
189 /** Encrypt/decrypt mbufs with same cipher key. */
190 static uint8_t
191 process_snow3g_cipher_op(struct rte_crypto_op **ops,
192                 struct snow3g_session *session,
193                 uint8_t num_ops)
194 {
195         unsigned i;
196         uint8_t processed_ops = 0;
197         uint8_t *src[SNOW3G_MAX_BURST], *dst[SNOW3G_MAX_BURST];
198         uint8_t *IV[SNOW3G_MAX_BURST];
199         uint32_t num_bytes[SNOW3G_MAX_BURST];
200
201         for (i = 0; i < num_ops; i++) {
202                 /* Sanity checks. */
203                 if (unlikely(ops[i]->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) {
204                         ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
205                         SNOW3G_LOG_ERR("iv");
206                         break;
207                 }
208
209                 src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
210                                 (ops[i]->sym->cipher.data.offset >> 3);
211                 dst[i] = ops[i]->sym->m_dst ?
212                         rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *) +
213                                 (ops[i]->sym->cipher.data.offset >> 3) :
214                         rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
215                                 (ops[i]->sym->cipher.data.offset >> 3);
216                 IV[i] = ops[i]->sym->cipher.iv.data;
217                 num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
218
219                 processed_ops++;
220         }
221
222         sso_snow3g_f8_n_buffer(&session->pKeySched_cipher, IV, src, dst,
223                         num_bytes, processed_ops);
224
225         return processed_ops;
226 }
227
228 /** Encrypt/decrypt mbuf (bit level function). */
229 static uint8_t
230 process_snow3g_cipher_op_bit(struct rte_crypto_op *op,
231                 struct snow3g_session *session)
232 {
233         uint8_t *src, *dst;
234         uint8_t *IV;
235         uint32_t length_in_bits, offset_in_bits;
236
237         /* Sanity checks. */
238         if (unlikely(op->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) {
239                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
240                 SNOW3G_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                 SNOW3G_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 = op->sym->cipher.iv.data;
253         length_in_bits = op->sym->cipher.data.length;
254
255         sso_snow3g_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_snow3g_hash_op(struct rte_crypto_op **ops,
264                 struct snow3g_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
272         for (i = 0; i < num_ops; i++) {
273                 if (unlikely(ops[i]->sym->auth.aad.length != SNOW3G_IV_LENGTH)) {
274                         ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
275                         SNOW3G_LOG_ERR("aad");
276                         break;
277                 }
278
279                 if (unlikely(ops[i]->sym->auth.digest.length != SNOW3G_DIGEST_LENGTH)) {
280                         ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
281                         SNOW3G_LOG_ERR("digest");
282                         break;
283                 }
284
285                 /* Data must be byte aligned */
286                 if ((ops[i]->sym->auth.data.offset % BYTE_LEN) != 0) {
287                         ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
288                         SNOW3G_LOG_ERR("Offset");
289                         break;
290                 }
291
292                 length_in_bits = ops[i]->sym->auth.data.length;
293
294                 src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
295                                 (ops[i]->sym->auth.data.offset >> 3);
296
297                 if (session->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) {
298                         dst = (uint8_t *)rte_pktmbuf_append(ops[i]->sym->m_src,
299                                         ops[i]->sym->auth.digest.length);
300
301                         sso_snow3g_f9_1_buffer(&session->pKeySched_hash,
302                                         ops[i]->sym->auth.aad.data, src,
303                                         length_in_bits, dst);
304                         /* Verify digest. */
305                         if (memcmp(dst, ops[i]->sym->auth.digest.data,
306                                         ops[i]->sym->auth.digest.length) != 0)
307                                 ops[i]->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
308
309                         /* Trim area used for digest from mbuf. */
310                         rte_pktmbuf_trim(ops[i]->sym->m_src,
311                                         ops[i]->sym->auth.digest.length);
312                 } else  {
313                         dst = ops[i]->sym->auth.digest.data;
314
315                         sso_snow3g_f9_1_buffer(&session->pKeySched_hash,
316                                         ops[i]->sym->auth.aad.data, src,
317                                         length_in_bits, dst);
318                 }
319                 processed_ops++;
320         }
321
322         return processed_ops;
323 }
324
325 /** Process a batch of crypto ops which shares the same session. */
326 static int
327 process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
328                 struct snow3g_qp *qp, uint8_t num_ops,
329                 uint16_t *accumulated_enqueued_ops)
330 {
331         unsigned i;
332         unsigned enqueued_ops, processed_ops;
333
334         switch (session->op) {
335         case SNOW3G_OP_ONLY_CIPHER:
336                 processed_ops = process_snow3g_cipher_op(ops,
337                                 session, num_ops);
338                 break;
339         case SNOW3G_OP_ONLY_AUTH:
340                 processed_ops = process_snow3g_hash_op(ops, session,
341                                 num_ops);
342                 break;
343         case SNOW3G_OP_CIPHER_AUTH:
344                 processed_ops = process_snow3g_cipher_op(ops, session,
345                                 num_ops);
346                 process_snow3g_hash_op(ops, session, processed_ops);
347                 break;
348         case SNOW3G_OP_AUTH_CIPHER:
349                 processed_ops = process_snow3g_hash_op(ops, session,
350                                 num_ops);
351                 process_snow3g_cipher_op(ops, session, processed_ops);
352                 break;
353         default:
354                 /* Operation not supported. */
355                 processed_ops = 0;
356         }
357
358         for (i = 0; i < num_ops; i++) {
359                 /*
360                  * If there was no error/authentication failure,
361                  * change status to successful.
362                  */
363                 if (ops[i]->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
364                         ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
365                 /* Free session if a session-less crypto op. */
366                 if (ops[i]->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
367                         rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
368                         ops[i]->sym->session = NULL;
369                 }
370         }
371
372         enqueued_ops = rte_ring_enqueue_burst(qp->processed_ops,
373                         (void **)ops, processed_ops);
374         qp->qp_stats.enqueued_count += enqueued_ops;
375         *accumulated_enqueued_ops += enqueued_ops;
376
377         return enqueued_ops;
378 }
379
380 /** Process a crypto op with length/offset in bits. */
381 static int
382 process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
383                 struct snow3g_qp *qp, uint16_t *accumulated_enqueued_ops)
384 {
385         unsigned enqueued_op, processed_op;
386
387         switch (session->op) {
388         case SNOW3G_OP_ONLY_CIPHER:
389                 processed_op = process_snow3g_cipher_op_bit(op,
390                                 session);
391                 break;
392         case SNOW3G_OP_ONLY_AUTH:
393                 processed_op = process_snow3g_hash_op(&op, session, 1);
394                 break;
395         case SNOW3G_OP_CIPHER_AUTH:
396                 processed_op = process_snow3g_cipher_op_bit(op, session);
397                 if (processed_op == 1)
398                         process_snow3g_hash_op(&op, session, 1);
399                 break;
400         case SNOW3G_OP_AUTH_CIPHER:
401                 processed_op = process_snow3g_hash_op(&op, session, 1);
402                 if (processed_op == 1)
403                         process_snow3g_cipher_op_bit(op, session);
404                 break;
405         default:
406                 /* Operation not supported. */
407                 processed_op = 0;
408         }
409
410         /*
411          * If there was no error/authentication failure,
412          * change status to successful.
413          */
414         if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
415                 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
416
417         /* Free session if a session-less crypto op. */
418         if (op->sym->sess_type == RTE_CRYPTO_SYM_OP_SESSIONLESS) {
419                 rte_mempool_put(qp->sess_mp, op->sym->session);
420                 op->sym->session = NULL;
421         }
422
423         enqueued_op = rte_ring_enqueue_burst(qp->processed_ops,
424                         (void **)&op, processed_op);
425         qp->qp_stats.enqueued_count += enqueued_op;
426         *accumulated_enqueued_ops += enqueued_op;
427
428         return enqueued_op;
429 }
430
431 static uint16_t
432 snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
433                 uint16_t nb_ops)
434 {
435         struct rte_crypto_op *c_ops[SNOW3G_MAX_BURST];
436         struct rte_crypto_op *curr_c_op;
437
438         struct snow3g_session *prev_sess = NULL, *curr_sess = NULL;
439         struct snow3g_qp *qp = queue_pair;
440         unsigned i;
441         uint8_t burst_size = 0;
442         uint16_t enqueued_ops = 0;
443         uint8_t processed_ops;
444
445         for (i = 0; i < nb_ops; i++) {
446                 curr_c_op = ops[i];
447
448                 /* Set status as enqueued (not processed yet) by default. */
449                 curr_c_op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
450
451                 curr_sess = snow3g_get_session(qp, curr_c_op);
452                 if (unlikely(curr_sess == NULL ||
453                                 curr_sess->op == SNOW3G_OP_NOT_SUPPORTED)) {
454                         curr_c_op->status =
455                                         RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
456                         break;
457                 }
458
459                 /* If length/offset is at bit-level, process this buffer alone. */
460                 if (((curr_c_op->sym->cipher.data.length % BYTE_LEN) != 0)
461                                 || ((curr_c_op->sym->cipher.data.offset
462                                         % BYTE_LEN) != 0)) {
463                         /* Process the ops of the previous session. */
464                         if (prev_sess != NULL) {
465                                 processed_ops = process_ops(c_ops, prev_sess,
466                                 qp, burst_size, &enqueued_ops);
467                                 if (processed_ops < burst_size) {
468                                         burst_size = 0;
469                                         break;
470                                 }
471
472                                 burst_size = 0;
473                                 prev_sess = NULL;
474                         }
475
476                         processed_ops = process_op_bit(curr_c_op, curr_sess,
477                                                         qp, &enqueued_ops);
478                         if (processed_ops != 1)
479                                 break;
480
481                         continue;
482                 }
483
484                 /* Batch ops that share the same session. */
485                 if (prev_sess == NULL) {
486                         prev_sess = curr_sess;
487                         c_ops[burst_size++] = curr_c_op;
488                 } else if (curr_sess == prev_sess) {
489                         c_ops[burst_size++] = curr_c_op;
490                         /*
491                          * When there are enough ops to process in a batch,
492                          * process them, and start a new batch.
493                          */
494                         if (burst_size == SNOW3G_MAX_BURST) {
495                                 processed_ops = process_ops(c_ops, prev_sess,
496                                                 qp, burst_size, &enqueued_ops);
497                                 if (processed_ops < burst_size) {
498                                         burst_size = 0;
499                                         break;
500                                 }
501
502                                 burst_size = 0;
503                                 prev_sess = NULL;
504                         }
505                 } else {
506                         /*
507                          * Different session, process the ops
508                          * of the previous session.
509                          */
510                         processed_ops = process_ops(c_ops, prev_sess,
511                                         qp, burst_size, &enqueued_ops);
512                         if (processed_ops < burst_size) {
513                                 burst_size = 0;
514                                 break;
515                         }
516
517                         burst_size = 0;
518                         prev_sess = curr_sess;
519
520                         c_ops[burst_size++] = curr_c_op;
521                 }
522         }
523
524         if (burst_size != 0) {
525                 /* Process the crypto ops of the last session. */
526                 processed_ops = process_ops(c_ops, prev_sess,
527                                 qp, burst_size, &enqueued_ops);
528         }
529
530         qp->qp_stats.enqueue_err_count += nb_ops - enqueued_ops;
531         return enqueued_ops;
532 }
533
534 static uint16_t
535 snow3g_pmd_dequeue_burst(void *queue_pair,
536                 struct rte_crypto_op **c_ops, uint16_t nb_ops)
537 {
538         struct snow3g_qp *qp = queue_pair;
539
540         unsigned nb_dequeued;
541
542         nb_dequeued = rte_ring_dequeue_burst(qp->processed_ops,
543                         (void **)c_ops, nb_ops);
544         qp->qp_stats.dequeued_count += nb_dequeued;
545
546         return nb_dequeued;
547 }
548
549 static int cryptodev_snow3g_uninit(const char *name);
550
551 static int
552 cryptodev_snow3g_create(const char *name,
553                 struct rte_crypto_vdev_init_params *init_params)
554 {
555         struct rte_cryptodev *dev;
556         char crypto_dev_name[RTE_CRYPTODEV_NAME_MAX_LEN];
557         struct snow3g_private *internals;
558
559         /* Create a unique device name. */
560         if (create_unique_device_name(crypto_dev_name,
561                         RTE_CRYPTODEV_NAME_MAX_LEN) != 0) {
562                 SNOW3G_LOG_ERR("failed to create unique cryptodev name");
563                 return -EINVAL;
564         }
565
566         dev = rte_cryptodev_pmd_virtual_dev_init(crypto_dev_name,
567                         sizeof(struct snow3g_private), init_params->socket_id);
568         if (dev == NULL) {
569                 SNOW3G_LOG_ERR("failed to create cryptodev vdev");
570                 goto init_error;
571         }
572
573         dev->dev_type = RTE_CRYPTODEV_SNOW3G_PMD;
574         dev->dev_ops = rte_snow3g_pmd_ops;
575
576         /* Register RX/TX burst functions for data path. */
577         dev->dequeue_burst = snow3g_pmd_dequeue_burst;
578         dev->enqueue_burst = snow3g_pmd_enqueue_burst;
579
580         dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
581                         RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING;
582
583         internals = dev->data->dev_private;
584
585         internals->max_nb_queue_pairs = init_params->max_nb_queue_pairs;
586         internals->max_nb_sessions = init_params->max_nb_sessions;
587
588         return 0;
589 init_error:
590         SNOW3G_LOG_ERR("driver %s: cryptodev_snow3g_create failed", name);
591
592         cryptodev_snow3g_uninit(crypto_dev_name);
593         return -EFAULT;
594 }
595
596 static int
597 cryptodev_snow3g_init(const char *name,
598                 const char *input_args)
599 {
600         struct rte_crypto_vdev_init_params init_params = {
601                 RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS,
602                 RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_SESSIONS,
603                 rte_socket_id()
604         };
605
606         rte_cryptodev_parse_vdev_init_params(&init_params, input_args);
607
608         RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name,
609                         init_params.socket_id);
610         RTE_LOG(INFO, PMD, "  Max number of queue pairs = %d\n",
611                         init_params.max_nb_queue_pairs);
612         RTE_LOG(INFO, PMD, "  Max number of sessions = %d\n",
613                         init_params.max_nb_sessions);
614
615         return cryptodev_snow3g_create(name, &init_params);
616 }
617
618 static int
619 cryptodev_snow3g_uninit(const char *name)
620 {
621         if (name == NULL)
622                 return -EINVAL;
623
624         RTE_LOG(INFO, PMD, "Closing SNOW3G crypto device %s"
625                         " on numa socket %u\n",
626                         name, rte_socket_id());
627
628         return 0;
629 }
630
631 static struct rte_driver cryptodev_snow3g_pmd_drv = {
632         .name = CRYPTODEV_NAME_SNOW3G_PMD,
633         .type = PMD_VDEV,
634         .init = cryptodev_snow3g_init,
635         .uninit = cryptodev_snow3g_uninit
636 };
637
638 PMD_REGISTER_DRIVER(cryptodev_snow3g_pmd_drv);