DPDK  16.04.0
rte_cryptodev_pmd.h
Go to the documentation of this file.
1 /*-
2  *
3  * Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * * Neither the name of Intel Corporation nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _RTE_CRYPTODEV_PMD_H_
33 #define _RTE_CRYPTODEV_PMD_H_
34 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #include <string.h>
48 
49 #include <rte_dev.h>
50 #include <rte_pci.h>
51 #include <rte_malloc.h>
52 #include <rte_mbuf.h>
53 #include <rte_mempool.h>
54 #include <rte_log.h>
55 
56 #include "rte_crypto.h"
57 #include "rte_cryptodev.h"
58 
59 
60 #ifdef RTE_LIBRTE_CRYPTODEV_DEBUG
61 #define RTE_PMD_DEBUG_TRACE(...) \
62  rte_pmd_debug_trace(__func__, __VA_ARGS__)
63 #else
64 #define RTE_PMD_DEBUG_TRACE(fmt, args...)
65 #endif
66 
67 struct rte_cryptodev_session {
68  struct {
69  uint8_t dev_id;
70  enum rte_cryptodev_type type;
71  struct rte_mempool *mp;
72  } __rte_aligned(8);
73 
74  char _private[0];
75 };
76 
78 
96 typedef int (*cryptodev_init_t)(struct rte_cryptodev_driver *drv,
97  struct rte_cryptodev *dev);
98 
116 typedef int (*cryptodev_uninit_t)(const struct rte_cryptodev_driver *drv,
117  struct rte_cryptodev *dev);
118 
133  unsigned dev_private_size;
137 };
138 
139 
142  struct rte_cryptodev *devs;
143  struct rte_cryptodev_data *data[RTE_CRYPTO_MAX_DEVS];
145  uint8_t nb_devs;
146  uint8_t max_devs;
147 };
148 
151 
161 static inline struct rte_cryptodev *
163 {
164  return &rte_cryptodev_globals->devs[dev_id];
165 }
166 
175 static inline struct rte_cryptodev *
177 {
178  struct rte_cryptodev *dev;
179  unsigned i;
180 
181  if (name == NULL)
182  return NULL;
183 
184  for (i = 0, dev = &rte_cryptodev_globals->devs[i];
185  i < rte_cryptodev_globals->max_devs; i++) {
186  if ((dev->attached == RTE_CRYPTODEV_ATTACHED) &&
187  (strcmp(dev->data->name, name) == 0))
188  return dev;
189  }
190 
191  return NULL;
192 }
193 
202 static inline unsigned
204 {
205  struct rte_cryptodev *dev = NULL;
206 
207  if (dev_id >= rte_cryptodev_globals->nb_devs)
208  return 0;
209 
210  dev = rte_cryptodev_pmd_get_dev(dev_id);
211  if (dev->attached != RTE_CRYPTODEV_ATTACHED)
212  return 0;
213  else
214  return 1;
215 }
216 
220 extern struct rte_cryptodev *rte_cryptodevs;
221 
222 
236 typedef int (*cryptodev_configure_t)(struct rte_cryptodev *dev);
237 
245 typedef int (*cryptodev_start_t)(struct rte_cryptodev *dev);
246 
252 typedef void (*cryptodev_stop_t)(struct rte_cryptodev *dev);
253 
262 typedef int (*cryptodev_close_t)(struct rte_cryptodev *dev);
263 
264 
271 typedef void (*cryptodev_stats_get_t)(struct rte_cryptodev *dev,
272  struct rte_cryptodev_stats *stats);
273 
274 
280 typedef void (*cryptodev_stats_reset_t)(struct rte_cryptodev *dev);
281 
282 
288 typedef void (*cryptodev_info_get_t)(struct rte_cryptodev *dev,
289  struct rte_cryptodev_info *dev_info);
290 
299 typedef int (*cryptodev_queue_pair_start_t)(struct rte_cryptodev *dev,
300  uint16_t qp_id);
301 
310 typedef int (*cryptodev_queue_pair_stop_t)(struct rte_cryptodev *dev,
311  uint16_t qp_id);
312 
323 typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev,
324  uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf,
325  int socket_id);
326 
338  uint16_t qp_id);
339 
347 typedef uint32_t (*cryptodev_queue_pair_count_t)(struct rte_cryptodev *dev);
348 
362  struct rte_cryptodev *dev, unsigned nb_objs,
363  unsigned obj_cache_size, int socket_id);
364 
365 
376  struct rte_cryptodev *dev);
377 
389 typedef void (*cryptodev_sym_initialize_session_t)(struct rte_mempool *mempool,
390  void *session_private);
391 
403 typedef void * (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
404  struct rte_crypto_sym_xform *xform, void *session_private);
405 
410 typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
411  void *session_private);
412 
413 
447 };
448 
449 
462 struct rte_cryptodev *
463 rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id);
464 
477 struct rte_cryptodev *
478 rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
479  int socket_id);
480 
481 
492 extern int
494 
495 
521 extern int
523  enum pmd_type type);
524 
536  enum rte_cryptodev_event_type event);
537 
538 
539 #ifdef __cplusplus
540 }
541 #endif
542 
543 #endif /* _RTE_CRYPTODEV_PMD_H_ */