1 1.1 hikaru /* $NetBSD: qat_hw15reg.h,v 1.1 2019/11/20 09:37:46 hikaru Exp $ */ 2 1.1 hikaru 3 1.1 hikaru /* 4 1.1 hikaru * Copyright (c) 2019 Internet Initiative Japan, Inc. 5 1.1 hikaru * All rights reserved. 6 1.1 hikaru * 7 1.1 hikaru * Redistribution and use in source and binary forms, with or without 8 1.1 hikaru * modification, are permitted provided that the following conditions 9 1.1 hikaru * are met: 10 1.1 hikaru * 1. Redistributions of source code must retain the above copyright 11 1.1 hikaru * notice, this list of conditions and the following disclaimer. 12 1.1 hikaru * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 hikaru * notice, this list of conditions and the following disclaimer in the 14 1.1 hikaru * documentation and/or other materials provided with the distribution. 15 1.1 hikaru * 16 1.1 hikaru * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 1.1 hikaru * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 1.1 hikaru * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 1.1 hikaru * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 1.1 hikaru * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 1.1 hikaru * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 1.1 hikaru * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 1.1 hikaru * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 1.1 hikaru * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 1.1 hikaru * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 1.1 hikaru * POSSIBILITY OF SUCH DAMAGE. 27 1.1 hikaru */ 28 1.1 hikaru 29 1.1 hikaru /* 30 1.1 hikaru * Copyright(c) 2007-2013 Intel Corporation. All rights reserved. 31 1.1 hikaru * 32 1.1 hikaru * Redistribution and use in source and binary forms, with or without 33 1.1 hikaru * modification, are permitted provided that the following conditions 34 1.1 hikaru * are met: 35 1.1 hikaru * 36 1.1 hikaru * * Redistributions of source code must retain the above copyright 37 1.1 hikaru * notice, this list of conditions and the following disclaimer. 38 1.1 hikaru * * Redistributions in binary form must reproduce the above copyright 39 1.1 hikaru * notice, this list of conditions and the following disclaimer in 40 1.1 hikaru * the documentation and/or other materials provided with the 41 1.1 hikaru * distribution. 42 1.1 hikaru * * Neither the name of Intel Corporation nor the names of its 43 1.1 hikaru * contributors may be used to endorse or promote products derived 44 1.1 hikaru * from this software without specific prior written permission. 45 1.1 hikaru * 46 1.1 hikaru * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 47 1.1 hikaru * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 48 1.1 hikaru * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 49 1.1 hikaru * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 50 1.1 hikaru * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 51 1.1 hikaru * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 52 1.1 hikaru * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 53 1.1 hikaru * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 54 1.1 hikaru * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 55 1.1 hikaru * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 56 1.1 hikaru * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 57 1.1 hikaru */ 58 1.1 hikaru 59 1.1 hikaru #ifndef _DEV_PCI_QAT_HW15REG_H_ 60 1.1 hikaru #define _DEV_PCI_QAT_HW15REG_H_ 61 1.1 hikaru 62 1.1 hikaru /* Default message size in bytes */ 63 1.1 hikaru #define FW_REQ_DEFAULT_SZ_HW15 64 64 1.1 hikaru #define FW_RESP_DEFAULT_SZ_HW15 64 65 1.1 hikaru 66 1.1 hikaru #define ADMIN_RING_SIZE 256 67 1.1 hikaru #define RING_NUM_ADMIN_TX 0 68 1.1 hikaru #define RING_NUM_ADMIN_RX 1 69 1.1 hikaru 70 1.1 hikaru /* -------------------------------------------------------------------------- */ 71 1.1 hikaru /* accel */ 72 1.1 hikaru 73 1.1 hikaru #define ARCH_IF_FLAGS_VALID_FLAG __BIT(7) 74 1.1 hikaru #define ARCH_IF_FLAGS_RESP_RING_TYPE __BITS(4, 3) 75 1.1 hikaru #define ARCH_IF_FLAGS_RESP_RING_TYPE_SHIFT 3 76 1.1 hikaru #define ARCH_IF_FLAGS_RESP_RING_TYPE_SCRATCH (0 << ARCH_IF_FLAGS_RESP_RING_TYPE_SHIFT) 77 1.1 hikaru #define ARCH_IF_FLAGS_RESP_RING_TYPE_NN (1 << ARCH_IF_FLAGS_RESP_RING_TYPE_SHIFT) 78 1.1 hikaru #define ARCH_IF_FLAGS_RESP_RING_TYPE_ET (2 << ARCH_IF_FLAGS_RESP_RING_TYPE_SHIFT) 79 1.1 hikaru #define ARCH_IF_FLAGS_RESP_TYPE __BITS(2, 0) 80 1.1 hikaru #define ARCH_IF_FLAGS_RESP_TYPE_SHIFT 0 81 1.1 hikaru #define ARCH_IF_FLAGS_RESP_TYPE_A (0 << ARCH_IF_FLAGS_RESP_TYPE_SHIFT) 82 1.1 hikaru #define ARCH_IF_FLAGS_RESP_TYPE_B (1 << ARCH_IF_FLAGS_RESP_TYPE_SHIFT) 83 1.1 hikaru #define ARCH_IF_FLAGS_RESP_TYPE_C (2 << ARCH_IF_FLAGS_RESP_TYPE_SHIFT) 84 1.1 hikaru #define ARCH_IF_FLAGS_RESP_TYPE_S (3 << ARCH_IF_FLAGS_RESP_TYPE_SHIFT) 85 1.1 hikaru 86 1.1 hikaru enum arch_if_req { 87 1.1 hikaru ARCH_IF_REQ_NULL, /* NULL request type */ 88 1.1 hikaru 89 1.1 hikaru /* QAT-AE Service Request Type IDs - 01 to 20 */ 90 1.1 hikaru ARCH_IF_REQ_QAT_FW_INIT, /* QAT-FW Initialization Request */ 91 1.1 hikaru ARCH_IF_REQ_QAT_FW_ADMIN, /* QAT-FW Administration Request */ 92 1.1 hikaru ARCH_IF_REQ_QAT_FW_PKE, /* QAT-FW PKE Request */ 93 1.1 hikaru ARCH_IF_REQ_QAT_FW_LA, /* QAT-FW Lookaside Request */ 94 1.1 hikaru ARCH_IF_REQ_QAT_FW_IPSEC, /* QAT-FW IPSec Request */ 95 1.1 hikaru ARCH_IF_REQ_QAT_FW_SSL, /* QAT-FW SSL Request */ 96 1.1 hikaru ARCH_IF_REQ_QAT_FW_DMA, /* QAT-FW DMA Request */ 97 1.1 hikaru ARCH_IF_REQ_QAT_FW_STORAGE, /* QAT-FW Storage Request */ 98 1.1 hikaru ARCH_IF_REQ_QAT_FW_COMPRESS, /* QAT-FW Compression Request */ 99 1.1 hikaru ARCH_IF_REQ_QAT_FW_PATMATCH, /* QAT-FW Pattern Matching Request */ 100 1.1 hikaru 101 1.1 hikaru /* IP Service (Range Match and Exception) Blocks Request Type IDs 21 - 30 */ 102 1.1 hikaru ARCH_IF_REQ_RM_FLOW_MISS = 21, /* RM flow miss request */ 103 1.1 hikaru ARCH_IF_REQ_RM_FLOW_TIMER_EXP, /* RM flow timer exp Request */ 104 1.1 hikaru ARCH_IF_REQ_IP_SERVICES_RFC_LOOKUP_UPDATE, /* RFC Lookup request */ 105 1.1 hikaru ARCH_IF_REQ_IP_SERVICES_CONFIG_UPDATE, /* Config Update request */ 106 1.1 hikaru ARCH_IF_REQ_IP_SERVICES_FCT_CONFIG, /* FCT Config request */ 107 1.1 hikaru ARCH_IF_REQ_IP_SERVICES_NEXT_HOP_TIMER_EXPIRY, /* NH Timer expiry request */ 108 1.1 hikaru ARCH_IF_REQ_IP_SERVICES_EXCEPTION, /* Exception processign request */ 109 1.1 hikaru ARCH_IF_REQ_IP_SERVICES_STACK_DRIVER, /* Send to SD request */ 110 1.1 hikaru ARCH_IF_REQ_IP_SERVICES_ACTION_HANDLER, /* Send to AH request */ 111 1.1 hikaru ARCH_IF_REQ_IP_SERVICES_EVENT_HANDLER, /* Send to EH request */ 112 1.1 hikaru ARCH_IF_REQ_DELIMITER /* End delimiter */ 113 1.1 hikaru }; 114 1.1 hikaru 115 1.1 hikaru struct arch_if_req_hdr { 116 1.1 hikaru uint8_t resp_dest_id; 117 1.1 hikaru /* Opaque identifier passed from the request to response to allow 118 1.1 hikaru * response handler perform any further processing */ 119 1.1 hikaru uint8_t resp_pipe_id; 120 1.1 hikaru /* Response pipe to write the response associated with this request to */ 121 1.1 hikaru uint8_t req_type; 122 1.1 hikaru /* Definition of the service described by the request */ 123 1.1 hikaru uint8_t flags; 124 1.1 hikaru /* Request and response control flags */ 125 1.1 hikaru }; 126 1.1 hikaru 127 1.1 hikaru struct arch_if_resp_hdr { 128 1.1 hikaru uint8_t dest_id; 129 1.1 hikaru /* Opaque identifier passed from the request to response to allow 130 1.1 hikaru * response handler perform any further processing */ 131 1.1 hikaru uint8_t serv_id; 132 1.1 hikaru /* Definition of the service id generating the response */ 133 1.1 hikaru uint8_t resp_type; 134 1.1 hikaru /* Definition of the service described by the request */ 135 1.1 hikaru uint8_t flags; 136 1.1 hikaru /* Request and response control flags */ 137 1.1 hikaru }; 138 1.1 hikaru 139 1.1 hikaru struct fw_comn_req_hdr { 140 1.1 hikaru struct arch_if_req_hdr arch_if; 141 1.1 hikaru /* Common arch fields used by all ICP interface requests. Remaining 142 1.1 hikaru * fields are specific to the common QAT FW service. */ 143 1.1 hikaru uint16_t comn_req_flags; 144 1.1 hikaru /* Flags used to describe common processing required by the request and 145 1.1 hikaru * the meaning of parameters in it i.e. differentiating between a buffer 146 1.1 hikaru * descriptor and a flat buffer pointer in the source (src) and destination 147 1.1 hikaru * (dest) data address fields. Full definition of the fields is given 148 1.1 hikaru * below */ 149 1.1 hikaru uint8_t content_desc_params_sz; 150 1.1 hikaru /* Size of the content descriptor parameters in quad words. These 151 1.1 hikaru * parameters describe the session setup configuration info for the 152 1.1 hikaru * slices that this request relies upon i.e. the configuration word and 153 1.1 hikaru * cipher key needed by the cipher slice if there is a request for cipher 154 1.1 hikaru * processing. The format of the parameters are contained in icp_qat_hw.h 155 1.1 hikaru * and vary depending on the algorithm and mode being used. It is the 156 1.1 hikaru * clients responsibility to ensure this structure is correctly packed */ 157 1.1 hikaru uint8_t content_desc_hdr_sz; 158 1.1 hikaru /* Size of the content descriptor header in quad words. This information 159 1.1 hikaru * is read into the QAT AE xfr registers */ 160 1.1 hikaru uint64_t content_desc_addr; 161 1.1 hikaru /* Address of the content descriptor containing both the content header 162 1.1 hikaru * the size of which is defined by content_desc_hdr_sz followed by the 163 1.1 hikaru * content parameters whose size is described bycontent_desc_params_sz 164 1.1 hikaru */ 165 1.1 hikaru }; 166 1.1 hikaru 167 1.1 hikaru struct fw_comn_req_mid { 168 1.1 hikaru uint64_t opaque_data; 169 1.1 hikaru /* Opaque data passed unmodified from the request to response messages 170 1.1 hikaru * by firmware (fw) */ 171 1.1 hikaru uint64_t src_data_addr; 172 1.1 hikaru /* Generic definition of the source data supplied to the QAT AE. The 173 1.1 hikaru * common flags are used to further describe the attributes of this 174 1.1 hikaru * field */ 175 1.1 hikaru uint64_t dest_data_addr; 176 1.1 hikaru /* Generic definition of the destination data supplied to the QAT AE. 177 1.1 hikaru * The common flags are used to further describe the attributes of this 178 1.1 hikaru * field */ 179 1.1 hikaru }; 180 1.1 hikaru 181 1.1 hikaru union fw_comn_req_ftr { 182 1.1 hikaru uint64_t next_request_addr; 183 1.1 hikaru /* Overloaded field, for stateful requests, this field is the pointer to 184 1.1 hikaru next request descriptor */ 185 1.1 hikaru struct { 186 1.1 hikaru uint32_t src_length; 187 1.1 hikaru /* Length of source flat buffer incase src buffer type is flat */ 188 1.1 hikaru uint32_t dst_length; 189 1.1 hikaru /* Length of source flat buffer incase dst buffer type is flat */ 190 1.1 hikaru } s; 191 1.1 hikaru }; 192 1.1 hikaru 193 1.1 hikaru union fw_comn_error { 194 1.1 hikaru struct { 195 1.1 hikaru uint8_t resrvd; /* 8 bit reserved field */ 196 1.1 hikaru uint8_t comn_err_code; /**< 8 bit common error code */ 197 1.1 hikaru } s; 198 1.1 hikaru /* Structure which is used for non-compression responses */ 199 1.1 hikaru 200 1.1 hikaru struct { 201 1.1 hikaru uint8_t xlat_err_code; /* 8 bit translator error field */ 202 1.1 hikaru uint8_t cmp_err_code; /* 8 bit compression error field */ 203 1.1 hikaru } s1; 204 1.1 hikaru /* Structure which is used for compression responses */ 205 1.1 hikaru }; 206 1.1 hikaru 207 1.1 hikaru struct fw_comn_resp_hdr { 208 1.1 hikaru struct arch_if_resp_hdr arch_if; 209 1.1 hikaru /* Common arch fields used by all ICP interface response messages. The 210 1.1 hikaru * remaining fields are specific to the QAT FW */ 211 1.1 hikaru union fw_comn_error comn_error; 212 1.1 hikaru /* This field is overloaded to allow for one 8 bit common error field 213 1.1 hikaru * or two 8 bit error fields from compression and translator */ 214 1.1 hikaru uint8_t comn_status; 215 1.1 hikaru /* Status field which specifies which slice(s) report an error */ 216 1.1 hikaru uint8_t serv_cmd_id; 217 1.1 hikaru /* For services that define multiple commands this field represents the 218 1.1 hikaru * command. If only 1 command is supported then this field will be 0 */ 219 1.1 hikaru uint64_t opaque_data; 220 1.1 hikaru /* Opaque data passed from the request to the response message */ 221 1.1 hikaru }; 222 1.1 hikaru 223 1.1 hikaru 224 1.1 hikaru #define RING_MASK_TABLE_ENTRY_LOG_SZ (5) 225 1.1 hikaru 226 1.1 hikaru #define FW_INIT_RING_MASK_SET(table, id) \ 227 1.1 hikaru table->firt_ring_mask[id >> RING_MASK_TABLE_ENTRY_LOG_SZ] =\ 228 1.1 hikaru table->firt_ring_mask[id >> RING_MASK_TABLE_ENTRY_LOG_SZ] | \ 229 1.1 hikaru (1 << (id & 0x1f)) 230 1.1 hikaru 231 1.1 hikaru struct fw_init_ring_params { 232 1.1 hikaru uint8_t firp_curr_weight; /* Current ring weight (working copy), 233 1.1 hikaru * has to be equal to init_weight */ 234 1.1 hikaru uint8_t firp_init_weight; /* Initial ring weight: -1 ... 0 235 1.1 hikaru * -1 is equal to FF, -2 is equal to FE, 236 1.1 hikaru * the weighting uses negative logic 237 1.1 hikaru * where FF means poll the ring once, 238 1.1 hikaru * -2 is poll the ring twice, 239 1.1 hikaru * 0 is poll the ring 255 times */ 240 1.1 hikaru uint8_t firp_ring_pvl; /* Ring Privilege Level. */ 241 1.1 hikaru uint8_t firp_reserved; /* Reserved field which must be set 242 1.1 hikaru * to 0 by the client */ 243 1.1 hikaru }; 244 1.1 hikaru 245 1.1 hikaru #define INIT_RING_TABLE_SZ 128 246 1.1 hikaru #define INIT_RING_TABLE_LW_SZ 4 247 1.1 hikaru 248 1.1 hikaru struct fw_init_ring_table { 249 1.1 hikaru struct fw_init_ring_params firt_bulk_rings[INIT_RING_TABLE_SZ]; 250 1.1 hikaru /* array of ring parameters */ 251 1.1 hikaru uint32_t firt_ring_mask[INIT_RING_TABLE_LW_SZ]; 252 1.1 hikaru /* Structure to hold the bit masks for 253 1.1 hikaru * 128 rings. */ 254 1.1 hikaru }; 255 1.1 hikaru 256 1.1 hikaru struct fw_init_set_ae_info_hdr { 257 1.1 hikaru uint16_t init_slice_mask; /* Init time flags to set the ownership of the slices */ 258 1.1 hikaru uint16_t resrvd; /* Reserved field and must be set to 0 by the client */ 259 1.1 hikaru uint8_t init_qat_id; /* Init time qat id described in the request */ 260 1.1 hikaru uint8_t init_ring_cluster_id; /* Init time ring cluster Id */ 261 1.1 hikaru uint8_t init_trgt_id; /* Init time target AE id described in the request */ 262 1.1 hikaru uint8_t init_cmd_id; /* Init time command that is described in the request */ 263 1.1 hikaru }; 264 1.1 hikaru 265 1.1 hikaru struct fw_init_set_ae_info { 266 1.1 hikaru uint64_t init_shram_mask; /* Init time shram mask to set the page ownership in page pool of AE*/ 267 1.1 hikaru uint64_t resrvd; /* Reserved field and must be set to 0 by the client */ 268 1.1 hikaru }; 269 1.1 hikaru 270 1.1 hikaru struct fw_init_set_ring_info_hdr { 271 1.1 hikaru uint32_t resrvd; /* Reserved field and must be set to 0 by the client */ 272 1.1 hikaru uint16_t init_ring_tbl_sz; /* Init time information to state size of the ring table */ 273 1.1 hikaru uint8_t init_trgt_id; /* Init time target AE id described in the request */ 274 1.1 hikaru uint8_t init_cmd_id; /* Init time command that is described in the request */ 275 1.1 hikaru }; 276 1.1 hikaru 277 1.1 hikaru struct fw_init_set_ring_info { 278 1.1 hikaru uint64_t init_ring_table_ptr; /* Pointer to weighting information for 128 rings */ 279 1.1 hikaru uint64_t resrvd; /* Reserved field and must be set to 0 by the client */ 280 1.1 hikaru }; 281 1.1 hikaru 282 1.1 hikaru struct fw_init_trng_hdr { 283 1.1 hikaru uint32_t resrvd; /* Reserved field and must be set to 0 by the client */ 284 1.1 hikaru union { 285 1.1 hikaru uint8_t resrvd; /* Reserved field set to if cmd type is trng disable */ 286 1.1 hikaru uint8_t init_trng_cfg_sz; /* Size of the trng config word in QW*/ 287 1.1 hikaru } u; 288 1.1 hikaru uint8_t resrvd1; /* Reserved field and must be set to 0 by the client */ 289 1.1 hikaru uint8_t init_trgt_id; /* Init time target AE id described in the request */ 290 1.1 hikaru uint8_t init_cmd_id; /* Init time command that is described in the request */ 291 1.1 hikaru }; 292 1.1 hikaru 293 1.1 hikaru struct fw_init_trng { 294 1.1 hikaru union { 295 1.1 hikaru uint64_t resrvd; /* Reserved field set to 0 if cmd type is trng disable */ 296 1.1 hikaru uint64_t init_trng_cfg_ptr; /* Pointer to TRNG Slice config word*/ 297 1.1 hikaru } u; 298 1.1 hikaru uint64_t resrvd; /* Reserved field and must be set to 0 by the client */ 299 1.1 hikaru }; 300 1.1 hikaru 301 1.1 hikaru struct fw_init_req { 302 1.1 hikaru struct fw_comn_req_hdr comn_hdr; /* Common request header */ 303 1.1 hikaru union { 304 1.1 hikaru struct fw_init_set_ae_info_hdr set_ae_info; 305 1.1 hikaru /* INIT SET_AE_INFO request header structure */ 306 1.1 hikaru struct fw_init_set_ring_info_hdr set_ring_info; 307 1.1 hikaru /* INIT SET_RING_INFO request header structure */ 308 1.1 hikaru struct fw_init_trng_hdr init_trng; 309 1.1 hikaru /* INIT TRNG ENABLE/DISABLE request header structure */ 310 1.1 hikaru } u; 311 1.1 hikaru struct fw_comn_req_mid comn_mid; /* Common request middle section */ 312 1.1 hikaru union { 313 1.1 hikaru struct fw_init_set_ae_info set_ae_info; 314 1.1 hikaru /* INIT SET_AE_INFO request data structure */ 315 1.1 hikaru struct fw_init_set_ring_info set_ring_info; 316 1.1 hikaru /* INIT SET_RING_INFO request data structure */ 317 1.1 hikaru struct fw_init_trng init_trng; 318 1.1 hikaru /* INIT TRNG ENABLE/DISABLE request data structure */ 319 1.1 hikaru } u1; 320 1.1 hikaru }; 321 1.1 hikaru 322 1.1 hikaru enum fw_init_cmd_id { 323 1.1 hikaru FW_INIT_CMD_SET_AE_INFO, /* Setup AE Info command type */ 324 1.1 hikaru FW_INIT_CMD_SET_RING_INFO, /* Setup Ring Info command type */ 325 1.1 hikaru FW_INIT_CMD_TRNG_ENABLE, /* TRNG Enable command type */ 326 1.1 hikaru FW_INIT_CMD_TRNG_DISABLE, /* TRNG Disable command type */ 327 1.1 hikaru FW_INIT_CMD_DELIMITER /* Delimiter type */ 328 1.1 hikaru }; 329 1.1 hikaru 330 1.1 hikaru struct fw_init_resp { 331 1.1 hikaru struct fw_comn_resp_hdr comn_resp; /* Common interface response */ 332 1.1 hikaru uint8_t resrvd[64 - sizeof(struct fw_comn_resp_hdr)]; 333 1.1 hikaru /* XXX FW_RESP_DEFAULT_SZ_HW15 */ 334 1.1 hikaru /* Reserved padding out to the default response size */ 335 1.1 hikaru }; 336 1.1 hikaru 337 1.1 hikaru 338 1.1 hikaru /* -------------------------------------------------------------------------- */ 339 1.1 hikaru /* look aside */ 340 1.1 hikaru 341 1.1 hikaru #define COMN_REQ_ORD UINT16_C(0x8000) 342 1.1 hikaru #define COMN_REQ_ORD_SHIFT 15 343 1.1 hikaru #define COMN_REQ_ORD_NONE (0 << COMN_REQ_ORD_SHIFT) 344 1.1 hikaru #define COMN_REQ_ORD_STRICT (1 << COMN_REQ_ORD_SHIFT) 345 1.1 hikaru #define COMN_REQ_PTR_TYPE UINT16_C(0x4000) 346 1.1 hikaru #define COMN_REQ_PTR_TYPE_SHIFT 14 347 1.1 hikaru #define COMN_REQ_PTR_TYPE_FLAT (0 << COMN_REQ_PTR_TYPE_SHIFT) 348 1.1 hikaru #define COMN_REQ_PTR_TYPE_SGL (1 << COMN_REQ_PTR_TYPE_SHIFT) 349 1.1 hikaru #define COMN_REQ_RESERVED UINT16_C(0x2000) 350 1.1 hikaru #define COMN_REQ_SHRAM_INIT UINT16_C(0x1000) 351 1.1 hikaru #define COMN_REQ_SHRAM_INIT_SHIFT 12 352 1.1 hikaru #define COMN_REQ_SHRAM_INIT_REQUIRED (1 << COMN_REQ_SHRAM_INIT_SHIFT) 353 1.1 hikaru #define COMN_REQ_REGEX_SLICE UINT16_C(0x0800) 354 1.1 hikaru #define COMN_REQ_REGEX_SLICE_SHIFT 11 355 1.1 hikaru #define COMN_REQ_REGEX_SLICE_REQUIRED (1 << COMN_REQ_REGEX_SLICE_SHIFT) 356 1.1 hikaru #define COMN_REQ_XLAT_SLICE UINT16_C(0x0400) 357 1.1 hikaru #define COMN_REQ_XLAT_SLICE_SHIFT 10 358 1.1 hikaru #define COMN_REQ_XLAT_SLICE_REQUIRED (1 << COMN_REQ_XLAT_SLICE_SHIFT) 359 1.1 hikaru #define COMN_REQ_CPR_SLICE UINT16_C(0x0200) 360 1.1 hikaru #define COMN_REQ_CPR_SLICE_SHIFT 9 361 1.1 hikaru #define COMN_REQ_CPR_SLICE_REQUIRED (1 << COMN_REQ_CPR_SLICE_SHIFT) 362 1.1 hikaru #define COMN_REQ_BULK_SLICE UINT16_C(0x0100) 363 1.1 hikaru #define COMN_REQ_BULK_SLICE_SHIFT 8 364 1.1 hikaru #define COMN_REQ_BULK_SLICE_REQUIRED (1 << COMN_REQ_BULK_SLICE_SHIFT) 365 1.1 hikaru #define COMN_REQ_STORAGE_SLICE UINT16_C(0x0080) 366 1.1 hikaru #define COMN_REQ_STORAGE_SLICE_SHIFT 7 367 1.1 hikaru #define COMN_REQ_STORAGE_SLICE_REQUIRED (1 << COMN_REQ_STORAGE_SLICE_SHIFT) 368 1.1 hikaru #define COMN_REQ_RND_SLICE UINT16_C(0x0040) 369 1.1 hikaru #define COMN_REQ_RND_SLICE_SHIFT 6 370 1.1 hikaru #define COMN_REQ_RND_SLICE_REQUIRED (1 << COMN_REQ_RND_SLICE_SHIFT) 371 1.1 hikaru #define COMN_REQ_PKE1_SLICE UINT16_C(0x0020) 372 1.1 hikaru #define COMN_REQ_PKE1_SLICE_SHIFT 5 373 1.1 hikaru #define COMN_REQ_PKE1_SLICE_REQUIRED (1 << COMN_REQ_PKE1_SLICE_SHIFT) 374 1.1 hikaru #define COMN_REQ_PKE0_SLICE UINT16_C(0x0010) 375 1.1 hikaru #define COMN_REQ_PKE0_SLICE_SHIFT 4 376 1.1 hikaru #define COMN_REQ_PKE0_SLICE_REQUIRED (1 << COMN_REQ_PKE0_SLICE_SHIFT) 377 1.1 hikaru #define COMN_REQ_AUTH1_SLICE UINT16_C(0x0008) 378 1.1 hikaru #define COMN_REQ_AUTH1_SLICE_SHIFT 3 379 1.1 hikaru #define COMN_REQ_AUTH1_SLICE_REQUIRED (1 << COMN_REQ_AUTH1_SLICE_SHIFT) 380 1.1 hikaru #define COMN_REQ_AUTH0_SLICE UINT16_C(0x0004) 381 1.1 hikaru #define COMN_REQ_AUTH0_SLICE_SHIFT 2 382 1.1 hikaru #define COMN_REQ_AUTH0_SLICE_REQUIRED (1 << COMN_REQ_AUTH0_SLICE_SHIFT) 383 1.1 hikaru #define COMN_REQ_CIPHER1_SLICE UINT16_C(0x0002) 384 1.1 hikaru #define COMN_REQ_CIPHER1_SLICE_SHIFT 1 385 1.1 hikaru #define COMN_REQ_CIPHER1_SLICE_REQUIRED (1 << COMN_REQ_CIPHER1_SLICE_SHIFT) 386 1.1 hikaru #define COMN_REQ_CIPHER0_SLICE UINT16_C(0x0001) 387 1.1 hikaru #define COMN_REQ_CIPHER0_SLICE_SHIFT 0 388 1.1 hikaru #define COMN_REQ_CIPHER0_SLICE_REQUIRED (1 << COMN_REQ_CIPHER0_SLICE_SHIFT) 389 1.1 hikaru 390 1.1 hikaru #define COMN_REQ_CY0_ONLY(shram) \ 391 1.1 hikaru COMN_REQ_ORD_STRICT | \ 392 1.1 hikaru COMN_REQ_PTR_TYPE_FLAT | \ 393 1.1 hikaru (shram) | \ 394 1.1 hikaru COMN_REQ_RND_SLICE_REQUIRED | \ 395 1.1 hikaru COMN_REQ_PKE0_SLICE_REQUIRED | \ 396 1.1 hikaru COMN_REQ_AUTH0_SLICE_REQUIRED | \ 397 1.1 hikaru COMN_REQ_CIPHER0_SLICE_REQUIRED; 398 1.1 hikaru #define COMN_REQ_CY1_ONLY(shram) \ 399 1.1 hikaru COMN_REQ_ORD_STRICT | \ 400 1.1 hikaru COMN_REQ_PTR_TYPE_FLAT | \ 401 1.1 hikaru (shram) | \ 402 1.1 hikaru COMN_REQ_PKE1_SLICE_REQUIRED | \ 403 1.1 hikaru COMN_REQ_AUTH1_SLICE_REQUIRED | \ 404 1.1 hikaru COMN_REQ_CIPHER1_SLICE_REQUIRED; 405 1.1 hikaru 406 1.1 hikaru #define COMN_RESP_CRYPTO_STATUS __BIT(7) 407 1.1 hikaru #define COMN_RESP_PKE_STATUS __BIT(6) 408 1.1 hikaru #define COMN_RESP_CMP_STATUS __BIT(5) 409 1.1 hikaru #define COMN_RESP_XLAT_STATUS __BIT(4) 410 1.1 hikaru #define COMN_RESP_PM_STATUS __BIT(3) 411 1.1 hikaru #define COMN_RESP_INIT_ADMIN_STATUS __BIT(2) 412 1.1 hikaru 413 1.1 hikaru #define COMN_STATUS_FLAG_OK 0 414 1.1 hikaru #define COMN_STATUS_FLAG_ERROR 1 415 1.1 hikaru 416 1.1 hikaru struct fw_la_ssl_tls_common { 417 1.1 hikaru uint8_t out_len; /* Number of bytes of key material to output. */ 418 1.1 hikaru uint8_t label_len; /* Number of bytes of label for SSL and bytes 419 1.1 hikaru * for TLS key generation */ 420 1.1 hikaru }; 421 1.1 hikaru 422 1.1 hikaru struct fw_la_mgf_common { 423 1.1 hikaru uint8_t hash_len; 424 1.1 hikaru /* Number of bytes of hash output by the QAT per iteration */ 425 1.1 hikaru uint8_t seed_len; 426 1.1 hikaru /* Number of bytes of seed provided in src buffer for MGF1 */ 427 1.1 hikaru }; 428 1.1 hikaru 429 1.1 hikaru struct fw_cipher_hdr { 430 1.1 hikaru uint8_t state_sz; 431 1.1 hikaru /* State size in quad words of the cipher algorithm used in this session. 432 1.1 hikaru * Set to zero if the algorithm doesnt provide any state */ 433 1.1 hikaru uint8_t offset; 434 1.1 hikaru /* Quad word offset from the content descriptor parameters address i.e. 435 1.1 hikaru * (content_address + (cd_hdr_sz << 3)) to the parameters for the cipher 436 1.1 hikaru * processing */ 437 1.1 hikaru uint8_t curr_id; 438 1.1 hikaru /* Initialised with the cipher slice type */ 439 1.1 hikaru uint8_t next_id; 440 1.1 hikaru /* Set to the next slice to pass the ciphered data through. 441 1.1 hikaru * Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go through 442 1.1 hikaru * anymore slices after cipher */ 443 1.1 hikaru uint16_t resrvd; 444 1.1 hikaru /* Reserved padding byte to bring the struct to the word boundary. MUST be 445 1.1 hikaru * set to 0 */ 446 1.1 hikaru uint8_t state_padding_sz; 447 1.1 hikaru /* State padding size in quad words. Set to 0 if no padding is required. */ 448 1.1 hikaru uint8_t key_sz; 449 1.1 hikaru /* Key size in quad words of the cipher algorithm used in this session */ 450 1.1 hikaru }; 451 1.1 hikaru 452 1.1 hikaru struct fw_auth_hdr { 453 1.1 hikaru uint8_t hash_flags; 454 1.1 hikaru /* General flags defining the processing to perform. 0 is normal processing 455 1.1 hikaru * and 1 means there is a nested hash processing loop to go through */ 456 1.1 hikaru uint8_t offset; 457 1.1 hikaru /* Quad word offset from the content descriptor parameters address to the 458 1.1 hikaru * parameters for the auth processing */ 459 1.1 hikaru uint8_t curr_id; 460 1.1 hikaru /* Initialised with the auth slice type */ 461 1.1 hikaru uint8_t next_id; 462 1.1 hikaru /* Set to the next slice to pass data through. 463 1.1 hikaru * Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go through 464 1.1 hikaru * anymore slices after auth */ 465 1.1 hikaru union { 466 1.1 hikaru uint8_t inner_prefix_sz; 467 1.1 hikaru /* Size in bytes of the inner prefix data */ 468 1.1 hikaru uint8_t aad_sz; 469 1.1 hikaru /* Size in bytes of padded AAD data to prefix to the packet for CCM 470 1.1 hikaru * or GCM processing */ 471 1.1 hikaru } u; 472 1.1 hikaru 473 1.1 hikaru uint8_t outer_prefix_sz; 474 1.1 hikaru /* Size in bytes of outer prefix data */ 475 1.1 hikaru uint8_t final_sz; 476 1.1 hikaru /* Size in bytes of digest to be returned to the client if requested */ 477 1.1 hikaru uint8_t inner_res_sz; 478 1.1 hikaru /* Size in bytes of the digest from the inner hash algorithm */ 479 1.1 hikaru uint8_t resrvd; 480 1.1 hikaru /* This field is unused, assumed value is zero. */ 481 1.1 hikaru uint8_t inner_state1_sz; 482 1.1 hikaru /* Size in bytes of inner hash state1 data. Must be a qword multiple */ 483 1.1 hikaru uint8_t inner_state2_off; 484 1.1 hikaru /* Quad word offset from the content descriptor parameters pointer to the 485 1.1 hikaru * inner state2 value */ 486 1.1 hikaru uint8_t inner_state2_sz; 487 1.1 hikaru /* Size in bytes of inner hash state2 data. Must be a qword multiple */ 488 1.1 hikaru uint8_t outer_config_off; 489 1.1 hikaru /* Quad word offset from the content descriptor parameters pointer to the 490 1.1 hikaru * outer configuration information */ 491 1.1 hikaru uint8_t outer_state1_sz; 492 1.1 hikaru /* Size in bytes of the outer state1 value */ 493 1.1 hikaru uint8_t outer_res_sz; 494 1.1 hikaru /* Size in bytes of digest from the outer auth algorithm */ 495 1.1 hikaru uint8_t outer_prefix_off; 496 1.1 hikaru /* Quad word offset from the start of the inner prefix data to the outer 497 1.1 hikaru * prefix information. Should equal the rounded inner prefix size, converted 498 1.1 hikaru * to qwords */ 499 1.1 hikaru }; 500 1.1 hikaru 501 1.1 hikaru #define FW_AUTH_HDR_FLAG_DO_NESTED 1 502 1.1 hikaru #define FW_AUTH_HDR_FLAG_NO_NESTED 0 503 1.1 hikaru 504 1.1 hikaru struct fw_la_comn_req { 505 1.1 hikaru union { 506 1.1 hikaru uint16_t la_flags; 507 1.1 hikaru /* Definition of the common LA processing flags used for the 508 1.1 hikaru * bulk processing */ 509 1.1 hikaru union { 510 1.1 hikaru struct fw_la_ssl_tls_common ssl_tls_common; 511 1.1 hikaru /* For TLS or SSL Key Generation, this field is 512 1.1 hikaru * overloaded with ssl_tls common information */ 513 1.1 hikaru struct fw_la_mgf_common mgf_common; 514 1.1 hikaru /* For MGF Key Generation, this field is overloaded with 515 1.1 hikaru mgf information */ 516 1.1 hikaru } u; 517 1.1 hikaru } u; 518 1.1 hikaru 519 1.1 hikaru union { 520 1.1 hikaru uint8_t resrvd; 521 1.1 hikaru /* If not useRd by a request this field must be set to 0 */ 522 1.1 hikaru uint8_t tls_seed_len; 523 1.1 hikaru /* Byte Len of tls seed */ 524 1.1 hikaru uint8_t req_params_blk_sz; 525 1.1 hikaru /* For bulk processing this field represents the request 526 1.1 hikaru * parameters block size */ 527 1.1 hikaru uint8_t trng_cfg_sz; 528 1.1 hikaru /* This field is used for TRNG_ENABLE requests to indicate the 529 1.1 hikaru * size of the TRNG Slice configuration word. Size is in QW's */ 530 1.1 hikaru } u1; 531 1.1 hikaru uint8_t la_cmd_id; 532 1.1 hikaru /* Definition of the LA command defined by this request */ 533 1.1 hikaru 534 1.1 hikaru }; 535 1.1 hikaru 536 1.1 hikaru #define LA_FLAGS_GCM_IV_LEN_FLAG __BIT(9) 537 1.1 hikaru #define LA_FLAGS_PROTO __BITS(8, 6) 538 1.1 hikaru #define LA_FLAGS_PROTO_SNOW_3G __SHIFTIN(4, LA_FLAGS_PROTO) 539 1.1 hikaru #define LA_FLAGS_PROTO_GCM __SHIFTIN(2, LA_FLAGS_PROTO) 540 1.1 hikaru #define LA_FLAGS_PROTO_CCM __SHIFTIN(1, LA_FLAGS_PROTO) 541 1.1 hikaru #define LA_FLAGS_PROTO_NO __SHIFTIN(0, LA_FLAGS_PROTO) 542 1.1 hikaru #define LA_FLAGS_DIGEST_IN_BUFFER __BIT(5) 543 1.1 hikaru #define LA_FLAGS_CMP_AUTH_RES __BIT(4) 544 1.1 hikaru #define LA_FLAGS_RET_AUTH_RES __BIT(3) 545 1.1 hikaru #define LA_FLAGS_UPDATE_STATE __BIT(2) 546 1.1 hikaru #define LA_FLAGS_PARTIAL __BITS(1, 0) 547 1.1 hikaru 548 1.1 hikaru 549 1.1 hikaru struct fw_la_bulk_req { 550 1.1 hikaru struct fw_comn_req_hdr comn_hdr; 551 1.1 hikaru /* Common request header */ 552 1.1 hikaru uint32_t flow_id; 553 1.1 hikaru /* Field used by Firmware to limit the number of stateful requests 554 1.1 hikaru * for a session being processed at a given point of time */ 555 1.1 hikaru struct fw_la_comn_req comn_la_req; 556 1.1 hikaru /* Common LA request parameters */ 557 1.1 hikaru struct fw_comn_req_mid comn_mid; 558 1.1 hikaru /* Common request middle section */ 559 1.1 hikaru uint64_t req_params_addr; 560 1.1 hikaru /* Memory address of the request parameters */ 561 1.1 hikaru union fw_comn_req_ftr comn_ftr; 562 1.1 hikaru /* Common request footer */ 563 1.1 hikaru }; 564 1.1 hikaru 565 1.1 hikaru struct fw_la_resp { 566 1.1 hikaru struct fw_comn_resp_hdr comn_resp; 567 1.1 hikaru uint8_t resrvd[64 - sizeof(struct fw_comn_resp_hdr)]; 568 1.1 hikaru /* FW_RESP_DEFAULT_SZ_HW15 */ 569 1.1 hikaru }; 570 1.1 hikaru 571 1.1 hikaru struct fw_la_cipher_req_params { 572 1.1 hikaru uint8_t resrvd; 573 1.1 hikaru /* Reserved field and assumed set to 0 */ 574 1.1 hikaru uint8_t cipher_state_sz; 575 1.1 hikaru /* Number of quad words of state data for the cipher algorithm */ 576 1.1 hikaru uint8_t curr_id; 577 1.1 hikaru /* Initialised with the cipher slice type */ 578 1.1 hikaru uint8_t next_id; 579 1.1 hikaru /* Set to the next slice to pass the ciphered data through. 580 1.1 hikaru * Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go through 581 1.1 hikaru * anymore slices after cipher */ 582 1.1 hikaru uint16_t resrvd1; 583 1.1 hikaru /* Reserved field, should be set to zero*/ 584 1.1 hikaru uint8_t resrvd2; 585 1.1 hikaru /* Reserved field, should be set to zero*/ 586 1.1 hikaru uint8_t next_offset; 587 1.1 hikaru /* Offset in bytes to the next request parameter block */ 588 1.1 hikaru uint32_t cipher_off; 589 1.1 hikaru /* Byte offset from the start of packet to the cipher data region */ 590 1.1 hikaru uint32_t cipher_len; 591 1.1 hikaru /* Byte length of the cipher data region */ 592 1.1 hikaru uint64_t state_address; 593 1.1 hikaru /* Flat buffer address in memory of the cipher state information. Unused 594 1.1 hikaru * if the state size is 0 */ 595 1.1 hikaru }; 596 1.1 hikaru 597 1.1 hikaru struct fw_la_auth_req_params { 598 1.1 hikaru uint8_t auth_res_sz; 599 1.1 hikaru /* Size in quad words of digest information to validate */ 600 1.1 hikaru uint8_t hash_state_sz; 601 1.1 hikaru /* Number of quad words of inner and outer hash prefix data to process */ 602 1.1 hikaru uint8_t curr_id; 603 1.1 hikaru /* Initialised with the auth slice type */ 604 1.1 hikaru uint8_t next_id; 605 1.1 hikaru /* Set to the next slice to pass the auth data through. 606 1.1 hikaru * Set to ICP_QAT_FW_SLICE_NULL for in-place auth-only requests 607 1.1 hikaru * Set to ICP_QAT_FW_SLICE_DRAM_WR for all other request types 608 1.1 hikaru * if the data is not to go through anymore slices after auth */ 609 1.1 hikaru union { 610 1.1 hikaru uint16_t resrvd; 611 1.1 hikaru /* Reserved field should be set to zero for bulk services */ 612 1.1 hikaru uint16_t tls_secret_len; 613 1.1 hikaru /* Length of Secret information for TLS. */ 614 1.1 hikaru } u; 615 1.1 hikaru uint8_t resrvd; 616 1.1 hikaru /* Reserved field, should be set to zero*/ 617 1.1 hikaru uint8_t next_offset; 618 1.1 hikaru /* offset in bytes to the next request parameter block */ 619 1.1 hikaru uint32_t auth_off; 620 1.1 hikaru /* Byte offset from the start of packet to the auth data region */ 621 1.1 hikaru uint32_t auth_len; 622 1.1 hikaru /* Byte length of the auth data region */ 623 1.1 hikaru union { 624 1.1 hikaru uint64_t prefix_addr; 625 1.1 hikaru /* Address of the prefix information */ 626 1.1 hikaru uint64_t aad_addr; 627 1.1 hikaru /* Address of the AAD info in DRAM. Used for the CCM and GCM 628 1.1 hikaru * protocols */ 629 1.1 hikaru } u1; 630 1.1 hikaru uint64_t auth_res_address; 631 1.1 hikaru /* Address of the auth result information to validate or the location to 632 1.1 hikaru * writeback the digest information to */ 633 1.1 hikaru }; 634 1.1 hikaru 635 1.1 hikaru 636 1.1 hikaru #endif 637