Home | History | Annotate | Line # | Download | only in qat
      1 /*	$NetBSD: qat_hw17reg.h,v 1.1 2019/11/20 09:37:46 hikaru Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2019 Internet Initiative Japan, Inc.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  * POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 /*
     30  *   Copyright(c) 2014 Intel Corporation.
     31  *   Redistribution and use in source and binary forms, with or without
     32  *   modification, are permitted provided that the following conditions
     33  *   are met:
     34  *
     35  *     * Redistributions of source code must retain the above copyright
     36  *       notice, this list of conditions and the following disclaimer.
     37  *     * Redistributions in binary form must reproduce the above copyright
     38  *       notice, this list of conditions and the following disclaimer in
     39  *       the documentation and/or other materials provided with the
     40  *       distribution.
     41  *     * Neither the name of Intel Corporation nor the names of its
     42  *       contributors may be used to endorse or promote products derived
     43  *       from this software without specific prior written permission.
     44  *
     45  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     46  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     47  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     48  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     49  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     50  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     51  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     52  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     53  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     54  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     55  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     56  */
     57 
     58 #ifndef _DEV_PCI_QAT_HW17REG_H_
     59 #define _DEV_PCI_QAT_HW17REG_H_
     60 
     61 /* Default message size in bytes */
     62 #define FW_REQ_DEFAULT_SZ_HW17		128
     63 #define FW_RESP_DEFAULT_SZ_HW17		32
     64 
     65 /* -------------------------------------------------------------------------- */
     66 /* accel */
     67 
     68 enum fw_init_admin_cmd_id {
     69 	FW_INIT_ME = 0,
     70 	FW_TRNG_ENABLE = 1,
     71 	FW_TRNG_DISABLE = 2,
     72 	FW_CONSTANTS_CFG = 3,
     73 	FW_STATUS_GET = 4,
     74 	FW_COUNTERS_GET = 5,
     75 	FW_LOOPBACK = 6,
     76 	FW_HEARTBEAT_SYNC = 7,
     77 	FW_HEARTBEAT_GET = 8,
     78 	FW_COMP_CAPABILITY_GET = 9,
     79 	FW_CRYPTO_CAPABILITY_GET = 10,
     80 	FW_HEARTBEAT_TIMER_SET = 13,
     81 };
     82 
     83 enum fw_init_admin_resp_status {
     84 	FW_INIT_RESP_STATUS_SUCCESS = 0,
     85 	FW_INIT_RESP_STATUS_FAIL = 1,
     86 	FW_INIT_RESP_STATUS_UNSUPPORTED = 4
     87 };
     88 
     89 struct fw_init_admin_req {
     90 	uint16_t init_cfg_sz;
     91 	uint8_t resrvd1;
     92 	uint8_t init_admin_cmd_id;
     93 	uint32_t resrvd2;
     94 	uint64_t opaque_data;
     95 	uint64_t init_cfg_ptr;
     96 
     97 	union {
     98 		struct {
     99 			uint16_t ibuf_size_in_kb;
    100 			uint16_t resrvd3;
    101 		};
    102 		uint32_t heartbeat_ticks;
    103 	};
    104 
    105 	uint32_t resrvd4;
    106 };
    107 
    108 struct fw_init_admin_resp_hdr {
    109 	uint8_t flags;
    110 	uint8_t resrvd1;
    111 	uint8_t status;
    112 	uint8_t init_admin_cmd_id;
    113 };
    114 
    115 enum fw_init_admin_init_flag {
    116 	FW_INIT_FLAG_PKE_DISABLED = 0
    117 };
    118 
    119 struct fw_init_admin_fw_capability_resp_hdr {
    120 	uint16_t     reserved;
    121 	uint8_t     status;
    122 	uint8_t     init_admin_cmd_id;
    123 };
    124 
    125 struct fw_init_admin_capability_resp {
    126 	struct fw_init_admin_fw_capability_resp_hdr init_resp_hdr;
    127 	uint32_t extended_features;
    128 	uint64_t opaque_data;
    129 	union {
    130 		struct {
    131 			uint16_t    compression_algos;
    132 			uint16_t    checksum_algos;
    133 			uint32_t    deflate_capabilities;
    134 			uint32_t    resrvd1;
    135 			uint32_t    lzs_capabilities;
    136 		} compression;
    137 		struct {
    138 			uint32_t    cipher_algos;
    139 			uint32_t    hash_algos;
    140 			uint16_t    keygen_algos;
    141 			uint16_t    other;
    142 			uint16_t    public_key_algos;
    143 			uint16_t    prime_algos;
    144 		} crypto;
    145 	};
    146 };
    147 
    148 struct fw_init_admin_resp_pars {
    149 	union {
    150 		uint32_t resrvd1[4];
    151 		struct {
    152 			uint32_t version_patch_num;
    153 			uint8_t context_id;
    154 			uint8_t ae_id;
    155 			uint16_t resrvd1;
    156 			uint64_t resrvd2;
    157 		} s1;
    158 		struct {
    159 			uint64_t req_rec_count;
    160 			uint64_t resp_sent_count;
    161 		} s2;
    162 	} u;
    163 };
    164 
    165 struct fw_init_admin_hb_cnt {
    166 	uint16_t resp_heartbeat_cnt;
    167 	uint16_t req_heartbeat_cnt;
    168 };
    169 
    170 #define QAT_NUM_THREADS 8
    171 
    172 struct fw_init_admin_hb_stats {
    173 	struct fw_init_admin_hb_cnt stats[QAT_NUM_THREADS];
    174 };
    175 
    176 struct fw_init_admin_resp {
    177 	struct fw_init_admin_resp_hdr init_resp_hdr;
    178 	union {
    179 		uint32_t resrvd2;
    180 		struct {
    181 			uint16_t version_minor_num;
    182 			uint16_t version_major_num;
    183 		} s;
    184 	} u;
    185 	uint64_t opaque_data;
    186 	struct fw_init_admin_resp_pars init_resp_pars;
    187 };
    188 
    189 #define FW_COMN_HEARTBEAT_OK 0
    190 #define FW_COMN_HEARTBEAT_BLOCKED 1
    191 #define FW_COMN_HEARTBEAT_FLAG_BITPOS 0
    192 #define FW_COMN_HEARTBEAT_FLAG_MASK 0x1
    193 #define FW_COMN_STATUS_RESRVD_FLD_MASK 0xFE
    194 #define FW_COMN_HEARTBEAT_HDR_FLAG_GET(hdr_t) \
    195 	FW_COMN_HEARTBEAT_FLAG_GET(hdr_t.flags)
    196 
    197 #define FW_COMN_HEARTBEAT_HDR_FLAG_SET(hdr_t, val) \
    198 	FW_COMN_HEARTBEAT_FLAG_SET(hdr_t, val)
    199 
    200 #define FW_COMN_HEARTBEAT_FLAG_GET(flags) \
    201 	QAT_FIELD_GET(flags, \
    202 		 FW_COMN_HEARTBEAT_FLAG_BITPOS, \
    203 		 FW_COMN_HEARTBEAT_FLAG_MASK)
    204 
    205 /* -------------------------------------------------------------------------- */
    206 
    207 /* Big assumptions that both bitpos and mask are constants */
    208 #define FIELD_SET(flags, val, bitpos, mask)                                \
    209     (flags) =                                                                  \
    210         (((flags) & (~((mask) << (bitpos)))) | (((val) & (mask)) << (bitpos)))
    211 
    212 #define FIELD_GET(flags, bitpos, mask) (((flags) >> (bitpos)) & (mask))
    213 
    214 #define FLAG_SET(flags, bitpos) (flags) = ((flags) | (1 << (bitpos)))
    215 
    216 #define FLAG_CLEAR(flags, bitpos) (flags) = ((flags) & (~(1 << (bitpos))))
    217 
    218 #define FLAG_GET(flags, bitpos) (((flags) >> (bitpos)) & 1)
    219 
    220 /* Default request and response ring size in bytes  */
    221 #define FW_REQ_DEFAULT_SZ 128
    222 #define FW_RESP_DEFAULT_SZ 32
    223 
    224 #define FW_COMN_ONE_BYTE_SHIFT 8
    225 #define FW_COMN_SINGLE_BYTE_MASK 0xFF
    226 
    227 /* Common Request - Block sizes definitions in multiples of individual long
    228  * words  */
    229 #define FW_NUM_LONGWORDS_1 1
    230 #define FW_NUM_LONGWORDS_2 2
    231 #define FW_NUM_LONGWORDS_3 3
    232 #define FW_NUM_LONGWORDS_4 4
    233 #define FW_NUM_LONGWORDS_5 5
    234 #define FW_NUM_LONGWORDS_6 6
    235 #define FW_NUM_LONGWORDS_7 7
    236 #define FW_NUM_LONGWORDS_10 10
    237 #define FW_NUM_LONGWORDS_13 13
    238 
    239 /* Definition of the associated service Id for NULL service type.
    240    Note: the response is expected to use FW_COMN_RESP_SERV_CPM_FW  */
    241 #define FW_NULL_REQ_SERV_ID 1
    242 
    243 /*
    244  * Definition of the firmware interface service users, for
    245  * responses.
    246  * Enumeration which is used to indicate the ids of the services
    247  * for responses using the external firmware interfaces.
    248  */
    249 
    250 enum fw_comn_resp_serv_id {
    251 	FW_COMN_RESP_SERV_NULL,     /* NULL service id type */
    252 	FW_COMN_RESP_SERV_CPM_FW,   /* CPM FW Service ID */
    253 	FW_COMN_RESP_SERV_DELIMITER /* Delimiter service id type */
    254 };
    255 
    256 /*
    257  * Definition of the request types
    258  * Enumeration which is used to indicate the ids of the request
    259  * types used in each of the external firmware interfaces
    260  */
    261 
    262 enum fw_comn_request_id {
    263 	FW_COMN_REQ_NULL = 0,        /* NULL request type */
    264 	FW_COMN_REQ_CPM_FW_PKE = 3,  /* CPM FW PKE Request */
    265 	FW_COMN_REQ_CPM_FW_LA = 4,   /* CPM FW Lookaside Request */
    266 	FW_COMN_REQ_CPM_FW_DMA = 7,  /* CPM FW DMA Request */
    267 	FW_COMN_REQ_CPM_FW_COMP = 9, /* CPM FW Compression Request */
    268 	FW_COMN_REQ_DELIMITER        /* End delimiter */
    269 
    270 };
    271 
    272 /*
    273  * Definition of the common QAT FW request content descriptor field -
    274  * points to the content descriptor parameters or itself contains service-
    275  * specific data. Also specifies content descriptor parameter size.
    276  * Contains reserved fields.
    277  * Common section of the request used across all of the services exposed
    278  * by the QAT FW. Each of the services inherit these common fields
    279  */
    280 union fw_comn_req_hdr_cd_pars {
    281 	/* LWs 2-5 */
    282 	struct
    283 	{
    284 		uint64_t content_desc_addr;
    285 		/* Address of the content descriptor */
    286 
    287 		uint16_t content_desc_resrvd1;
    288 		/* Content descriptor reserved field */
    289 
    290 		uint8_t content_desc_params_sz;
    291 		/* Size of the content descriptor parameters in quad words. These
    292 		 * parameters describe the session setup configuration info for the
    293 		 * slices that this request relies upon i.e. the configuration word and
    294 		 * cipher key needed by the cipher slice if there is a request for
    295 		 * cipher processing. */
    296 
    297 		uint8_t content_desc_hdr_resrvd2;
    298 		/* Content descriptor reserved field */
    299 
    300 		uint32_t content_desc_resrvd3;
    301 		/* Content descriptor reserved field */
    302 	} s;
    303 
    304 	struct
    305 	{
    306 		uint32_t serv_specif_fields[FW_NUM_LONGWORDS_4];
    307 
    308 	} s1;
    309 
    310 };
    311 
    312 /*
    313  * Definition of the common QAT FW request middle block.
    314  * Common section of the request used across all of the services exposed
    315  * by the QAT FW. Each of the services inherit these common fields
    316  */
    317 struct fw_comn_req_mid
    318 {
    319 	/* LWs 6-13 */
    320 	uint64_t opaque_data;
    321 	/* Opaque data passed unmodified from the request to response messages by
    322 	 * firmware (fw) */
    323 
    324 	uint64_t src_data_addr;
    325 	/* Generic definition of the source data supplied to the QAT AE. The
    326 	 * common flags are used to further describe the attributes of this
    327 	 * field */
    328 
    329 	uint64_t dest_data_addr;
    330 	/* Generic definition of the destination data supplied to the QAT AE. The
    331 	 * common flags are used to further describe the attributes of this
    332 	 * field */
    333 
    334 	uint32_t src_length;
    335 	/* Length of source flat buffer incase src buffer
    336 	 * type is flat */
    337 
    338 	uint32_t dst_length;
    339 	/* Length of source flat buffer incase dst buffer
    340 	 * type is flat */
    341 
    342 };
    343 
    344 /*
    345  * Definition of the common QAT FW request content descriptor control
    346  * block.
    347  *
    348  * Service specific section of the request used across all of the services
    349  * exposed by the QAT FW. Each of the services populates this block
    350  * uniquely. Refer to the service-specific header structures e.g.
    351  * 'fw_cipher_hdr_s' (for Cipher) etc.
    352  */
    353 struct fw_comn_req_cd_ctrl
    354 {
    355 	/* LWs 27-31 */
    356 	uint32_t content_desc_ctrl_lw[FW_NUM_LONGWORDS_5];
    357 
    358 };
    359 
    360 /*
    361  * Definition of the common QAT FW request header.
    362  * Common section of the request used across all of the services exposed
    363  * by the QAT FW. Each of the services inherit these common fields. The
    364  * reserved field of 7 bits and the service command Id field are all
    365  * service-specific fields, along with the service specific flags.
    366  */
    367 struct fw_comn_req_hdr
    368 {
    369 	/* LW0 */
    370 	uint8_t resrvd1;
    371 	/* reserved field */
    372 
    373 	uint8_t service_cmd_id;
    374 	/* Service Command Id  - this field is service-specific
    375 	 * Please use service-specific command Id here e.g.Crypto Command Id
    376 	 * or Compression Command Id etc. */
    377 
    378 	uint8_t service_type;
    379 	/* Service type */
    380 
    381 	uint8_t hdr_flags;
    382 	/* This represents a flags field for the Service Request.
    383 	 * The most significant bit is the 'valid' flag and the only
    384 	 * one used. All remaining bit positions are unused and
    385 	 * are therefore reserved and need to be set to 0. */
    386 
    387 	/* LW1 */
    388 	uint16_t serv_specif_flags;
    389 	/* Common Request service-specific flags
    390 	 * e.g. Symmetric Crypto Command Flags */
    391 
    392 	uint16_t comn_req_flags;
    393 	/* Common Request Flags consisting of
    394 	 * - 14 reserved bits,
    395 	 * - 1 Content Descriptor field type bit and
    396 	 * - 1 Source/destination pointer type bit */
    397 
    398 };
    399 
    400 /*
    401  * Definition of the common QAT FW request parameter field.
    402  *
    403  * Service specific section of the request used across all of the services
    404  * exposed by the QAT FW. Each of the services populates this block
    405  * uniquely. Refer to service-specific header structures e.g.
    406  * 'fw_comn_req_cipher_rqpars_s' (for Cipher) etc.
    407  *
    408  */
    409 struct fw_comn_req_rqpars
    410 {
    411 	/* LWs 14-26 */
    412 	uint32_t serv_specif_rqpars_lw[FW_NUM_LONGWORDS_13];
    413 
    414 };
    415 
    416 /*
    417  * Definition of the common request structure with service specific
    418  * fields
    419  * This is a definition of the full qat request structure used by all
    420  * services. Each service is free to use the service fields in its own
    421  * way. This struct is useful as a message passing argument before the
    422  * service contained within the request is determined.
    423  */
    424 struct fw_comn_req
    425 {
    426 	/* LWs 0-1 */
    427 	struct fw_comn_req_hdr comn_hdr;
    428 	/* Common request header */
    429 
    430 	/* LWs 2-5 */
    431 	union fw_comn_req_hdr_cd_pars cd_pars;
    432 	/* Common Request content descriptor field which points either to a
    433 	 * content descriptor
    434 	 * parameter block or contains the service-specific data itself. */
    435 
    436 	/* LWs 6-13 */
    437 	struct fw_comn_req_mid comn_mid;
    438 	/* Common request middle section */
    439 
    440 	/* LWs 14-26 */
    441 	struct fw_comn_req_rqpars serv_specif_rqpars;
    442 	/* Common request service-specific parameter field */
    443 
    444 	/* LWs 27-31 */
    445 	struct fw_comn_req_cd_ctrl cd_ctrl;
    446 	/* Common request content descriptor control block -
    447 	 * this field is service-specific */
    448 
    449 };
    450 
    451 /*
    452  * Error code field
    453  *
    454  * Overloaded field with 8 bit common error field or two
    455  * 8 bit compression error fields for compression and translator slices
    456  */
    457 union fw_comn_error {
    458 	struct
    459 	{
    460 		uint8_t resrvd;
    461 		/* 8 bit reserved field */
    462 
    463 		uint8_t comn_err_code;
    464 		/* 8 bit common error code */
    465 
    466 	} s;
    467 	/* Structure which is used for non-compression responses */
    468 
    469 	struct
    470 	{
    471 		uint8_t xlat_err_code;
    472 		/* 8 bit translator error field */
    473 
    474 		uint8_t cmp_err_code;
    475 		/* 8 bit compression error field */
    476 
    477 	} s1;
    478 	/* Structure which is used for compression responses */
    479 
    480 };
    481 
    482 /*
    483  * Definition of the common QAT FW response header.
    484  * This section of the response is common across all of the services
    485  * that generate a firmware interface response
    486  */
    487 struct fw_comn_resp_hdr
    488 {
    489 	/* LW0 */
    490 	uint8_t resrvd1;
    491 	/* Reserved field - this field is service-specific -
    492 	 * Note: The Response Destination Id has been removed
    493 	 * from first QWord */
    494 
    495 	uint8_t service_id;
    496 	/* Service Id returned by service block */
    497 
    498 	uint8_t response_type;
    499 	/* Response type - copied from the request to
    500 	 * the response message */
    501 
    502 	uint8_t hdr_flags;
    503 	/* This represents a flags field for the Response.
    504 	 * Bit<7> = 'valid' flag
    505 	 * Bit<6> = 'CNV' flag indicating that CNV was executed
    506 	 *          on the current request
    507 	 * Bit<5> = 'CNVNR' flag indicating that a recovery happened
    508 	 *          on the current request following a CNV error
    509 	 * All remaining bits are unused and are therefore reserved.
    510 	 * They must to be set to 0.
    511 	 */
    512 
    513 	/* LW 1 */
    514 	union fw_comn_error comn_error;
    515 	/* This field is overloaded to allow for one 8 bit common error field
    516 	 *   or two 8 bit error fields from compression and translator  */
    517 
    518 	uint8_t comn_status;
    519 	/* Status field which specifies which slice(s) report an error */
    520 
    521 	uint8_t cmd_id;
    522 	/* Command Id - passed from the request to the response message */
    523 
    524 };
    525 
    526 /*
    527  * Definition of the common response structure with service specific
    528  * fields
    529  * This is a definition of the full qat response structure used by all
    530  * services.
    531  */
    532 struct fw_comn_resp
    533 {
    534 	/* LWs 0-1 */
    535 	struct fw_comn_resp_hdr comn_hdr;
    536 	/* Common header fields */
    537 
    538 	/* LWs 2-3 */
    539 	uint64_t opaque_data;
    540 	/* Opaque data passed from the request to the response message */
    541 
    542 	/* LWs 4-7 */
    543 	uint32_t resrvd[FW_NUM_LONGWORDS_4];
    544 	/* Reserved */
    545 
    546 };
    547 
    548 /*  Common QAT FW request header - structure of LW0
    549  *  + ===== + ---- + ----------- + ----------- + ----------- + ----------- +
    550  *  |  Bit  |  31  |  30 - 24    |  21 - 16    |  15 - 8     |  7 - 0      |
    551  *  + ===== + ---- + ----------- + ----------- + ----------- + ----------- +
    552  *  | Flags |  V   |   Reserved  | Serv Type   | Serv Cmd Id |  Reserved   |
    553  *  + ===== + ---- + ----------- + ----------- + ----------- + ----------- +
    554  */
    555 
    556 #define FW_COMN_VALID		__BIT(7)
    557 
    558 /*  Common QAT FW response header - structure of LW0
    559  *  + ===== + --- + --- + ----- + ----- + --------- + ----------- + ----- +
    560  *  |  Bit  | 31  | 30  |   29  | 28-24 |  21 - 16  |  15 - 8     |  7-0  |
    561  *  + ===== + --- + ----+ ----- + ----- + --------- + ----------- + ----- +
    562  *  | Flags |  V  | CNV | CNVNR | Rsvd  | Serv Type | Serv Cmd Id |  Rsvd |
    563  *  + ===== + --- + --- + ----- + ----- + --------- + ----------- + ----- +  */
    564 /* Macros defining the bit position and mask of 'CNV' flag
    565  * within the hdr_flags field of LW0 (service response only)  */
    566 #define FW_COMN_CNV_FLAG_BITPOS 6
    567 #define FW_COMN_CNV_FLAG_MASK 0x1
    568 
    569 /* Macros defining the bit position and mask of CNVNR flag
    570  * within the hdr_flags field of LW0 (service response only)  */
    571 #define FW_COMN_CNVNR_FLAG_BITPOS 5
    572 #define FW_COMN_CNVNR_FLAG_MASK 0x1
    573 
    574 /*
    575  * Macro for extraction of Service Type Field
    576  *
    577  * struct fw_comn_req_hdr  Structure 'fw_comn_req_hdr_t'
    578  *                 to extract the Service Type Field
    579  */
    580 #define FW_COMN_OV_SRV_TYPE_GET(fw_comn_req_hdr_t)	\
    581 	fw_comn_req_hdr_t.service_type
    582 
    583 /*
    584  * Macro for setting of Service Type Field
    585  *
    586  * 'fw_comn_req_hdr_t' structure to set the Service
    587  *                  Type Field
    588  * val    Value of the Service Type Field
    589  */
    590 #define FW_COMN_OV_SRV_TYPE_SET(fw_comn_req_hdr_t, val)	\
    591 	fw_comn_req_hdr_t.service_type = val
    592 
    593 /*
    594  * Macro for extraction of Service Command Id Field
    595  *
    596  * struct fw_comn_req_hdr  Structure 'fw_comn_req_hdr_t'
    597  *                 to extract the Service Command Id Field
    598  */
    599 #define FW_COMN_OV_SRV_CMD_ID_GET(fw_comn_req_hdr_t)	\
    600 	fw_comn_req_hdr_t.service_cmd_id
    601 
    602 /*
    603  * Macro for setting of Service Command Id Field
    604  *
    605  * 'fw_comn_req_hdr_t' structure to set the
    606  *                  Service Command Id Field
    607  * val    Value of the Service Command Id Field
    608  */
    609 #define FW_COMN_OV_SRV_CMD_ID_SET(fw_comn_req_hdr_t, val)	\
    610 	fw_comn_req_hdr_t.service_cmd_id = val
    611 
    612 /*
    613  * Extract the valid flag from the request or response's header flags.
    614  *
    615  * hdr_t  Request or Response 'hdr_t' structure to extract the valid bit
    616  *  from the  'hdr_flags' field.
    617  */
    618 #define FW_COMN_HDR_VALID_FLAG_GET(hdr_t)	\
    619 	FW_COMN_VALID_FLAG_GET(hdr_t.hdr_flags)
    620 
    621 /*
    622  * Extract the CNVNR flag from the header flags in the response only.
    623  *
    624  * hdr_t  Response 'hdr_t' structure to extract the CNVNR bit
    625  *  from the  'hdr_flags' field.
    626  */
    627 #define FW_COMN_HDR_CNVNR_FLAG_GET(hdr_flags)	\
    628 	FIELD_GET(hdr_flags,	\
    629 			      FW_COMN_CNVNR_FLAG_BITPOS,	\
    630 			      FW_COMN_CNVNR_FLAG_MASK)
    631 
    632 /*
    633  * Extract the CNV flag from the header flags in the response only.
    634  *
    635  * hdr_t  Response 'hdr_t' structure to extract the CNV bit
    636  *  from the  'hdr_flags' field.
    637  */
    638 #define FW_COMN_HDR_CNV_FLAG_GET(hdr_flags)	\
    639 	FIELD_GET(hdr_flags,	\
    640 			      FW_COMN_CNV_FLAG_BITPOS,	\
    641 			      FW_COMN_CNV_FLAG_MASK)
    642 
    643 /*
    644  * Set the valid bit in the request's header flags.
    645  *
    646  * hdr_t  Request or Response 'hdr_t' structure to set the valid bit
    647  * val    Value of the valid bit flag.
    648  */
    649 #define FW_COMN_HDR_VALID_FLAG_SET(hdr_t, val)	\
    650 	FW_COMN_VALID_FLAG_SET(hdr_t, val)
    651 
    652 /*
    653  * Common macro to extract the valid flag from the header flags field
    654  * within the header structure (request or response).
    655  *
    656  * hdr_t  Structure (request or response) to extract the
    657  *  valid bit from the 'hdr_flags' field.
    658  */
    659 #define FW_COMN_VALID_FLAG_GET(hdr_flags)	\
    660 	FIELD_GET(hdr_flags,	\
    661 			      FW_COMN_VALID_FLAG_BITPOS,	\
    662 			      FW_COMN_VALID_FLAG_MASK)
    663 
    664 /*
    665  * Common macro to extract the remaining reserved flags from the header
    666  * flags field within the header structure (request or response).
    667  *
    668  * hdr_t  Structure (request or response) to extract the
    669  *  remaining bits from the 'hdr_flags' field (excluding the
    670  *  valid flag).
    671  */
    672 #define FW_COMN_HDR_RESRVD_FLD_GET(hdr_flags)	\
    673 	(hdr_flags & FW_COMN_HDR_RESRVD_FLD_MASK)
    674 
    675 /*
    676  * Common macro to set the valid bit in the header flags field within
    677  * the header structure (request or response).
    678  *
    679  * hdr_t  Structure (request or response) containing the header
    680  *  flags field, to allow the valid bit to be set.
    681  * val    Value of the valid bit flag.
    682  */
    683 #define FW_COMN_VALID_FLAG_SET(hdr_t, val)	\
    684 	FIELD_SET((hdr_t.hdr_flags),	\
    685 			      (val),	\
    686 			      FW_COMN_VALID_FLAG_BITPOS,	\
    687 			      FW_COMN_VALID_FLAG_MASK)
    688 
    689 /*
    690  * Macro that must be used when building the common header flags.
    691  * Note that all bits reserved field bits 0-6 (LW0) need to be forced to 0.
    692  *
    693  * ptr   Value of the valid flag
    694  */
    695 
    696 #define FW_COMN_HDR_FLAGS_BUILD(valid)	\
    697 	(((valid)&FW_COMN_VALID_FLAG_MASK)	\
    698 	 << FW_COMN_VALID_FLAG_BITPOS)
    699 
    700 /*
    701  *  Common Request Flags Definition
    702  *  The bit offsets below are within the flags field. These are NOT relative to
    703  *  the memory word. Unused fields e.g. reserved bits, must be zeroed.
    704  *
    705  *  + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- +
    706  *  | Bits [15:8]    |  15 |  14 |  13 |  12 |  11 |  10 |  9  |  8  |
    707  *  + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- +
    708  *  | Flags[15:8]    | Rsv | Rsv | Rsv | Rsv | Rsv | Rsv | Rsv | Rsv |
    709  *  + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- +
    710  *  | Bits  [7:0]    |  7  |  6  |  5  |  4  |  3  |  2  |  1  |  0  |
    711  *  + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- +
    712  *  | Flags [7:0]    | Rsv | Rsv | Rsv | Rsv | Rsv | BnP | Cdt | Ptr |
    713  *  + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- +
    714  */
    715 
    716 #define COMN_PTR_TYPE_BITPOS 0
    717 /* Common Request Flags - Starting bit position indicating
    718  * Src&Dst Buffer Pointer type   */
    719 
    720 #define COMN_PTR_TYPE_MASK 0x1
    721 /* Common Request Flags - One bit mask used to determine
    722  * Src&Dst Buffer Pointer type  */
    723 
    724 #define COMN_CD_FLD_TYPE_BITPOS 1
    725 /* Common Request Flags - Starting bit position indicating
    726  * CD Field type   */
    727 
    728 #define COMN_CD_FLD_TYPE_MASK 0x1
    729 /* Common Request Flags - One bit mask used to determine
    730  * CD Field type  */
    731 
    732 #define COMN_BNP_ENABLED_BITPOS 2
    733 /* Common Request Flags - Starting bit position indicating
    734  * the source buffer contains batch of requests. if this
    735  * bit is set, source buffer is type of Batch And Pack OpData List
    736  * and the Ptr Type Bit only applies to Destination buffer.  */
    737 
    738 #define COMN_BNP_ENABLED_MASK 0x1
    739 /* Batch And Pack Enabled Flag Mask - One bit mask used to determine
    740  * the source buffer is in Batch and Pack OpData Link List Mode.  */
    741 
    742 /* ========================================================================= */
    743 /*                                       Pointer Type Flag definitions       */
    744 /* ========================================================================= */
    745 #define COMN_PTR_TYPE_FLAT 0x0
    746 /* Constant value indicating Src&Dst Buffer Pointer type is flat
    747  * If Batch and Pack mode is enabled, only applies to Destination buffer. */
    748 
    749 #define COMN_PTR_TYPE_SGL 0x1
    750 /* Constant value indicating Src&Dst Buffer Pointer type is SGL type
    751  * If Batch and Pack mode is enabled, only applies to Destination buffer. */
    752 
    753 #define COMN_PTR_TYPE_BATCH 0x2
    754 /* Constant value indicating Src is a batch request
    755  * and Dst Buffer Pointer type is SGL type  */
    756 
    757 /* ========================================================================= */
    758 /*                                       CD Field Flag definitions           */
    759 /* ========================================================================= */
    760 #define COMN_CD_FLD_TYPE_64BIT_ADR 0x0
    761 /* Constant value indicating CD Field contains 64-bit address  */
    762 
    763 #define COMN_CD_FLD_TYPE_16BYTE_DATA 0x1
    764 /* Constant value indicating CD Field contains 16 bytes of setup data  */
    765 
    766 /* ========================================================================= */
    767 /*                       Batch And Pack Enable/Disable Definitions           */
    768 /* ========================================================================= */
    769 #define COMN_BNP_ENABLED 0x1
    770 /* Constant value indicating Source buffer will point to Batch And Pack OpData
    771  * List  */
    772 
    773 #define COMN_BNP_DISABLED 0x0
    774 /* Constant value indicating Source buffer will point to Batch And Pack OpData
    775  * List  */
    776 
    777 /*
    778  * Macro that must be used when building the common request flags (for all
    779  * requests but comp BnP).
    780  * Note that all bits reserved field bits 2-15 (LW1) need to be forced to 0.
    781  *
    782  * ptr   Value of the pointer type flag
    783  * cdt   Value of the cd field type flag
    784 */
    785 #define FW_COMN_FLAGS_BUILD(cdt, ptr)	\
    786 	((((cdt)&COMN_CD_FLD_TYPE_MASK) << COMN_CD_FLD_TYPE_BITPOS) |	\
    787 	 (((ptr)&COMN_PTR_TYPE_MASK) << COMN_PTR_TYPE_BITPOS))
    788 
    789 /*
    790  * Macro that must be used when building the common request flags for comp
    791  * BnP service.
    792  * Note that all bits reserved field bits 3-15 (LW1) need to be forced to 0.
    793  *
    794  * ptr   Value of the pointer type flag
    795  * cdt   Value of the cd field type flag
    796  * bnp   Value of the bnp enabled flag
    797  */
    798 #define FW_COMN_FLAGS_BUILD_BNP(cdt, ptr, bnp)	\
    799 	((((cdt)&COMN_CD_FLD_TYPE_MASK) << COMN_CD_FLD_TYPE_BITPOS) |	\
    800 	 (((ptr)&COMN_PTR_TYPE_MASK) << COMN_PTR_TYPE_BITPOS) |	\
    801 	 (((bnp)&COMN_BNP_ENABLED_MASK) << COMN_BNP_ENABLED_BITPOS))
    802 
    803 /*
    804  * Macro for extraction of the pointer type bit from the common flags
    805  *
    806  * flags      Flags to extract the pointer type bit from
    807  */
    808 #define FW_COMN_PTR_TYPE_GET(flags)	\
    809 	FIELD_GET(flags, COMN_PTR_TYPE_BITPOS, COMN_PTR_TYPE_MASK)
    810 
    811 /*
    812  * Macro for extraction of the cd field type bit from the common flags
    813  *
    814  * flags      Flags to extract the cd field type type bit from
    815  */
    816 #define FW_COMN_CD_FLD_TYPE_GET(flags)	\
    817 	FIELD_GET(flags, COMN_CD_FLD_TYPE_BITPOS, COMN_CD_FLD_TYPE_MASK)
    818 
    819 /*
    820  * Macro for extraction of the bnp field type bit from the common flags
    821  *
    822  * flags      Flags to extract the bnp field type type bit from
    823  *
    824  */
    825 #define FW_COMN_BNP_ENABLED_GET(flags)	\
    826 	FIELD_GET(flags, COMN_BNP_ENABLED_BITPOS, COMN_BNP_ENABLED_MASK)
    827 
    828 /*
    829  * Macro for setting the pointer type bit in the common flags
    830  *
    831  * flags      Flags in which Pointer Type bit will be set
    832  * val        Value of the bit to be set in flags
    833  *
    834  */
    835 #define FW_COMN_PTR_TYPE_SET(flags, val)	\
    836 	FIELD_SET(flags, val, COMN_PTR_TYPE_BITPOS, COMN_PTR_TYPE_MASK)
    837 
    838 /*
    839  * Macro for setting the cd field type bit in the common flags
    840  *
    841  * flags      Flags in which Cd Field Type bit will be set
    842  * val        Value of the bit to be set in flags
    843  *
    844  */
    845 #define FW_COMN_CD_FLD_TYPE_SET(flags, val)	\
    846 	FIELD_SET(	\
    847 		flags, val, COMN_CD_FLD_TYPE_BITPOS, COMN_CD_FLD_TYPE_MASK)
    848 
    849 /*
    850  * Macro for setting the bnp field type bit in the common flags
    851  *
    852  * flags      Flags in which Bnp Field Type bit will be set
    853  * val        Value of the bit to be set in flags
    854  *
    855  */
    856 #define FW_COMN_BNP_ENABLE_SET(flags, val)	\
    857 	FIELD_SET(	\
    858 		flags, val, COMN_BNP_ENABLED_BITPOS, COMN_BNP_ENABLED_MASK)
    859 
    860 /*
    861  * Macros using the bit position and mask to set/extract the next
    862  * and current id nibbles within the next_curr_id field of the
    863  * content descriptor header block. Note that these are defined
    864  * in the common header file, as they are used by compression, cipher
    865  * and authentication.
    866  *
    867  * cd_ctrl_hdr_t      Content descriptor control block header pointer.
    868  * val                Value of the field being set.
    869  */
    870 #define FW_COMN_NEXT_ID_BITPOS 4
    871 #define FW_COMN_NEXT_ID_MASK 0xF0
    872 #define FW_COMN_CURR_ID_BITPOS 0
    873 #define FW_COMN_CURR_ID_MASK 0x0F
    874 
    875 #define FW_COMN_NEXT_ID_GET(cd_ctrl_hdr_t)	\
    876 	((((cd_ctrl_hdr_t)->next_curr_id) & FW_COMN_NEXT_ID_MASK) >>	\
    877 	 (FW_COMN_NEXT_ID_BITPOS))
    878 
    879 #define FW_COMN_NEXT_ID_SET(cd_ctrl_hdr_t, val)	\
    880 	((cd_ctrl_hdr_t)->next_curr_id) =	\
    881 		((((cd_ctrl_hdr_t)->next_curr_id) & FW_COMN_CURR_ID_MASK) |	\
    882 		 ((val << FW_COMN_NEXT_ID_BITPOS) &	\
    883 		  FW_COMN_NEXT_ID_MASK))
    884 
    885 #define FW_COMN_CURR_ID_GET(cd_ctrl_hdr_t)	\
    886 	(((cd_ctrl_hdr_t)->next_curr_id) & FW_COMN_CURR_ID_MASK)
    887 
    888 #define FW_COMN_CURR_ID_SET(cd_ctrl_hdr_t, val)	\
    889 	((cd_ctrl_hdr_t)->next_curr_id) =	\
    890 		((((cd_ctrl_hdr_t)->next_curr_id) & FW_COMN_NEXT_ID_MASK) |	\
    891 		 ((val)&FW_COMN_CURR_ID_MASK))
    892 
    893 /*
    894  *  Common Status Field Definition  The bit offsets below are within the COMMON
    895  *  RESPONSE status field, assumed to be 8 bits wide. In the case of the PKE
    896  *  response (which follows the CPM 1.5 message format), the status field is 16
    897  *  bits wide.
    898  *  The status flags are contained within the most significant byte and align
    899  *  with the diagram below. Please therefore refer to the service-specific PKE
    900  *  header file for the appropriate macro definition to extract the PKE status
    901  *  flag from the PKE response, which assumes that a word is passed to the
    902  *  macro.
    903  *  + ===== + ------ + --- + --- + ---- + ---- + -------- + ---- + ---------- +
    904  *  |  Bit  |   7    |  6  |  5  |  4   |  3   |    2     |   1  |      0     |
    905  *  + ===== + ------ + --- + --- + ---- + ---- + -------- + ---- + ---------- +
    906  *  | Flags | Crypto | Pke | Cmp | Xlat | EOLB | UnSupReq | Rsvd | XltWaApply |
    907  *  + ===== + ------ + --- + --- + ---- + ---- + -------- + ---- + ---------- +
    908  * Note:
    909  * For the service specific status bit definitions refer to service header files
    910  * Eg. Crypto Status bit refers to Symmetric Crypto, Key Generation, and NRBG
    911  * Requests' Status. Unused bits e.g. reserved bits need to have been forced to
    912  * 0.
    913  */
    914 
    915 #define COMN_RESP_CRYPTO_STATUS_BITPOS 7
    916 /* Starting bit position indicating Response for Crypto service Flag  */
    917 
    918 #define COMN_RESP_CRYPTO_STATUS_MASK 0x1
    919 /* One bit mask used to determine Crypto status mask  */
    920 
    921 #define COMN_RESP_PKE_STATUS_BITPOS 6
    922 /* Starting bit position indicating Response for PKE service Flag  */
    923 
    924 #define COMN_RESP_PKE_STATUS_MASK 0x1
    925 /* One bit mask used to determine PKE status mask  */
    926 
    927 #define COMN_RESP_CMP_STATUS_BITPOS 5
    928 /* Starting bit position indicating Response for Compression service Flag  */
    929 
    930 #define COMN_RESP_CMP_STATUS_MASK 0x1
    931 /* One bit mask used to determine Compression status mask  */
    932 
    933 #define COMN_RESP_XLAT_STATUS_BITPOS 4
    934 /* Starting bit position indicating Response for Xlat service Flag  */
    935 
    936 #define COMN_RESP_XLAT_STATUS_MASK 0x1
    937 /* One bit mask used to determine Translator status mask  */
    938 
    939 #define COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS 3
    940 /* Starting bit position indicating the last block in a deflate stream for
    941   the compression service Flag */
    942 
    943 #define COMN_RESP_CMP_END_OF_LAST_BLK_MASK 0x1
    944 /* One bit mask used to determine the last block in a deflate stream
    945    status mask */
    946 
    947 #define COMN_RESP_UNSUPPORTED_REQUEST_BITPOS 2
    948 /* Starting bit position indicating when an unsupported service request Flag  */
    949 
    950 #define COMN_RESP_UNSUPPORTED_REQUEST_MASK 0x1
    951 /* One bit mask used to determine the unsupported service request status mask  */
    952 
    953 #define COMN_RESP_XLT_WA_APPLIED_BITPOS 0
    954 /* Bit position indicating a firmware workaround was applied to translation  */
    955 
    956 #define COMN_RESP_XLT_WA_APPLIED_MASK 0x1
    957 /* One bit mask  */
    958 
    959 /*
    960  * Macro that must be used when building the status
    961  * for the common response
    962  *
    963  * crypto   Value of the Crypto Service status flag
    964  * comp     Value of the Compression Service Status flag
    965  * xlat     Value of the Xlator Status flag
    966  * eolb     Value of the Compression End of Last Block Status flag
    967  * unsupp   Value of the Unsupported Request flag
    968  * xlt_wa   Value of the Translation WA marker
    969  */
    970 #define FW_COMN_RESP_STATUS_BUILD(	\
    971 	crypto, pke, comp, xlat, eolb, unsupp, xlt_wa)	\
    972 	((((crypto)&COMN_RESP_CRYPTO_STATUS_MASK)	\
    973 	  << COMN_RESP_CRYPTO_STATUS_BITPOS) |	\
    974 	 (((pke)&COMN_RESP_PKE_STATUS_MASK)	\
    975 	  << COMN_RESP_PKE_STATUS_BITPOS) |	\
    976 	 (((xlt_wa)&COMN_RESP_XLT_WA_APPLIED_MASK)	\
    977 	  << COMN_RESP_XLT_WA_APPLIED_BITPOS) |	\
    978 	 (((comp)&COMN_RESP_CMP_STATUS_MASK)	\
    979 	  << COMN_RESP_CMP_STATUS_BITPOS) |	\
    980 	 (((xlat)&COMN_RESP_XLAT_STATUS_MASK)	\
    981 	  << COMN_RESP_XLAT_STATUS_BITPOS) |	\
    982 	 (((eolb)&COMN_RESP_CMP_END_OF_LAST_BLK_MASK)	\
    983 	  << COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS) |	\
    984 	 (((unsupp)&COMN_RESP_UNSUPPORTED_REQUEST_BITPOS)	\
    985 	  << COMN_RESP_UNSUPPORTED_REQUEST_MASK))
    986 
    987 /*
    988  * Macro for extraction of the Crypto bit from the status
    989  *
    990  * status Status to extract the status bit from
    991  */
    992 #define FW_COMN_RESP_CRYPTO_STAT_GET(status)	\
    993 	FIELD_GET(status,	\
    994 			      COMN_RESP_CRYPTO_STATUS_BITPOS,	\
    995 			      COMN_RESP_CRYPTO_STATUS_MASK)
    996 
    997 /*
    998  * Macro for extraction of the PKE bit from the status
    999  *
   1000  * status Status to extract the status bit from
   1001  */
   1002 #define FW_COMN_RESP_PKE_STAT_GET(status)	\
   1003 	FIELD_GET(status,	\
   1004 			      COMN_RESP_PKE_STATUS_BITPOS,	\
   1005 			      COMN_RESP_PKE_STATUS_MASK)
   1006 
   1007 /*
   1008  * Macro for extraction of the Compression bit from the status
   1009  *
   1010  * status Status to extract the status bit from
   1011  */
   1012 #define FW_COMN_RESP_CMP_STAT_GET(status)	\
   1013 	FIELD_GET(status,	\
   1014 			      COMN_RESP_CMP_STATUS_BITPOS,	\
   1015 			      COMN_RESP_CMP_STATUS_MASK)
   1016 
   1017 /*
   1018  * Macro for extraction of the Translator bit from the status
   1019  *
   1020  * status Status to extract the status bit from
   1021  */
   1022 #define FW_COMN_RESP_XLAT_STAT_GET(status)	\
   1023 	FIELD_GET(status,	\
   1024 			      COMN_RESP_XLAT_STATUS_BITPOS,	\
   1025 			      COMN_RESP_XLAT_STATUS_MASK)
   1026 
   1027 /*
   1028  * Macro for extraction of the Translation Workaround Applied bit from the
   1029  * status
   1030  *
   1031  * status Status to extract the status bit from
   1032  */
   1033 #define FW_COMN_RESP_XLT_WA_APPLIED_GET(status)	\
   1034 	FIELD_GET(status,	\
   1035 			      COMN_RESP_XLT_WA_APPLIED_BITPOS,	\
   1036 			      COMN_RESP_XLT_WA_APPLIED_MASK)
   1037 
   1038 /*
   1039  * Macro for extraction of the end of compression block bit from the
   1040  * status
   1041  *
   1042  * status
   1043  * Status to extract the status bit from
   1044  */
   1045 #define FW_COMN_RESP_CMP_END_OF_LAST_BLK_FLAG_GET(status)	\
   1046 	FIELD_GET(status,	\
   1047 			      COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS,	\
   1048 			      COMN_RESP_CMP_END_OF_LAST_BLK_MASK)
   1049 
   1050 /*
   1051  * Macro for extraction of the Unsupported request from the status
   1052  *
   1053  * status
   1054  * Status to extract the status bit from
   1055  */
   1056 #define FW_COMN_RESP_UNSUPPORTED_REQUEST_STAT_GET(status)	\
   1057 	FIELD_GET(status,	\
   1058 			      COMN_RESP_UNSUPPORTED_REQUEST_BITPOS,	\
   1059 			      COMN_RESP_UNSUPPORTED_REQUEST_MASK)
   1060 
   1061 #define FW_COMN_STATUS_FLAG_OK 0
   1062 /* Definition of successful processing of a request  */
   1063 
   1064 #define FW_COMN_STATUS_FLAG_ERROR 1
   1065 /* Definition of erroneous processing of a request  */
   1066 
   1067 #define FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_CLR 0
   1068 /* Final Deflate block of a compression request not completed  */
   1069 
   1070 #define FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_SET 1
   1071 /* Final Deflate block of a compression request completed  */
   1072 
   1073 #define ERR_CODE_NO_ERROR 0
   1074 /* Error Code constant value for no error  */
   1075 
   1076 #define ERR_CODE_INVALID_BLOCK_TYPE -1
   1077 /* Invalid block type (type == 3)*/
   1078 
   1079 #define ERR_CODE_NO_MATCH_ONES_COMP -2
   1080 /* Stored block length does not match one's complement */
   1081 
   1082 #define ERR_CODE_TOO_MANY_LEN_OR_DIS -3
   1083 /* Too many length or distance codes */
   1084 
   1085 #define ERR_CODE_INCOMPLETE_LEN -4
   1086 /* Code lengths codes incomplete */
   1087 
   1088 #define ERR_CODE_RPT_LEN_NO_FIRST_LEN -5
   1089 /* Repeat lengths with no first length */
   1090 
   1091 #define ERR_CODE_RPT_GT_SPEC_LEN -6
   1092 /* Repeat more than specified lengths */
   1093 
   1094 #define ERR_CODE_INV_LIT_LEN_CODE_LEN -7
   1095 /* Invalid lit/len code lengths */
   1096 
   1097 #define ERR_CODE_INV_DIS_CODE_LEN -8
   1098 /* Invalid distance code lengths */
   1099 
   1100 #define ERR_CODE_INV_LIT_LEN_DIS_IN_BLK -9
   1101 /* Invalid lit/len or distance code in fixed/dynamic block */
   1102 
   1103 #define ERR_CODE_DIS_TOO_FAR_BACK -10
   1104 /* Distance too far back in fixed or dynamic block */
   1105 
   1106 /* Common Error code definitions */
   1107 #define ERR_CODE_OVERFLOW_ERROR -11
   1108 /* Error Code constant value for overflow error  */
   1109 
   1110 #define ERR_CODE_SOFT_ERROR -12
   1111 /* Error Code constant value for soft error  */
   1112 
   1113 #define ERR_CODE_FATAL_ERROR -13
   1114 /* Error Code constant value for hard/fatal error  */
   1115 
   1116 #define ERR_CODE_COMP_OUTPUT_CORRUPTION -14
   1117 /* Error Code constant for compression output corruption */
   1118 
   1119 #define ERR_CODE_HW_INCOMPLETE_FILE -15
   1120 /* Error Code constant value for incomplete file hardware error  */
   1121 
   1122 #define ERR_CODE_SSM_ERROR -16
   1123 /* Error Code constant value for error detected by SSM e.g. slice hang  */
   1124 
   1125 #define ERR_CODE_ENDPOINT_ERROR -17
   1126 /* Error Code constant value for error detected by PCIe Endpoint, e.g. push
   1127  * data error   */
   1128 
   1129 #define ERR_CODE_CNV_ERROR -18
   1130 /* Error Code constant value for cnv failure  */
   1131 
   1132 #define ERR_CODE_EMPTY_DYM_BLOCK -19
   1133 /* Error Code constant value for submission of empty dynamic stored block to
   1134  * slice   */
   1135 
   1136 #define ERR_CODE_KPT_CRYPTO_SERVICE_FAIL_INVALID_HANDLE -20
   1137 /* Error Code constant for invalid handle in kpt crypto service */
   1138 
   1139 #define ERR_CODE_KPT_CRYPTO_SERVICE_FAIL_HMAC_FAILED -21
   1140 /* Error Code constant for failed hmac in kpt crypto service */
   1141 
   1142 #define ERR_CODE_KPT_CRYPTO_SERVICE_FAIL_INVALID_WRAPPING_ALGO -22
   1143 /* Error Code constant for invalid wrapping algo in kpt crypto service */
   1144 
   1145 #define ERR_CODE_KPT_DRNG_SEED_NOT_LOAD -23
   1146 /* Error Code constant for no drng seed is not loaded in kpt ecdsa signrs
   1147 /service */
   1148 
   1149 #define FW_LA_ICV_VER_STATUS_PASS FW_COMN_STATUS_FLAG_OK
   1150 /* Status flag indicating that the ICV verification passed  */
   1151 
   1152 #define FW_LA_ICV_VER_STATUS_FAIL FW_COMN_STATUS_FLAG_ERROR
   1153 /* Status flag indicating that the ICV verification failed  */
   1154 
   1155 #define FW_LA_TRNG_STATUS_PASS FW_COMN_STATUS_FLAG_OK
   1156 /* Status flag indicating that the TRNG returned valid entropy data  */
   1157 
   1158 #define FW_LA_TRNG_STATUS_FAIL FW_COMN_STATUS_FLAG_ERROR
   1159 /* Status flag indicating that the TRNG Command Failed.  */
   1160 
   1161 /* -------------------------------------------------------------------------- */
   1162 
   1163 /*
   1164  * Definition of the full bulk processing request structure.
   1165  * Used for hash, cipher, hash-cipher and authentication-encryption
   1166  * requests etc.
   1167  */
   1168 struct fw_la_bulk_req
   1169 {
   1170 	/* LWs 0-1 */
   1171 	struct fw_comn_req_hdr comn_hdr;
   1172 	/* Common request header - for Service Command Id,
   1173 	 * use service-specific Crypto Command Id.
   1174 	 * Service Specific Flags - use Symmetric Crypto Command Flags
   1175 	 * (all of cipher, auth, SSL3, TLS and MGF,
   1176 	 * excluding TRNG - field unused) */
   1177 
   1178 	/* LWs 2-5 */
   1179 	union fw_comn_req_hdr_cd_pars cd_pars;
   1180 	/* Common Request content descriptor field which points either to a
   1181 	 * content descriptor
   1182 	 * parameter block or contains the service-specific data itself. */
   1183 
   1184 	/* LWs 6-13 */
   1185 	struct fw_comn_req_mid comn_mid;
   1186 	/* Common request middle section */
   1187 
   1188 	/* LWs 14-26 */
   1189 	struct fw_comn_req_rqpars serv_specif_rqpars;
   1190 	/* Common request service-specific parameter field */
   1191 
   1192 	/* LWs 27-31 */
   1193 	struct fw_comn_req_cd_ctrl cd_ctrl;
   1194 	/* Common request content descriptor control block -
   1195 	 * this field is service-specific */
   1196 
   1197 };
   1198 
   1199 /* clang-format off */
   1200 
   1201 /*
   1202  *  LA BULK (SYMMETRIC CRYPTO) COMMAND FLAGS
   1203  *
   1204  *  + ===== + ---------- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- +
   1205  *  |  Bit  |   [15:13]  |  12   |  11   |  10   |  7-9  |   6   |   5   |   4   |  3    |   2   |  1-0  |
   1206  *  + ===== + ---------- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ------+ ----- +
   1207  *  | Flags | Resvd Bits | ZUC   | GcmIV |Digest | Prot  | Cmp   | Rtn   | Upd   | Ciph/ | CiphIV| Part- |
   1208  *  |       |     =0     | Prot  | Len   | In Buf| flgs  | Auth  | Auth  | State | Auth  | Field |  ial  |
   1209  *  + ===== + ---------- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ------+ ----- +
   1210  */
   1211 
   1212 /* clang-format on */
   1213 
   1214 /* Private defines */
   1215 
   1216 #define FW_LA_ZUC_3G_PROTO			__BIT(12)
   1217 /* Indicating ZUC processing for a encrypt command
   1218  * Must be set for Cipher-only, Cipher + Auth and Auth-only   */
   1219 
   1220 #define FW_LA_GCM_IV_LEN_12_OCTETS		__BIT(11)
   1221 /* Indicates the IV Length for GCM protocol is 96 Bits (12 Octets)
   1222  * If set FW does the padding to compute CTR0  */
   1223 
   1224 #define FW_LA_DIGEST_IN_BUFFER			__BIT(10)
   1225 /* Flag representing that authentication digest is stored or is extracted
   1226  * from the source buffer. Auth Result Pointer will be ignored in this case.  */
   1227 
   1228 #define FW_LA_PRORO				__BITS(7, 9)
   1229 #define FW_LA_PROTO_SNOW_3G			4
   1230 /* Indicates SNOW_3G processing for a encrypt command  */
   1231 #define FW_LA_PROTO_GCM				2
   1232 /* Indicates GCM processing for a auth_encrypt command  */
   1233 #define FW_LA_PROTO_CCM				1
   1234 /* Indicates CCM processing for a auth_encrypt command  */
   1235 #define FW_LA_PROTO_NO				0
   1236 /* Indicates no specific protocol processing for the command  */
   1237 
   1238 #define FW_LA_CMP_AUTH_RES			__BIT(6)
   1239 /* Flag representing the need to compare the auth result data to the expected
   1240  * value in DRAM at the auth_address.  */
   1241 
   1242 #define FW_LA_RET_AUTH_RES			__BIT(5)
   1243 /* Flag representing the need to return the auth result data to dram after the
   1244  * request processing is complete  */
   1245 
   1246 #define FW_LA_UPDATE_STATE			__BIT(4)
   1247 /* Flag representing the need to update the state data in dram after the
   1248  * request processing is complete  */
   1249 
   1250 #define FW_CIPH_AUTH_CFG_OFFSET_IN_SHRAM_CP	__BIT(3)
   1251 /* Flag representing Cipher/Auth Config Offset Type, where the offset
   1252  * is contained in SHRAM constants page. When the SHRAM constants page
   1253  * is not used for cipher/auth configuration, then the Content Descriptor
   1254  * pointer field must be a pointer (as opposed to a 16-byte key), since
   1255  * the block pointed to must contain both the slice config and the key  */
   1256 
   1257 #define FW_CIPH_IV_16BYTE_DATA			__BIT(2)
   1258 /* Flag representing Cipher IV field contents as 16-byte data array
   1259  * Otherwise Cipher IV field contents via 64-bit pointer */
   1260 
   1261 #define FW_LA_PARTIAL				__BITS(0, 1)
   1262 #define FW_LA_PARTIAL_NONE			0
   1263 /* Flag representing no need for partial processing condition i.e.
   1264  * entire packet processed in the current command  */
   1265 #define FW_LA_PARTIAL_START			1
   1266 /* Flag representing the first chunk of the partial packet  */
   1267 #define FW_LA_PARTIAL_MID			3
   1268 /* Flag representing a middle chunk of the partial packet  */
   1269 #define FW_LA_PARTIAL_END			2
   1270 /* Flag representing the final/end chunk of the partial packet  */
   1271 
   1272 /* The table below defines the meaning of the prefix_addr & hash_state_sz in
   1273  * the case of partial processing. See the HLD for further details
   1274  *
   1275  *  + ====== + ------------------------- + ----------------------- +
   1276  *  | Parial |       Prefix Addr         |       Hash State Sz     |
   1277  *  | State  |                           |                         |
   1278  *  + ====== + ------------------------- + ----------------------- +
   1279  *  |  FULL  | Points to the prefix data | Prefix size as below.   |
   1280  *  |        |                           | No update of state      |
   1281  *  + ====== + ------------------------- + ----------------------- +
   1282  *  |  SOP   | Points to the prefix      | = inner prefix rounded  |
   1283  *  |        | data. State is updated    | to qwrds + outer prefix |
   1284  *  |        | at prefix_addr - state_sz | rounded to qwrds. The   |
   1285  *  |        | - 8 (counter size)        | writeback state sz      |
   1286  *  |        |                           | comes from the CD       |
   1287  *  + ====== + ------------------------- + ----------------------- +
   1288  *  |  MOP   | Points to the state data  | State size rounded to   |
   1289  *  |        | Updated state written to  | num qwrds + 8 (for the  |
   1290  *  |        | same location             | counter) + inner prefix |
   1291  *  |        |                           | rounded to qwrds +      |
   1292  *  |        |                           | outer prefix rounded to |
   1293  *  |        |                           | qwrds.                  |
   1294  *  + ====== + ------------------------- + ----------------------- +
   1295  *  |  EOP   | Points to the state data  | State size rounded to   |
   1296  *  |        |                           | num qwrds + 8 (for the  |
   1297  *  |        |                           | counter) + inner prefix |
   1298  *  |        |                           | rounded to qwrds +      |
   1299  *  |        |                           | outer prefix rounded to |
   1300  *  |        |                           | qwrds.                  |
   1301  *  + ====== + ------------------------- + ----------------------- +
   1302  *
   1303  *  Notes:
   1304  *
   1305  *  - If the EOP is set it is assumed that no state update is to be performed.
   1306  *    However it is the clients responsibility to set the update_state flag
   1307  *    correctly i.e. not set for EOP or Full packet cases. Only set for SOP and
   1308  *    MOP with no EOP flag
   1309  *  - The SOP take precedence over the MOP and EOP i.e. in the calculation of
   1310  *    the address to writeback the state.
   1311  *  - The prefix address must be on at least the 8 byte boundary
   1312  */
   1313 
   1314 /* Macros for extracting field bits */
   1315 /*
   1316  *   Macro for extraction of the Cipher IV field contents (bit 2)
   1317  *
   1318  * flags        Flags to extract the Cipher IV field contents
   1319  *
   1320  */
   1321 #define FW_LA_CIPH_IV_FLD_FLAG_GET(flags)	\
   1322 	FIELD_GET(flags, LA_CIPH_IV_FLD_BITPOS, LA_CIPH_IV_FLD_MASK)
   1323 
   1324 /*
   1325  *   Macro for extraction of the Cipher/Auth Config
   1326  *   offset type (bit 3)
   1327  *
   1328  * flags        Flags to extract the Cipher/Auth Config offset type
   1329  *
   1330  */
   1331 #define FW_LA_CIPH_AUTH_CFG_OFFSET_FLAG_GET(flags)	\
   1332 	FIELD_GET(flags,	\
   1333 	    LA_CIPH_AUTH_CFG_OFFSET_BITPOS,	\
   1334 	    LA_CIPH_AUTH_CFG_OFFSET_MASK)
   1335 
   1336 /*
   1337  * Macro for extraction of the ZUC protocol bit
   1338  * information (bit 11)
   1339  *
   1340  * flags        Flags to extract the ZUC protocol bit
   1341  */
   1342 #define FW_LA_ZUC_3G_PROTO_FLAG_GET(flags)	\
   1343 	FIELD_GET(flags,	\
   1344 	    FW_LA_ZUC_3G_PROTO_FLAG_BITPOS,	\
   1345 	    FW_LA_ZUC_3G_PROTO_FLAG_MASK)
   1346 
   1347 /*
   1348  * Macro for extraction of the GCM IV Len is 12 Octets / 96 Bits
   1349  * information (bit 11)
   1350  *
   1351  * flags        Flags to extract the GCM IV length
   1352  */
   1353 #define FW_LA_GCM_IV_LEN_FLAG_GET(flags)	\
   1354 	FIELD_GET(	\
   1355 		flags, LA_GCM_IV_LEN_FLAG_BITPOS, LA_GCM_IV_LEN_FLAG_MASK)
   1356 
   1357 /*
   1358  * Macro for extraction of the LA protocol state (bits 9-7)
   1359  *
   1360  * flags        Flags to extract the protocol state
   1361  */
   1362 #define FW_LA_PROTO_GET(flags)	\
   1363 	FIELD_GET(flags, LA_PROTO_BITPOS, LA_PROTO_MASK)
   1364 
   1365 /*
   1366  * Macro for extraction of the "compare auth" state (bit 6)
   1367  *
   1368  * flags        Flags to extract the compare auth result state
   1369  *
   1370  */
   1371 #define FW_LA_CMP_AUTH_GET(flags)	\
   1372 	FIELD_GET(flags, LA_CMP_AUTH_RES_BITPOS, LA_CMP_AUTH_RES_MASK)
   1373 
   1374 /*
   1375  * Macro for extraction of the "return auth" state (bit 5)
   1376  *
   1377  * flags        Flags to extract the return auth result state
   1378  *
   1379  */
   1380 #define FW_LA_RET_AUTH_GET(flags)	\
   1381 	FIELD_GET(flags, LA_RET_AUTH_RES_BITPOS, LA_RET_AUTH_RES_MASK)
   1382 
   1383 /*
   1384  * Macro for extraction of the "digest in buffer" state (bit 10)
   1385  *
   1386  * flags     Flags to extract the digest in buffer state
   1387  *
   1388  */
   1389 #define FW_LA_DIGEST_IN_BUFFER_GET(flags)	\
   1390 	FIELD_GET(	\
   1391 		flags, LA_DIGEST_IN_BUFFER_BITPOS, LA_DIGEST_IN_BUFFER_MASK)
   1392 
   1393 /*
   1394  * Macro for extraction of the update content state value. (bit 4)
   1395  *
   1396  * flags        Flags to extract the update content state bit
   1397  */
   1398 #define FW_LA_UPDATE_STATE_GET(flags)	\
   1399 	FIELD_GET(flags, LA_UPDATE_STATE_BITPOS, LA_UPDATE_STATE_MASK)
   1400 
   1401 /*
   1402  * Macro for extraction of the "partial" packet state (bits 1-0)
   1403  *
   1404  * flags        Flags to extract the partial state
   1405  */
   1406 #define FW_LA_PARTIAL_GET(flags)	\
   1407 	FIELD_GET(flags, LA_PARTIAL_BITPOS, LA_PARTIAL_MASK)
   1408 
   1409 /* Macros for setting field bits */
   1410 /*
   1411  *   Macro for setting the Cipher IV field contents
   1412  *
   1413  * flags        Flags to set with the Cipher IV field contents
   1414  * val          Field contents indicator value
   1415  */
   1416 #define FW_LA_CIPH_IV_FLD_FLAG_SET(flags, val)	\
   1417 	FIELD_SET(	\
   1418 		flags, val, LA_CIPH_IV_FLD_BITPOS, LA_CIPH_IV_FLD_MASK)
   1419 
   1420 /*
   1421  * Macro for setting the Cipher/Auth Config
   1422  * offset type
   1423  *
   1424  * flags        Flags to set the Cipher/Auth Config offset type
   1425  * val          Offset type value
   1426  */
   1427 #define FW_LA_CIPH_AUTH_CFG_OFFSET_FLAG_SET(flags, val)	\
   1428 	FIELD_SET(flags,	\
   1429 	    val,	\
   1430 	    LA_CIPH_AUTH_CFG_OFFSET_BITPOS,	\
   1431 	    LA_CIPH_AUTH_CFG_OFFSET_MASK)
   1432 
   1433 /*
   1434  * Macro for setting the ZUC protocol flag
   1435  *
   1436  * flags      Flags to set the ZUC protocol flag
   1437  * val        Protocol value
   1438  */
   1439 #define FW_LA_ZUC_3G_PROTO_FLAG_SET(flags, val)	\
   1440 	FIELD_SET(flags,	\
   1441 	    val,	\
   1442 	    FW_LA_ZUC_3G_PROTO_FLAG_BITPOS,	\
   1443 	    FW_LA_ZUC_3G_PROTO_FLAG_MASK)
   1444 
   1445 /*
   1446  * Macro for setting the GCM IV length flag state
   1447  *
   1448  * flags      Flags to set the GCM IV length flag state
   1449  * val        Protocol value
   1450  */
   1451 #define FW_LA_GCM_IV_LEN_FLAG_SET(flags, val)	\
   1452 	FIELD_SET(flags,	\
   1453 	    val,	\
   1454 	    LA_GCM_IV_LEN_FLAG_BITPOS,	\
   1455 	    LA_GCM_IV_LEN_FLAG_MASK)
   1456 
   1457 /*
   1458  * Macro for setting the LA protocol flag state
   1459  *
   1460  * flags        Flags to set the protocol state
   1461  * val          Protocol value
   1462  */
   1463 #define FW_LA_PROTO_SET(flags, val)	\
   1464 	FIELD_SET(flags, val, LA_PROTO_BITPOS, LA_PROTO_MASK)
   1465 
   1466 /*
   1467  * Macro for setting the "compare auth" flag state
   1468  *
   1469  * flags      Flags to set the compare auth result state
   1470  * val        Compare Auth value
   1471  */
   1472 #define FW_LA_CMP_AUTH_SET(flags, val)	\
   1473 	FIELD_SET(	\
   1474 		flags, val, LA_CMP_AUTH_RES_BITPOS, LA_CMP_AUTH_RES_MASK)
   1475 
   1476 /*
   1477  * Macro for setting the "return auth" flag state
   1478  *
   1479  * flags      Flags to set the return auth result state
   1480  * val        Return Auth value
   1481  */
   1482 #define FW_LA_RET_AUTH_SET(flags, val)	\
   1483 	FIELD_SET(	\
   1484 		flags, val, LA_RET_AUTH_RES_BITPOS, LA_RET_AUTH_RES_MASK)
   1485 
   1486 /*
   1487  * Macro for setting the "digest in buffer" flag state
   1488  *
   1489  * flags     Flags to set the digest in buffer state
   1490  * val       Digest in buffer value
   1491  */
   1492 #define FW_LA_DIGEST_IN_BUFFER_SET(flags, val)	\
   1493 	FIELD_SET(flags,	\
   1494 	    val,	\
   1495 	    LA_DIGEST_IN_BUFFER_BITPOS,	\
   1496 	    LA_DIGEST_IN_BUFFER_MASK)
   1497 
   1498 /*
   1499  *   Macro for setting the "update state" flag value
   1500  *
   1501  * flags      Flags to set the update content state
   1502  * val        Update Content State flag value
   1503  */
   1504 #define FW_LA_UPDATE_STATE_SET(flags, val)	\
   1505 	FIELD_SET(	\
   1506 		flags, val, LA_UPDATE_STATE_BITPOS, LA_UPDATE_STATE_MASK)
   1507 
   1508 /*
   1509  *   Macro for setting the "partial" packet flag state
   1510  *
   1511  * flags      Flags to set the partial state
   1512  * val        Partial state value
   1513  */
   1514 #define FW_LA_PARTIAL_SET(flags, val)	\
   1515 	FIELD_SET(flags, val, LA_PARTIAL_BITPOS, LA_PARTIAL_MASK)
   1516 
   1517 /*
   1518  * Definition of the Cipher header Content Descriptor pars block
   1519  * Definition of the cipher processing header cd pars block.
   1520  * The structure is a service-specific implementation of the common
   1521  * 'fw_comn_req_hdr_cd_pars_s' structure.
   1522  */
   1523 union fw_cipher_req_hdr_cd_pars {
   1524 	/* LWs 2-5 */
   1525 	struct
   1526 	{
   1527 		uint64_t content_desc_addr;
   1528 		/* Address of the content descriptor */
   1529 
   1530 		uint16_t content_desc_resrvd1;
   1531 		/* Content descriptor reserved field */
   1532 
   1533 		uint8_t content_desc_params_sz;
   1534 		/* Size of the content descriptor parameters in quad words. These
   1535 		 * parameters describe the session setup configuration info for the
   1536 		 * slices that this request relies upon i.e. the configuration word and
   1537 		 * cipher key needed by the cipher slice if there is a request for
   1538 		 * cipher processing. */
   1539 
   1540 		uint8_t content_desc_hdr_resrvd2;
   1541 		/* Content descriptor reserved field */
   1542 
   1543 		uint32_t content_desc_resrvd3;
   1544 		/* Content descriptor reserved field */
   1545 	} s;
   1546 
   1547 	struct
   1548 	{
   1549 		uint32_t cipher_key_array[FW_NUM_LONGWORDS_4];
   1550 		/* Cipher Key Array */
   1551 
   1552 	} s1;
   1553 
   1554 };
   1555 
   1556 /*
   1557  * Definition of the Authentication header Content Descriptor pars block
   1558  * Definition of the authentication processing header cd pars block.
   1559  */
   1560 /* Note: Authentication uses the common 'fw_comn_req_hdr_cd_pars_s'
   1561  * structure - similarly, it is also used by SSL3, TLS and MGF. Only cipher
   1562  * and cipher + authentication require service-specific implementations of
   1563  * the structure  */
   1564 
   1565 /*
   1566  * Definition of the Cipher + Auth header Content Descriptor pars block
   1567  * Definition of the cipher + auth processing header cd pars block.
   1568  * The structure is a service-specific implementation of the common
   1569  * 'fw_comn_req_hdr_cd_pars_s' structure.
   1570  */
   1571 union fw_cipher_auth_req_hdr_cd_pars {
   1572 	/* LWs 2-5 */
   1573 	struct
   1574 	{
   1575 		uint64_t content_desc_addr;
   1576 		/* Address of the content descriptor */
   1577 
   1578 		uint16_t content_desc_resrvd1;
   1579 		/* Content descriptor reserved field */
   1580 
   1581 		uint8_t content_desc_params_sz;
   1582 		/* Size of the content descriptor parameters in quad words. These
   1583 		 * parameters describe the session setup configuration info for the
   1584 		 * slices that this request relies upon i.e. the configuration word and
   1585 		 * cipher key needed by the cipher slice if there is a request for
   1586 		 * cipher processing. */
   1587 
   1588 		uint8_t content_desc_hdr_resrvd2;
   1589 		/* Content descriptor reserved field */
   1590 
   1591 		uint32_t content_desc_resrvd3;
   1592 		/* Content descriptor reserved field */
   1593 	} s;
   1594 
   1595 	struct
   1596 	{
   1597 		uint32_t cipher_key_array[FW_NUM_LONGWORDS_4];
   1598 		/* Cipher Key Array */
   1599 
   1600 	} sl;
   1601 
   1602 };
   1603 
   1604 /*
   1605  * Cipher content descriptor control block (header)
   1606  * Definition of the service-specific cipher control block header
   1607  * structure. This header forms part of the content descriptor
   1608  * block incorporating LWs 27-31, as defined by the common base
   1609  * parameters structure.
   1610  */
   1611 struct fw_cipher_cd_ctrl_hdr
   1612 {
   1613 	/* LW 27 */
   1614 	uint8_t cipher_state_sz;
   1615 	/* State size in quad words of the cipher algorithm used in this session.
   1616 	 * Set to zero if the algorithm doesnt provide any state */
   1617 
   1618 	uint8_t cipher_key_sz;
   1619 	/* Key size in quad words of the cipher algorithm used in this session */
   1620 
   1621 	uint8_t cipher_cfg_offset;
   1622 	/* Quad word offset from the content descriptor parameters address i.e.
   1623 	 * (content_address + (cd_hdr_sz << 3)) to the parameters for the cipher
   1624 	 * processing */
   1625 
   1626 	uint8_t next_curr_id;
   1627 	/* This field combines the next and current id (each four bits) -
   1628 	  * the next id is the most significant nibble.
   1629 	  * Next Id:  Set to the next slice to pass the ciphered data through.
   1630 	  * Set to FW_SLICE_DRAM_WR if the data is not to go through
   1631 	  * any more slices after cipher.
   1632 	  * Current Id: Initialised with the cipher  slice type */
   1633 
   1634 	/* LW 28 */
   1635 	uint8_t cipher_padding_sz;
   1636 	/* State padding size in quad words. Set to 0 if no padding is required.
   1637 	 */
   1638 
   1639 	uint8_t resrvd1;
   1640 	uint16_t resrvd2;
   1641 	/* Reserved bytes to bring the struct to the word boundary, used by
   1642 	 * authentication. MUST be set to 0 */
   1643 
   1644 	/* LWs 29-31 */
   1645 	uint32_t resrvd3[FW_NUM_LONGWORDS_3];
   1646 	/* Reserved bytes used by authentication. MUST be set to 0 */
   1647 
   1648 };
   1649 
   1650 /*
   1651  * Authentication content descriptor control block (header)
   1652  * Definition of the service-specific authentication control block
   1653  * header structure. This header forms part of the content descriptor
   1654  * block incorporating LWs 27-31, as defined by the common base
   1655  * parameters structure, the first portion of which is reserved for
   1656  * cipher.
   1657  */
   1658 struct fw_auth_cd_ctrl_hdr
   1659 {
   1660 	/* LW 27 */
   1661 	uint32_t resrvd1;
   1662 	/* Reserved bytes, used by cipher only. MUST be set to 0 */
   1663 
   1664 	/* LW 28 */
   1665 	uint8_t resrvd2;
   1666 	/* Reserved byte, used by cipher only. MUST be set to 0 */
   1667 
   1668 	uint8_t hash_flags;
   1669 	/* General flags defining the processing to perform. 0 is normal
   1670 	 * processing
   1671 	 * and 1 means there is a nested hash processing loop to go through */
   1672 
   1673 	uint8_t hash_cfg_offset;
   1674 	/* Quad word offset from the content descriptor parameters address to the
   1675 	 * parameters for the auth processing */
   1676 
   1677 	uint8_t next_curr_id;
   1678 	/* This field combines the next and current id (each four bits) -
   1679 	  * the next id is the most significant nibble.
   1680 	  * Next Id:  Set to the next slice to pass the authentication data through.
   1681 	  * Set to FW_SLICE_DRAM_WR if the data is not to go through
   1682 	  * any more slices after authentication.
   1683 	  * Current Id: Initialised with the authentication slice type */
   1684 
   1685 	/* LW 29 */
   1686 	uint8_t resrvd3;
   1687 	/* Now a reserved field. MUST be set to 0 */
   1688 
   1689 	uint8_t outer_prefix_sz;
   1690 	/* Size in bytes of outer prefix data */
   1691 
   1692 	uint8_t final_sz;
   1693 	/* Size in bytes of digest to be returned to the client if requested */
   1694 
   1695 	uint8_t inner_res_sz;
   1696 	/* Size in bytes of the digest from the inner hash algorithm */
   1697 
   1698 	/* LW 30 */
   1699 	uint8_t resrvd4;
   1700 	/* Now a reserved field. MUST be set to zero. */
   1701 
   1702 	uint8_t inner_state1_sz;
   1703 	/* Size in bytes of inner hash state1 data. Must be a qword multiple */
   1704 
   1705 	uint8_t inner_state2_offset;
   1706 	/* Quad word offset from the content descriptor parameters pointer to the
   1707 	 * inner state2 value */
   1708 
   1709 	uint8_t inner_state2_sz;
   1710 	/* Size in bytes of inner hash state2 data. Must be a qword multiple */
   1711 
   1712 	/* LW 31 */
   1713 	uint8_t outer_config_offset;
   1714 	/* Quad word offset from the content descriptor parameters pointer to the
   1715 	 * outer configuration information */
   1716 
   1717 	uint8_t outer_state1_sz;
   1718 	/* Size in bytes of the outer state1 value */
   1719 
   1720 	uint8_t outer_res_sz;
   1721 	/* Size in bytes of digest from the outer auth algorithm */
   1722 
   1723 	uint8_t outer_prefix_offset;
   1724 	/* Quad word offset from the start of the inner prefix data to the outer
   1725 	 * prefix information. Should equal the rounded inner prefix size, converted
   1726 	 * to qwords  */
   1727 
   1728 };
   1729 
   1730 /*
   1731  * Cipher + Authentication content descriptor control block header
   1732  * Definition of both service-specific cipher + authentication control
   1733  * block header structures. This header forms part of the content
   1734  * descriptor block incorporating LWs 27-31, as defined by the common
   1735  * base  parameters structure.
   1736  */
   1737 struct fw_cipher_auth_cd_ctrl_hdr
   1738 {
   1739 	/* LW 27 */
   1740 	uint8_t cipher_state_sz;
   1741 	/* State size in quad words of the cipher algorithm used in this session.
   1742 	 * Set to zero if the algorithm doesnt provide any state */
   1743 
   1744 	uint8_t cipher_key_sz;
   1745 	/* Key size in quad words of the cipher algorithm used in this session */
   1746 
   1747 	uint8_t cipher_cfg_offset;
   1748 	/* Quad word offset from the content descriptor parameters address i.e.
   1749 	 * (content_address + (cd_hdr_sz << 3)) to the parameters for the cipher
   1750 	 * processing */
   1751 
   1752 	uint8_t next_curr_id_cipher;
   1753 	/* This field combines the next and current id (each four bits) -
   1754 	  * the next id is the most significant nibble.
   1755 	  * Next Id:  Set to the next slice to pass the ciphered data through.
   1756 	  * Set to FW_SLICE_DRAM_WR if the data is not to go through
   1757 	  * any more slices after cipher.
   1758 	  * Current Id: Initialised with the cipher  slice type */
   1759 
   1760 	/* LW 28 */
   1761 	uint8_t cipher_padding_sz;
   1762 	/* State padding size in quad words. Set to 0 if no padding is required.
   1763 	 */
   1764 
   1765 	uint8_t hash_flags;
   1766 	/* General flags defining the processing to perform. 0 is normal
   1767 	 * processing
   1768 	 * and 1 means there is a nested hash processing loop to go through */
   1769 
   1770 	uint8_t hash_cfg_offset;
   1771 	/* Quad word offset from the content descriptor parameters address to the
   1772 	 * parameters for the auth processing */
   1773 
   1774 	uint8_t next_curr_id_auth;
   1775 	/* This field combines the next and current id (each four bits) -
   1776 	  * the next id is the most significant nibble.
   1777 	  * Next Id:  Set to the next slice to pass the authentication data through.
   1778 	  * Set to FW_SLICE_DRAM_WR if the data is not to go through
   1779 	  * any more slices after authentication.
   1780 	  * Current Id: Initialised with the authentication slice type */
   1781 
   1782 	/* LW 29 */
   1783 	uint8_t resrvd1;
   1784 	/* Reserved field. MUST be set to 0 */
   1785 
   1786 	uint8_t outer_prefix_sz;
   1787 	/* Size in bytes of outer prefix data */
   1788 
   1789 	uint8_t final_sz;
   1790 	/* Size in bytes of digest to be returned to the client if requested */
   1791 
   1792 	uint8_t inner_res_sz;
   1793 	/* Size in bytes of the digest from the inner hash algorithm */
   1794 
   1795 	/* LW 30 */
   1796 	uint8_t resrvd2;
   1797 	/* Now a reserved field. MUST be set to zero. */
   1798 
   1799 	uint8_t inner_state1_sz;
   1800 	/* Size in bytes of inner hash state1 data. Must be a qword multiple */
   1801 
   1802 	uint8_t inner_state2_offset;
   1803 	/* Quad word offset from the content descriptor parameters pointer to the
   1804 	 * inner state2 value */
   1805 
   1806 	uint8_t inner_state2_sz;
   1807 	/* Size in bytes of inner hash state2 data. Must be a qword multiple */
   1808 
   1809 	/* LW 31 */
   1810 	uint8_t outer_config_offset;
   1811 	/* Quad word offset from the content descriptor parameters pointer to the
   1812 	 * outer configuration information */
   1813 
   1814 	uint8_t outer_state1_sz;
   1815 	/* Size in bytes of the outer state1 value */
   1816 
   1817 	uint8_t outer_res_sz;
   1818 	/* Size in bytes of digest from the outer auth algorithm */
   1819 
   1820 	uint8_t outer_prefix_offset;
   1821 	/* Quad word offset from the start of the inner prefix data to the outer
   1822 	 * prefix information. Should equal the rounded inner prefix size, converted
   1823 	 * to qwords  */
   1824 
   1825 };
   1826 
   1827 #define FW_AUTH_HDR_FLAG_DO_NESTED 1
   1828 /* Definition of the hash_flags bit of the auth_hdr to indicate the request
   1829  * requires nested hashing  */
   1830 
   1831 #define FW_AUTH_HDR_FLAG_NO_NESTED 0
   1832 /* Definition of the hash_flags bit of the auth_hdr for no nested hashing
   1833  * required  */
   1834 
   1835 #define FW_CCM_GCM_AAD_SZ_MAX 240
   1836 /* Maximum size of AAD data allowed for CCM or GCM processing. AAD data size90 -
   1837  * is stored in 8-bit field and must be multiple of hash block size. 240 is
   1838  * largest value which satisfy both requirements.AAD_SZ_MAX is in byte units  */
   1839 
   1840 /*
   1841  * request parameter #defines
   1842  */
   1843 #define FW_HASH_REQUEST_PARAMETERS_OFFSET	\
   1844 	(sizeof(fw_la_cipher_req_params_t))
   1845 /* Offset in bytes from the start of the request parameters block to the hash
   1846  * (auth) request parameters  */
   1847 
   1848 #define FW_CIPHER_REQUEST_PARAMETERS_OFFSET (0)
   1849 /* Offset in bytes from the start of the request parameters block to the cipher
   1850  * request parameters  */
   1851 
   1852 /*
   1853  * Definition of the cipher request parameters block
   1854  *
   1855  * Definition of the cipher processing request parameters block
   1856  * structure, which forms part of the block incorporating LWs 14-26,
   1857  * as defined by the common base parameters structure.
   1858  * Unused fields must be set to 0.
   1859  */
   1860 struct fw_la_cipher_req_params
   1861 {
   1862 	/* LW 14 */
   1863 	uint32_t cipher_offset;
   1864 	/* Cipher offset long word. */
   1865 
   1866 	/* LW 15 */
   1867 	uint32_t cipher_length;
   1868 	/* Cipher length long word. */
   1869 
   1870 	/* LWs 16-19 */
   1871 	union {
   1872 		uint32_t cipher_IV_array[FW_NUM_LONGWORDS_4];
   1873 		/* Cipher IV array  */
   1874 
   1875 		struct
   1876 		{
   1877 			uint64_t cipher_IV_ptr;
   1878 			/* Cipher IV pointer or Partial State Pointer */
   1879 
   1880 			uint64_t resrvd1;
   1881 			/* reserved */
   1882 
   1883 		} s;
   1884 
   1885 	} u;
   1886 
   1887 };
   1888 
   1889 /*
   1890  * Definition of the auth request parameters block
   1891  * Definition of the authentication processing request parameters block
   1892  * structure, which forms part of the block incorporating LWs 14-26,
   1893  * as defined by the common base parameters structure. Note:
   1894  * This structure is used by TLS only.
   1895  */
   1896 /* Pack compiler directive added to prevent the
   1897  * compiler from padding this structure to a 64-bit boundary  */
   1898 #pragma pack(push, 1)
   1899 
   1900 struct fw_la_auth_req_params
   1901 {
   1902 	/* LW 20 */
   1903 	uint32_t auth_off;
   1904 	/* Byte offset from the start of packet to the auth data region */
   1905 
   1906 	/* LW 21 */
   1907 	uint32_t auth_len;
   1908 	/* Byte length of the auth data region */
   1909 
   1910 	/* LWs 22-23 */
   1911 	union {
   1912 		uint64_t auth_partial_st_prefix;
   1913 		/* Address of the authentication partial state prefix
   1914 		 * information */
   1915 
   1916 		uint64_t aad_adr;
   1917 		/* Address of the AAD info in DRAM. Used for the CCM and GCM
   1918 		 * protocols */
   1919 
   1920 	} u1;
   1921 
   1922 	/* LWs 24-25 */
   1923 	uint64_t auth_res_addr;
   1924 	/* Address of the authentication result information to validate or
   1925 	 * the location to which the digest information can be written back to */
   1926 
   1927 	/* LW 26 */
   1928 	union {
   1929 		uint8_t inner_prefix_sz;
   1930 		/* Size in bytes of the inner prefix data */
   1931 
   1932 		uint8_t aad_sz;
   1933 		/* Size in bytes of padded AAD data to prefix to the packet for CCM
   1934 		 *  or GCM processing */
   1935 	} u2;
   1936 
   1937 	uint8_t resrvd1;
   1938 	/* reserved */
   1939 
   1940 	uint8_t hash_state_sz;
   1941 	/* Number of quad words of inner and outer hash prefix data to process
   1942 	 * Maximum size is 240 */
   1943 
   1944 	uint8_t auth_res_sz;
   1945 	/* Size in bytes of the authentication result */
   1946 
   1947 };
   1948 
   1949 #pragma pack(pop)
   1950 
   1951 /*
   1952  * Definition of the auth request parameters block
   1953  * Definition of the authentication processing request parameters block
   1954  * structure, which forms part of the block incorporating LWs 14-26,
   1955  * as defined by the common base parameters structure. Note:
   1956  * This structure is used by SSL3 and MGF1 only. All fields other than
   1957  * inner prefix/ AAD size are unused and therefore reserved.
   1958  */
   1959 struct fw_la_auth_req_params_resrvd_flds
   1960 {
   1961 	/* LWs 20-25 */
   1962 	uint32_t resrvd[FW_NUM_LONGWORDS_6];
   1963 
   1964 	/* LW 26 */
   1965 	union {
   1966 		uint8_t inner_prefix_sz;
   1967 		/* Size in bytes of the inner prefix data */
   1968 
   1969 		uint8_t aad_sz;
   1970 		/* Size in bytes of padded AAD data to prefix to the packet for CCM
   1971 		 *  or GCM processing */
   1972 	} u2;
   1973 
   1974 	uint8_t resrvd1;
   1975 	/* reserved */
   1976 
   1977 	uint16_t resrvd2;
   1978 	/* reserved */
   1979 
   1980 };
   1981 
   1982 /*
   1983  *   Definition of the shared fields within the parameter block
   1984  *   containing SSL, TLS or MGF information.
   1985  *   This structure defines the shared fields for SSL, TLS or MGF
   1986  *   within the parameter block incorporating LWs 14-26, as defined
   1987  *   by the common base parameters structure.
   1988  *   Unused fields must be set to 0.
   1989  */
   1990 struct fw_la_key_gen_common
   1991 {
   1992 	/* LW 14 */
   1993 	union {
   1994 		/* SSL3 */
   1995 		uint16_t secret_lgth_ssl;
   1996 		/* Length of Secret information for SSL. In the case of TLS the
   1997 		* secret is supplied in the content descriptor */
   1998 
   1999 		/* MGF */
   2000 		uint16_t mask_length;
   2001 		/* Size in bytes of the desired output mask for MGF1*/
   2002 
   2003 		/* TLS */
   2004 		uint16_t secret_lgth_tls;
   2005 		/* TLS Secret length */
   2006 
   2007 	} u;
   2008 
   2009 	union {
   2010 		/* SSL3 */
   2011 		struct
   2012 		{
   2013 			uint8_t output_lgth_ssl;
   2014 			/* Output length */
   2015 
   2016 			uint8_t label_lgth_ssl;
   2017 			/* Label length */
   2018 
   2019 		} s1;
   2020 
   2021 		/* MGF */
   2022 		struct
   2023 		{
   2024 			uint8_t hash_length;
   2025 			/* Hash length */
   2026 
   2027 			uint8_t seed_length;
   2028 			/* Seed length */
   2029 
   2030 		} s2;
   2031 
   2032 		/* TLS */
   2033 		struct
   2034 		{
   2035 			uint8_t output_lgth_tls;
   2036 			/* Output length */
   2037 
   2038 			uint8_t label_lgth_tls;
   2039 			/* Label length */
   2040 
   2041 		} s3;
   2042 
   2043 	} u1;
   2044 
   2045 	/* LW 15 */
   2046 	union {
   2047 		/* SSL3 */
   2048 		uint8_t iter_count;
   2049 		/* Iteration count used by the SSL key gen request */
   2050 
   2051 		/* TLS */
   2052 		uint8_t tls_seed_length;
   2053 		/* TLS Seed length */
   2054 
   2055 		uint8_t resrvd1;
   2056 		/* Reserved field set to 0 for MGF1 */
   2057 
   2058 	} u2;
   2059 
   2060 	uint8_t resrvd2;
   2061 	uint16_t resrvd3;
   2062 	/* Reserved space - unused */
   2063 
   2064 };
   2065 
   2066 /*
   2067  *   Definition of the SSL3 request parameters block
   2068  *   This structure contains the the SSL3 processing request parameters
   2069  *   incorporating LWs 14-26, as defined by the common base
   2070  *   parameters structure. Unused fields must be set to 0.
   2071  */
   2072 struct fw_la_ssl3_req_params
   2073 {
   2074 	/* LWs 14-15 */
   2075 	struct fw_la_key_gen_common keygen_comn;
   2076 	/* For other key gen processing these field holds ssl, tls or mgf
   2077 	 *   parameters */
   2078 
   2079 	/* LW 16-25 */
   2080 	uint32_t resrvd[FW_NUM_LONGWORDS_10];
   2081 	/* Reserved */
   2082 
   2083 	/* LW 26 */
   2084 	union {
   2085 		uint8_t inner_prefix_sz;
   2086 		/* Size in bytes of the inner prefix data */
   2087 
   2088 		uint8_t aad_sz;
   2089 		/* Size in bytes of padded AAD data to prefix to the packet for CCM
   2090 		 *  or GCM processing */
   2091 	} u2;
   2092 
   2093 	uint8_t resrvd1;
   2094 	/* reserved */
   2095 
   2096 	uint16_t resrvd2;
   2097 	/* reserved */
   2098 
   2099 };
   2100 
   2101 /*
   2102  * Definition of the MGF request parameters block
   2103  * This structure contains the the MGF processing request parameters
   2104  * incorporating LWs 14-26, as defined by the common base parameters
   2105  * structure. Unused fields must be set to 0.
   2106  */
   2107 struct fw_la_mgf_req_params
   2108 {
   2109 	/* LWs 14-15 */
   2110 	struct fw_la_key_gen_common keygen_comn;
   2111 	/* For other key gen processing these field holds ssl or mgf
   2112 	 *   parameters */
   2113 
   2114 	/* LW 16-25 */
   2115 	uint32_t resrvd[FW_NUM_LONGWORDS_10];
   2116 	/* Reserved */
   2117 
   2118 	/* LW 26 */
   2119 	union {
   2120 		uint8_t inner_prefix_sz;
   2121 		/* Size in bytes of the inner prefix data */
   2122 
   2123 		uint8_t aad_sz;
   2124 		/* Size in bytes of padded AAD data to prefix to the packet for CCM
   2125 		 *  or GCM processing */
   2126 	} u2;
   2127 
   2128 	uint8_t resrvd1;
   2129 	/* reserved */
   2130 
   2131 	uint16_t resrvd2;
   2132 	/* reserved */
   2133 
   2134 };
   2135 
   2136 /*
   2137  * Definition of the TLS request parameters block
   2138  * This structure contains the the TLS processing request parameters
   2139  * incorporating LWs 14-26, as defined by the common base parameters
   2140  * structure. Unused fields must be set to 0.
   2141  */
   2142 struct fw_la_tls_req_params
   2143 {
   2144 	/* LWs 14-15 */
   2145 	struct fw_la_key_gen_common keygen_comn;
   2146 	/* For other key gen processing these field holds ssl, tls or mgf
   2147 	 *   parameters */
   2148 
   2149 	/* LW 16-19 */
   2150 	uint32_t resrvd[FW_NUM_LONGWORDS_4];
   2151 	/* Reserved */
   2152 
   2153 };
   2154 
   2155 /*
   2156  * Definition of the common QAT FW request middle block for TRNG.
   2157  * Common section of the request used across all of the services exposed
   2158  * by the QAT FW. Each of the services inherit these common fields. TRNG
   2159  * requires a specific implementation.
   2160  */
   2161 struct fw_la_trng_req_mid
   2162 {
   2163 	/* LWs 6-13 */
   2164 	uint64_t opaque_data;
   2165 	/* Opaque data passed unmodified from the request to response messages by
   2166 	 * firmware (fw) */
   2167 
   2168 	uint64_t resrvd1;
   2169 	/* Reserved, unused for TRNG */
   2170 
   2171 	uint64_t dest_data_addr;
   2172 	/* Generic definition of the destination data supplied to the QAT AE. The
   2173 	 * common flags are used to further describe the attributes of this
   2174 	 * field */
   2175 
   2176 	uint32_t resrvd2;
   2177 	/* Reserved, unused for TRNG */
   2178 
   2179 	uint32_t entropy_length;
   2180 	/* Size of the data in bytes to process. Used by the get_random
   2181 	 * command. Set to 0 for commands that dont need a length parameter */
   2182 
   2183 };
   2184 
   2185 /*
   2186  * Definition of the common LA QAT FW TRNG request
   2187  * Definition of the TRNG processing request type
   2188  */
   2189 struct fw_la_trng_req
   2190 {
   2191 	/* LWs 0-1 */
   2192 	struct fw_comn_req_hdr comn_hdr;
   2193 	/* Common request header */
   2194 
   2195 	/* LWs 2-5 */
   2196 	union fw_comn_req_hdr_cd_pars cd_pars;
   2197 	/* Common Request content descriptor field which points either to a
   2198 	 * content descriptor
   2199 	 * parameter block or contains the service-specific data itself. */
   2200 
   2201 	/* LWs 6-13 */
   2202 	struct fw_la_trng_req_mid comn_mid;
   2203 	/* TRNG request middle section - differs from the common mid-section */
   2204 
   2205 	/* LWs 14-26 */
   2206 	uint32_t resrvd1[FW_NUM_LONGWORDS_13];
   2207 
   2208 	/* LWs 27-31 */
   2209 	uint32_t resrvd2[FW_NUM_LONGWORDS_5];
   2210 
   2211 };
   2212 
   2213 /*
   2214  * Definition of the Lookaside Eagle Tail Response
   2215  * This is the response delivered to the ET rings by the Lookaside
   2216  * QAT FW service for all commands
   2217  */
   2218 struct fw_la_resp
   2219 {
   2220 	/* LWs 0-1 */
   2221 	struct fw_comn_resp_hdr comn_resp;
   2222 	/* Common interface response format see fw.h */
   2223 
   2224 	/* LWs 2-3 */
   2225 	uint64_t opaque_data;
   2226 	/* Opaque data passed from the request to the response message */
   2227 
   2228 	/* LWs 4-7 */
   2229 	uint32_t resrvd[FW_NUM_LONGWORDS_4];
   2230 	/* Reserved */
   2231 
   2232 };
   2233 
   2234 /*
   2235  *   Definition of the Lookaside TRNG Test Status Structure
   2236  *   As an addition to FW_LA_TRNG_STATUS Pass or Fail information
   2237  *   in common response fields, as a response to TRNG_TEST request, Test
   2238  *   status, Counter for failed tests and 4 entropy counter values are
   2239  *   sent
   2240  *   Status of test status and the fail counts.
   2241  */
   2242 struct fw_la_trng_test_result
   2243 {
   2244 	uint32_t test_status_info;
   2245 	/* TRNG comparator health test status& Validity information
   2246 	see Test Status Bit Fields below. */
   2247 
   2248 	uint32_t test_status_fail_count;
   2249 	/* TRNG comparator health test status, 32bit fail counter */
   2250 
   2251 	uint64_t r_ent_ones_cnt;
   2252 	/* Raw Entropy ones counter */
   2253 
   2254 	uint64_t r_ent_zeros_cnt;
   2255 	/* Raw Entropy zeros counter */
   2256 
   2257 	uint64_t c_ent_ones_cnt;
   2258 	/* Conditioned Entropy ones counter */
   2259 
   2260 	uint64_t c_ent_zeros_cnt;
   2261 	/* Conditioned Entropy zeros counter */
   2262 
   2263 	uint64_t resrvd;
   2264 	/* Reserved field must be set to zero */
   2265 
   2266 };
   2267 
   2268 /*
   2269  * Definition of the Lookaside SSL Key Material Input
   2270  * This struct defines the layout of input parameters for the
   2271  * SSL3 key generation (source flat buffer format)
   2272  */
   2273 struct fw_la_ssl_key_material_input
   2274 {
   2275 	uint64_t seed_addr;
   2276 	/* Pointer to seed */
   2277 
   2278 	uint64_t label_addr;
   2279 	/* Pointer to label(s) */
   2280 
   2281 	uint64_t secret_addr;
   2282 	/* Pointer to secret */
   2283 
   2284 };
   2285 
   2286 /*
   2287  * Definition of the Lookaside TLS Key Material Input
   2288  * This struct defines the layout of input parameters for the
   2289  * TLS key generation (source flat buffer format)
   2290  * NOTE:
   2291  * Secret state value (S split into S1 and S2 parts) is supplied via
   2292  * Content Descriptor. S1 is placed in an outer prefix buffer, and S2
   2293  * inside the inner prefix buffer.
   2294  */
   2295 struct fw_la_tls_key_material_input
   2296 {
   2297 	uint64_t seed_addr;
   2298 	/* Pointer to seed */
   2299 
   2300 	uint64_t label_addr;
   2301 	/* Pointer to label(s) */
   2302 
   2303 };
   2304 
   2305 /*
   2306  * Macros using the bit position and mask to set/extract the next
   2307  * and current id nibbles within the next_curr_id field of the
   2308  * content descriptor header block, ONLY FOR CIPHER + AUTH COMBINED.
   2309  * Note that for cipher only or authentication only, the common macros
   2310  * need to be used. These are defined in the 'fw.h' common header
   2311  * file, as they are used by compression, cipher and authentication.
   2312  *
   2313  * cd_ctrl_hdr_t      Content descriptor control block header.
   2314  * val                Value of the field being set.
   2315  */
   2316 /* Cipher fields within Cipher + Authentication structure */
   2317 #define FW_CIPHER_NEXT_ID_GET(cd_ctrl_hdr_t)	\
   2318 	((((cd_ctrl_hdr_t)->next_curr_id_cipher) &	\
   2319 	  FW_COMN_NEXT_ID_MASK) >>	\
   2320 	 (FW_COMN_NEXT_ID_BITPOS))
   2321 
   2322 #define FW_CIPHER_NEXT_ID_SET(cd_ctrl_hdr_t, val)	\
   2323 	(cd_ctrl_hdr_t)->next_curr_id_cipher =	\
   2324 		((((cd_ctrl_hdr_t)->next_curr_id_cipher) &	\
   2325 		  FW_COMN_CURR_ID_MASK) |	\
   2326 		 ((val << FW_COMN_NEXT_ID_BITPOS) &	\
   2327 		  FW_COMN_NEXT_ID_MASK))
   2328 
   2329 #define FW_CIPHER_CURR_ID_GET(cd_ctrl_hdr_t)	\
   2330 	(((cd_ctrl_hdr_t)->next_curr_id_cipher) & FW_COMN_CURR_ID_MASK)
   2331 
   2332 #define FW_CIPHER_CURR_ID_SET(cd_ctrl_hdr_t, val)	\
   2333 	(cd_ctrl_hdr_t)->next_curr_id_cipher =	\
   2334 		((((cd_ctrl_hdr_t)->next_curr_id_cipher) &	\
   2335 		  FW_COMN_NEXT_ID_MASK) |	\
   2336 		 ((val)&FW_COMN_CURR_ID_MASK))
   2337 
   2338 /* Authentication fields within Cipher + Authentication structure */
   2339 #define FW_AUTH_NEXT_ID_GET(cd_ctrl_hdr_t)	\
   2340 	((((cd_ctrl_hdr_t)->next_curr_id_auth) & FW_COMN_NEXT_ID_MASK) >>	\
   2341 	 (FW_COMN_NEXT_ID_BITPOS))
   2342 
   2343 #define FW_AUTH_NEXT_ID_SET(cd_ctrl_hdr_t, val)	\
   2344 	(cd_ctrl_hdr_t)->next_curr_id_auth =	\
   2345 		((((cd_ctrl_hdr_t)->next_curr_id_auth) &	\
   2346 		  FW_COMN_CURR_ID_MASK) |	\
   2347 		 ((val << FW_COMN_NEXT_ID_BITPOS) &	\
   2348 		  FW_COMN_NEXT_ID_MASK))
   2349 
   2350 #define FW_AUTH_CURR_ID_GET(cd_ctrl_hdr_t)	\
   2351 	(((cd_ctrl_hdr_t)->next_curr_id_auth) & FW_COMN_CURR_ID_MASK)
   2352 
   2353 #define FW_AUTH_CURR_ID_SET(cd_ctrl_hdr_t, val)	\
   2354 	(cd_ctrl_hdr_t)->next_curr_id_auth =	\
   2355 		((((cd_ctrl_hdr_t)->next_curr_id_auth) &	\
   2356 		  FW_COMN_NEXT_ID_MASK) |	\
   2357 		 ((val)&FW_COMN_CURR_ID_MASK))
   2358 
   2359 /*  Definitions of the bits in the test_status_info of the TRNG_TEST response.
   2360  *  The values returned by the Lookaside service are given below
   2361  *  The Test result and Test Fail Count values are only valid if the Test
   2362  *  Results Valid (Tv) is set.
   2363  *
   2364  *  TRNG Test Status Info
   2365  *  + ===== + ------------------------------------------------ + --- + --- +
   2366  *  |  Bit  |                   31 - 2                         |  1  |  0  |
   2367  *  + ===== + ------------------------------------------------ + --- + --- +
   2368  *  | Flags |                 RESERVED = 0                     | Tv  | Ts  |
   2369  *  + ===== + ------------------------------------------------------------ +
   2370  */
   2371 /*
   2372  *   Definition of the Lookaside TRNG Test Status Information received as
   2373  *   a part of fw_la_trng_test_result_t
   2374  *
   2375  */
   2376 #define FW_LA_TRNG_TEST_STATUS_TS_BITPOS 0
   2377 /* TRNG Test Result t_status field bit pos definition. */
   2378 
   2379 #define FW_LA_TRNG_TEST_STATUS_TS_MASK 0x1
   2380 /* TRNG Test Result t_status field mask definition. */
   2381 
   2382 #define FW_LA_TRNG_TEST_STATUS_TV_BITPOS 1
   2383 /* TRNG Test Result test results valid field bit pos definition. */
   2384 
   2385 #define FW_LA_TRNG_TEST_STATUS_TV_MASK 0x1
   2386 /* TRNG Test Result test results valid field mask definition. */
   2387 
   2388 /*
   2389  *   Definition of the Lookaside TRNG test_status values.
   2390  *
   2391  *
   2392  */
   2393 #define FW_LA_TRNG_TEST_STATUS_TV_VALID 1
   2394 /* TRNG TEST Response Test Results Valid Value. */
   2395 
   2396 #define FW_LA_TRNG_TEST_STATUS_TV_NOT_VALID 0
   2397 /* TRNG TEST Response Test Results are NOT Valid Value. */
   2398 
   2399 #define FW_LA_TRNG_TEST_STATUS_TS_NO_FAILS 1
   2400 /* Value for TRNG Test status tests have NO FAILs Value. */
   2401 
   2402 #define FW_LA_TRNG_TEST_STATUS_TS_HAS_FAILS 0
   2403 /* Value for TRNG Test status tests have one or more FAILS Value. */
   2404 
   2405 /*
   2406  *  Macro for extraction of the Test Status Field returned in the response
   2407  *  to TRNG TEST command.
   2408  *
   2409  * test_status        8 bit test_status value to extract the status bit
   2410  */
   2411 #define FW_LA_TRNG_TEST_STATUS_TS_FLD_GET(test_status)	\
   2412 	FIELD_GET(test_status,	\
   2413 			      FW_LA_TRNG_TEST_STATUS_TS_BITPOS,	\
   2414 			      FW_LA_TRNG_TEST_STATUS_TS_MASK)
   2415 /*
   2416  *  Macro for extraction of the Test Results Valid Field returned in the
   2417  *  response to TRNG TEST command.
   2418  *
   2419  * test_status        8 bit test_status value to extract the Tests
   2420  *         Results valid bit
   2421  */
   2422 #define FW_LA_TRNG_TEST_STATUS_TV_FLD_GET(test_status)	\
   2423 	FIELD_GET(test_status,	\
   2424 			      FW_LA_TRNG_TEST_STATUS_TV_BITPOS,	\
   2425 			      FW_LA_TRNG_TEST_STATUS_TV_MASK)
   2426 
   2427 /*
   2428  * MGF Max supported input parameters
   2429  */
   2430 #define FW_LA_MGF_SEED_LEN_MAX 255
   2431 /* Maximum seed length for MGF1 request in bytes
   2432  * Typical values may be 48, 64, 128 bytes (or any). */
   2433 
   2434 #define FW_LA_MGF_MASK_LEN_MAX 65528
   2435 /* Maximum mask length for MGF1 request in bytes
   2436  * Typical values may be 8 (64-bit), 16 (128-bit). MUST be quad word multiple  */
   2437 
   2438 /*
   2439  * SSL Max supported input parameters
   2440  */
   2441 #define FW_LA_SSL_SECRET_LEN_MAX 512
   2442 /* Maximum secret length for SSL3 Key Gen request (bytes)  */
   2443 
   2444 #define FW_LA_SSL_ITERATES_LEN_MAX 16
   2445 /* Maximum iterations for SSL3 Key Gen request (integer)  */
   2446 
   2447 #define FW_LA_SSL_LABEL_LEN_MAX 136
   2448 /* Maximum label length for SSL3 Key Gen request (bytes)  */
   2449 
   2450 #define FW_LA_SSL_SEED_LEN_MAX 64
   2451 /* Maximum seed length for SSL3 Key Gen request (bytes)  */
   2452 
   2453 #define FW_LA_SSL_OUTPUT_LEN_MAX 248
   2454 /* Maximum output length for SSL3 Key Gen request (bytes)  */
   2455 
   2456 /*
   2457  * TLS Max supported input parameters
   2458  */
   2459 #define FW_LA_TLS_SECRET_LEN_MAX 128
   2460 /* Maximum secret length for TLS Key Gen request (bytes)  */
   2461 
   2462 #define FW_LA_TLS_V1_1_SECRET_LEN_MAX 128
   2463 /* Maximum secret length for TLS Key Gen request (bytes)  */
   2464 
   2465 #define FW_LA_TLS_V1_2_SECRET_LEN_MAX 64
   2466 /* Maximum secret length for TLS Key Gen request (bytes)  */
   2467 
   2468 #define FW_LA_TLS_LABEL_LEN_MAX 255
   2469 /* Maximum label length for TLS Key Gen request (bytes)  */
   2470 
   2471 #define FW_LA_TLS_SEED_LEN_MAX 64
   2472 /* Maximum seed length for TLS Key Gen request (bytes)  */
   2473 
   2474 #define FW_LA_TLS_OUTPUT_LEN_MAX 248
   2475 /* Maximum output length for TLS Key Gen request (bytes)  */
   2476 
   2477 
   2478 #endif
   2479