DPDK  17.08.2
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_malloc.h>
51 #include <rte_mbuf.h>
52 #include <rte_mempool.h>
53 #include <rte_log.h>
54 #include <rte_common.h>
55 
56 #include "rte_crypto.h"
57 #include "rte_cryptodev.h"
58 
61  struct rte_cryptodev *devs;
62  struct rte_cryptodev_data *data[RTE_CRYPTO_MAX_DEVS];
64  uint8_t nb_devs;
65  uint8_t max_devs;
66 };
67 
70 
80 struct rte_cryptodev *
81 rte_cryptodev_pmd_get_dev(uint8_t dev_id);
82 
91 struct rte_cryptodev *
92 rte_cryptodev_pmd_get_named_dev(const char *name);
93 
102 unsigned int
103 rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id);
104 
108 extern struct rte_cryptodev *rte_cryptodevs;
109 
110 
125 typedef int (*cryptodev_configure_t)(struct rte_cryptodev *dev,
126  struct rte_cryptodev_config *config);
127 
135 typedef int (*cryptodev_start_t)(struct rte_cryptodev *dev);
136 
142 typedef void (*cryptodev_stop_t)(struct rte_cryptodev *dev);
143 
152 typedef int (*cryptodev_close_t)(struct rte_cryptodev *dev);
153 
154 
161 typedef void (*cryptodev_stats_get_t)(struct rte_cryptodev *dev,
162  struct rte_cryptodev_stats *stats);
163 
164 
170 typedef void (*cryptodev_stats_reset_t)(struct rte_cryptodev *dev);
171 
172 
178 typedef void (*cryptodev_info_get_t)(struct rte_cryptodev *dev,
179  struct rte_cryptodev_info *dev_info);
180 
189 typedef int (*cryptodev_queue_pair_start_t)(struct rte_cryptodev *dev,
190  uint16_t qp_id);
191 
200 typedef int (*cryptodev_queue_pair_stop_t)(struct rte_cryptodev *dev,
201  uint16_t qp_id);
202 
214 typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev,
215  uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf,
216  int socket_id, struct rte_mempool *session_pool);
217 
229  uint16_t qp_id);
230 
238 typedef uint32_t (*cryptodev_queue_pair_count_t)(struct rte_cryptodev *dev);
239 
253  struct rte_cryptodev *dev, unsigned nb_objs,
254  unsigned obj_cache_size, int socket_id);
255 
256 
267  struct rte_cryptodev *dev);
268 
284  struct rte_crypto_sym_xform *xform,
285  struct rte_cryptodev_sym_session *session,
286  struct rte_mempool *mp);
287 
294 typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
295  struct rte_cryptodev_sym_session *sess);
296 
306  struct rte_cryptodev *dev,
307  uint16_t qp_id,
308  void *session_private);
309 
319  struct rte_cryptodev *dev,
320  uint16_t qp_id,
321  void *session_private);
322 
358 };
359 
360 
372 struct rte_cryptodev *
373 rte_cryptodev_pmd_allocate(const char *name, int socket_id);
374 
385 extern int
387 
399  enum rte_cryptodev_event_type event);
400 
405 int
406 rte_cryptodev_pmd_create_dev_name(char *name, const char *dev_name_prefix);
407 
408 static inline void *
409 get_session_private_data(const struct rte_cryptodev_sym_session *sess,
410  uint8_t driver_id) {
411  return sess->sess_private_data[driver_id];
412 }
413 
414 static inline void
415 set_session_private_data(struct rte_cryptodev_sym_session *sess,
416  uint8_t driver_id, void *private_data)
417 {
418  sess->sess_private_data[driver_id] = private_data;
419 }
420 
421 #ifdef __cplusplus
422 }
423 #endif
424 
425 #endif /* _RTE_CRYPTODEV_PMD_H_ */