1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2016 Intel Corporation
8 #include <rte_cryptodev_pmd.h>
9 #include <rte_memzone.h>
11 #include "qat_crypto_capabilities.h"
13 #define CRYPTODEV_NAME_QAT_SYM_PMD crypto_qat
14 /**< Intel QAT Symmetric Crypto PMD device name */
17 * This macro rounds up a number to a be a multiple of
18 * the alignment when the alignment is a power of 2
20 #define ALIGN_POW2_ROUNDUP(num, align) \
21 (((num) + (align) - 1) & ~((align) - 1))
22 #define QAT_64_BTYE_ALIGN_MASK (~0x3f)
24 #define QAT_CSR_HEAD_WRITE_THRESH 32U
25 /* number of requests to accumulate before writing head CSR */
26 #define QAT_CSR_TAIL_WRITE_THRESH 32U
27 /* number of requests to accumulate before writing tail CSR */
28 #define QAT_CSR_TAIL_FORCE_WRITE_THRESH 256U
29 /* number of inflights below which no tail write coalescing should occur */
39 * Structure associated with each queue.
42 char memz_name[RTE_MEMZONE_NAMESIZE];
43 void *base_addr; /* Base address */
44 rte_iova_t base_phys_addr; /* Queue physical address */
45 uint32_t head; /* Shadow copy of the head */
46 uint32_t tail; /* Shadow copy of the tail */
49 uint16_t max_inflights;
51 uint8_t hw_bundle_number;
52 uint8_t hw_queue_number;
53 /* HW queue aka ring offset on bundle */
54 uint32_t csr_head; /* last written head value */
55 uint32_t csr_tail; /* last written tail value */
56 uint16_t nb_processed_responses;
57 /* number of responses processed since last CSR head write */
58 uint16_t nb_pending_requests;
59 /* number of requests pending since last CSR tail write */
65 struct qat_queue tx_q;
66 struct qat_queue rx_q;
67 struct rte_cryptodev_stats stats;
68 struct rte_mempool *op_cookie_pool;
70 uint32_t nb_descriptors;
71 enum qat_device_gen qat_dev_gen;
72 } __rte_cache_aligned;
74 /** private data structure for each QAT device */
75 struct qat_pmd_private {
76 unsigned max_nb_queue_pairs;
77 /**< Max number of queue pairs supported by device */
78 unsigned max_nb_sessions;
79 /**< Max number of sessions supported by device */
80 enum qat_device_gen qat_dev_gen;
81 /**< QAT device generation */
82 const struct rte_cryptodev_capabilities *qat_dev_capabilities;
85 extern uint8_t cryptodev_qat_driver_id;
87 int qat_dev_config(struct rte_cryptodev *dev,
88 struct rte_cryptodev_config *config);
89 int qat_dev_start(struct rte_cryptodev *dev);
90 void qat_dev_stop(struct rte_cryptodev *dev);
91 int qat_dev_close(struct rte_cryptodev *dev);
92 void qat_dev_info_get(struct rte_cryptodev *dev,
93 struct rte_cryptodev_info *info);
95 void qat_crypto_sym_stats_get(struct rte_cryptodev *dev,
96 struct rte_cryptodev_stats *stats);
97 void qat_crypto_sym_stats_reset(struct rte_cryptodev *dev);
99 int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
100 const struct rte_cryptodev_qp_conf *rx_conf, int socket_id,
101 struct rte_mempool *session_pool);
102 int qat_crypto_sym_qp_release(struct rte_cryptodev *dev,
103 uint16_t queue_pair_id);
106 qat_pmd_session_mempool_create(struct rte_cryptodev *dev,
107 unsigned nb_objs, unsigned obj_cache_size, int socket_id);
110 qat_crypto_sym_get_session_private_size(struct rte_cryptodev *dev);
113 qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
114 struct rte_crypto_sym_xform *xform,
115 struct rte_cryptodev_sym_session *sess,
116 struct rte_mempool *mempool);
120 qat_crypto_set_session_parameters(struct rte_cryptodev *dev,
121 struct rte_crypto_sym_xform *xform, void *session_private);
124 qat_crypto_sym_configure_session_aead(struct rte_crypto_sym_xform *xform,
125 struct qat_session *session);
128 qat_crypto_sym_configure_session_auth(struct rte_cryptodev *dev,
129 struct rte_crypto_sym_xform *xform,
130 struct qat_session *session);
133 qat_crypto_sym_configure_session_cipher(struct rte_cryptodev *dev,
134 struct rte_crypto_sym_xform *xform,
135 struct qat_session *session);
139 qat_crypto_sym_clear_session(struct rte_cryptodev *dev,
140 struct rte_cryptodev_sym_session *session);
143 qat_pmd_enqueue_op_burst(void *qp, struct rte_crypto_op **ops,
147 qat_pmd_dequeue_op_burst(void *qp, struct rte_crypto_op **ops,
150 #endif /* _QAT_CRYPTO_H_ */