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