diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2014-06-05 16:43:15 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-06-20 09:26:16 -0400 |
commit | 38154e65ce258196c411fc5385eaa13c2fa0eab2 (patch) | |
tree | 2bf0ba71f5c0d3f8682fae6bcd9af953d21a8b96 | |
parent | a672a9dc872ec4eea91bd331f6d55aee4ac48d4f (diff) |
crypto: qat - Intel(R) QAT FW interface
This patch adds FW interface structure definitions.
Acked-by: John Griffin <john.griffin@intel.com>
Reviewed-by: Bruce W. Allan <bruce.w.allan@intel.com>
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/qat/qat_common/icp_qat_fw.h | 316 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_common/icp_qat_fw_init_admin.h | 131 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_common/icp_qat_fw_la.h | 403 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_common/icp_qat_hw.h | 305 |
4 files changed, 1155 insertions, 0 deletions
diff --git a/drivers/crypto/qat/qat_common/icp_qat_fw.h b/drivers/crypto/qat/qat_common/icp_qat_fw.h new file mode 100644 index 000000000000..f1e30e24a419 --- /dev/null +++ b/drivers/crypto/qat/qat_common/icp_qat_fw.h | |||
@@ -0,0 +1,316 @@ | |||
1 | /* | ||
2 | This file is provided under a dual BSD/GPLv2 license. When using or | ||
3 | redistributing this file, you may do so under either license. | ||
4 | |||
5 | GPL LICENSE SUMMARY | ||
6 | Copyright(c) 2014 Intel Corporation. | ||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of version 2 of the GNU General Public License as | ||
9 | published by the Free Software Foundation. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | Contact Information: | ||
17 | qat-linux@intel.com | ||
18 | |||
19 | BSD LICENSE | ||
20 | Copyright(c) 2014 Intel Corporation. | ||
21 | Redistribution and use in source and binary forms, with or without | ||
22 | modification, are permitted provided that the following conditions | ||
23 | are met: | ||
24 | |||
25 | * Redistributions of source code must retain the above copyright | ||
26 | notice, this list of conditions and the following disclaimer. | ||
27 | * Redistributions in binary form must reproduce the above copyright | ||
28 | notice, this list of conditions and the following disclaimer in | ||
29 | the documentation and/or other materials provided with the | ||
30 | distribution. | ||
31 | * Neither the name of Intel Corporation nor the names of its | ||
32 | contributors may be used to endorse or promote products derived | ||
33 | from this software without specific prior written permission. | ||
34 | |||
35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
36 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
37 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
38 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
39 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
40 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
41 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
42 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
43 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
44 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
45 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
46 | */ | ||
47 | #ifndef _ICP_QAT_FW_H_ | ||
48 | #define _ICP_QAT_FW_H_ | ||
49 | #include <linux/types.h> | ||
50 | #include "icp_qat_hw.h" | ||
51 | |||
52 | #define QAT_FIELD_SET(flags, val, bitpos, mask) \ | ||
53 | { (flags) = (((flags) & (~((mask) << (bitpos)))) | \ | ||
54 | (((val) & (mask)) << (bitpos))) ; } | ||
55 | |||
56 | #define QAT_FIELD_GET(flags, bitpos, mask) \ | ||
57 | (((flags) >> (bitpos)) & (mask)) | ||
58 | |||
59 | #define ICP_QAT_FW_REQ_DEFAULT_SZ 128 | ||
60 | #define ICP_QAT_FW_RESP_DEFAULT_SZ 32 | ||
61 | #define ICP_QAT_FW_COMN_ONE_BYTE_SHIFT 8 | ||
62 | #define ICP_QAT_FW_COMN_SINGLE_BYTE_MASK 0xFF | ||
63 | #define ICP_QAT_FW_NUM_LONGWORDS_1 1 | ||
64 | #define ICP_QAT_FW_NUM_LONGWORDS_2 2 | ||
65 | #define ICP_QAT_FW_NUM_LONGWORDS_3 3 | ||
66 | #define ICP_QAT_FW_NUM_LONGWORDS_4 4 | ||
67 | #define ICP_QAT_FW_NUM_LONGWORDS_5 5 | ||
68 | #define ICP_QAT_FW_NUM_LONGWORDS_6 6 | ||
69 | #define ICP_QAT_FW_NUM_LONGWORDS_7 7 | ||
70 | #define ICP_QAT_FW_NUM_LONGWORDS_10 10 | ||
71 | #define ICP_QAT_FW_NUM_LONGWORDS_13 13 | ||
72 | #define ICP_QAT_FW_NULL_REQ_SERV_ID 1 | ||
73 | |||
74 | enum icp_qat_fw_comn_resp_serv_id { | ||
75 | ICP_QAT_FW_COMN_RESP_SERV_NULL, | ||
76 | ICP_QAT_FW_COMN_RESP_SERV_CPM_FW, | ||
77 | ICP_QAT_FW_COMN_RESP_SERV_DELIMITER | ||
78 | }; | ||
79 | |||
80 | enum icp_qat_fw_comn_request_id { | ||
81 | ICP_QAT_FW_COMN_REQ_NULL = 0, | ||
82 | ICP_QAT_FW_COMN_REQ_CPM_FW_PKE = 3, | ||
83 | ICP_QAT_FW_COMN_REQ_CPM_FW_LA = 4, | ||
84 | ICP_QAT_FW_COMN_REQ_CPM_FW_DMA = 7, | ||
85 | ICP_QAT_FW_COMN_REQ_CPM_FW_COMP = 9, | ||
86 | ICP_QAT_FW_COMN_REQ_DELIMITER | ||
87 | }; | ||
88 | |||
89 | struct icp_qat_fw_comn_req_hdr_cd_pars { | ||
90 | union { | ||
91 | struct { | ||
92 | uint64_t content_desc_addr; | ||
93 | uint16_t content_desc_resrvd1; | ||
94 | uint8_t content_desc_params_sz; | ||
95 | uint8_t content_desc_hdr_resrvd2; | ||
96 | uint32_t content_desc_resrvd3; | ||
97 | } s; | ||
98 | struct { | ||
99 | uint32_t serv_specif_fields[4]; | ||
100 | } s1; | ||
101 | } u; | ||
102 | }; | ||
103 | |||
104 | struct icp_qat_fw_comn_req_mid { | ||
105 | uint64_t opaque_data; | ||
106 | uint64_t src_data_addr; | ||
107 | uint64_t dest_data_addr; | ||
108 | uint32_t src_length; | ||
109 | uint32_t dst_length; | ||
110 | }; | ||
111 | |||
112 | struct icp_qat_fw_comn_req_cd_ctrl { | ||
113 | uint32_t content_desc_ctrl_lw[ICP_QAT_FW_NUM_LONGWORDS_5]; | ||
114 | }; | ||
115 | |||
116 | struct icp_qat_fw_comn_req_hdr { | ||
117 | uint8_t resrvd1; | ||
118 | uint8_t service_cmd_id; | ||
119 | uint8_t service_type; | ||
120 | uint8_t hdr_flags; | ||
121 | uint16_t serv_specif_flags; | ||
122 | uint16_t comn_req_flags; | ||
123 | }; | ||
124 | |||
125 | struct icp_qat_fw_comn_req_rqpars { | ||
126 | uint32_t serv_specif_rqpars_lw[ICP_QAT_FW_NUM_LONGWORDS_13]; | ||
127 | }; | ||
128 | |||
129 | struct icp_qat_fw_comn_req { | ||
130 | struct icp_qat_fw_comn_req_hdr comn_hdr; | ||
131 | struct icp_qat_fw_comn_req_hdr_cd_pars cd_pars; | ||
132 | struct icp_qat_fw_comn_req_mid comn_mid; | ||
133 | struct icp_qat_fw_comn_req_rqpars serv_specif_rqpars; | ||
134 | struct icp_qat_fw_comn_req_cd_ctrl cd_ctrl; | ||
135 | }; | ||
136 | |||
137 | struct icp_qat_fw_comn_error { | ||
138 | uint8_t xlat_err_code; | ||
139 | uint8_t cmp_err_code; | ||
140 | }; | ||
141 | |||
142 | struct icp_qat_fw_comn_resp_hdr { | ||
143 | uint8_t resrvd1; | ||
144 | uint8_t service_id; | ||
145 | uint8_t response_type; | ||
146 | uint8_t hdr_flags; | ||
147 | struct icp_qat_fw_comn_error comn_error; | ||
148 | uint8_t comn_status; | ||
149 | uint8_t cmd_id; | ||
150 | }; | ||
151 | |||
152 | struct icp_qat_fw_comn_resp { | ||
153 | struct icp_qat_fw_comn_resp_hdr comn_hdr; | ||
154 | uint64_t opaque_data; | ||
155 | uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_4]; | ||
156 | }; | ||
157 | |||
158 | #define ICP_QAT_FW_COMN_REQ_FLAG_SET 1 | ||
159 | #define ICP_QAT_FW_COMN_REQ_FLAG_CLR 0 | ||
160 | #define ICP_QAT_FW_COMN_VALID_FLAG_BITPOS 7 | ||
161 | #define ICP_QAT_FW_COMN_VALID_FLAG_MASK 0x1 | ||
162 | #define ICP_QAT_FW_COMN_HDR_RESRVD_FLD_MASK 0x7F | ||
163 | |||
164 | #define ICP_QAT_FW_COMN_OV_SRV_TYPE_GET(icp_qat_fw_comn_req_hdr_t) \ | ||
165 | icp_qat_fw_comn_req_hdr_t.service_type | ||
166 | |||
167 | #define ICP_QAT_FW_COMN_OV_SRV_TYPE_SET(icp_qat_fw_comn_req_hdr_t, val) \ | ||
168 | icp_qat_fw_comn_req_hdr_t.service_type = val | ||
169 | |||
170 | #define ICP_QAT_FW_COMN_OV_SRV_CMD_ID_GET(icp_qat_fw_comn_req_hdr_t) \ | ||
171 | icp_qat_fw_comn_req_hdr_t.service_cmd_id | ||
172 | |||
173 | #define ICP_QAT_FW_COMN_OV_SRV_CMD_ID_SET(icp_qat_fw_comn_req_hdr_t, val) \ | ||
174 | icp_qat_fw_comn_req_hdr_t.service_cmd_id = val | ||
175 | |||
176 | #define ICP_QAT_FW_COMN_HDR_VALID_FLAG_GET(hdr_t) \ | ||
177 | ICP_QAT_FW_COMN_VALID_FLAG_GET(hdr_t.hdr_flags) | ||
178 | |||
179 | #define ICP_QAT_FW_COMN_HDR_VALID_FLAG_SET(hdr_t, val) \ | ||
180 | ICP_QAT_FW_COMN_VALID_FLAG_SET(hdr_t, val) | ||
181 | |||
182 | #define ICP_QAT_FW_COMN_VALID_FLAG_GET(hdr_flags) \ | ||
183 | QAT_FIELD_GET(hdr_flags, \ | ||
184 | ICP_QAT_FW_COMN_VALID_FLAG_BITPOS, \ | ||
185 | ICP_QAT_FW_COMN_VALID_FLAG_MASK) | ||
186 | |||
187 | #define ICP_QAT_FW_COMN_HDR_RESRVD_FLD_GET(hdr_flags) \ | ||
188 | (hdr_flags & ICP_QAT_FW_COMN_HDR_RESRVD_FLD_MASK) | ||
189 | |||
190 | #define ICP_QAT_FW_COMN_VALID_FLAG_SET(hdr_t, val) \ | ||
191 | QAT_FIELD_SET((hdr_t.hdr_flags), (val), \ | ||
192 | ICP_QAT_FW_COMN_VALID_FLAG_BITPOS, \ | ||
193 | ICP_QAT_FW_COMN_VALID_FLAG_MASK) | ||
194 | |||
195 | #define ICP_QAT_FW_COMN_HDR_FLAGS_BUILD(valid) \ | ||
196 | (((valid) & ICP_QAT_FW_COMN_VALID_FLAG_MASK) << \ | ||
197 | ICP_QAT_FW_COMN_VALID_FLAG_BITPOS) | ||
198 | |||
199 | #define QAT_COMN_PTR_TYPE_BITPOS 0 | ||
200 | #define QAT_COMN_PTR_TYPE_MASK 0x1 | ||
201 | #define QAT_COMN_CD_FLD_TYPE_BITPOS 1 | ||
202 | #define QAT_COMN_CD_FLD_TYPE_MASK 0x1 | ||
203 | #define QAT_COMN_PTR_TYPE_FLAT 0x0 | ||
204 | #define QAT_COMN_PTR_TYPE_SGL 0x1 | ||
205 | #define QAT_COMN_CD_FLD_TYPE_64BIT_ADR 0x0 | ||
206 | #define QAT_COMN_CD_FLD_TYPE_16BYTE_DATA 0x1 | ||
207 | |||
208 | #define ICP_QAT_FW_COMN_FLAGS_BUILD(cdt, ptr) \ | ||
209 | ((((cdt) & QAT_COMN_CD_FLD_TYPE_MASK) << QAT_COMN_CD_FLD_TYPE_BITPOS) \ | ||
210 | | (((ptr) & QAT_COMN_PTR_TYPE_MASK) << QAT_COMN_PTR_TYPE_BITPOS)) | ||
211 | |||
212 | #define ICP_QAT_FW_COMN_PTR_TYPE_GET(flags) \ | ||
213 | QAT_FIELD_GET(flags, QAT_COMN_PTR_TYPE_BITPOS, QAT_COMN_PTR_TYPE_MASK) | ||
214 | |||
215 | #define ICP_QAT_FW_COMN_CD_FLD_TYPE_GET(flags) \ | ||
216 | QAT_FIELD_GET(flags, QAT_COMN_CD_FLD_TYPE_BITPOS, \ | ||
217 | QAT_COMN_CD_FLD_TYPE_MASK) | ||
218 | |||
219 | #define ICP_QAT_FW_COMN_PTR_TYPE_SET(flags, val) \ | ||
220 | QAT_FIELD_SET(flags, val, QAT_COMN_PTR_TYPE_BITPOS, \ | ||
221 | QAT_COMN_PTR_TYPE_MASK) | ||
222 | |||
223 | #define ICP_QAT_FW_COMN_CD_FLD_TYPE_SET(flags, val) \ | ||
224 | QAT_FIELD_SET(flags, val, QAT_COMN_CD_FLD_TYPE_BITPOS, \ | ||
225 | QAT_COMN_CD_FLD_TYPE_MASK) | ||
226 | |||
227 | #define ICP_QAT_FW_COMN_NEXT_ID_BITPOS 4 | ||
228 | #define ICP_QAT_FW_COMN_NEXT_ID_MASK 0xF0 | ||
229 | #define ICP_QAT_FW_COMN_CURR_ID_BITPOS 0 | ||
230 | #define ICP_QAT_FW_COMN_CURR_ID_MASK 0x0F | ||
231 | |||
232 | #define ICP_QAT_FW_COMN_NEXT_ID_GET(cd_ctrl_hdr_t) \ | ||
233 | ((((cd_ctrl_hdr_t)->next_curr_id) & ICP_QAT_FW_COMN_NEXT_ID_MASK) \ | ||
234 | >> (ICP_QAT_FW_COMN_NEXT_ID_BITPOS)) | ||
235 | |||
236 | #define ICP_QAT_FW_COMN_NEXT_ID_SET(cd_ctrl_hdr_t, val) \ | ||
237 | { ((cd_ctrl_hdr_t)->next_curr_id) = ((((cd_ctrl_hdr_t)->next_curr_id) \ | ||
238 | & ICP_QAT_FW_COMN_CURR_ID_MASK) | \ | ||
239 | ((val << ICP_QAT_FW_COMN_NEXT_ID_BITPOS) \ | ||
240 | & ICP_QAT_FW_COMN_NEXT_ID_MASK)); } | ||
241 | |||
242 | #define ICP_QAT_FW_COMN_CURR_ID_GET(cd_ctrl_hdr_t) \ | ||
243 | (((cd_ctrl_hdr_t)->next_curr_id) & ICP_QAT_FW_COMN_CURR_ID_MASK) | ||
244 | |||
245 | #define ICP_QAT_FW_COMN_CURR_ID_SET(cd_ctrl_hdr_t, val) \ | ||
246 | { ((cd_ctrl_hdr_t)->next_curr_id) = ((((cd_ctrl_hdr_t)->next_curr_id) \ | ||
247 | & ICP_QAT_FW_COMN_NEXT_ID_MASK) | \ | ||
248 | ((val) & ICP_QAT_FW_COMN_CURR_ID_MASK)); } | ||
249 | |||
250 | #define QAT_COMN_RESP_CRYPTO_STATUS_BITPOS 7 | ||
251 | #define QAT_COMN_RESP_CRYPTO_STATUS_MASK 0x1 | ||
252 | #define QAT_COMN_RESP_CMP_STATUS_BITPOS 5 | ||
253 | #define QAT_COMN_RESP_CMP_STATUS_MASK 0x1 | ||
254 | #define QAT_COMN_RESP_XLAT_STATUS_BITPOS 4 | ||
255 | #define QAT_COMN_RESP_XLAT_STATUS_MASK 0x1 | ||
256 | #define QAT_COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS 3 | ||
257 | #define QAT_COMN_RESP_CMP_END_OF_LAST_BLK_MASK 0x1 | ||
258 | |||
259 | #define ICP_QAT_FW_COMN_RESP_STATUS_BUILD(crypto, comp, xlat, eolb) \ | ||
260 | ((((crypto) & QAT_COMN_RESP_CRYPTO_STATUS_MASK) << \ | ||
261 | QAT_COMN_RESP_CRYPTO_STATUS_BITPOS) | \ | ||
262 | (((comp) & QAT_COMN_RESP_CMP_STATUS_MASK) << \ | ||
263 | QAT_COMN_RESP_CMP_STATUS_BITPOS) | \ | ||
264 | (((xlat) & QAT_COMN_RESP_XLAT_STATUS_MASK) << \ | ||
265 | QAT_COMN_RESP_XLAT_STATUS_BITPOS) | \ | ||
266 | (((eolb) & QAT_COMN_RESP_CMP_END_OF_LAST_BLK_MASK) << \ | ||
267 | QAT_COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS)) | ||
268 | |||
269 | #define ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET(status) \ | ||
270 | QAT_FIELD_GET(status, QAT_COMN_RESP_CRYPTO_STATUS_BITPOS, \ | ||
271 | QAT_COMN_RESP_CRYPTO_STATUS_MASK) | ||
272 | |||
273 | #define ICP_QAT_FW_COMN_RESP_CMP_STAT_GET(status) \ | ||
274 | QAT_FIELD_GET(status, QAT_COMN_RESP_CMP_STATUS_BITPOS, \ | ||
275 | QAT_COMN_RESP_CMP_STATUS_MASK) | ||
276 | |||
277 | #define ICP_QAT_FW_COMN_RESP_XLAT_STAT_GET(status) \ | ||
278 | QAT_FIELD_GET(status, QAT_COMN_RESP_XLAT_STATUS_BITPOS, \ | ||
279 | QAT_COMN_RESP_XLAT_STATUS_MASK) | ||
280 | |||
281 | #define ICP_QAT_FW_COMN_RESP_CMP_END_OF_LAST_BLK_FLAG_GET(status) \ | ||
282 | QAT_FIELD_GET(status, QAT_COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS, \ | ||
283 | QAT_COMN_RESP_CMP_END_OF_LAST_BLK_MASK) | ||
284 | |||
285 | #define ICP_QAT_FW_COMN_STATUS_FLAG_OK 0 | ||
286 | #define ICP_QAT_FW_COMN_STATUS_FLAG_ERROR 1 | ||
287 | #define ICP_QAT_FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_CLR 0 | ||
288 | #define ICP_QAT_FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_SET 1 | ||
289 | #define ERR_CODE_NO_ERROR 0 | ||
290 | #define ERR_CODE_INVALID_BLOCK_TYPE -1 | ||
291 | #define ERR_CODE_NO_MATCH_ONES_COMP -2 | ||
292 | #define ERR_CODE_TOO_MANY_LEN_OR_DIS -3 | ||
293 | #define ERR_CODE_INCOMPLETE_LEN -4 | ||
294 | #define ERR_CODE_RPT_LEN_NO_FIRST_LEN -5 | ||
295 | #define ERR_CODE_RPT_GT_SPEC_LEN -6 | ||
296 | #define ERR_CODE_INV_LIT_LEN_CODE_LEN -7 | ||
297 | #define ERR_CODE_INV_DIS_CODE_LEN -8 | ||
298 | #define ERR_CODE_INV_LIT_LEN_DIS_IN_BLK -9 | ||
299 | #define ERR_CODE_DIS_TOO_FAR_BACK -10 | ||
300 | #define ERR_CODE_OVERFLOW_ERROR -11 | ||
301 | #define ERR_CODE_SOFT_ERROR -12 | ||
302 | #define ERR_CODE_FATAL_ERROR -13 | ||
303 | #define ERR_CODE_SSM_ERROR -14 | ||
304 | #define ERR_CODE_ENDPOINT_ERROR -15 | ||
305 | |||
306 | enum icp_qat_fw_slice { | ||
307 | ICP_QAT_FW_SLICE_NULL = 0, | ||
308 | ICP_QAT_FW_SLICE_CIPHER = 1, | ||
309 | ICP_QAT_FW_SLICE_AUTH = 2, | ||
310 | ICP_QAT_FW_SLICE_DRAM_RD = 3, | ||
311 | ICP_QAT_FW_SLICE_DRAM_WR = 4, | ||
312 | ICP_QAT_FW_SLICE_COMP = 5, | ||
313 | ICP_QAT_FW_SLICE_XLAT = 6, | ||
314 | ICP_QAT_FW_SLICE_DELIMITER | ||
315 | }; | ||
316 | #endif | ||
diff --git a/drivers/crypto/qat/qat_common/icp_qat_fw_init_admin.h b/drivers/crypto/qat/qat_common/icp_qat_fw_init_admin.h new file mode 100644 index 000000000000..72a59faa9005 --- /dev/null +++ b/drivers/crypto/qat/qat_common/icp_qat_fw_init_admin.h | |||
@@ -0,0 +1,131 @@ | |||
1 | /* | ||
2 | This file is provided under a dual BSD/GPLv2 license. When using or | ||
3 | redistributing this file, you may do so under either license. | ||
4 | |||
5 | GPL LICENSE SUMMARY | ||
6 | Copyright(c) 2014 Intel Corporation. | ||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of version 2 of the GNU General Public License as | ||
9 | published by the Free Software Foundation. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | Contact Information: | ||
17 | qat-linux@intel.com | ||
18 | |||
19 | BSD LICENSE | ||
20 | Copyright(c) 2014 Intel Corporation. | ||
21 | Redistribution and use in source and binary forms, with or without | ||
22 | modification, are permitted provided that the following conditions | ||
23 | are met: | ||
24 | |||
25 | * Redistributions of source code must retain the above copyright | ||
26 | notice, this list of conditions and the following disclaimer. | ||
27 | * Redistributions in binary form must reproduce the above copyright | ||
28 | notice, this list of conditions and the following disclaimer in | ||
29 | the documentation and/or other materials provided with the | ||
30 | distribution. | ||
31 | * Neither the name of Intel Corporation nor the names of its | ||
32 | contributors may be used to endorse or promote products derived | ||
33 | from this software without specific prior written permission. | ||
34 | |||
35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
36 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
37 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
38 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
39 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
40 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
41 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
42 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
43 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
44 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
45 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
46 | */ | ||
47 | #ifndef _ICP_QAT_FW_INIT_ADMIN_H_ | ||
48 | #define _ICP_QAT_FW_INIT_ADMIN_H_ | ||
49 | |||
50 | #include "icp_qat_fw.h" | ||
51 | |||
52 | enum icp_qat_fw_init_admin_cmd_id { | ||
53 | ICP_QAT_FW_INIT_ME = 0, | ||
54 | ICP_QAT_FW_TRNG_ENABLE = 1, | ||
55 | ICP_QAT_FW_TRNG_DISABLE = 2, | ||
56 | ICP_QAT_FW_CONSTANTS_CFG = 3, | ||
57 | ICP_QAT_FW_STATUS_GET = 4, | ||
58 | ICP_QAT_FW_COUNTERS_GET = 5, | ||
59 | ICP_QAT_FW_LOOPBACK = 6, | ||
60 | ICP_QAT_FW_HEARTBEAT_SYNC = 7, | ||
61 | ICP_QAT_FW_HEARTBEAT_GET = 8 | ||
62 | }; | ||
63 | |||
64 | enum icp_qat_fw_init_admin_resp_status { | ||
65 | ICP_QAT_FW_INIT_RESP_STATUS_SUCCESS = 0, | ||
66 | ICP_QAT_FW_INIT_RESP_STATUS_FAIL | ||
67 | }; | ||
68 | |||
69 | struct icp_qat_fw_init_admin_req { | ||
70 | uint16_t init_cfg_sz; | ||
71 | uint8_t resrvd1; | ||
72 | uint8_t init_admin_cmd_id; | ||
73 | uint32_t resrvd2; | ||
74 | uint64_t opaque_data; | ||
75 | uint64_t init_cfg_ptr; | ||
76 | uint64_t resrvd3; | ||
77 | }; | ||
78 | |||
79 | struct icp_qat_fw_init_admin_resp_hdr { | ||
80 | uint8_t flags; | ||
81 | uint8_t resrvd1; | ||
82 | uint8_t status; | ||
83 | uint8_t init_admin_cmd_id; | ||
84 | }; | ||
85 | |||
86 | struct icp_qat_fw_init_admin_resp_pars { | ||
87 | union { | ||
88 | uint32_t resrvd1[ICP_QAT_FW_NUM_LONGWORDS_4]; | ||
89 | struct { | ||
90 | uint32_t version_patch_num; | ||
91 | uint8_t context_id; | ||
92 | uint8_t ae_id; | ||
93 | uint16_t resrvd1; | ||
94 | uint64_t resrvd2; | ||
95 | } s1; | ||
96 | struct { | ||
97 | uint64_t req_rec_count; | ||
98 | uint64_t resp_sent_count; | ||
99 | } s2; | ||
100 | } u; | ||
101 | }; | ||
102 | |||
103 | struct icp_qat_fw_init_admin_resp { | ||
104 | struct icp_qat_fw_init_admin_resp_hdr init_resp_hdr; | ||
105 | union { | ||
106 | uint32_t resrvd2; | ||
107 | struct { | ||
108 | uint16_t version_minor_num; | ||
109 | uint16_t version_major_num; | ||
110 | } s; | ||
111 | } u; | ||
112 | uint64_t opaque_data; | ||
113 | struct icp_qat_fw_init_admin_resp_pars init_resp_pars; | ||
114 | }; | ||
115 | |||
116 | #define ICP_QAT_FW_COMN_HEARTBEAT_OK 0 | ||
117 | #define ICP_QAT_FW_COMN_HEARTBEAT_BLOCKED 1 | ||
118 | #define ICP_QAT_FW_COMN_HEARTBEAT_FLAG_BITPOS 0 | ||
119 | #define ICP_QAT_FW_COMN_HEARTBEAT_FLAG_MASK 0x1 | ||
120 | #define ICP_QAT_FW_COMN_STATUS_RESRVD_FLD_MASK 0xFE | ||
121 | #define ICP_QAT_FW_COMN_HEARTBEAT_HDR_FLAG_GET(hdr_t) \ | ||
122 | ICP_QAT_FW_COMN_HEARTBEAT_FLAG_GET(hdr_t.flags) | ||
123 | |||
124 | #define ICP_QAT_FW_COMN_HEARTBEAT_HDR_FLAG_SET(hdr_t, val) \ | ||
125 | ICP_QAT_FW_COMN_HEARTBEAT_FLAG_SET(hdr_t, val) | ||
126 | |||
127 | #define ICP_QAT_FW_COMN_HEARTBEAT_FLAG_GET(flags) \ | ||
128 | QAT_FIELD_GET(flags, \ | ||
129 | ICP_QAT_FW_COMN_HEARTBEAT_FLAG_BITPOS, \ | ||
130 | ICP_QAT_FW_COMN_HEARTBEAT_FLAG_MASK) | ||
131 | #endif | ||
diff --git a/drivers/crypto/qat/qat_common/icp_qat_fw_la.h b/drivers/crypto/qat/qat_common/icp_qat_fw_la.h new file mode 100644 index 000000000000..d1d4802a857f --- /dev/null +++ b/drivers/crypto/qat/qat_common/icp_qat_fw_la.h | |||
@@ -0,0 +1,403 @@ | |||
1 | /* | ||
2 | This file is provided under a dual BSD/GPLv2 license. When using or | ||
3 | redistributing this file, you may do so under either license. | ||
4 | |||
5 | GPL LICENSE SUMMARY | ||
6 | Copyright(c) 2014 Intel Corporation. | ||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of version 2 of the GNU General Public License as | ||
9 | published by the Free Software Foundation. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | Contact Information: | ||
17 | qat-linux@intel.com | ||
18 | |||
19 | BSD LICENSE | ||
20 | Copyright(c) 2014 Intel Corporation. | ||
21 | Redistribution and use in source and binary forms, with or without | ||
22 | modification, are permitted provided that the following conditions | ||
23 | are met: | ||
24 | |||
25 | * Redistributions of source code must retain the above copyright | ||
26 | notice, this list of conditions and the following disclaimer. | ||
27 | * Redistributions in binary form must reproduce the above copyright | ||
28 | notice, this list of conditions and the following disclaimer in | ||
29 | the documentation and/or other materials provided with the | ||
30 | distribution. | ||
31 | * Neither the name of Intel Corporation nor the names of its | ||
32 | contributors may be used to endorse or promote products derived | ||
33 | from this software without specific prior written permission. | ||
34 | |||
35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
36 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
37 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
38 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
39 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
40 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
41 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
42 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
43 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
44 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
45 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
46 | */ | ||
47 | #ifndef _ICP_QAT_FW_LA_H_ | ||
48 | #define _ICP_QAT_FW_LA_H_ | ||
49 | #include "icp_qat_fw.h" | ||
50 | |||
51 | enum icp_qat_fw_la_cmd_id { | ||
52 | ICP_QAT_FW_LA_CMD_CIPHER = 0, | ||
53 | ICP_QAT_FW_LA_CMD_AUTH = 1, | ||
54 | ICP_QAT_FW_LA_CMD_CIPHER_HASH = 2, | ||
55 | ICP_QAT_FW_LA_CMD_HASH_CIPHER = 3, | ||
56 | ICP_QAT_FW_LA_CMD_TRNG_GET_RANDOM = 4, | ||
57 | ICP_QAT_FW_LA_CMD_TRNG_TEST = 5, | ||
58 | ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE = 6, | ||
59 | ICP_QAT_FW_LA_CMD_TLS_V1_1_KEY_DERIVE = 7, | ||
60 | ICP_QAT_FW_LA_CMD_TLS_V1_2_KEY_DERIVE = 8, | ||
61 | ICP_QAT_FW_LA_CMD_MGF1 = 9, | ||
62 | ICP_QAT_FW_LA_CMD_AUTH_PRE_COMP = 10, | ||
63 | ICP_QAT_FW_LA_CMD_CIPHER_PRE_COMP = 11, | ||
64 | ICP_QAT_FW_LA_CMD_DELIMITER = 12 | ||
65 | }; | ||
66 | |||
67 | #define ICP_QAT_FW_LA_ICV_VER_STATUS_PASS ICP_QAT_FW_COMN_STATUS_FLAG_OK | ||
68 | #define ICP_QAT_FW_LA_ICV_VER_STATUS_FAIL ICP_QAT_FW_COMN_STATUS_FLAG_ERROR | ||
69 | #define ICP_QAT_FW_LA_TRNG_STATUS_PASS ICP_QAT_FW_COMN_STATUS_FLAG_OK | ||
70 | #define ICP_QAT_FW_LA_TRNG_STATUS_FAIL ICP_QAT_FW_COMN_STATUS_FLAG_ERROR | ||
71 | |||
72 | struct icp_qat_fw_la_bulk_req { | ||
73 | struct icp_qat_fw_comn_req_hdr comn_hdr; | ||
74 | struct icp_qat_fw_comn_req_hdr_cd_pars cd_pars; | ||
75 | struct icp_qat_fw_comn_req_mid comn_mid; | ||
76 | struct icp_qat_fw_comn_req_rqpars serv_specif_rqpars; | ||
77 | struct icp_qat_fw_comn_req_cd_ctrl cd_ctrl; | ||
78 | }; | ||
79 | |||
80 | #define ICP_QAT_FW_LA_GCM_IV_LEN_12_OCTETS 1 | ||
81 | #define ICP_QAT_FW_LA_GCM_IV_LEN_NOT_12_OCTETS 0 | ||
82 | #define QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS 12 | ||
83 | #define ICP_QAT_FW_LA_ZUC_3G_PROTO 1 | ||
84 | #define QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK 0x1 | ||
85 | #define QAT_LA_GCM_IV_LEN_FLAG_BITPOS 11 | ||
86 | #define QAT_LA_GCM_IV_LEN_FLAG_MASK 0x1 | ||
87 | #define ICP_QAT_FW_LA_DIGEST_IN_BUFFER 1 | ||
88 | #define ICP_QAT_FW_LA_NO_DIGEST_IN_BUFFER 0 | ||
89 | #define QAT_LA_DIGEST_IN_BUFFER_BITPOS 10 | ||
90 | #define QAT_LA_DIGEST_IN_BUFFER_MASK 0x1 | ||
91 | #define ICP_QAT_FW_LA_SNOW_3G_PROTO 4 | ||
92 | #define ICP_QAT_FW_LA_GCM_PROTO 2 | ||
93 | #define ICP_QAT_FW_LA_CCM_PROTO 1 | ||
94 | #define ICP_QAT_FW_LA_NO_PROTO 0 | ||
95 | #define QAT_LA_PROTO_BITPOS 7 | ||
96 | #define QAT_LA_PROTO_MASK 0x7 | ||
97 | #define ICP_QAT_FW_LA_CMP_AUTH_RES 1 | ||
98 | #define ICP_QAT_FW_LA_NO_CMP_AUTH_RES 0 | ||
99 | #define QAT_LA_CMP_AUTH_RES_BITPOS 6 | ||
100 | #define QAT_LA_CMP_AUTH_RES_MASK 0x1 | ||
101 | #define ICP_QAT_FW_LA_RET_AUTH_RES 1 | ||
102 | #define ICP_QAT_FW_LA_NO_RET_AUTH_RES 0 | ||
103 | #define QAT_LA_RET_AUTH_RES_BITPOS 5 | ||
104 | #define QAT_LA_RET_AUTH_RES_MASK 0x1 | ||
105 | #define ICP_QAT_FW_LA_UPDATE_STATE 1 | ||
106 | #define ICP_QAT_FW_LA_NO_UPDATE_STATE 0 | ||
107 | #define QAT_LA_UPDATE_STATE_BITPOS 4 | ||
108 | #define QAT_LA_UPDATE_STATE_MASK 0x1 | ||
109 | #define ICP_QAT_FW_CIPH_AUTH_CFG_OFFSET_IN_CD_SETUP 0 | ||
110 | #define ICP_QAT_FW_CIPH_AUTH_CFG_OFFSET_IN_SHRAM_CP 1 | ||
111 | #define QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS 3 | ||
112 | #define QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK 0x1 | ||
113 | #define ICP_QAT_FW_CIPH_IV_64BIT_PTR 0 | ||
114 | #define ICP_QAT_FW_CIPH_IV_16BYTE_DATA 1 | ||
115 | #define QAT_LA_CIPH_IV_FLD_BITPOS 2 | ||
116 | #define QAT_LA_CIPH_IV_FLD_MASK 0x1 | ||
117 | #define ICP_QAT_FW_LA_PARTIAL_NONE 0 | ||
118 | #define ICP_QAT_FW_LA_PARTIAL_START 1 | ||
119 | #define ICP_QAT_FW_LA_PARTIAL_MID 3 | ||
120 | #define ICP_QAT_FW_LA_PARTIAL_END 2 | ||
121 | #define QAT_LA_PARTIAL_BITPOS 0 | ||
122 | #define QAT_LA_PARTIAL_MASK 0x3 | ||
123 | #define ICP_QAT_FW_LA_FLAGS_BUILD(zuc_proto, gcm_iv_len, auth_rslt, proto, \ | ||
124 | cmp_auth, ret_auth, update_state, \ | ||
125 | ciph_iv, ciphcfg, partial) \ | ||
126 | (((zuc_proto & QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK) << \ | ||
127 | QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS) | \ | ||
128 | ((gcm_iv_len & QAT_LA_GCM_IV_LEN_FLAG_MASK) << \ | ||
129 | QAT_LA_GCM_IV_LEN_FLAG_BITPOS) | \ | ||
130 | ((auth_rslt & QAT_LA_DIGEST_IN_BUFFER_MASK) << \ | ||
131 | QAT_LA_DIGEST_IN_BUFFER_BITPOS) | \ | ||
132 | ((proto & QAT_LA_PROTO_MASK) << \ | ||
133 | QAT_LA_PROTO_BITPOS) | \ | ||
134 | ((cmp_auth & QAT_LA_CMP_AUTH_RES_MASK) << \ | ||
135 | QAT_LA_CMP_AUTH_RES_BITPOS) | \ | ||
136 | ((ret_auth & QAT_LA_RET_AUTH_RES_MASK) << \ | ||
137 | QAT_LA_RET_AUTH_RES_BITPOS) | \ | ||
138 | ((update_state & QAT_LA_UPDATE_STATE_MASK) << \ | ||
139 | QAT_LA_UPDATE_STATE_BITPOS) | \ | ||
140 | ((ciph_iv & QAT_LA_CIPH_IV_FLD_MASK) << \ | ||
141 | QAT_LA_CIPH_IV_FLD_BITPOS) | \ | ||
142 | ((ciphcfg & QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK) << \ | ||
143 | QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS) | \ | ||
144 | ((partial & QAT_LA_PARTIAL_MASK) << \ | ||
145 | QAT_LA_PARTIAL_BITPOS)) | ||
146 | |||
147 | #define ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_GET(flags) \ | ||
148 | QAT_FIELD_GET(flags, QAT_LA_CIPH_IV_FLD_BITPOS, \ | ||
149 | QAT_LA_CIPH_IV_FLD_MASK) | ||
150 | |||
151 | #define ICP_QAT_FW_LA_CIPH_AUTH_CFG_OFFSET_FLAG_GET(flags) \ | ||
152 | QAT_FIELD_GET(flags, QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS, \ | ||
153 | QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK) | ||
154 | |||
155 | #define ICP_QAT_FW_LA_ZUC_3G_PROTO_FLAG_GET(flags) \ | ||
156 | QAT_FIELD_GET(flags, QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS, \ | ||
157 | QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK) | ||
158 | |||
159 | #define ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_GET(flags) \ | ||
160 | QAT_FIELD_GET(flags, QAT_LA_GCM_IV_LEN_FLAG_BITPOS, \ | ||
161 | QAT_LA_GCM_IV_LEN_FLAG_MASK) | ||
162 | |||
163 | #define ICP_QAT_FW_LA_PROTO_GET(flags) \ | ||
164 | QAT_FIELD_GET(flags, QAT_LA_PROTO_BITPOS, QAT_LA_PROTO_MASK) | ||
165 | |||
166 | #define ICP_QAT_FW_LA_CMP_AUTH_GET(flags) \ | ||
167 | QAT_FIELD_GET(flags, QAT_LA_CMP_AUTH_RES_BITPOS, \ | ||
168 | QAT_LA_CMP_AUTH_RES_MASK) | ||
169 | |||
170 | #define ICP_QAT_FW_LA_RET_AUTH_GET(flags) \ | ||
171 | QAT_FIELD_GET(flags, QAT_LA_RET_AUTH_RES_BITPOS, \ | ||
172 | QAT_LA_RET_AUTH_RES_MASK) | ||
173 | |||
174 | #define ICP_QAT_FW_LA_DIGEST_IN_BUFFER_GET(flags) \ | ||
175 | QAT_FIELD_GET(flags, QAT_LA_DIGEST_IN_BUFFER_BITPOS, \ | ||
176 | QAT_LA_DIGEST_IN_BUFFER_MASK) | ||
177 | |||
178 | #define ICP_QAT_FW_LA_UPDATE_STATE_GET(flags) \ | ||
179 | QAT_FIELD_GET(flags, QAT_LA_UPDATE_STATE_BITPOS, \ | ||
180 | QAT_LA_UPDATE_STATE_MASK) | ||
181 | |||
182 | #define ICP_QAT_FW_LA_PARTIAL_GET(flags) \ | ||
183 | QAT_FIELD_GET(flags, QAT_LA_PARTIAL_BITPOS, \ | ||
184 | QAT_LA_PARTIAL_MASK) | ||
185 | |||
186 | #define ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_SET(flags, val) \ | ||
187 | QAT_FIELD_SET(flags, val, QAT_LA_CIPH_IV_FLD_BITPOS, \ | ||
188 | QAT_LA_CIPH_IV_FLD_MASK) | ||
189 | |||
190 | #define ICP_QAT_FW_LA_CIPH_AUTH_CFG_OFFSET_FLAG_SET(flags, val) \ | ||
191 | QAT_FIELD_SET(flags, val, QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS, \ | ||
192 | QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK) | ||
193 | |||
194 | #define ICP_QAT_FW_LA_ZUC_3G_PROTO_FLAG_SET(flags, val) \ | ||
195 | QAT_FIELD_SET(flags, val, QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS, \ | ||
196 | QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK) | ||
197 | |||
198 | #define ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_SET(flags, val) \ | ||
199 | QAT_FIELD_SET(flags, val, QAT_LA_GCM_IV_LEN_FLAG_BITPOS, \ | ||
200 | QAT_LA_GCM_IV_LEN_FLAG_MASK) | ||
201 | |||
202 | #define ICP_QAT_FW_LA_PROTO_SET(flags, val) \ | ||
203 | QAT_FIELD_SET(flags, val, QAT_LA_PROTO_BITPOS, \ | ||
204 | QAT_LA_PROTO_MASK) | ||
205 | |||
206 | #define ICP_QAT_FW_LA_CMP_AUTH_SET(flags, val) \ | ||
207 | QAT_FIELD_SET(flags, val, QAT_LA_CMP_AUTH_RES_BITPOS, \ | ||
208 | QAT_LA_CMP_AUTH_RES_MASK) | ||
209 | |||
210 | #define ICP_QAT_FW_LA_RET_AUTH_SET(flags, val) \ | ||
211 | QAT_FIELD_SET(flags, val, QAT_LA_RET_AUTH_RES_BITPOS, \ | ||
212 | QAT_LA_RET_AUTH_RES_MASK) | ||
213 | |||
214 | #define ICP_QAT_FW_LA_DIGEST_IN_BUFFER_SET(flags, val) \ | ||
215 | QAT_FIELD_SET(flags, val, QAT_LA_DIGEST_IN_BUFFER_BITPOS, \ | ||
216 | QAT_LA_DIGEST_IN_BUFFER_MASK) | ||
217 | |||
218 | #define ICP_QAT_FW_LA_UPDATE_STATE_SET(flags, val) \ | ||
219 | QAT_FIELD_SET(flags, val, QAT_LA_UPDATE_STATE_BITPOS, \ | ||
220 | QAT_LA_UPDATE_STATE_MASK) | ||
221 | |||
222 | #define ICP_QAT_FW_LA_PARTIAL_SET(flags, val) \ | ||
223 | QAT_FIELD_SET(flags, val, QAT_LA_PARTIAL_BITPOS, \ | ||
224 | QAT_LA_PARTIAL_MASK) | ||
225 | |||
226 | struct icp_qat_fw_cipher_req_hdr_cd_pars { | ||
227 | union { | ||
228 | struct { | ||
229 | uint64_t content_desc_addr; | ||
230 | uint16_t content_desc_resrvd1; | ||
231 | uint8_t content_desc_params_sz; | ||
232 | uint8_t content_desc_hdr_resrvd2; | ||
233 | uint32_t content_desc_resrvd3; | ||
234 | } s; | ||
235 | struct { | ||
236 | uint32_t cipher_key_array[ICP_QAT_FW_NUM_LONGWORDS_4]; | ||
237 | } s1; | ||
238 | } u; | ||
239 | }; | ||
240 | |||
241 | struct icp_qat_fw_cipher_auth_req_hdr_cd_pars { | ||
242 | union { | ||
243 | struct { | ||
244 | uint64_t content_desc_addr; | ||
245 | uint16_t content_desc_resrvd1; | ||
246 | uint8_t content_desc_params_sz; | ||
247 | uint8_t content_desc_hdr_resrvd2; | ||
248 | uint32_t content_desc_resrvd3; | ||
249 | } s; | ||
250 | struct { | ||
251 | uint32_t cipher_key_array[ICP_QAT_FW_NUM_LONGWORDS_4]; | ||
252 | } sl; | ||
253 | } u; | ||
254 | }; | ||
255 | |||
256 | struct icp_qat_fw_cipher_cd_ctrl_hdr { | ||
257 | uint8_t cipher_state_sz; | ||
258 | uint8_t cipher_key_sz; | ||
259 | uint8_t cipher_cfg_offset; | ||
260 | uint8_t next_curr_id; | ||
261 | uint8_t cipher_padding_sz; | ||
262 | uint8_t resrvd1; | ||
263 | uint16_t resrvd2; | ||
264 | uint32_t resrvd3[ICP_QAT_FW_NUM_LONGWORDS_3]; | ||
265 | }; | ||
266 | |||
267 | struct icp_qat_fw_auth_cd_ctrl_hdr { | ||
268 | uint32_t resrvd1; | ||
269 | uint8_t resrvd2; | ||
270 | uint8_t hash_flags; | ||
271 | uint8_t hash_cfg_offset; | ||
272 | uint8_t next_curr_id; | ||
273 | uint8_t resrvd3; | ||
274 | uint8_t outer_prefix_sz; | ||
275 | uint8_t final_sz; | ||
276 | uint8_t inner_res_sz; | ||
277 | uint8_t resrvd4; | ||
278 | uint8_t inner_state1_sz; | ||
279 | uint8_t inner_state2_offset; | ||
280 | uint8_t inner_state2_sz; | ||
281 | uint8_t outer_config_offset; | ||
282 | uint8_t outer_state1_sz; | ||
283 | uint8_t outer_res_sz; | ||
284 | uint8_t outer_prefix_offset; | ||
285 | }; | ||
286 | |||
287 | struct icp_qat_fw_cipher_auth_cd_ctrl_hdr { | ||
288 | uint8_t cipher_state_sz; | ||
289 | uint8_t cipher_key_sz; | ||
290 | uint8_t cipher_cfg_offset; | ||
291 | uint8_t next_curr_id_cipher; | ||
292 | uint8_t cipher_padding_sz; | ||
293 | uint8_t hash_flags; | ||
294 | uint8_t hash_cfg_offset; | ||
295 | uint8_t next_curr_id_auth; | ||
296 | uint8_t resrvd1; | ||
297 | uint8_t outer_prefix_sz; | ||
298 | uint8_t final_sz; | ||
299 | uint8_t inner_res_sz; | ||
300 | uint8_t resrvd2; | ||
301 | uint8_t inner_state1_sz; | ||
302 | uint8_t inner_state2_offset; | ||
303 | uint8_t inner_state2_sz; | ||
304 | uint8_t outer_config_offset; | ||
305 | uint8_t outer_state1_sz; | ||
306 | uint8_t outer_res_sz; | ||
307 | uint8_t outer_prefix_offset; | ||
308 | }; | ||
309 | |||
310 | #define ICP_QAT_FW_AUTH_HDR_FLAG_DO_NESTED 1 | ||
311 | #define ICP_QAT_FW_AUTH_HDR_FLAG_NO_NESTED 0 | ||
312 | #define ICP_QAT_FW_CCM_GCM_AAD_SZ_MAX 240 | ||
313 | #define ICP_QAT_FW_HASH_REQUEST_PARAMETERS_OFFSET \ | ||
314 | (sizeof(struct icp_qat_fw_la_cipher_req_params_t)) | ||
315 | #define ICP_QAT_FW_CIPHER_REQUEST_PARAMETERS_OFFSET (0) | ||
316 | |||
317 | struct icp_qat_fw_la_cipher_req_params { | ||
318 | uint32_t cipher_offset; | ||
319 | uint32_t cipher_length; | ||
320 | union { | ||
321 | uint32_t cipher_IV_array[ICP_QAT_FW_NUM_LONGWORDS_4]; | ||
322 | struct { | ||
323 | uint64_t cipher_IV_ptr; | ||
324 | uint64_t resrvd1; | ||
325 | } s; | ||
326 | } u; | ||
327 | }; | ||
328 | |||
329 | struct icp_qat_fw_la_auth_req_params { | ||
330 | uint32_t auth_off; | ||
331 | uint32_t auth_len; | ||
332 | union { | ||
333 | uint64_t auth_partial_st_prefix; | ||
334 | uint64_t aad_adr; | ||
335 | } u1; | ||
336 | uint64_t auth_res_addr; | ||
337 | union { | ||
338 | uint8_t inner_prefix_sz; | ||
339 | uint8_t aad_sz; | ||
340 | } u2; | ||
341 | uint8_t resrvd1; | ||
342 | uint8_t hash_state_sz; | ||
343 | uint8_t auth_res_sz; | ||
344 | } __packed; | ||
345 | |||
346 | struct icp_qat_fw_la_auth_req_params_resrvd_flds { | ||
347 | uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_6]; | ||
348 | union { | ||
349 | uint8_t inner_prefix_sz; | ||
350 | uint8_t aad_sz; | ||
351 | } u2; | ||
352 | uint8_t resrvd1; | ||
353 | uint16_t resrvd2; | ||
354 | }; | ||
355 | |||
356 | struct icp_qat_fw_la_resp { | ||
357 | struct icp_qat_fw_comn_resp_hdr comn_resp; | ||
358 | uint64_t opaque_data; | ||
359 | uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_4]; | ||
360 | }; | ||
361 | #define ICP_QAT_FW_CIPHER_NEXT_ID_GET(cd_ctrl_hdr_t) \ | ||
362 | ((((cd_ctrl_hdr_t)->next_curr_id_cipher) & \ | ||
363 | ICP_QAT_FW_COMN_NEXT_ID_MASK) >> (ICP_QAT_FW_COMN_NEXT_ID_BITPOS)) | ||
364 | |||
365 | #define ICP_QAT_FW_CIPHER_NEXT_ID_SET(cd_ctrl_hdr_t, val) \ | ||
366 | { (cd_ctrl_hdr_t)->next_curr_id_cipher = \ | ||
367 | ((((cd_ctrl_hdr_t)->next_curr_id_cipher) \ | ||
368 | & ICP_QAT_FW_COMN_CURR_ID_MASK) | \ | ||
369 | ((val << ICP_QAT_FW_COMN_NEXT_ID_BITPOS) \ | ||
370 | & ICP_QAT_FW_COMN_NEXT_ID_MASK)) } | ||
371 | |||
372 | #define ICP_QAT_FW_CIPHER_CURR_ID_GET(cd_ctrl_hdr_t) \ | ||
373 | (((cd_ctrl_hdr_t)->next_curr_id_cipher) \ | ||
374 | & ICP_QAT_FW_COMN_CURR_ID_MASK) | ||
375 | |||
376 | #define ICP_QAT_FW_CIPHER_CURR_ID_SET(cd_ctrl_hdr_t, val) \ | ||
377 | { (cd_ctrl_hdr_t)->next_curr_id_cipher = \ | ||
378 | ((((cd_ctrl_hdr_t)->next_curr_id_cipher) \ | ||
379 | & ICP_QAT_FW_COMN_NEXT_ID_MASK) | \ | ||
380 | ((val) & ICP_QAT_FW_COMN_CURR_ID_MASK)) } | ||
381 | |||
382 | #define ICP_QAT_FW_AUTH_NEXT_ID_GET(cd_ctrl_hdr_t) \ | ||
383 | ((((cd_ctrl_hdr_t)->next_curr_id_auth) & ICP_QAT_FW_COMN_NEXT_ID_MASK) \ | ||
384 | >> (ICP_QAT_FW_COMN_NEXT_ID_BITPOS)) | ||
385 | |||
386 | #define ICP_QAT_FW_AUTH_NEXT_ID_SET(cd_ctrl_hdr_t, val) \ | ||
387 | { (cd_ctrl_hdr_t)->next_curr_id_auth = \ | ||
388 | ((((cd_ctrl_hdr_t)->next_curr_id_auth) \ | ||
389 | & ICP_QAT_FW_COMN_CURR_ID_MASK) | \ | ||
390 | ((val << ICP_QAT_FW_COMN_NEXT_ID_BITPOS) \ | ||
391 | & ICP_QAT_FW_COMN_NEXT_ID_MASK)) } | ||
392 | |||
393 | #define ICP_QAT_FW_AUTH_CURR_ID_GET(cd_ctrl_hdr_t) \ | ||
394 | (((cd_ctrl_hdr_t)->next_curr_id_auth) \ | ||
395 | & ICP_QAT_FW_COMN_CURR_ID_MASK) | ||
396 | |||
397 | #define ICP_QAT_FW_AUTH_CURR_ID_SET(cd_ctrl_hdr_t, val) \ | ||
398 | { (cd_ctrl_hdr_t)->next_curr_id_auth = \ | ||
399 | ((((cd_ctrl_hdr_t)->next_curr_id_auth) \ | ||
400 | & ICP_QAT_FW_COMN_NEXT_ID_MASK) | \ | ||
401 | ((val) & ICP_QAT_FW_COMN_CURR_ID_MASK)) } | ||
402 | |||
403 | #endif | ||
diff --git a/drivers/crypto/qat/qat_common/icp_qat_hw.h b/drivers/crypto/qat/qat_common/icp_qat_hw.h new file mode 100644 index 000000000000..cc7ec4071929 --- /dev/null +++ b/drivers/crypto/qat/qat_common/icp_qat_hw.h | |||
@@ -0,0 +1,305 @@ | |||
1 | /* | ||
2 | This file is provided under a dual BSD/GPLv2 license. When using or | ||
3 | redistributing this file, you may do so under either license. | ||
4 | |||
5 | GPL LICENSE SUMMARY | ||
6 | Copyright(c) 2014 Intel Corporation. | ||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of version 2 of the GNU General Public License as | ||
9 | published by the Free Software Foundation. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | Contact Information: | ||
17 | qat-linux@intel.com | ||
18 | |||
19 | BSD LICENSE | ||
20 | Copyright(c) 2014 Intel Corporation. | ||
21 | Redistribution and use in source and binary forms, with or without | ||
22 | modification, are permitted provided that the following conditions | ||
23 | are met: | ||
24 | |||
25 | * Redistributions of source code must retain the above copyright | ||
26 | notice, this list of conditions and the following disclaimer. | ||
27 | * Redistributions in binary form must reproduce the above copyright | ||
28 | notice, this list of conditions and the following disclaimer in | ||
29 | the documentation and/or other materials provided with the | ||
30 | distribution. | ||
31 | * Neither the name of Intel Corporation nor the names of its | ||
32 | contributors may be used to endorse or promote products derived | ||
33 | from this software without specific prior written permission. | ||
34 | |||
35 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
36 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
37 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
38 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
39 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
40 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
41 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
42 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
43 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
44 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
45 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
46 | */ | ||
47 | #ifndef _ICP_QAT_HW_H_ | ||
48 | #define _ICP_QAT_HW_H_ | ||
49 | |||
50 | enum icp_qat_hw_ae_id { | ||
51 | ICP_QAT_HW_AE_0 = 0, | ||
52 | ICP_QAT_HW_AE_1 = 1, | ||
53 | ICP_QAT_HW_AE_2 = 2, | ||
54 | ICP_QAT_HW_AE_3 = 3, | ||
55 | ICP_QAT_HW_AE_4 = 4, | ||
56 | ICP_QAT_HW_AE_5 = 5, | ||
57 | ICP_QAT_HW_AE_6 = 6, | ||
58 | ICP_QAT_HW_AE_7 = 7, | ||
59 | ICP_QAT_HW_AE_8 = 8, | ||
60 | ICP_QAT_HW_AE_9 = 9, | ||
61 | ICP_QAT_HW_AE_10 = 10, | ||
62 | ICP_QAT_HW_AE_11 = 11, | ||
63 | ICP_QAT_HW_AE_DELIMITER = 12 | ||
64 | }; | ||
65 | |||
66 | enum icp_qat_hw_qat_id { | ||
67 | ICP_QAT_HW_QAT_0 = 0, | ||
68 | ICP_QAT_HW_QAT_1 = 1, | ||
69 | ICP_QAT_HW_QAT_2 = 2, | ||
70 | ICP_QAT_HW_QAT_3 = 3, | ||
71 | ICP_QAT_HW_QAT_4 = 4, | ||
72 | ICP_QAT_HW_QAT_5 = 5, | ||
73 | ICP_QAT_HW_QAT_DELIMITER = 6 | ||
74 | }; | ||
75 | |||
76 | enum icp_qat_hw_auth_algo { | ||
77 | ICP_QAT_HW_AUTH_ALGO_NULL = 0, | ||
78 | ICP_QAT_HW_AUTH_ALGO_SHA1 = 1, | ||
79 | ICP_QAT_HW_AUTH_ALGO_MD5 = 2, | ||
80 | ICP_QAT_HW_AUTH_ALGO_SHA224 = 3, | ||
81 | ICP_QAT_HW_AUTH_ALGO_SHA256 = 4, | ||
82 | ICP_QAT_HW_AUTH_ALGO_SHA384 = 5, | ||
83 | ICP_QAT_HW_AUTH_ALGO_SHA512 = 6, | ||
84 | ICP_QAT_HW_AUTH_ALGO_AES_XCBC_MAC = 7, | ||
85 | ICP_QAT_HW_AUTH_ALGO_AES_CBC_MAC = 8, | ||
86 | ICP_QAT_HW_AUTH_ALGO_AES_F9 = 9, | ||
87 | ICP_QAT_HW_AUTH_ALGO_GALOIS_128 = 10, | ||
88 | ICP_QAT_HW_AUTH_ALGO_GALOIS_64 = 11, | ||
89 | ICP_QAT_HW_AUTH_ALGO_KASUMI_F9 = 12, | ||
90 | ICP_QAT_HW_AUTH_ALGO_SNOW_3G_UIA2 = 13, | ||
91 | ICP_QAT_HW_AUTH_ALGO_ZUC_3G_128_EIA3 = 14, | ||
92 | ICP_QAT_HW_AUTH_RESERVED_1 = 15, | ||
93 | ICP_QAT_HW_AUTH_RESERVED_2 = 16, | ||
94 | ICP_QAT_HW_AUTH_ALGO_SHA3_256 = 17, | ||
95 | ICP_QAT_HW_AUTH_RESERVED_3 = 18, | ||
96 | ICP_QAT_HW_AUTH_ALGO_SHA3_512 = 19, | ||
97 | ICP_QAT_HW_AUTH_ALGO_DELIMITER = 20 | ||
98 | }; | ||
99 | |||
100 | enum icp_qat_hw_auth_mode { | ||
101 | ICP_QAT_HW_AUTH_MODE0 = 0, | ||
102 | ICP_QAT_HW_AUTH_MODE1 = 1, | ||
103 | ICP_QAT_HW_AUTH_MODE2 = 2, | ||
104 | ICP_QAT_HW_AUTH_MODE_DELIMITER = 3 | ||
105 | }; | ||
106 | |||
107 | struct icp_qat_hw_auth_config { | ||
108 | uint32_t config; | ||
109 | uint32_t reserved; | ||
110 | }; | ||
111 | |||
112 | #define QAT_AUTH_MODE_BITPOS 4 | ||
113 | #define QAT_AUTH_MODE_MASK 0xF | ||
114 | #define QAT_AUTH_ALGO_BITPOS 0 | ||
115 | #define QAT_AUTH_ALGO_MASK 0xF | ||
116 | #define QAT_AUTH_CMP_BITPOS 8 | ||
117 | #define QAT_AUTH_CMP_MASK 0x7F | ||
118 | #define QAT_AUTH_SHA3_PADDING_BITPOS 16 | ||
119 | #define QAT_AUTH_SHA3_PADDING_MASK 0x1 | ||
120 | #define QAT_AUTH_ALGO_SHA3_BITPOS 22 | ||
121 | #define QAT_AUTH_ALGO_SHA3_MASK 0x3 | ||
122 | #define ICP_QAT_HW_AUTH_CONFIG_BUILD(mode, algo, cmp_len) \ | ||
123 | ((((mode) & QAT_AUTH_MODE_MASK) << QAT_AUTH_MODE_BITPOS) | \ | ||
124 | (((algo) & QAT_AUTH_ALGO_MASK) << QAT_AUTH_ALGO_BITPOS) | \ | ||
125 | (((algo >> 4) & QAT_AUTH_ALGO_SHA3_MASK) << \ | ||
126 | QAT_AUTH_ALGO_SHA3_BITPOS) | \ | ||
127 | (((((algo == ICP_QAT_HW_AUTH_ALGO_SHA3_256) || \ | ||
128 | (algo == ICP_QAT_HW_AUTH_ALGO_SHA3_512)) ? 1 : 0) \ | ||
129 | & QAT_AUTH_SHA3_PADDING_MASK) << QAT_AUTH_SHA3_PADDING_BITPOS) | \ | ||
130 | (((cmp_len) & QAT_AUTH_CMP_MASK) << QAT_AUTH_CMP_BITPOS)) | ||
131 | |||
132 | struct icp_qat_hw_auth_counter { | ||
133 | __be32 counter; | ||
134 | uint32_t reserved; | ||
135 | }; | ||
136 | |||
137 | #define QAT_AUTH_COUNT_MASK 0xFFFFFFFF | ||
138 | #define QAT_AUTH_COUNT_BITPOS 0 | ||
139 | #define ICP_QAT_HW_AUTH_COUNT_BUILD(val) \ | ||
140 | (((val) & QAT_AUTH_COUNT_MASK) << QAT_AUTH_COUNT_BITPOS) | ||
141 | |||
142 | struct icp_qat_hw_auth_setup { | ||
143 | struct icp_qat_hw_auth_config auth_config; | ||
144 | struct icp_qat_hw_auth_counter auth_counter; | ||
145 | }; | ||
146 | |||
147 | #define QAT_HW_DEFAULT_ALIGNMENT 8 | ||
148 | #define QAT_HW_ROUND_UP(val, n) (((val) + ((n)-1)) & (~(n-1))) | ||
149 | #define ICP_QAT_HW_NULL_STATE1_SZ 32 | ||
150 | #define ICP_QAT_HW_MD5_STATE1_SZ 16 | ||
151 | #define ICP_QAT_HW_SHA1_STATE1_SZ 20 | ||
152 | #define ICP_QAT_HW_SHA224_STATE1_SZ 32 | ||
153 | #define ICP_QAT_HW_SHA256_STATE1_SZ 32 | ||
154 | #define ICP_QAT_HW_SHA3_256_STATE1_SZ 32 | ||
155 | #define ICP_QAT_HW_SHA384_STATE1_SZ 64 | ||
156 | #define ICP_QAT_HW_SHA512_STATE1_SZ 64 | ||
157 | #define ICP_QAT_HW_SHA3_512_STATE1_SZ 64 | ||
158 | #define ICP_QAT_HW_SHA3_224_STATE1_SZ 28 | ||
159 | #define ICP_QAT_HW_SHA3_384_STATE1_SZ 48 | ||
160 | #define ICP_QAT_HW_AES_XCBC_MAC_STATE1_SZ 16 | ||
161 | #define ICP_QAT_HW_AES_CBC_MAC_STATE1_SZ 16 | ||
162 | #define ICP_QAT_HW_AES_F9_STATE1_SZ 32 | ||
163 | #define ICP_QAT_HW_KASUMI_F9_STATE1_SZ 16 | ||
164 | #define ICP_QAT_HW_GALOIS_128_STATE1_SZ 16 | ||
165 | #define ICP_QAT_HW_SNOW_3G_UIA2_STATE1_SZ 8 | ||
166 | #define ICP_QAT_HW_ZUC_3G_EIA3_STATE1_SZ 8 | ||
167 | #define ICP_QAT_HW_NULL_STATE2_SZ 32 | ||
168 | #define ICP_QAT_HW_MD5_STATE2_SZ 16 | ||
169 | #define ICP_QAT_HW_SHA1_STATE2_SZ 20 | ||
170 | #define ICP_QAT_HW_SHA224_STATE2_SZ 32 | ||
171 | #define ICP_QAT_HW_SHA256_STATE2_SZ 32 | ||
172 | #define ICP_QAT_HW_SHA3_256_STATE2_SZ 0 | ||
173 | #define ICP_QAT_HW_SHA384_STATE2_SZ 64 | ||
174 | #define ICP_QAT_HW_SHA512_STATE2_SZ 64 | ||
175 | #define ICP_QAT_HW_SHA3_512_STATE2_SZ 0 | ||
176 | #define ICP_QAT_HW_SHA3_224_STATE2_SZ 0 | ||
177 | #define ICP_QAT_HW_SHA3_384_STATE2_SZ 0 | ||
178 | #define ICP_QAT_HW_AES_XCBC_MAC_KEY_SZ 16 | ||
179 | #define ICP_QAT_HW_AES_CBC_MAC_KEY_SZ 16 | ||
180 | #define ICP_QAT_HW_AES_CCM_CBC_E_CTR0_SZ 16 | ||
181 | #define ICP_QAT_HW_F9_IK_SZ 16 | ||
182 | #define ICP_QAT_HW_F9_FK_SZ 16 | ||
183 | #define ICP_QAT_HW_KASUMI_F9_STATE2_SZ (ICP_QAT_HW_F9_IK_SZ + \ | ||
184 | ICP_QAT_HW_F9_FK_SZ) | ||
185 | #define ICP_QAT_HW_AES_F9_STATE2_SZ ICP_QAT_HW_KASUMI_F9_STATE2_SZ | ||
186 | #define ICP_QAT_HW_SNOW_3G_UIA2_STATE2_SZ 24 | ||
187 | #define ICP_QAT_HW_ZUC_3G_EIA3_STATE2_SZ 32 | ||
188 | #define ICP_QAT_HW_GALOIS_H_SZ 16 | ||
189 | #define ICP_QAT_HW_GALOIS_LEN_A_SZ 8 | ||
190 | #define ICP_QAT_HW_GALOIS_E_CTR0_SZ 16 | ||
191 | |||
192 | struct icp_qat_hw_auth_sha512 { | ||
193 | struct icp_qat_hw_auth_setup inner_setup; | ||
194 | uint8_t state1[ICP_QAT_HW_SHA512_STATE1_SZ]; | ||
195 | struct icp_qat_hw_auth_setup outer_setup; | ||
196 | uint8_t state2[ICP_QAT_HW_SHA512_STATE2_SZ]; | ||
197 | }; | ||
198 | |||
199 | struct icp_qat_hw_auth_algo_blk { | ||
200 | struct icp_qat_hw_auth_sha512 sha; | ||
201 | }; | ||
202 | |||
203 | #define ICP_QAT_HW_GALOIS_LEN_A_BITPOS 0 | ||
204 | #define ICP_QAT_HW_GALOIS_LEN_A_MASK 0xFFFFFFFF | ||
205 | |||
206 | enum icp_qat_hw_cipher_algo { | ||
207 | ICP_QAT_HW_CIPHER_ALGO_NULL = 0, | ||
208 | ICP_QAT_HW_CIPHER_ALGO_DES = 1, | ||
209 | ICP_QAT_HW_CIPHER_ALGO_3DES = 2, | ||
210 | ICP_QAT_HW_CIPHER_ALGO_AES128 = 3, | ||
211 | ICP_QAT_HW_CIPHER_ALGO_AES192 = 4, | ||
212 | ICP_QAT_HW_CIPHER_ALGO_AES256 = 5, | ||
213 | ICP_QAT_HW_CIPHER_ALGO_ARC4 = 6, | ||
214 | ICP_QAT_HW_CIPHER_ALGO_KASUMI = 7, | ||
215 | ICP_QAT_HW_CIPHER_ALGO_SNOW_3G_UEA2 = 8, | ||
216 | ICP_QAT_HW_CIPHER_ALGO_ZUC_3G_128_EEA3 = 9, | ||
217 | ICP_QAT_HW_CIPHER_DELIMITER = 10 | ||
218 | }; | ||
219 | |||
220 | enum icp_qat_hw_cipher_mode { | ||
221 | ICP_QAT_HW_CIPHER_ECB_MODE = 0, | ||
222 | ICP_QAT_HW_CIPHER_CBC_MODE = 1, | ||
223 | ICP_QAT_HW_CIPHER_CTR_MODE = 2, | ||
224 | ICP_QAT_HW_CIPHER_F8_MODE = 3, | ||
225 | ICP_QAT_HW_CIPHER_XTS_MODE = 6, | ||
226 | ICP_QAT_HW_CIPHER_MODE_DELIMITER = 7 | ||
227 | }; | ||
228 | |||
229 | struct icp_qat_hw_cipher_config { | ||
230 | uint32_t val; | ||
231 | uint32_t reserved; | ||
232 | }; | ||
233 | |||
234 | enum icp_qat_hw_cipher_dir { | ||
235 | ICP_QAT_HW_CIPHER_ENCRYPT = 0, | ||
236 | ICP_QAT_HW_CIPHER_DECRYPT = 1, | ||
237 | }; | ||
238 | |||
239 | enum icp_qat_hw_cipher_convert { | ||
240 | ICP_QAT_HW_CIPHER_NO_CONVERT = 0, | ||
241 | ICP_QAT_HW_CIPHER_KEY_CONVERT = 1, | ||
242 | }; | ||
243 | |||
244 | #define QAT_CIPHER_MODE_BITPOS 4 | ||
245 | #define QAT_CIPHER_MODE_MASK 0xF | ||
246 | #define QAT_CIPHER_ALGO_BITPOS 0 | ||
247 | #define QAT_CIPHER_ALGO_MASK 0xF | ||
248 | #define QAT_CIPHER_CONVERT_BITPOS 9 | ||
249 | #define QAT_CIPHER_CONVERT_MASK 0x1 | ||
250 | #define QAT_CIPHER_DIR_BITPOS 8 | ||
251 | #define QAT_CIPHER_DIR_MASK 0x1 | ||
252 | #define QAT_CIPHER_MODE_F8_KEY_SZ_MULT 2 | ||
253 | #define QAT_CIPHER_MODE_XTS_KEY_SZ_MULT 2 | ||
254 | #define ICP_QAT_HW_CIPHER_CONFIG_BUILD(mode, algo, convert, dir) \ | ||
255 | (((mode & QAT_CIPHER_MODE_MASK) << QAT_CIPHER_MODE_BITPOS) | \ | ||
256 | ((algo & QAT_CIPHER_ALGO_MASK) << QAT_CIPHER_ALGO_BITPOS) | \ | ||
257 | ((convert & QAT_CIPHER_CONVERT_MASK) << QAT_CIPHER_CONVERT_BITPOS) | \ | ||
258 | ((dir & QAT_CIPHER_DIR_MASK) << QAT_CIPHER_DIR_BITPOS)) | ||
259 | #define ICP_QAT_HW_DES_BLK_SZ 8 | ||
260 | #define ICP_QAT_HW_3DES_BLK_SZ 8 | ||
261 | #define ICP_QAT_HW_NULL_BLK_SZ 8 | ||
262 | #define ICP_QAT_HW_AES_BLK_SZ 16 | ||
263 | #define ICP_QAT_HW_KASUMI_BLK_SZ 8 | ||
264 | #define ICP_QAT_HW_SNOW_3G_BLK_SZ 8 | ||
265 | #define ICP_QAT_HW_ZUC_3G_BLK_SZ 8 | ||
266 | #define ICP_QAT_HW_NULL_KEY_SZ 256 | ||
267 | #define ICP_QAT_HW_DES_KEY_SZ 8 | ||
268 | #define ICP_QAT_HW_3DES_KEY_SZ 24 | ||
269 | #define ICP_QAT_HW_AES_128_KEY_SZ 16 | ||
270 | #define ICP_QAT_HW_AES_192_KEY_SZ 24 | ||
271 | #define ICP_QAT_HW_AES_256_KEY_SZ 32 | ||
272 | #define ICP_QAT_HW_AES_128_F8_KEY_SZ (ICP_QAT_HW_AES_128_KEY_SZ * \ | ||
273 | QAT_CIPHER_MODE_F8_KEY_SZ_MULT) | ||
274 | #define ICP_QAT_HW_AES_192_F8_KEY_SZ (ICP_QAT_HW_AES_192_KEY_SZ * \ | ||
275 | QAT_CIPHER_MODE_F8_KEY_SZ_MULT) | ||
276 | #define ICP_QAT_HW_AES_256_F8_KEY_SZ (ICP_QAT_HW_AES_256_KEY_SZ * \ | ||
277 | QAT_CIPHER_MODE_F8_KEY_SZ_MULT) | ||
278 | #define ICP_QAT_HW_AES_128_XTS_KEY_SZ (ICP_QAT_HW_AES_128_KEY_SZ * \ | ||
279 | QAT_CIPHER_MODE_XTS_KEY_SZ_MULT) | ||
280 | #define ICP_QAT_HW_AES_256_XTS_KEY_SZ (ICP_QAT_HW_AES_256_KEY_SZ * \ | ||
281 | QAT_CIPHER_MODE_XTS_KEY_SZ_MULT) | ||
282 | #define ICP_QAT_HW_KASUMI_KEY_SZ 16 | ||
283 | #define ICP_QAT_HW_KASUMI_F8_KEY_SZ (ICP_QAT_HW_KASUMI_KEY_SZ * \ | ||
284 | QAT_CIPHER_MODE_F8_KEY_SZ_MULT) | ||
285 | #define ICP_QAT_HW_AES_128_XTS_KEY_SZ (ICP_QAT_HW_AES_128_KEY_SZ * \ | ||
286 | QAT_CIPHER_MODE_XTS_KEY_SZ_MULT) | ||
287 | #define ICP_QAT_HW_AES_256_XTS_KEY_SZ (ICP_QAT_HW_AES_256_KEY_SZ * \ | ||
288 | QAT_CIPHER_MODE_XTS_KEY_SZ_MULT) | ||
289 | #define ICP_QAT_HW_ARC4_KEY_SZ 256 | ||
290 | #define ICP_QAT_HW_SNOW_3G_UEA2_KEY_SZ 16 | ||
291 | #define ICP_QAT_HW_SNOW_3G_UEA2_IV_SZ 16 | ||
292 | #define ICP_QAT_HW_ZUC_3G_EEA3_KEY_SZ 16 | ||
293 | #define ICP_QAT_HW_ZUC_3G_EEA3_IV_SZ 16 | ||
294 | #define ICP_QAT_HW_MODE_F8_NUM_REG_TO_CLEAR 2 | ||
295 | #define INIT_SHRAM_CONSTANTS_TABLE_SZ 1024 | ||
296 | |||
297 | struct icp_qat_hw_cipher_aes256_f8 { | ||
298 | struct icp_qat_hw_cipher_config cipher_config; | ||
299 | uint8_t key[ICP_QAT_HW_AES_256_F8_KEY_SZ]; | ||
300 | }; | ||
301 | |||
302 | struct icp_qat_hw_cipher_algo_blk { | ||
303 | struct icp_qat_hw_cipher_aes256_f8 aes; | ||
304 | }; | ||
305 | #endif | ||