DPDK  20.05.0-rc0
rte_cryptodev_pmd.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020 Intel Corporation.
3  */
4 
5 #ifndef _RTE_CRYPTODEV_PMD_H_
6 #define _RTE_CRYPTODEV_PMD_H_
7 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include <string.h>
21 
22 #include <rte_config.h>
23 #include <rte_dev.h>
24 #include <rte_malloc.h>
25 #include <rte_mbuf.h>
26 #include <rte_mempool.h>
27 #include <rte_log.h>
28 #include <rte_common.h>
29 
30 #include "rte_crypto.h"
31 #include "rte_cryptodev.h"
32 
33 
34 #define RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS 8
35 
36 #define RTE_CRYPTODEV_PMD_NAME_ARG ("name")
37 #define RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG ("max_nb_queue_pairs")
38 #define RTE_CRYPTODEV_PMD_SOCKET_ID_ARG ("socket_id")
39 
40 
41 static const char * const cryptodev_pmd_valid_params[] = {
42  RTE_CRYPTODEV_PMD_NAME_ARG,
43  RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG,
44  RTE_CRYPTODEV_PMD_SOCKET_ID_ARG
45 };
46 
51 struct rte_cryptodev_pmd_init_params {
52  char name[RTE_CRYPTODEV_NAME_MAX_LEN];
53  size_t private_data_size;
54  int socket_id;
55  unsigned int max_nb_queue_pairs;
56 };
57 
60  struct rte_cryptodev *devs;
61  struct rte_cryptodev_data *data[RTE_CRYPTO_MAX_DEVS];
63  uint8_t nb_devs;
64 };
65 
66 /* Cryptodev driver, containing the driver ID */
67 struct cryptodev_driver {
68  TAILQ_ENTRY(cryptodev_driver) next;
69  const struct rte_driver *driver;
70  uint8_t id;
71 };
72 
82 struct rte_cryptodev *
83 rte_cryptodev_pmd_get_dev(uint8_t dev_id);
84 
93 struct rte_cryptodev *
94 rte_cryptodev_pmd_get_named_dev(const char *name);
95 
104 unsigned int
105 rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id);
106 
110 extern struct rte_cryptodev *rte_cryptodevs;
111 
112 
127 typedef int (*cryptodev_configure_t)(struct rte_cryptodev *dev,
128  struct rte_cryptodev_config *config);
129 
137 typedef int (*cryptodev_start_t)(struct rte_cryptodev *dev);
138 
144 typedef void (*cryptodev_stop_t)(struct rte_cryptodev *dev);
145 
154 typedef int (*cryptodev_close_t)(struct rte_cryptodev *dev);
155 
156 
163 typedef void (*cryptodev_stats_get_t)(struct rte_cryptodev *dev,
164  struct rte_cryptodev_stats *stats);
165 
166 
172 typedef void (*cryptodev_stats_reset_t)(struct rte_cryptodev *dev);
173 
174 
180 typedef void (*cryptodev_info_get_t)(struct rte_cryptodev *dev,
181  struct rte_cryptodev_info *dev_info);
182 
193 typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev,
194  uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf,
195  int socket_id);
196 
208  uint16_t qp_id);
209 
217 typedef uint32_t (*cryptodev_queue_pair_count_t)(struct rte_cryptodev *dev);
218 
232  struct rte_cryptodev *dev, unsigned nb_objs,
233  unsigned obj_cache_size, int socket_id);
234 
235 
246  struct rte_cryptodev *dev);
257  struct rte_cryptodev *dev);
258 
274  struct rte_crypto_sym_xform *xform,
275  struct rte_cryptodev_sym_session *session,
276  struct rte_mempool *mp);
292  struct rte_crypto_asym_xform *xform,
293  struct rte_cryptodev_asym_session *session,
294  struct rte_mempool *mp);
301 typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
302  struct rte_cryptodev_sym_session *sess);
309 typedef void (*cryptodev_asym_free_session_t)(struct rte_cryptodev *dev,
310  struct rte_cryptodev_asym_session *sess);
324 typedef uint32_t (*cryptodev_sym_cpu_crypto_process_t)
325  (struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess,
326  union rte_crypto_sym_ofs ofs, struct rte_crypto_sym_vec *vec);
327 
328 
364 };
365 
366 
378 struct rte_cryptodev *
379 rte_cryptodev_pmd_allocate(const char *name, int socket_id);
380 
391 extern int
393 
394 
412 int
413 rte_cryptodev_pmd_parse_input_args(
414  struct rte_cryptodev_pmd_init_params *params,
415  const char *args);
416 
431 struct rte_cryptodev *
432 rte_cryptodev_pmd_create(const char *name,
433  struct rte_device *device,
434  struct rte_cryptodev_pmd_init_params *params);
435 
448 int
449 rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev);
450 
462  enum rte_cryptodev_event_type event);
463 
468 int
469 rte_cryptodev_pmd_create_dev_name(char *name, const char *dev_name_prefix);
470 
483 uint8_t rte_cryptodev_allocate_driver(struct cryptodev_driver *crypto_drv,
484  const struct rte_driver *drv);
485 
486 
487 #define RTE_PMD_REGISTER_CRYPTO_DRIVER(crypto_drv, drv, driver_id)\
488 RTE_INIT(init_ ##driver_id)\
489 {\
490  driver_id = rte_cryptodev_allocate_driver(&crypto_drv, &(drv));\
491 }
492 
493 static inline void *
494 get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
495  uint8_t driver_id) {
496  if (unlikely(sess->nb_drivers <= driver_id))
497  return NULL;
498 
499  return sess->sess_data[driver_id].data;
500 }
501 
502 static inline void
503 set_sym_session_private_data(struct rte_cryptodev_sym_session *sess,
504  uint8_t driver_id, void *private_data)
505 {
506  if (unlikely(sess->nb_drivers <= driver_id)) {
507  CDEV_LOG_ERR("Set private data for driver %u not allowed\n",
508  driver_id);
509  return;
510  }
511 
512  sess->sess_data[driver_id].data = private_data;
513 }
514 
515 static inline void *
516 get_asym_session_private_data(const struct rte_cryptodev_asym_session *sess,
517  uint8_t driver_id) {
518  return sess->sess_private_data[driver_id];
519 }
520 
521 static inline void
522 set_asym_session_private_data(struct rte_cryptodev_asym_session *sess,
523  uint8_t driver_id, void *private_data)
524 {
525  sess->sess_private_data[driver_id] = private_data;
526 }
527 
528 #ifdef __cplusplus
529 }
530 #endif
531 
532 #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)
cryptodev_close_t dev_close
unsigned int(* cryptodev_asym_get_session_private_size_t)(struct rte_cryptodev *dev)
int rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
void(* cryptodev_asym_free_session_t)(struct rte_cryptodev *dev, struct rte_cryptodev_asym_session *sess)
cryptodev_stop_t dev_stop
cryptodev_asym_get_session_private_size_t asym_session_get_size
struct rte_cryptodev * devs
cryptodev_sym_get_session_private_size_t sym_session_get_size
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)
uint32_t(* cryptodev_sym_cpu_crypto_process_t)(struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess, union rte_crypto_sym_ofs ofs, struct rte_crypto_sym_vec *vec)
__extension__ struct rte_cryptodev_sym_session::@132 sess_data[0]
uint8_t driver_id
cryptodev_sym_configure_session_t sym_session_configure
__extension__ void * sess_private_data[0]
struct rte_cryptodev * rte_cryptodev_pmd_get_named_dev(const char *name)
#define unlikely(x)
#define RTE_CRYPTODEV_NAME_MAX_LEN
cryptodev_sym_free_session_t sym_session_clear
struct rte_cryptodev * rte_cryptodev_pmd_get_dev(uint8_t dev_id)
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)
cryptodev_sym_cpu_crypto_process_t sym_cpu_process
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_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_asym_configure_session_t asym_session_configure
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
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
void(* cryptodev_stats_get_t)(struct rte_cryptodev *dev, struct rte_cryptodev_stats *stats)
void(* cryptodev_sym_free_session_t)(struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess)
cryptodev_queue_pair_release_t queue_pair_release
int(* cryptodev_asym_configure_session_t)(struct rte_cryptodev *dev, struct rte_crypto_asym_xform *xform, struct rte_cryptodev_asym_session *session, struct rte_mempool *mp)
cryptodev_asym_free_session_t asym_session_clear
struct rte_cryptodev * rte_cryptodevs
int(* cryptodev_start_t)(struct rte_cryptodev *dev)