4 * Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _QAT_CRYPTO_H_
35 #define _QAT_CRYPTO_H_
37 #include <rte_cryptodev_pmd.h>
38 #include <rte_memzone.h>
40 #include "qat_crypto_capabilities.h"
42 #define CRYPTODEV_NAME_QAT_SYM_PMD crypto_qat
43 /**< Intel QAT Symmetric Crypto PMD device name */
46 * This macro rounds up a number to a be a multiple of
47 * the alignment when the alignment is a power of 2
49 #define ALIGN_POW2_ROUNDUP(num, align) \
50 (((num) + (align) - 1) & ~((align) - 1))
51 #define QAT_64_BTYE_ALIGN_MASK (~0x3f)
59 * Structure associated with each queue.
62 char memz_name[RTE_MEMZONE_NAMESIZE];
63 void *base_addr; /* Base address */
64 phys_addr_t base_phys_addr; /* Queue physical address */
65 uint32_t head; /* Shadow copy of the head */
66 uint32_t tail; /* Shadow copy of the tail */
69 uint16_t max_inflights;
71 uint8_t hw_bundle_number;
72 uint8_t hw_queue_number;
73 /* HW queue aka ring offset on bundle */
78 rte_atomic16_t inflights16;
79 struct qat_queue tx_q;
80 struct qat_queue rx_q;
81 struct rte_cryptodev_stats stats;
82 struct rte_mempool *op_cookie_pool;
84 uint32_t nb_descriptors;
85 enum qat_device_gen qat_dev_gen;
86 } __rte_cache_aligned;
88 /** private data structure for each QAT device */
89 struct qat_pmd_private {
90 unsigned max_nb_queue_pairs;
91 /**< Max number of queue pairs supported by device */
92 unsigned max_nb_sessions;
93 /**< Max number of sessions supported by device */
94 enum qat_device_gen qat_dev_gen;
95 /**< QAT device generation */
96 const struct rte_cryptodev_capabilities *qat_dev_capabilities;
99 extern uint8_t cryptodev_qat_driver_id;
101 int qat_dev_config(struct rte_cryptodev *dev,
102 struct rte_cryptodev_config *config);
103 int qat_dev_start(struct rte_cryptodev *dev);
104 void qat_dev_stop(struct rte_cryptodev *dev);
105 int qat_dev_close(struct rte_cryptodev *dev);
106 void qat_dev_info_get(struct rte_cryptodev *dev,
107 struct rte_cryptodev_info *info);
109 void qat_crypto_sym_stats_get(struct rte_cryptodev *dev,
110 struct rte_cryptodev_stats *stats);
111 void qat_crypto_sym_stats_reset(struct rte_cryptodev *dev);
113 int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
114 const struct rte_cryptodev_qp_conf *rx_conf, int socket_id,
115 struct rte_mempool *session_pool);
116 int qat_crypto_sym_qp_release(struct rte_cryptodev *dev,
117 uint16_t queue_pair_id);
120 qat_pmd_session_mempool_create(struct rte_cryptodev *dev,
121 unsigned nb_objs, unsigned obj_cache_size, int socket_id);
124 qat_crypto_sym_get_session_private_size(struct rte_cryptodev *dev);
127 qat_crypto_sym_configure_session(struct rte_cryptodev *dev,
128 struct rte_crypto_sym_xform *xform,
129 struct rte_cryptodev_sym_session *sess,
130 struct rte_mempool *mempool);
134 qat_crypto_set_session_parameters(struct rte_cryptodev *dev,
135 struct rte_crypto_sym_xform *xform, void *session_private);
138 qat_crypto_sym_configure_session_aead(struct rte_crypto_sym_xform *xform,
139 struct qat_session *session_private);
142 qat_crypto_sym_configure_session_auth(struct rte_cryptodev *dev,
143 struct rte_crypto_sym_xform *xform,
144 struct qat_session *session_private);
147 qat_crypto_sym_configure_session_cipher(struct rte_cryptodev *dev,
148 struct rte_crypto_sym_xform *xform, void *session_private);
152 qat_crypto_sym_clear_session(struct rte_cryptodev *dev,
153 struct rte_cryptodev_sym_session *session);
156 qat_pmd_enqueue_op_burst(void *qp, struct rte_crypto_op **ops,
160 qat_pmd_dequeue_op_burst(void *qp, struct rte_crypto_op **ops,
163 #endif /* _QAT_CRYPTO_H_ */