DPDK  17.11.10
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_config.h>
50 #include <rte_dev.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 
61 #define RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS 8
62 #define RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_SESSIONS 2048
63 
64 #define RTE_CRYPTODEV_PMD_NAME_ARG ("name")
65 #define RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG ("max_nb_queue_pairs")
66 #define RTE_CRYPTODEV_PMD_MAX_NB_SESS_ARG ("max_nb_sessions")
67 #define RTE_CRYPTODEV_PMD_SOCKET_ID_ARG ("socket_id")
68 
69 
70 static const char * const cryptodev_pmd_valid_params[] = {
71  RTE_CRYPTODEV_PMD_NAME_ARG,
72  RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG,
73  RTE_CRYPTODEV_PMD_MAX_NB_SESS_ARG,
74  RTE_CRYPTODEV_PMD_SOCKET_ID_ARG
75 };
76 
81 struct rte_cryptodev_pmd_init_params {
82  char name[RTE_CRYPTODEV_NAME_MAX_LEN];
83  size_t private_data_size;
84  int socket_id;
85  unsigned int max_nb_queue_pairs;
86  unsigned int max_nb_sessions;
87 };
88 
91  struct rte_cryptodev *devs;
92  struct rte_cryptodev_data *data[RTE_CRYPTO_MAX_DEVS];
94  uint8_t nb_devs;
95 };
96 
97 /* Cryptodev driver, containing the driver ID */
98 struct cryptodev_driver {
99  TAILQ_ENTRY(cryptodev_driver) next;
100  const struct rte_driver *driver;
101  uint8_t id;
102 };
103 
106 
116 struct rte_cryptodev *
117 rte_cryptodev_pmd_get_dev(uint8_t dev_id);
118 
127 struct rte_cryptodev *
128 rte_cryptodev_pmd_get_named_dev(const char *name);
129 
138 unsigned int
139 rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id);
140 
144 extern struct rte_cryptodev *rte_cryptodevs;
145 
146 
161 typedef int (*cryptodev_configure_t)(struct rte_cryptodev *dev,
162  struct rte_cryptodev_config *config);
163 
171 typedef int (*cryptodev_start_t)(struct rte_cryptodev *dev);
172 
178 typedef void (*cryptodev_stop_t)(struct rte_cryptodev *dev);
179 
188 typedef int (*cryptodev_close_t)(struct rte_cryptodev *dev);
189 
190 
197 typedef void (*cryptodev_stats_get_t)(struct rte_cryptodev *dev,
198  struct rte_cryptodev_stats *stats);
199 
200 
206 typedef void (*cryptodev_stats_reset_t)(struct rte_cryptodev *dev);
207 
208 
214 typedef void (*cryptodev_info_get_t)(struct rte_cryptodev *dev,
215  struct rte_cryptodev_info *dev_info);
216 
225 typedef int (*cryptodev_queue_pair_start_t)(struct rte_cryptodev *dev,
226  uint16_t qp_id);
227 
236 typedef int (*cryptodev_queue_pair_stop_t)(struct rte_cryptodev *dev,
237  uint16_t qp_id);
238 
250 typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev,
251  uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf,
252  int socket_id, struct rte_mempool *session_pool);
253 
265  uint16_t qp_id);
266 
274 typedef uint32_t (*cryptodev_queue_pair_count_t)(struct rte_cryptodev *dev);
275 
289  struct rte_cryptodev *dev, unsigned nb_objs,
290  unsigned obj_cache_size, int socket_id);
291 
292 
303  struct rte_cryptodev *dev);
304 
320  struct rte_crypto_sym_xform *xform,
321  struct rte_cryptodev_sym_session *session,
322  struct rte_mempool *mp);
323 
330 typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
331  struct rte_cryptodev_sym_session *sess);
332 
342  struct rte_cryptodev *dev,
343  uint16_t qp_id,
344  void *session_private);
345 
355  struct rte_cryptodev *dev,
356  uint16_t qp_id,
357  void *session_private);
358 
394 };
395 
396 
408 struct rte_cryptodev *
409 rte_cryptodev_pmd_allocate(const char *name, int socket_id);
410 
421 extern int
423 
424 
442 int
443 rte_cryptodev_pmd_parse_input_args(
444  struct rte_cryptodev_pmd_init_params *params,
445  const char *args);
446 
461 struct rte_cryptodev *
462 rte_cryptodev_pmd_create(const char *name,
463  struct rte_device *device,
464  struct rte_cryptodev_pmd_init_params *params);
465 
478 int
479 rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev);
480 
492  enum rte_cryptodev_event_type event);
493 
498 int
499 rte_cryptodev_pmd_create_dev_name(char *name, const char *dev_name_prefix);
500 
513 uint8_t rte_cryptodev_allocate_driver(struct cryptodev_driver *crypto_drv,
514  const struct rte_driver *drv);
515 
516 
517 #define RTE_PMD_REGISTER_CRYPTO_DRIVER(crypto_drv, drv, driver_id)\
518 RTE_INIT(init_ ##driver_id);\
519 static void init_ ##driver_id(void)\
520 {\
521  driver_id = rte_cryptodev_allocate_driver(&crypto_drv, &(drv).driver);\
522 }
523 
524 static inline void *
525 get_session_private_data(const struct rte_cryptodev_sym_session *sess,
526  uint8_t driver_id) {
527  return sess->sess_private_data[driver_id];
528 }
529 
530 static inline void
531 set_session_private_data(struct rte_cryptodev_sym_session *sess,
532  uint8_t driver_id, void *private_data)
533 {
534  sess->sess_private_data[driver_id] = private_data;
535 }
536 
537 #ifdef __cplusplus
538 }
539 #endif
540 
541 #endif /* _RTE_CRYPTODEV_PMD_H_ */
void(* cryptodev_stop_t)(struct rte_cryptodev *dev)
__extension__ void * sess_private_data[0]
void(* cryptodev_info_get_t)(struct rte_cryptodev *dev, struct rte_cryptodev_info *dev_info)
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, struct rte_mempool *session_pool)
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)
struct rte_cryptodev_data * data[RTE_CRYPTO_MAX_DEVS]
cryptodev_stop_t dev_stop
struct rte_cryptodev * devs
uint32_t(* cryptodev_queue_pair_count_t)(struct rte_cryptodev *dev)
int(* cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, struct rte_cryptodev_sym_session *session, struct rte_mempool *mp)
cryptodev_sym_queue_pair_detach_session_t qp_detach_session
int(* cryptodev_queue_pair_stop_t)(struct rte_cryptodev *dev, uint16_t qp_id)
uint8_t driver_id
struct rte_cryptodev * rte_cryptodev_pmd_get_named_dev(const char *name)
#define RTE_CRYPTODEV_NAME_MAX_LEN
cryptodev_queue_pair_stop_t queue_pair_stop
struct rte_cryptodev * rte_cryptodev_pmd_get_dev(uint8_t dev_id)
int(* cryptodev_sym_queue_pair_detach_session_t)(struct rte_cryptodev *dev, uint16_t qp_id, void *session_private)
unsigned(* cryptodev_sym_get_session_private_size_t)(struct rte_cryptodev *dev)
cryptodev_queue_pair_count_t queue_pair_count
struct rte_cryptodev * rte_cryptodev_pmd_allocate(const char *name, int socket_id)
int(* cryptodev_configure_t)(struct rte_cryptodev *dev, struct rte_cryptodev_config *config)
void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev, enum rte_cryptodev_event_type event)
unsigned int rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id)
int(* cryptodev_queue_pair_release_t)(struct rte_cryptodev *dev, uint16_t qp_id)
cryptodev_stats_get_t stats_get
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_queue_pair_attach_session_t qp_attach_session
cryptodev_sym_free_session_t session_clear
cryptodev_queue_pair_start_t queue_pair_start
void(* cryptodev_stats_reset_t)(struct rte_cryptodev *dev)
cryptodev_info_get_t dev_infos_get
cryptodev_start_t dev_start
int(* cryptodev_close_t)(struct rte_cryptodev *dev)
struct rte_device * device
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
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
void(* cryptodev_sym_free_session_t)(struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess)
cryptodev_queue_pair_release_t queue_pair_release
struct rte_cryptodev * rte_cryptodevs
int(* cryptodev_start_t)(struct rte_cryptodev *dev)
int(* cryptodev_sym_queue_pair_attach_session_t)(struct rte_cryptodev *dev, uint16_t qp_id, void *session_private)