DPDK  16.11.11
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 #include <rte_common.h>
56 
57 #include "rte_crypto.h"
58 #include "rte_cryptodev.h"
59 
60 struct rte_cryptodev_session {
62  struct {
63  uint8_t dev_id;
64  enum rte_cryptodev_type type;
65  struct rte_mempool *mp;
66  } __rte_aligned(8);
67 
68  __extension__ char _private[0];
69 };
70 
72 
90 typedef int (*cryptodev_init_t)(struct rte_cryptodev_driver *drv,
91  struct rte_cryptodev *dev);
92 
110 typedef int (*cryptodev_uninit_t)(const struct rte_cryptodev_driver *drv,
111  struct rte_cryptodev *dev);
112 
127  unsigned dev_private_size;
131 };
132 
133 
136  struct rte_cryptodev *devs;
137  struct rte_cryptodev_data *data[RTE_CRYPTO_MAX_DEVS];
139  uint8_t nb_devs;
140  uint8_t max_devs;
141 };
142 
145 
155 static inline struct rte_cryptodev *
157 {
158  return &rte_cryptodev_globals->devs[dev_id];
159 }
160 
169 static inline struct rte_cryptodev *
171 {
172  struct rte_cryptodev *dev;
173  unsigned i;
174 
175  if (name == NULL)
176  return NULL;
177 
178  for (i = 0; i < rte_cryptodev_globals->max_devs; i++) {
179  dev = &rte_cryptodev_globals->devs[i];
180 
181  if ((dev->attached == RTE_CRYPTODEV_ATTACHED) &&
182  (strcmp(dev->data->name, name) == 0))
183  return dev;
184  }
185 
186  return NULL;
187 }
188 
197 static inline unsigned
199 {
200  struct rte_cryptodev *dev = NULL;
201 
202  if (dev_id >= rte_cryptodev_globals->nb_devs)
203  return 0;
204 
205  dev = rte_cryptodev_pmd_get_dev(dev_id);
206  if (dev->attached != RTE_CRYPTODEV_ATTACHED)
207  return 0;
208  else
209  return 1;
210 }
211 
215 extern struct rte_cryptodev *rte_cryptodevs;
216 
217 
231 typedef int (*cryptodev_configure_t)(struct rte_cryptodev *dev);
232 
240 typedef int (*cryptodev_start_t)(struct rte_cryptodev *dev);
241 
247 typedef void (*cryptodev_stop_t)(struct rte_cryptodev *dev);
248 
257 typedef int (*cryptodev_close_t)(struct rte_cryptodev *dev);
258 
259 
266 typedef void (*cryptodev_stats_get_t)(struct rte_cryptodev *dev,
267  struct rte_cryptodev_stats *stats);
268 
269 
275 typedef void (*cryptodev_stats_reset_t)(struct rte_cryptodev *dev);
276 
277 
283 typedef void (*cryptodev_info_get_t)(struct rte_cryptodev *dev,
284  struct rte_cryptodev_info *dev_info);
285 
294 typedef int (*cryptodev_queue_pair_start_t)(struct rte_cryptodev *dev,
295  uint16_t qp_id);
296 
305 typedef int (*cryptodev_queue_pair_stop_t)(struct rte_cryptodev *dev,
306  uint16_t qp_id);
307 
318 typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev,
319  uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf,
320  int socket_id);
321 
333  uint16_t qp_id);
334 
342 typedef uint32_t (*cryptodev_queue_pair_count_t)(struct rte_cryptodev *dev);
343 
357  struct rte_cryptodev *dev, unsigned nb_objs,
358  unsigned obj_cache_size, int socket_id);
359 
360 
371  struct rte_cryptodev *dev);
372 
384 typedef void (*cryptodev_sym_initialize_session_t)(struct rte_mempool *mempool,
385  void *session_private);
386 
398 typedef void * (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
399  struct rte_crypto_sym_xform *xform, void *session_private);
400 
405 typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
406  void *session_private);
407 
408 
442 };
443 
444 
456 struct rte_cryptodev *
457 rte_cryptodev_pmd_allocate(const char *name, int socket_id);
458 
471 struct rte_cryptodev *
472 rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
473  int socket_id);
474 
475 
486 extern int
488 
500  enum rte_cryptodev_event_type event);
501 
506 int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
507  struct rte_pci_device *pci_dev);
508 
514 
515 #ifdef __cplusplus
516 }
517 #endif
518 
519 #endif /* _RTE_CRYPTODEV_PMD_H_ */
void(* cryptodev_stop_t)(struct rte_cryptodev *dev)
void(* cryptodev_info_get_t)(struct rte_cryptodev *dev, struct rte_cryptodev_info *dev_info)
struct rte_pci_device * pci_dev
static struct rte_cryptodev * rte_cryptodev_pmd_get_named_dev(const char *name)
cryptodev_sym_get_session_private_size_t session_get_size
cryptodev_close_t dev_close
int rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
cryptodev_init_t cryptodev_init
struct rte_cryptodev_data * data[RTE_CRYPTO_MAX_DEVS]
int rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
int(* cryptodev_init_t)(struct rte_cryptodev_driver *drv, struct rte_cryptodev *dev)
cryptodev_stop_t dev_stop
__extension__ uint8_t attached
void(* cryptodev_sym_free_session_t)(struct rte_cryptodev *dev, void *session_private)
struct rte_cryptodev * devs
char name[RTE_CRYPTODEV_NAME_MAX_LEN]
uint32_t(* cryptodev_queue_pair_count_t)(struct rte_cryptodev *dev)
int(* cryptodev_queue_pair_stop_t)(struct rte_cryptodev *dev, uint16_t qp_id)
struct rte_mempool * mp
int(* cryptodev_uninit_t)(const struct rte_cryptodev_driver *drv, struct rte_cryptodev *dev)
rte_cryptodev_type
Definition: rte_cryptodev.h:71
struct rte_cryptodev * rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size, int socket_id)
cryptodev_queue_pair_stop_t queue_pair_stop
unsigned(* cryptodev_sym_get_session_private_size_t)(struct rte_cryptodev *dev)
struct rte_cryptodev_data * data
cryptodev_queue_pair_count_t queue_pair_count
struct rte_cryptodev * rte_cryptodev_pmd_allocate(const char *name, int socket_id)
void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev, enum rte_cryptodev_event_type event)
int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
void *(* cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, void *session_private)
int(* cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev, uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
int(* cryptodev_queue_pair_release_t)(struct rte_cryptodev *dev, uint16_t qp_id)
cryptodev_stats_get_t stats_get
cryptodev_sym_initialize_session_t session_initialize
#define RTE_STD_C11
Definition: rte_common.h:64
struct rte_pci_driver pci_drv
int(* cryptodev_sym_create_session_pool_t)(struct rte_cryptodev *dev, unsigned nb_objs, unsigned obj_cache_size, int socket_id)
cryptodev_configure_t dev_configure
cryptodev_sym_free_session_t session_clear
cryptodev_queue_pair_start_t queue_pair_start
void(* cryptodev_stats_reset_t)(struct rte_cryptodev *dev)
uint8_t dev_id
cryptodev_info_get_t dev_infos_get
cryptodev_start_t dev_start
int(* cryptodev_close_t)(struct rte_cryptodev *dev)
static unsigned rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id)
cryptodev_stats_reset_t stats_reset
rte_cryptodev_event_type
cryptodev_queue_pair_setup_t queue_pair_setup
struct rte_cryptodev_global * rte_cryptodev_globals
cryptodev_uninit_t cryptodev_uninit
int(* cryptodev_queue_pair_start_t)(struct rte_cryptodev *dev, uint16_t qp_id)
void(* cryptodev_stats_get_t)(struct rte_cryptodev *dev, struct rte_cryptodev_stats *stats)
cryptodev_sym_configure_session_t session_configure
static struct rte_cryptodev * rte_cryptodev_pmd_get_dev(uint8_t dev_id)
cryptodev_queue_pair_release_t queue_pair_release
int(* cryptodev_configure_t)(struct rte_cryptodev *dev)
void(* cryptodev_sym_initialize_session_t)(struct rte_mempool *mempool, void *session_private)
struct rte_cryptodev * rte_cryptodevs
int(* cryptodev_start_t)(struct rte_cryptodev *dev)
#define __rte_aligned(a)
Definition: rte_common.h:82