event/dpaa: support Tx adapter
[dpdk.git] / drivers / crypto / snow3g / rte_snow3g_pmd.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2018 Intel Corporation
3  */
4
5 #include <rte_common.h>
6 #include <rte_hexdump.h>
7 #include <rte_cryptodev.h>
8 #include <rte_cryptodev_pmd.h>
9 #include <rte_bus_vdev.h>
10 #include <rte_malloc.h>
11 #include <rte_cpuflags.h>
12
13 #include "rte_snow3g_pmd_private.h"
14
15 #define SNOW3G_IV_LENGTH 16
16 #define SNOW3G_MAX_BURST 8
17 #define BYTE_LEN 8
18
19 static uint8_t cryptodev_driver_id;
20
21 /** Get xform chain order. */
22 static enum snow3g_operation
23 snow3g_get_mode(const struct rte_crypto_sym_xform *xform)
24 {
25         if (xform == NULL)
26                 return SNOW3G_OP_NOT_SUPPORTED;
27
28         if (xform->next)
29                 if (xform->next->next != NULL)
30                         return SNOW3G_OP_NOT_SUPPORTED;
31
32         if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH) {
33                 if (xform->next == NULL)
34                         return SNOW3G_OP_ONLY_AUTH;
35                 else if (xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER)
36                         return SNOW3G_OP_AUTH_CIPHER;
37                 else
38                         return SNOW3G_OP_NOT_SUPPORTED;
39         }
40
41         if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER) {
42                 if (xform->next == NULL)
43                         return SNOW3G_OP_ONLY_CIPHER;
44                 else if (xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH)
45                         return SNOW3G_OP_CIPHER_AUTH;
46                 else
47                         return SNOW3G_OP_NOT_SUPPORTED;
48         }
49
50         return SNOW3G_OP_NOT_SUPPORTED;
51 }
52
53
54 /** Parse crypto xform chain and set private session parameters. */
55 int
56 snow3g_set_session_parameters(struct snow3g_session *sess,
57                 const struct rte_crypto_sym_xform *xform)
58 {
59         const struct rte_crypto_sym_xform *auth_xform = NULL;
60         const struct rte_crypto_sym_xform *cipher_xform = NULL;
61         enum snow3g_operation mode;
62
63         /* Select Crypto operation - hash then cipher / cipher then hash */
64         mode = snow3g_get_mode(xform);
65
66         switch (mode) {
67         case SNOW3G_OP_CIPHER_AUTH:
68                 auth_xform = xform->next;
69
70                 /* Fall-through */
71         case SNOW3G_OP_ONLY_CIPHER:
72                 cipher_xform = xform;
73                 break;
74         case SNOW3G_OP_AUTH_CIPHER:
75                 cipher_xform = xform->next;
76                 /* Fall-through */
77         case SNOW3G_OP_ONLY_AUTH:
78                 auth_xform = xform;
79                 break;
80         case SNOW3G_OP_NOT_SUPPORTED:
81         default:
82                 SNOW3G_LOG(ERR, "Unsupported operation chain order parameter");
83                 return -ENOTSUP;
84         }
85
86         if (cipher_xform) {
87                 uint8_t cipher_key[SNOW3G_MAX_KEY_SIZE];
88
89                 /* Only SNOW 3G UEA2 supported */
90                 if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_SNOW3G_UEA2)
91                         return -ENOTSUP;
92
93                 if (cipher_xform->cipher.iv.length != SNOW3G_IV_LENGTH) {
94                         SNOW3G_LOG(ERR, "Wrong IV length");
95                         return -EINVAL;
96                 }
97                 if (cipher_xform->cipher.key.length > SNOW3G_MAX_KEY_SIZE) {
98                         SNOW3G_LOG(ERR, "Not enough memory to store the key");
99                         return -ENOMEM;
100                 }
101
102                 sess->cipher_iv_offset = cipher_xform->cipher.iv.offset;
103
104                 /* Initialize key */
105                 memcpy(cipher_key, cipher_xform->cipher.key.data,
106                                 cipher_xform->cipher.key.length);
107                 sso_snow3g_init_key_sched(cipher_key, &sess->pKeySched_cipher);
108         }
109
110         if (auth_xform) {
111                 uint8_t auth_key[SNOW3G_MAX_KEY_SIZE];
112
113                 /* Only SNOW 3G UIA2 supported */
114                 if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_SNOW3G_UIA2)
115                         return -ENOTSUP;
116
117                 if (auth_xform->auth.digest_length != SNOW3G_DIGEST_LENGTH) {
118                         SNOW3G_LOG(ERR, "Wrong digest length");
119                         return -EINVAL;
120                 }
121                 if (auth_xform->auth.key.length > SNOW3G_MAX_KEY_SIZE) {
122                         SNOW3G_LOG(ERR, "Not enough memory to store the key");
123                         return -ENOMEM;
124                 }
125
126                 sess->auth_op = auth_xform->auth.op;
127
128                 if (auth_xform->auth.iv.length != SNOW3G_IV_LENGTH) {
129                         SNOW3G_LOG(ERR, "Wrong IV length");
130                         return -EINVAL;
131                 }
132                 sess->auth_iv_offset = auth_xform->auth.iv.offset;
133
134                 /* Initialize key */
135                 memcpy(auth_key, auth_xform->auth.key.data,
136                                 auth_xform->auth.key.length);
137                 sso_snow3g_init_key_sched(auth_key, &sess->pKeySched_hash);
138         }
139
140
141         sess->op = mode;
142
143         return 0;
144 }
145
146 /** Get SNOW 3G session. */
147 static struct snow3g_session *
148 snow3g_get_session(struct snow3g_qp *qp, struct rte_crypto_op *op)
149 {
150         struct snow3g_session *sess = NULL;
151
152         if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
153                 if (likely(op->sym->session != NULL))
154                         sess = (struct snow3g_session *)
155                                         get_sym_session_private_data(
156                                         op->sym->session,
157                                         cryptodev_driver_id);
158         } else {
159                 void *_sess = NULL;
160                 void *_sess_private_data = NULL;
161
162                 if (rte_mempool_get(qp->sess_mp, (void **)&_sess))
163                         return NULL;
164
165                 if (rte_mempool_get(qp->sess_mp_priv,
166                                 (void **)&_sess_private_data))
167                         return NULL;
168
169                 sess = (struct snow3g_session *)_sess_private_data;
170
171                 if (unlikely(snow3g_set_session_parameters(sess,
172                                 op->sym->xform) != 0)) {
173                         rte_mempool_put(qp->sess_mp, _sess);
174                         rte_mempool_put(qp->sess_mp_priv, _sess_private_data);
175                         sess = NULL;
176                 }
177                 op->sym->session = (struct rte_cryptodev_sym_session *)_sess;
178                 set_sym_session_private_data(op->sym->session,
179                                 cryptodev_driver_id, _sess_private_data);
180         }
181
182         if (unlikely(sess == NULL))
183                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
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                 src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
203                                 (ops[i]->sym->cipher.data.offset >> 3);
204                 dst[i] = ops[i]->sym->m_dst ?
205                         rte_pktmbuf_mtod(ops[i]->sym->m_dst, uint8_t *) +
206                                 (ops[i]->sym->cipher.data.offset >> 3) :
207                         rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
208                                 (ops[i]->sym->cipher.data.offset >> 3);
209                 iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
210                                 session->cipher_iv_offset);
211                 num_bytes[i] = ops[i]->sym->cipher.data.length >> 3;
212
213                 processed_ops++;
214         }
215
216         sso_snow3g_f8_n_buffer(&session->pKeySched_cipher, iv, src, dst,
217                         num_bytes, processed_ops);
218
219         return processed_ops;
220 }
221
222 /** Encrypt/decrypt mbuf (bit level function). */
223 static uint8_t
224 process_snow3g_cipher_op_bit(struct rte_crypto_op *op,
225                 struct snow3g_session *session)
226 {
227         uint8_t *src, *dst;
228         uint8_t *iv;
229         uint32_t length_in_bits, offset_in_bits;
230
231         offset_in_bits = op->sym->cipher.data.offset;
232         src = rte_pktmbuf_mtod(op->sym->m_src, uint8_t *);
233         if (op->sym->m_dst == NULL) {
234                 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
235                 SNOW3G_LOG(ERR, "bit-level in-place not supported\n");
236                 return 0;
237         }
238         dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *);
239         iv = rte_crypto_op_ctod_offset(op, uint8_t *,
240                                 session->cipher_iv_offset);
241         length_in_bits = op->sym->cipher.data.length;
242
243         sso_snow3g_f8_1_buffer_bit(&session->pKeySched_cipher, iv,
244                         src, dst, length_in_bits, offset_in_bits);
245
246         return 1;
247 }
248
249 /** Generate/verify hash from mbufs with same hash key. */
250 static int
251 process_snow3g_hash_op(struct snow3g_qp *qp, struct rte_crypto_op **ops,
252                 struct snow3g_session *session,
253                 uint8_t num_ops)
254 {
255         unsigned i;
256         uint8_t processed_ops = 0;
257         uint8_t *src, *dst;
258         uint32_t length_in_bits;
259         uint8_t *iv;
260
261         for (i = 0; i < num_ops; i++) {
262                 /* Data must be byte aligned */
263                 if ((ops[i]->sym->auth.data.offset % BYTE_LEN) != 0) {
264                         ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
265                         SNOW3G_LOG(ERR, "Offset");
266                         break;
267                 }
268
269                 length_in_bits = ops[i]->sym->auth.data.length;
270
271                 src = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) +
272                                 (ops[i]->sym->auth.data.offset >> 3);
273                 iv = rte_crypto_op_ctod_offset(ops[i], uint8_t *,
274                                 session->auth_iv_offset);
275
276                 if (session->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY) {
277                         dst = qp->temp_digest;
278
279                         sso_snow3g_f9_1_buffer(&session->pKeySched_hash,
280                                         iv, src,
281                                         length_in_bits, dst);
282                         /* Verify digest. */
283                         if (memcmp(dst, ops[i]->sym->auth.digest.data,
284                                         SNOW3G_DIGEST_LENGTH) != 0)
285                                 ops[i]->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
286                 } else  {
287                         dst = ops[i]->sym->auth.digest.data;
288
289                         sso_snow3g_f9_1_buffer(&session->pKeySched_hash,
290                                         iv, src,
291                                         length_in_bits, dst);
292                 }
293                 processed_ops++;
294         }
295
296         return processed_ops;
297 }
298
299 /** Process a batch of crypto ops which shares the same session. */
300 static int
301 process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
302                 struct snow3g_qp *qp, uint8_t num_ops,
303                 uint16_t *accumulated_enqueued_ops)
304 {
305         unsigned i;
306         unsigned enqueued_ops, processed_ops;
307
308 #ifdef RTE_LIBRTE_PMD_SNOW3G_DEBUG
309         for (i = 0; i < num_ops; i++) {
310                 if (!rte_pktmbuf_is_contiguous(ops[i]->sym->m_src) ||
311                                 (ops[i]->sym->m_dst != NULL &&
312                                 !rte_pktmbuf_is_contiguous(
313                                                 ops[i]->sym->m_dst))) {
314                         SNOW3G_LOG(ERR, "PMD supports only contiguous mbufs, "
315                                 "op (%p) provides noncontiguous mbuf as "
316                                 "source/destination buffer.\n", ops[i]);
317                         ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
318                         return 0;
319                 }
320         }
321 #endif
322
323         switch (session->op) {
324         case SNOW3G_OP_ONLY_CIPHER:
325                 processed_ops = process_snow3g_cipher_op(ops,
326                                 session, num_ops);
327                 break;
328         case SNOW3G_OP_ONLY_AUTH:
329                 processed_ops = process_snow3g_hash_op(qp, ops, session,
330                                 num_ops);
331                 break;
332         case SNOW3G_OP_CIPHER_AUTH:
333                 processed_ops = process_snow3g_cipher_op(ops, session,
334                                 num_ops);
335                 process_snow3g_hash_op(qp, ops, session, processed_ops);
336                 break;
337         case SNOW3G_OP_AUTH_CIPHER:
338                 processed_ops = process_snow3g_hash_op(qp, ops, session,
339                                 num_ops);
340                 process_snow3g_cipher_op(ops, session, processed_ops);
341                 break;
342         default:
343                 /* Operation not supported. */
344                 processed_ops = 0;
345         }
346
347         for (i = 0; i < num_ops; i++) {
348                 /*
349                  * If there was no error/authentication failure,
350                  * change status to successful.
351                  */
352                 if (ops[i]->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
353                         ops[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
354                 /* Free session if a session-less crypto op. */
355                 if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
356                         memset(session, 0, sizeof(struct snow3g_session));
357                         memset(ops[i]->sym->session, 0,
358                         rte_cryptodev_sym_get_existing_header_session_size(
359                                         ops[i]->sym->session));
360                         rte_mempool_put(qp->sess_mp_priv, session);
361                         rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
362                         ops[i]->sym->session = NULL;
363                 }
364         }
365
366         enqueued_ops = rte_ring_enqueue_burst(qp->processed_ops,
367                         (void **)ops, processed_ops, NULL);
368         qp->qp_stats.enqueued_count += enqueued_ops;
369         *accumulated_enqueued_ops += enqueued_ops;
370
371         return enqueued_ops;
372 }
373
374 /** Process a crypto op with length/offset in bits. */
375 static int
376 process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
377                 struct snow3g_qp *qp, uint16_t *accumulated_enqueued_ops)
378 {
379         unsigned enqueued_op, processed_op;
380
381         switch (session->op) {
382         case SNOW3G_OP_ONLY_CIPHER:
383                 processed_op = process_snow3g_cipher_op_bit(op,
384                                 session);
385                 break;
386         case SNOW3G_OP_ONLY_AUTH:
387                 processed_op = process_snow3g_hash_op(qp, &op, session, 1);
388                 break;
389         case SNOW3G_OP_CIPHER_AUTH:
390                 processed_op = process_snow3g_cipher_op_bit(op, session);
391                 if (processed_op == 1)
392                         process_snow3g_hash_op(qp, &op, session, 1);
393                 break;
394         case SNOW3G_OP_AUTH_CIPHER:
395                 processed_op = process_snow3g_hash_op(qp, &op, session, 1);
396                 if (processed_op == 1)
397                         process_snow3g_cipher_op_bit(op, session);
398                 break;
399         default:
400                 /* Operation not supported. */
401                 processed_op = 0;
402         }
403
404         /*
405          * If there was no error/authentication failure,
406          * change status to successful.
407          */
408         if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
409                 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
410
411         /* Free session if a session-less crypto op. */
412         if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
413                 memset(op->sym->session, 0, sizeof(struct snow3g_session));
414                 rte_cryptodev_sym_session_free(op->sym->session);
415                 op->sym->session = NULL;
416         }
417
418         enqueued_op = rte_ring_enqueue_burst(qp->processed_ops,
419                         (void **)&op, processed_op, NULL);
420         qp->qp_stats.enqueued_count += enqueued_op;
421         *accumulated_enqueued_ops += enqueued_op;
422
423         return enqueued_op;
424 }
425
426 static uint16_t
427 snow3g_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
428                 uint16_t nb_ops)
429 {
430         struct rte_crypto_op *c_ops[SNOW3G_MAX_BURST];
431         struct rte_crypto_op *curr_c_op;
432
433         struct snow3g_session *prev_sess = NULL, *curr_sess = NULL;
434         struct snow3g_qp *qp = queue_pair;
435         unsigned i;
436         uint8_t burst_size = 0;
437         uint16_t enqueued_ops = 0;
438         uint8_t processed_ops;
439
440         for (i = 0; i < nb_ops; i++) {
441                 curr_c_op = ops[i];
442
443                 /* Set status as enqueued (not processed yet) by default. */
444                 curr_c_op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
445
446                 curr_sess = snow3g_get_session(qp, curr_c_op);
447                 if (unlikely(curr_sess == NULL ||
448                                 curr_sess->op == SNOW3G_OP_NOT_SUPPORTED)) {
449                         curr_c_op->status =
450                                         RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
451                         break;
452                 }
453
454                 /* If length/offset is at bit-level, process this buffer alone. */
455                 if (((curr_c_op->sym->cipher.data.length % BYTE_LEN) != 0)
456                                 || ((curr_c_op->sym->cipher.data.offset
457                                         % BYTE_LEN) != 0)) {
458                         /* Process the ops of the previous session. */
459                         if (prev_sess != NULL) {
460                                 processed_ops = process_ops(c_ops, prev_sess,
461                                 qp, burst_size, &enqueued_ops);
462                                 if (processed_ops < burst_size) {
463                                         burst_size = 0;
464                                         break;
465                                 }
466
467                                 burst_size = 0;
468                                 prev_sess = NULL;
469                         }
470
471                         processed_ops = process_op_bit(curr_c_op, curr_sess,
472                                                         qp, &enqueued_ops);
473                         if (processed_ops != 1)
474                                 break;
475
476                         continue;
477                 }
478
479                 /* Batch ops that share the same session. */
480                 if (prev_sess == NULL) {
481                         prev_sess = curr_sess;
482                         c_ops[burst_size++] = curr_c_op;
483                 } else if (curr_sess == prev_sess) {
484                         c_ops[burst_size++] = curr_c_op;
485                         /*
486                          * When there are enough ops to process in a batch,
487                          * process them, and start a new batch.
488                          */
489                         if (burst_size == SNOW3G_MAX_BURST) {
490                                 processed_ops = process_ops(c_ops, prev_sess,
491                                                 qp, burst_size, &enqueued_ops);
492                                 if (processed_ops < burst_size) {
493                                         burst_size = 0;
494                                         break;
495                                 }
496
497                                 burst_size = 0;
498                                 prev_sess = NULL;
499                         }
500                 } else {
501                         /*
502                          * Different session, process the ops
503                          * of the previous session.
504                          */
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 = curr_sess;
514
515                         c_ops[burst_size++] = curr_c_op;
516                 }
517         }
518
519         if (burst_size != 0) {
520                 /* Process the crypto ops of the last session. */
521                 processed_ops = process_ops(c_ops, prev_sess,
522                                 qp, burst_size, &enqueued_ops);
523         }
524
525         qp->qp_stats.enqueue_err_count += nb_ops - enqueued_ops;
526         return enqueued_ops;
527 }
528
529 static uint16_t
530 snow3g_pmd_dequeue_burst(void *queue_pair,
531                 struct rte_crypto_op **c_ops, uint16_t nb_ops)
532 {
533         struct snow3g_qp *qp = queue_pair;
534
535         unsigned nb_dequeued;
536
537         nb_dequeued = rte_ring_dequeue_burst(qp->processed_ops,
538                         (void **)c_ops, nb_ops, NULL);
539         qp->qp_stats.dequeued_count += nb_dequeued;
540
541         return nb_dequeued;
542 }
543
544 static int cryptodev_snow3g_remove(struct rte_vdev_device *vdev);
545
546 static int
547 cryptodev_snow3g_create(const char *name,
548                         struct rte_vdev_device *vdev,
549                         struct rte_cryptodev_pmd_init_params *init_params)
550 {
551         struct rte_cryptodev *dev;
552         struct snow3g_private *internals;
553         uint64_t cpu_flags = RTE_CRYPTODEV_FF_CPU_SSE;
554
555         dev = rte_cryptodev_pmd_create(name, &vdev->device, init_params);
556         if (dev == NULL) {
557                 SNOW3G_LOG(ERR, "failed to create cryptodev vdev");
558                 goto init_error;
559         }
560
561         dev->driver_id = cryptodev_driver_id;
562         dev->dev_ops = rte_snow3g_pmd_ops;
563
564         /* Register RX/TX burst functions for data path. */
565         dev->dequeue_burst = snow3g_pmd_dequeue_burst;
566         dev->enqueue_burst = snow3g_pmd_enqueue_burst;
567
568         dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
569                         RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
570                         cpu_flags;
571
572         internals = dev->data->dev_private;
573
574         internals->max_nb_queue_pairs = init_params->max_nb_queue_pairs;
575
576         return 0;
577 init_error:
578         SNOW3G_LOG(ERR, "driver %s: cryptodev_snow3g_create failed",
579                         init_params->name);
580
581         cryptodev_snow3g_remove(vdev);
582         return -EFAULT;
583 }
584
585 static int
586 cryptodev_snow3g_probe(struct rte_vdev_device *vdev)
587 {
588         struct rte_cryptodev_pmd_init_params init_params = {
589                 "",
590                 sizeof(struct snow3g_private),
591                 rte_socket_id(),
592                 RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS
593         };
594         const char *name;
595         const char *input_args;
596
597         name = rte_vdev_device_name(vdev);
598         if (name == NULL)
599                 return -EINVAL;
600         input_args = rte_vdev_device_args(vdev);
601
602         rte_cryptodev_pmd_parse_input_args(&init_params, input_args);
603
604         return cryptodev_snow3g_create(name, vdev, &init_params);
605 }
606
607 static int
608 cryptodev_snow3g_remove(struct rte_vdev_device *vdev)
609 {
610         struct rte_cryptodev *cryptodev;
611         const char *name;
612
613         name = rte_vdev_device_name(vdev);
614         if (name == NULL)
615                 return -EINVAL;
616
617         cryptodev = rte_cryptodev_pmd_get_named_dev(name);
618         if (cryptodev == NULL)
619                 return -ENODEV;
620
621         return rte_cryptodev_pmd_destroy(cryptodev);
622 }
623
624 static struct rte_vdev_driver cryptodev_snow3g_pmd_drv = {
625         .probe = cryptodev_snow3g_probe,
626         .remove = cryptodev_snow3g_remove
627 };
628
629 static struct cryptodev_driver snow3g_crypto_drv;
630
631 RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_SNOW3G_PMD, cryptodev_snow3g_pmd_drv);
632 RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_SNOW3G_PMD, cryptodev_snow3g_pmd);
633 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_SNOW3G_PMD,
634         "max_nb_queue_pairs=<int> "
635         "socket_id=<int>");
636 RTE_PMD_REGISTER_CRYPTO_DRIVER(snow3g_crypto_drv,
637                 cryptodev_snow3g_pmd_drv.driver, cryptodev_driver_id);
638
639 RTE_INIT(snow3g_init_log)
640 {
641         snow3g_logtype_driver = rte_log_register("pmd.crypto.snow3g");
642 }