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