1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */
2 /* Copyright(c) 2014 - 2020 Intel Corporation */
3 #ifndef _ICP_QAT_FW_LA_H_
4 #define _ICP_QAT_FW_LA_H_
5 #include "icp_qat_fw.h"
7 enum icp_qat_fw_la_cmd_id
{
8 ICP_QAT_FW_LA_CMD_CIPHER
= 0,
9 ICP_QAT_FW_LA_CMD_AUTH
= 1,
10 ICP_QAT_FW_LA_CMD_CIPHER_HASH
= 2,
11 ICP_QAT_FW_LA_CMD_HASH_CIPHER
= 3,
12 ICP_QAT_FW_LA_CMD_TRNG_GET_RANDOM
= 4,
13 ICP_QAT_FW_LA_CMD_TRNG_TEST
= 5,
14 ICP_QAT_FW_LA_CMD_SSL3_KEY_DERIVE
= 6,
15 ICP_QAT_FW_LA_CMD_TLS_V1_1_KEY_DERIVE
= 7,
16 ICP_QAT_FW_LA_CMD_TLS_V1_2_KEY_DERIVE
= 8,
17 ICP_QAT_FW_LA_CMD_MGF1
= 9,
18 ICP_QAT_FW_LA_CMD_AUTH_PRE_COMP
= 10,
19 ICP_QAT_FW_LA_CMD_CIPHER_PRE_COMP
= 11,
20 ICP_QAT_FW_LA_CMD_DELIMITER
= 12
23 #define ICP_QAT_FW_LA_ICV_VER_STATUS_PASS ICP_QAT_FW_COMN_STATUS_FLAG_OK
24 #define ICP_QAT_FW_LA_ICV_VER_STATUS_FAIL ICP_QAT_FW_COMN_STATUS_FLAG_ERROR
25 #define ICP_QAT_FW_LA_TRNG_STATUS_PASS ICP_QAT_FW_COMN_STATUS_FLAG_OK
26 #define ICP_QAT_FW_LA_TRNG_STATUS_FAIL ICP_QAT_FW_COMN_STATUS_FLAG_ERROR
28 struct icp_qat_fw_la_bulk_req
{
29 struct icp_qat_fw_comn_req_hdr comn_hdr
;
30 struct icp_qat_fw_comn_req_hdr_cd_pars cd_pars
;
31 struct icp_qat_fw_comn_req_mid comn_mid
;
32 struct icp_qat_fw_comn_req_rqpars serv_specif_rqpars
;
33 struct icp_qat_fw_comn_req_cd_ctrl cd_ctrl
;
36 #define ICP_QAT_FW_LA_USE_UCS_SLICE_TYPE 1
37 #define QAT_LA_SLICE_TYPE_BITPOS 14
38 #define QAT_LA_SLICE_TYPE_MASK 0x3
39 #define ICP_QAT_FW_LA_GCM_IV_LEN_12_OCTETS 1
40 #define ICP_QAT_FW_LA_GCM_IV_LEN_NOT_12_OCTETS 0
41 #define QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS 12
42 #define ICP_QAT_FW_LA_ZUC_3G_PROTO 1
43 #define QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK 0x1
44 #define QAT_LA_GCM_IV_LEN_FLAG_BITPOS 11
45 #define QAT_LA_GCM_IV_LEN_FLAG_MASK 0x1
46 #define ICP_QAT_FW_LA_DIGEST_IN_BUFFER 1
47 #define ICP_QAT_FW_LA_NO_DIGEST_IN_BUFFER 0
48 #define QAT_LA_DIGEST_IN_BUFFER_BITPOS 10
49 #define QAT_LA_DIGEST_IN_BUFFER_MASK 0x1
50 #define ICP_QAT_FW_LA_SNOW_3G_PROTO 4
51 #define ICP_QAT_FW_LA_GCM_PROTO 2
52 #define ICP_QAT_FW_LA_CCM_PROTO 1
53 #define ICP_QAT_FW_LA_NO_PROTO 0
54 #define QAT_LA_PROTO_BITPOS 7
55 #define QAT_LA_PROTO_MASK 0x7
56 #define ICP_QAT_FW_LA_CMP_AUTH_RES 1
57 #define ICP_QAT_FW_LA_NO_CMP_AUTH_RES 0
58 #define QAT_LA_CMP_AUTH_RES_BITPOS 6
59 #define QAT_LA_CMP_AUTH_RES_MASK 0x1
60 #define ICP_QAT_FW_LA_RET_AUTH_RES 1
61 #define ICP_QAT_FW_LA_NO_RET_AUTH_RES 0
62 #define QAT_LA_RET_AUTH_RES_BITPOS 5
63 #define QAT_LA_RET_AUTH_RES_MASK 0x1
64 #define ICP_QAT_FW_LA_UPDATE_STATE 1
65 #define ICP_QAT_FW_LA_NO_UPDATE_STATE 0
66 #define QAT_LA_UPDATE_STATE_BITPOS 4
67 #define QAT_LA_UPDATE_STATE_MASK 0x1
68 #define ICP_QAT_FW_CIPH_AUTH_CFG_OFFSET_IN_CD_SETUP 0
69 #define ICP_QAT_FW_CIPH_AUTH_CFG_OFFSET_IN_SHRAM_CP 1
70 #define QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS 3
71 #define QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK 0x1
72 #define ICP_QAT_FW_CIPH_IV_64BIT_PTR 0
73 #define ICP_QAT_FW_CIPH_IV_16BYTE_DATA 1
74 #define QAT_LA_CIPH_IV_FLD_BITPOS 2
75 #define QAT_LA_CIPH_IV_FLD_MASK 0x1
76 #define ICP_QAT_FW_LA_PARTIAL_NONE 0
77 #define ICP_QAT_FW_LA_PARTIAL_START 1
78 #define ICP_QAT_FW_LA_PARTIAL_MID 3
79 #define ICP_QAT_FW_LA_PARTIAL_END 2
80 #define QAT_LA_PARTIAL_BITPOS 0
81 #define QAT_LA_PARTIAL_MASK 0x3
82 #define ICP_QAT_FW_LA_FLAGS_BUILD(zuc_proto, gcm_iv_len, auth_rslt, proto, \
83 cmp_auth, ret_auth, update_state, \
84 ciph_iv, ciphcfg, partial) \
85 (((zuc_proto & QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK) << \
86 QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS) | \
87 ((gcm_iv_len & QAT_LA_GCM_IV_LEN_FLAG_MASK) << \
88 QAT_LA_GCM_IV_LEN_FLAG_BITPOS) | \
89 ((auth_rslt & QAT_LA_DIGEST_IN_BUFFER_MASK) << \
90 QAT_LA_DIGEST_IN_BUFFER_BITPOS) | \
91 ((proto & QAT_LA_PROTO_MASK) << \
92 QAT_LA_PROTO_BITPOS) | \
93 ((cmp_auth & QAT_LA_CMP_AUTH_RES_MASK) << \
94 QAT_LA_CMP_AUTH_RES_BITPOS) | \
95 ((ret_auth & QAT_LA_RET_AUTH_RES_MASK) << \
96 QAT_LA_RET_AUTH_RES_BITPOS) | \
97 ((update_state & QAT_LA_UPDATE_STATE_MASK) << \
98 QAT_LA_UPDATE_STATE_BITPOS) | \
99 ((ciph_iv & QAT_LA_CIPH_IV_FLD_MASK) << \
100 QAT_LA_CIPH_IV_FLD_BITPOS) | \
101 ((ciphcfg & QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK) << \
102 QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS) | \
103 ((partial & QAT_LA_PARTIAL_MASK) << \
104 QAT_LA_PARTIAL_BITPOS))
106 #define ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_GET(flags) \
107 QAT_FIELD_GET(flags, QAT_LA_CIPH_IV_FLD_BITPOS, \
108 QAT_LA_CIPH_IV_FLD_MASK)
110 #define ICP_QAT_FW_LA_CIPH_AUTH_CFG_OFFSET_FLAG_GET(flags) \
111 QAT_FIELD_GET(flags, QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS, \
112 QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK)
114 #define ICP_QAT_FW_LA_ZUC_3G_PROTO_FLAG_GET(flags) \
115 QAT_FIELD_GET(flags, QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS, \
116 QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK)
118 #define ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_GET(flags) \
119 QAT_FIELD_GET(flags, QAT_LA_GCM_IV_LEN_FLAG_BITPOS, \
120 QAT_LA_GCM_IV_LEN_FLAG_MASK)
122 #define ICP_QAT_FW_LA_PROTO_GET(flags) \
123 QAT_FIELD_GET(flags, QAT_LA_PROTO_BITPOS, QAT_LA_PROTO_MASK)
125 #define ICP_QAT_FW_LA_CMP_AUTH_GET(flags) \
126 QAT_FIELD_GET(flags, QAT_LA_CMP_AUTH_RES_BITPOS, \
127 QAT_LA_CMP_AUTH_RES_MASK)
129 #define ICP_QAT_FW_LA_RET_AUTH_GET(flags) \
130 QAT_FIELD_GET(flags, QAT_LA_RET_AUTH_RES_BITPOS, \
131 QAT_LA_RET_AUTH_RES_MASK)
133 #define ICP_QAT_FW_LA_DIGEST_IN_BUFFER_GET(flags) \
134 QAT_FIELD_GET(flags, QAT_LA_DIGEST_IN_BUFFER_BITPOS, \
135 QAT_LA_DIGEST_IN_BUFFER_MASK)
137 #define ICP_QAT_FW_LA_UPDATE_STATE_GET(flags) \
138 QAT_FIELD_GET(flags, QAT_LA_UPDATE_STATE_BITPOS, \
139 QAT_LA_UPDATE_STATE_MASK)
141 #define ICP_QAT_FW_LA_PARTIAL_GET(flags) \
142 QAT_FIELD_GET(flags, QAT_LA_PARTIAL_BITPOS, \
145 #define ICP_QAT_FW_LA_CIPH_IV_FLD_FLAG_SET(flags, val) \
146 QAT_FIELD_SET(flags, val, QAT_LA_CIPH_IV_FLD_BITPOS, \
147 QAT_LA_CIPH_IV_FLD_MASK)
149 #define ICP_QAT_FW_LA_CIPH_AUTH_CFG_OFFSET_FLAG_SET(flags, val) \
150 QAT_FIELD_SET(flags, val, QAT_LA_CIPH_AUTH_CFG_OFFSET_BITPOS, \
151 QAT_LA_CIPH_AUTH_CFG_OFFSET_MASK)
153 #define ICP_QAT_FW_LA_ZUC_3G_PROTO_FLAG_SET(flags, val) \
154 QAT_FIELD_SET(flags, val, QAT_FW_LA_ZUC_3G_PROTO_FLAG_BITPOS, \
155 QAT_FW_LA_ZUC_3G_PROTO_FLAG_MASK)
157 #define ICP_QAT_FW_LA_GCM_IV_LEN_FLAG_SET(flags, val) \
158 QAT_FIELD_SET(flags, val, QAT_LA_GCM_IV_LEN_FLAG_BITPOS, \
159 QAT_LA_GCM_IV_LEN_FLAG_MASK)
161 #define ICP_QAT_FW_LA_PROTO_SET(flags, val) \
162 QAT_FIELD_SET(flags, val, QAT_LA_PROTO_BITPOS, \
165 #define ICP_QAT_FW_LA_CMP_AUTH_SET(flags, val) \
166 QAT_FIELD_SET(flags, val, QAT_LA_CMP_AUTH_RES_BITPOS, \
167 QAT_LA_CMP_AUTH_RES_MASK)
169 #define ICP_QAT_FW_LA_RET_AUTH_SET(flags, val) \
170 QAT_FIELD_SET(flags, val, QAT_LA_RET_AUTH_RES_BITPOS, \
171 QAT_LA_RET_AUTH_RES_MASK)
173 #define ICP_QAT_FW_LA_DIGEST_IN_BUFFER_SET(flags, val) \
174 QAT_FIELD_SET(flags, val, QAT_LA_DIGEST_IN_BUFFER_BITPOS, \
175 QAT_LA_DIGEST_IN_BUFFER_MASK)
177 #define ICP_QAT_FW_LA_UPDATE_STATE_SET(flags, val) \
178 QAT_FIELD_SET(flags, val, QAT_LA_UPDATE_STATE_BITPOS, \
179 QAT_LA_UPDATE_STATE_MASK)
181 #define ICP_QAT_FW_LA_PARTIAL_SET(flags, val) \
182 QAT_FIELD_SET(flags, val, QAT_LA_PARTIAL_BITPOS, \
185 #define ICP_QAT_FW_LA_SLICE_TYPE_SET(flags, val) \
186 QAT_FIELD_SET(flags, val, QAT_LA_SLICE_TYPE_BITPOS, \
187 QAT_LA_SLICE_TYPE_MASK)
189 struct icp_qat_fw_cipher_req_hdr_cd_pars
{
192 __u64 content_desc_addr
;
193 __u16 content_desc_resrvd1
;
194 __u8 content_desc_params_sz
;
195 __u8 content_desc_hdr_resrvd2
;
196 __u32 content_desc_resrvd3
;
199 __u32 cipher_key_array
[ICP_QAT_FW_NUM_LONGWORDS_4
];
204 struct icp_qat_fw_cipher_auth_req_hdr_cd_pars
{
207 __u64 content_desc_addr
;
208 __u16 content_desc_resrvd1
;
209 __u8 content_desc_params_sz
;
210 __u8 content_desc_hdr_resrvd2
;
211 __u32 content_desc_resrvd3
;
214 __u32 cipher_key_array
[ICP_QAT_FW_NUM_LONGWORDS_4
];
219 struct icp_qat_fw_cipher_cd_ctrl_hdr
{
220 __u8 cipher_state_sz
;
222 __u8 cipher_cfg_offset
;
224 __u8 cipher_padding_sz
;
227 __u32 resrvd3
[ICP_QAT_FW_NUM_LONGWORDS_3
];
230 struct icp_qat_fw_auth_cd_ctrl_hdr
{
234 __u8 hash_cfg_offset
;
237 __u8 outer_prefix_sz
;
241 __u8 inner_state1_sz
;
242 __u8 inner_state2_offset
;
243 __u8 inner_state2_sz
;
244 __u8 outer_config_offset
;
245 __u8 outer_state1_sz
;
247 __u8 outer_prefix_offset
;
250 struct icp_qat_fw_cipher_auth_cd_ctrl_hdr
{
251 __u8 cipher_state_sz
;
253 __u8 cipher_cfg_offset
;
254 __u8 next_curr_id_cipher
;
255 __u8 cipher_padding_sz
;
257 __u8 hash_cfg_offset
;
258 __u8 next_curr_id_auth
;
260 __u8 outer_prefix_sz
;
264 __u8 inner_state1_sz
;
265 __u8 inner_state2_offset
;
266 __u8 inner_state2_sz
;
267 __u8 outer_config_offset
;
268 __u8 outer_state1_sz
;
270 __u8 outer_prefix_offset
;
273 #define ICP_QAT_FW_AUTH_HDR_FLAG_DO_NESTED 1
274 #define ICP_QAT_FW_AUTH_HDR_FLAG_NO_NESTED 0
275 #define ICP_QAT_FW_CCM_GCM_AAD_SZ_MAX 240
276 #define ICP_QAT_FW_HASH_REQUEST_PARAMETERS_OFFSET \
277 (sizeof(struct icp_qat_fw_la_cipher_req_params_t))
278 #define ICP_QAT_FW_CIPHER_REQUEST_PARAMETERS_OFFSET (0)
280 struct icp_qat_fw_la_cipher_req_params
{
284 __u32 cipher_IV_array
[ICP_QAT_FW_NUM_LONGWORDS_4
];
292 struct icp_qat_fw_la_auth_req_params
{
296 __u64 auth_partial_st_prefix
;
301 __u8 inner_prefix_sz
;
309 struct icp_qat_fw_la_auth_req_params_resrvd_flds
{
310 __u32 resrvd
[ICP_QAT_FW_NUM_LONGWORDS_6
];
312 __u8 inner_prefix_sz
;
319 struct icp_qat_fw_la_resp
{
320 struct icp_qat_fw_comn_resp_hdr comn_resp
;
322 __u32 resrvd
[ICP_QAT_FW_NUM_LONGWORDS_4
];
325 #define ICP_QAT_FW_CIPHER_NEXT_ID_GET(cd_ctrl_hdr_t) \
326 ((((cd_ctrl_hdr_t)->next_curr_id_cipher) & \
327 ICP_QAT_FW_COMN_NEXT_ID_MASK) >> (ICP_QAT_FW_COMN_NEXT_ID_BITPOS))
329 #define ICP_QAT_FW_CIPHER_NEXT_ID_SET(cd_ctrl_hdr_t, val) \
330 { (cd_ctrl_hdr_t)->next_curr_id_cipher = \
331 ((((cd_ctrl_hdr_t)->next_curr_id_cipher) \
332 & ICP_QAT_FW_COMN_CURR_ID_MASK) | \
333 ((val << ICP_QAT_FW_COMN_NEXT_ID_BITPOS) \
334 & ICP_QAT_FW_COMN_NEXT_ID_MASK)) }
336 #define ICP_QAT_FW_CIPHER_CURR_ID_GET(cd_ctrl_hdr_t) \
337 (((cd_ctrl_hdr_t)->next_curr_id_cipher) \
338 & ICP_QAT_FW_COMN_CURR_ID_MASK)
340 #define ICP_QAT_FW_CIPHER_CURR_ID_SET(cd_ctrl_hdr_t, val) \
341 { (cd_ctrl_hdr_t)->next_curr_id_cipher = \
342 ((((cd_ctrl_hdr_t)->next_curr_id_cipher) \
343 & ICP_QAT_FW_COMN_NEXT_ID_MASK) | \
344 ((val) & ICP_QAT_FW_COMN_CURR_ID_MASK)) }
346 #define ICP_QAT_FW_AUTH_NEXT_ID_GET(cd_ctrl_hdr_t) \
347 ((((cd_ctrl_hdr_t)->next_curr_id_auth) & ICP_QAT_FW_COMN_NEXT_ID_MASK) \
348 >> (ICP_QAT_FW_COMN_NEXT_ID_BITPOS))
350 #define ICP_QAT_FW_AUTH_NEXT_ID_SET(cd_ctrl_hdr_t, val) \
351 { (cd_ctrl_hdr_t)->next_curr_id_auth = \
352 ((((cd_ctrl_hdr_t)->next_curr_id_auth) \
353 & ICP_QAT_FW_COMN_CURR_ID_MASK) | \
354 ((val << ICP_QAT_FW_COMN_NEXT_ID_BITPOS) \
355 & ICP_QAT_FW_COMN_NEXT_ID_MASK)) }
357 #define ICP_QAT_FW_AUTH_CURR_ID_GET(cd_ctrl_hdr_t) \
358 (((cd_ctrl_hdr_t)->next_curr_id_auth) \
359 & ICP_QAT_FW_COMN_CURR_ID_MASK)
361 #define ICP_QAT_FW_AUTH_CURR_ID_SET(cd_ctrl_hdr_t, val) \
362 { (cd_ctrl_hdr_t)->next_curr_id_auth = \
363 ((((cd_ctrl_hdr_t)->next_curr_id_auth) \
364 & ICP_QAT_FW_COMN_NEXT_ID_MASK) | \
365 ((val) & ICP_QAT_FW_COMN_CURR_ID_MASK)) }