1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /**
4  *****************************************************************************
5  * @file icp_qat_fw.h
6  * @defgroup icp_qat_fw_comn ICP QAT FW Common Processing Definitions
7  * @ingroup icp_qat_fw
8  *
9  * @description
10  *      This file documents the common interfaces that the QAT FW running on
11  *      the QAT AE exports. This common layer is used by a number of services
12  *      to export content processing services.
13  *
14  *****************************************************************************/
15 
16 #ifndef _ICP_QAT_FW_H_
17 #define _ICP_QAT_FW_H_
18 
19 /*
20 * ==============================
21 * General Notes on the Interface
22 */
23 
24 /*
25 *
26 * ==============================
27 *
28 * Introduction
29 *
30 * Data movement and slice chaining
31 *
32 * Endianness
33 *      - Unless otherwise stated, all structures are defined in LITTLE ENDIAN
34 *        MODE
35 *
36 * Alignment
37 *      - In general all data structures provided to a request should be aligned
38 *      on the 64 byte boundary so as to allow optimal memory transfers. At the
39 *      minimum they must be aligned to the 8 byte boundary
40 *
41 * Sizes
42 *   Quad words = 8 bytes
43 *
44 * Terminology
45 *
46 * ==============================
47 */
48 
49 /*
50 ******************************************************************************
51 * Include public/global header files
52 ******************************************************************************
53 */
54 
55 #include "icp_qat_hw.h"
56 
57 /* Big assumptions that both bitpos and mask are constants */
58 #define QAT_FIELD_SET(flags, val, bitpos, mask)                                \
59 	(flags) = (((flags) & (~((mask) << (bitpos)))) |                       \
60 		   (((val) & (mask)) << (bitpos)))
61 
62 #define QAT_FIELD_GET(flags, bitpos, mask) (((flags) >> (bitpos)) & (mask))
63 #define QAT_FLAG_SET(flags, val, bitpos)                                       \
64 	((flags) = (((flags) & (~(1 << (bitpos)))) | (((val)&1) << (bitpos))))
65 
66 #define QAT_FLAG_CLEAR(flags, bitpos) (flags) = ((flags) & (~(1 << (bitpos))))
67 
68 #define QAT_FLAG_GET(flags, bitpos) (((flags) >> (bitpos)) & 1)
69 
70 /**< @ingroup icp_qat_fw_comn
71  * Default request and response ring size in bytes */
72 #define ICP_QAT_FW_REQ_DEFAULT_SZ 128
73 #define ICP_QAT_FW_RESP_DEFAULT_SZ 32
74 
75 #define ICP_QAT_FW_COMN_ONE_BYTE_SHIFT 8
76 #define ICP_QAT_FW_COMN_SINGLE_BYTE_MASK 0xFF
77 
78 /**< @ingroup icp_qat_fw_comn
79  * Common Request - Block sizes definitions in multiples of individual long
80  * words */
81 #define ICP_QAT_FW_NUM_LONGWORDS_1 1
82 #define ICP_QAT_FW_NUM_LONGWORDS_2 2
83 #define ICP_QAT_FW_NUM_LONGWORDS_3 3
84 #define ICP_QAT_FW_NUM_LONGWORDS_4 4
85 #define ICP_QAT_FW_NUM_LONGWORDS_5 5
86 #define ICP_QAT_FW_NUM_LONGWORDS_6 6
87 #define ICP_QAT_FW_NUM_LONGWORDS_7 7
88 #define ICP_QAT_FW_NUM_LONGWORDS_10 10
89 #define ICP_QAT_FW_NUM_LONGWORDS_13 13
90 
91 /**< @ingroup icp_qat_fw_comn
92  * Definition of the associated service Id for NULL service type.
93  * Note: the response is expected to use ICP_QAT_FW_COMN_RESP_SERV_CPM_FW */
94 #define ICP_QAT_FW_NULL_REQ_SERV_ID 1
95 
96 /**
97  *****************************************************************************
98  * @ingroup icp_qat_fw_comn
99  *              Definition of the firmware interface service users, for
100  *              responses.
101  * @description
102  *              Enumeration which is used to indicate the ids of the services
103  *              for responses using the external firmware interfaces.
104  *
105  *****************************************************************************/
106 
107 typedef enum {
108 	ICP_QAT_FW_COMN_RESP_SERV_NULL,     /**< NULL service id type */
109 	ICP_QAT_FW_COMN_RESP_SERV_CPM_FW,   /**< CPM FW Service ID */
110 	ICP_QAT_FW_COMN_RESP_SERV_DELIMITER /**< Delimiter service id type */
111 } icp_qat_fw_comn_resp_serv_id_t;
112 
113 /**
114  *****************************************************************************
115  * @ingroup icp_qat_fw_comn
116  *              Definition of the request types
117  * @description
118  *              Enumeration which is used to indicate the ids of the request
119  *              types used in each of the external firmware interfaces
120  *
121  *****************************************************************************/
122 
123 typedef enum {
124 	ICP_QAT_FW_COMN_REQ_NULL = 0,	/**< NULL request type */
125 	ICP_QAT_FW_COMN_REQ_CPM_FW_PKE = 3,  /**< CPM FW PKE Request */
126 	ICP_QAT_FW_COMN_REQ_CPM_FW_LA = 4,   /**< CPM FW Lookaside Request */
127 	ICP_QAT_FW_COMN_REQ_CPM_FW_DMA = 7,  /**< CPM FW DMA Request */
128 	ICP_QAT_FW_COMN_REQ_CPM_FW_COMP = 9, /**< CPM FW Compression Request */
129 	ICP_QAT_FW_COMN_REQ_DELIMITER	/**< End delimiter */
130 
131 } icp_qat_fw_comn_request_id_t;
132 
133 /* ========================================================================= */
134 /*                           QAT FW REQUEST STRUCTURES                       */
135 /* ========================================================================= */
136 
137 /**
138  *****************************************************************************
139  * @ingroup icp_qat_fw_comn
140  *      Common request flags type
141  *
142  * @description
143  *      Definition of the common request flags.
144  *
145  *****************************************************************************/
146 typedef uint8_t icp_qat_fw_comn_flags;
147 
148 /**
149  *****************************************************************************
150  * @ingroup icp_qat_fw_comn
151  *      Common request - Service specific flags type
152  *
153  * @description
154  *      Definition of the common request service specific flags.
155  *
156  *****************************************************************************/
157 typedef uint16_t icp_qat_fw_serv_specif_flags;
158 
159 /**
160  *****************************************************************************
161  * @ingroup icp_qat_fw_comn
162  *      Common request - Extended service specific flags type
163  *
164  * @description
165  *      Definition of the common request extended service specific flags.
166  *
167  *****************************************************************************/
168 typedef uint8_t icp_qat_fw_ext_serv_specif_flags;
169 
170 /**
171  *****************************************************************************
172  * @ingroup icp_qat_fw_comn
173  *      Definition of the common QAT FW request content descriptor field -
174  *      points to the content descriptor parameters or itself contains service-
175  *      specific data. Also specifies content descriptor parameter size.
176  *      Contains reserved fields.
177  * @description
178  *      Common section of the request used across all of the services exposed
179  *      by the QAT FW. Each of the services inherit these common fields
180  *
181  *****************************************************************************/
182 typedef union icp_qat_fw_comn_req_hdr_cd_pars_s {
183 	/**< LWs 2-5 */
184 	struct {
185 		uint64_t content_desc_addr;
186 		/**< Address of the content descriptor */
187 
188 		uint16_t content_desc_resrvd1;
189 		/**< Content descriptor reserved field */
190 
191 		uint8_t content_desc_params_sz;
192 		/**< Size of the content descriptor parameters in quad words.
193 		 * These
194 		 * parameters describe the session setup configuration info for
195 		 * the
196 		 * slices that this request relies upon i.e. the configuration
197 		 * word and
198 		 * cipher key needed by the cipher slice if there is a request
199 		 * for
200 		 * cipher processing. */
201 
202 		uint8_t content_desc_hdr_resrvd2;
203 		/**< Content descriptor reserved field */
204 
205 		uint32_t content_desc_resrvd3;
206 		/**< Content descriptor reserved field */
207 	} s;
208 
209 	struct {
210 		uint32_t serv_specif_fields[ICP_QAT_FW_NUM_LONGWORDS_4];
211 
212 	} s1;
213 
214 } icp_qat_fw_comn_req_hdr_cd_pars_t;
215 
216 /**
217  *****************************************************************************
218  * @ingroup icp_qat_fw_comn
219  *      Definition of the common QAT FW request middle block.
220  * @description
221  *      Common section of the request used across all of the services exposed
222  *      by the QAT FW. Each of the services inherit these common fields
223  *
224  *****************************************************************************/
225 typedef struct icp_qat_fw_comn_req_mid_s {
226 	/**< LWs 6-13 */
227 	uint64_t opaque_data;
228 	/**< Opaque data passed unmodified from the request to response messages
229 	 * by
230 	 * firmware (fw) */
231 
232 	uint64_t src_data_addr;
233 	/**< Generic definition of the source data supplied to the QAT AE. The
234 	 * common flags are used to further describe the attributes of this
235 	 * field */
236 
237 	uint64_t dest_data_addr;
238 	/**< Generic definition of the destination data supplied to the QAT AE.
239 	 * The
240 	 * common flags are used to further describe the attributes of this
241 	 * field */
242 
243 	uint32_t src_length;
244 	/** < Length of source flat buffer incase src buffer
245 	 * type is flat */
246 
247 	uint32_t dst_length;
248 	/** < Length of source flat buffer incase dst buffer
249 	 * type is flat */
250 
251 } icp_qat_fw_comn_req_mid_t;
252 
253 /**
254  *****************************************************************************
255  * @ingroup icp_qat_fw_comn
256  *      Definition of the common QAT FW request content descriptor control
257  *      block.
258  *
259  * @description
260  *      Service specific section of the request used across all of the services
261  *      exposed by the QAT FW. Each of the services populates this block
262  *      uniquely. Refer to the service-specific header structures e.g.
263  *      'icp_qat_fw_cipher_hdr_s' (for Cipher) etc.
264  *
265  *****************************************************************************/
266 typedef struct icp_qat_fw_comn_req_cd_ctrl_s {
267 	/**< LWs 27-31 */
268 	uint32_t content_desc_ctrl_lw[ICP_QAT_FW_NUM_LONGWORDS_5];
269 
270 } icp_qat_fw_comn_req_cd_ctrl_t;
271 
272 /**
273  *****************************************************************************
274  * @ingroup icp_qat_fw_comn
275  *      Definition of the common QAT FW request header.
276  * @description
277  *      Common section of the request used across all of the services exposed
278  *      by the QAT FW. Each of the services inherit these common fields. The
279  *      reserved field of 7 bits and the service command Id field are all
280  *      service-specific fields, along with the service specific flags.
281  *
282  *****************************************************************************/
283 typedef struct icp_qat_fw_comn_req_hdr_s {
284 	/**< LW0 */
285 	uint8_t resrvd1;
286 	/**< reserved field */
287 
288 	uint8_t service_cmd_id;
289 	/**< Service Command Id  - this field is service-specific
290 	 * Please use service-specific command Id here e.g.Crypto Command Id
291 	 * or Compression Command Id etc. */
292 
293 	uint8_t service_type;
294 	/**< Service type */
295 
296 	uint8_t hdr_flags;
297 	/**< This represents a flags field for the Service Request.
298 	 * The most significant bit is the 'valid' flag and the only
299 	 * one used. All remaining bit positions are unused and
300 	 * are therefore reserved and need to be set to 0. */
301 
302 	/**< LW1 */
303 	icp_qat_fw_serv_specif_flags serv_specif_flags;
304 	/**< Common Request service-specific flags
305 	 * e.g. Symmetric Crypto Command Flags */
306 
307 	icp_qat_fw_comn_flags comn_req_flags;
308 	/**< Common Request Flags consisting of
309 	 * - 6 reserved bits,
310 	 * - 1 Content Descriptor field type bit and
311 	 * - 1 Source/destination pointer type bit */
312 
313 	icp_qat_fw_ext_serv_specif_flags extended_serv_specif_flags;
314 	/**< An extension of serv_specif_flags
315 	 */
316 } icp_qat_fw_comn_req_hdr_t;
317 
318 /**
319  *****************************************************************************
320  * @ingroup icp_qat_fw_comn
321  *      Definition of the common QAT FW request parameter field.
322  *
323  * @description
324  *      Service specific section of the request used across all of the services
325  *      exposed by the QAT FW. Each of the services populates this block
326  *      uniquely. Refer to service-specific header structures e.g.
327  *      'icp_qat_fw_comn_req_cipher_rqpars_s' (for Cipher) etc.
328  *
329  *****************************************************************************/
330 typedef struct icp_qat_fw_comn_req_rqpars_s {
331 	/**< LWs 14-26 */
332 	uint32_t serv_specif_rqpars_lw[ICP_QAT_FW_NUM_LONGWORDS_13];
333 
334 } icp_qat_fw_comn_req_rqpars_t;
335 
336 /**
337  *****************************************************************************
338  * @ingroup icp_qat_fw_comn
339  *      Definition of the common request structure with service specific
340  *      fields
341  * @description
342  *      This is a definition of the full qat request structure used by all
343  *      services. Each service is free to use the service fields in its own
344  *      way. This struct is useful as a message passing argument before the
345  *      service contained within the request is determined.
346  *
347  *****************************************************************************/
348 typedef struct icp_qat_fw_comn_req_s {
349 	/**< LWs 0-1 */
350 	icp_qat_fw_comn_req_hdr_t comn_hdr;
351 	/**< Common request header */
352 
353 	/**< LWs 2-5 */
354 	icp_qat_fw_comn_req_hdr_cd_pars_t cd_pars;
355 	/**< Common Request content descriptor field which points either to a
356 	 * content descriptor
357 	 * parameter block or contains the service-specific data itself. */
358 
359 	/**< LWs 6-13 */
360 	icp_qat_fw_comn_req_mid_t comn_mid;
361 	/**< Common request middle section */
362 
363 	/**< LWs 14-26 */
364 	icp_qat_fw_comn_req_rqpars_t serv_specif_rqpars;
365 	/**< Common request service-specific parameter field */
366 
367 	/**< LWs 27-31 */
368 	icp_qat_fw_comn_req_cd_ctrl_t cd_ctrl;
369 	/**< Common request content descriptor control block -
370 	 * this field is service-specific */
371 
372 } icp_qat_fw_comn_req_t;
373 
374 /* ========================================================================= */
375 /*                           QAT FW RESPONSE STRUCTURES                      */
376 /* ========================================================================= */
377 
378 /**
379  *****************************************************************************
380  * @ingroup icp_qat_fw_comn
381  *      Error code field
382  *
383  * @description
384  *      Overloaded field with 8 bit common error field or two
385  *      8 bit compression error fields for compression and translator slices
386  *
387  *****************************************************************************/
388 typedef union icp_qat_fw_comn_error_s {
389 	struct {
390 		uint8_t resrvd;
391 		/**< 8 bit reserved field */
392 
393 		uint8_t comn_err_code;
394 		/**< 8 bit common error code */
395 
396 	} s;
397 	/**< Structure which is used for non-compression responses */
398 
399 	struct {
400 		uint8_t xlat_err_code;
401 		/**< 8 bit translator error field */
402 
403 		uint8_t cmp_err_code;
404 		/**< 8 bit compression error field */
405 
406 	} s1;
407 	/** Structure which is used for compression responses */
408 
409 } icp_qat_fw_comn_error_t;
410 
411 /**
412  *****************************************************************************
413  * @ingroup icp_qat_fw_comn
414  *      Definition of the common QAT FW response header.
415  * @description
416  *      This section of the response is common across all of the services
417  *      that generate a firmware interface response
418  *
419  *****************************************************************************/
420 typedef struct icp_qat_fw_comn_resp_hdr_s {
421 	/**< LW0 */
422 	uint8_t resrvd1;
423 	/**< Reserved field - this field is service-specific -
424 	 * Note: The Response Destination Id has been removed
425 	 * from first QWord */
426 
427 	uint8_t service_id;
428 	/**< Service Id returned by service block */
429 
430 	uint8_t response_type;
431 	/**< Response type - copied from the request to
432 	 * the response message */
433 
434 	uint8_t hdr_flags;
435 	/**< This represents a flags field for the Response.
436 	 * Bit<7> = 'valid' flag
437 	 * Bit<6> = 'CNV' flag indicating that CNV was executed
438 	 *          on the current request
439 	 * Bit<5> = 'CNVNR' flag indicating that a recovery happened
440 	 *          on the current request following a CNV error
441 	 * All remaining bits are unused and are therefore reserved.
442 	 * They must to be set to 0.
443 	 */
444 
445 	/**< LW 1 */
446 	icp_qat_fw_comn_error_t comn_error;
447 	/**< This field is overloaded to allow for one 8 bit common error field
448 	 *   or two 8 bit error fields from compression and translator  */
449 
450 	uint8_t comn_status;
451 	/**< Status field which specifies which slice(s) report an error */
452 
453 	uint8_t cmd_id;
454 	/**< Command Id - passed from the request to the response message */
455 
456 } icp_qat_fw_comn_resp_hdr_t;
457 
458 /**
459  *****************************************************************************
460  * @ingroup icp_qat_fw_comn
461  *      Definition of the common response structure with service specific
462  *      fields
463  * @description
464  *      This is a definition of the full qat response structure used by all
465  *      services.
466  *
467  *****************************************************************************/
468 typedef struct icp_qat_fw_comn_resp_s {
469 	/**< LWs 0-1 */
470 	icp_qat_fw_comn_resp_hdr_t comn_hdr;
471 	/**< Common header fields */
472 
473 	/**< LWs 2-3 */
474 	uint64_t opaque_data;
475 	/**< Opaque data passed from the request to the response message */
476 
477 	/**< LWs 4-7 */
478 	uint32_t resrvd[ICP_QAT_FW_NUM_LONGWORDS_4];
479 	/**< Reserved */
480 
481 } icp_qat_fw_comn_resp_t;
482 
483 /* ========================================================================= */
484 /*                           MACRO DEFINITIONS                               */
485 /* ========================================================================= */
486 
487 /*  Common QAT FW request header - structure of LW0
488  *  + ===== + ------- + ----------- + ----------- + ----------- + -------- +
489  *  |  Bit  |  31/30  |  29 - 24    |  21 - 16    |  15 - 8     |  7 - 0   |
490  *  + ===== + ------- + ----------- + ----------- + ----------- + -------- +
491  *  | Flags |  V/Gen  |   Reserved  | Serv Type   | Serv Cmd Id |  Rsv     |
492  *  + ===== + ------- + ----------- + ----------- + ----------- + -------- +
493  */
494 
495 /**< @ingroup icp_qat_fw_comn
496  *  Definition of the setting of the header's valid flag */
497 #define ICP_QAT_FW_COMN_REQ_FLAG_SET 1
498 /**< @ingroup icp_qat_fw_comn
499  *  Definition of the setting of the header's valid flag */
500 #define ICP_QAT_FW_COMN_REQ_FLAG_CLR 0
501 
502 /**< @ingroup icp_qat_fw_comn
503  * Macros defining the bit position and mask of the 'valid' flag, within the
504  * hdr_flags field of LW0 (service request and response) */
505 #define ICP_QAT_FW_COMN_VALID_FLAG_BITPOS 7
506 #define ICP_QAT_FW_COMN_VALID_FLAG_MASK 0x1
507 
508 /**< @ingroup icp_qat_fw_comn
509  * Macros defining the bit position and mask of the 'generation' flag, within
510  * the hdr_flags field of LW0 (service request and response) */
511 #define ICP_QAT_FW_COMN_GEN_FLAG_BITPOS 6
512 #define ICP_QAT_FW_COMN_GEN_FLAG_MASK 0x1
513 /**< @ingroup icp_qat_fw_comn
514  *  The request is targeted for QAT2.0 */
515 #define ICP_QAT_FW_COMN_GEN_2 1
516 /**< @ingroup icp_qat_fw_comn
517 *  The request is targeted for QAT1.x. QAT2.0 FW will return
518    'unsupported request' if GEN1 request type is sent to QAT2.0 FW */
519 #define ICP_QAT_FW_COMN_GEN_1 0
520 
521 #define ICP_QAT_FW_COMN_HDR_RESRVD_FLD_MASK 0x7F
522 
523 /*  Common QAT FW response header - structure of LW0
524  *  + ===== + --- + --- + ----- + ----- + --------- + ----------- + ----- +
525  *  |  Bit  | 31  | 30  |   29  | 28-24 |  21 - 16  |  15 - 8     |  7-0  |
526  *  + ===== + --- + ----+ ----- + ----- + --------- + ----------- + ----- +
527  *  | Flags |  V  | CNV | CNVNR | Rsvd  | Serv Type | Serv Cmd Id |  Rsvd |
528  *  + ===== + --- + --- + ----- + ----- + --------- + ----------- + ----- + */
529 /**< @ingroup icp_qat_fw_comn
530  * Macros defining the bit position and mask of 'CNV' flag
531  * within the hdr_flags field of LW0 (service response only) */
532 #define ICP_QAT_FW_COMN_CNV_FLAG_BITPOS 6
533 #define ICP_QAT_FW_COMN_CNV_FLAG_MASK 0x1
534 
535 /**< @ingroup icp_qat_fw_comn
536  * Macros defining the bit position and mask of CNVNR flag
537  * within the hdr_flags field of LW0 (service response only) */
538 #define ICP_QAT_FW_COMN_CNVNR_FLAG_BITPOS 5
539 #define ICP_QAT_FW_COMN_CNVNR_FLAG_MASK 0x1
540 
541 /**< @ingroup icp_qat_fw_comn
542  * Macros defining the bit position and mask of Stored Blocks flag
543  * within the hdr_flags field of LW0 (service response only)
544  */
545 #define ICP_QAT_FW_COMN_ST_BLK_FLAG_BITPOS 4
546 #define ICP_QAT_FW_COMN_ST_BLK_FLAG_MASK 0x1
547 
548 /**
549  ******************************************************************************
550  * @ingroup icp_qat_fw_comn
551  *
552  * @description
553  *      Macro for extraction of Service Type Field
554  *
555  * @param icp_qat_fw_comn_req_hdr_t  Structure 'icp_qat_fw_comn_req_hdr_t'
556  *                                   to extract the Service Type Field
557  *
558  *****************************************************************************/
559 #define ICP_QAT_FW_COMN_OV_SRV_TYPE_GET(icp_qat_fw_comn_req_hdr_t)             \
560 	icp_qat_fw_comn_req_hdr_t.service_type
561 
562 /**
563  ******************************************************************************
564  * @ingroup icp_qat_fw_comn
565  *
566  * @description
567  *      Macro for setting of Service Type Field
568  *
569  * @param 'icp_qat_fw_comn_req_hdr_t' structure to set the Service
570  *                                    Type Field
571  * @param val    Value of the Service Type Field
572  *
573  *****************************************************************************/
574 #define ICP_QAT_FW_COMN_OV_SRV_TYPE_SET(icp_qat_fw_comn_req_hdr_t, val)        \
575 	icp_qat_fw_comn_req_hdr_t.service_type = val
576 
577 /**
578  ******************************************************************************
579  * @ingroup icp_qat_fw_comn
580  *
581  * @description
582  *      Macro for extraction of Service Command Id Field
583  *
584  * @param icp_qat_fw_comn_req_hdr_t  Structure 'icp_qat_fw_comn_req_hdr_t'
585  *                                   to extract the Service Command Id Field
586  *
587  *****************************************************************************/
588 #define ICP_QAT_FW_COMN_OV_SRV_CMD_ID_GET(icp_qat_fw_comn_req_hdr_t)           \
589 	icp_qat_fw_comn_req_hdr_t.service_cmd_id
590 
591 /**
592  ******************************************************************************
593  * @ingroup icp_qat_fw_comn
594  *
595  * @description
596  *      Macro for setting of Service Command Id Field
597  *
598  * @param 'icp_qat_fw_comn_req_hdr_t' structure to set the
599  *                                    Service Command Id Field
600  * @param val    Value of the Service Command Id Field
601  *
602  *****************************************************************************/
603 #define ICP_QAT_FW_COMN_OV_SRV_CMD_ID_SET(icp_qat_fw_comn_req_hdr_t, val)      \
604 	icp_qat_fw_comn_req_hdr_t.service_cmd_id = val
605 
606 /**
607  ******************************************************************************
608  * @ingroup icp_qat_fw_comn
609  *
610  * @description
611  *      Extract the valid flag from the request or response's header flags.
612  *
613  * @param hdr_t  Request or Response 'hdr_t' structure to extract the valid bit
614  *               from the  'hdr_flags' field.
615  *
616  *****************************************************************************/
617 #define ICP_QAT_FW_COMN_HDR_VALID_FLAG_GET(hdr_t)                              \
618 	ICP_QAT_FW_COMN_VALID_FLAG_GET(hdr_t.hdr_flags)
619 
620 /**
621  ******************************************************************************
622  * @ingroup icp_qat_fw_comn
623  *
624  * @description
625  *      Extract the CNVNR flag from the header flags in the response only.
626  *
627  * @param hdr_t  Response 'hdr_t' structure to extract the CNVNR bit
628  *               from the  'hdr_flags' field.
629  *
630  *****************************************************************************/
631 #define ICP_QAT_FW_COMN_HDR_CNVNR_FLAG_GET(hdr_flags)                          \
632 	QAT_FIELD_GET(hdr_flags,                                               \
633 		      ICP_QAT_FW_COMN_CNVNR_FLAG_BITPOS,                       \
634 		      ICP_QAT_FW_COMN_CNVNR_FLAG_MASK)
635 
636 /**
637  ******************************************************************************
638  * @ingroup icp_qat_fw_comn
639  *
640  * @description
641  *      Extract the CNV flag from the header flags in the response only.
642  *
643  * @param hdr_t  Response 'hdr_t' structure to extract the CNV bit
644  *               from the  'hdr_flags' field.
645  *
646  *****************************************************************************/
647 #define ICP_QAT_FW_COMN_HDR_CNV_FLAG_GET(hdr_flags)                            \
648 	QAT_FIELD_GET(hdr_flags,                                               \
649 		      ICP_QAT_FW_COMN_CNV_FLAG_BITPOS,                         \
650 		      ICP_QAT_FW_COMN_CNV_FLAG_MASK)
651 
652 /**
653  ******************************************************************************
654  * @ingroup icp_qat_fw_comn
655  *
656  * @description
657  *      Set the valid bit in the request's header flags.
658  *
659  * @param hdr_t  Request or Response 'hdr_t' structure to set the valid bit
660  * @param val    Value of the valid bit flag.
661  *
662  *****************************************************************************/
663 #define ICP_QAT_FW_COMN_HDR_VALID_FLAG_SET(hdr_t, val)                         \
664 	ICP_QAT_FW_COMN_VALID_FLAG_SET(hdr_t, val)
665 
666 /**
667  ******************************************************************************
668  * @ingroup icp_qat_fw_comn
669  *
670  * @description
671  *      Common macro to extract the valid flag from the header flags field
672  *      within the header structure (request or response).
673  *
674  * @param hdr_t  Structure (request or response) to extract the
675  *               valid bit from the 'hdr_flags' field.
676  *
677  *****************************************************************************/
678 #define ICP_QAT_FW_COMN_VALID_FLAG_GET(hdr_flags)                              \
679 	QAT_FIELD_GET(hdr_flags,                                               \
680 		      ICP_QAT_FW_COMN_VALID_FLAG_BITPOS,                       \
681 		      ICP_QAT_FW_COMN_VALID_FLAG_MASK)
682 
683 /**
684  ******************************************************************************
685  * @ingroup icp_qat_fw_comn
686  *
687  * @description
688  *      Extract the Stored Block flag from the header flags in the
689  *      response only.
690  *
691  * @param hdr_flags  Response 'hdr' structure to extract the
692  *                   Stored Block bit from the 'hdr_flags' field.
693  *
694  *****************************************************************************/
695 #define ICP_QAT_FW_COMN_HDR_ST_BLK_FLAG_GET(hdr_flags)                         \
696 	QAT_FIELD_GET(hdr_flags,                                               \
697 		      ICP_QAT_FW_COMN_ST_BLK_FLAG_BITPOS,                      \
698 		      ICP_QAT_FW_COMN_ST_BLK_FLAG_MASK)
699 
700 /**
701  ******************************************************************************
702  * @ingroup icp_qat_fw_comn
703  *
704  * @description
705  *      Set the Stored Block bit in the response's header flags.
706  *
707  * @param hdr_t  Response 'hdr_t' structure to set the ST_BLK bit
708  * @param val    Value of the ST_BLK bit flag.
709  *
710  *****************************************************************************/
711 #define ICP_QAT_FW_COMN_HDR_ST_BLK_FLAG_SET(hdr_t, val)                        \
712 	QAT_FIELD_SET((hdr_t.hdr_flags),                                       \
713 		      (val),                                                   \
714 		      ICP_QAT_FW_COMN_ST_BLK_FLAG_BITPOS,                      \
715 		      ICP_QAT_FW_COMN_ST_BLK_FLAG_MASK)
716 
717 /**
718  ******************************************************************************
719  * @ingroup icp_qat_fw_comn
720  *
721  * @description
722  *      Set the generation bit in the request's header flags.
723  *
724  * @param hdr_t  Request or Response 'hdr_t' structure to set the gen bit
725  * @param val    Value of the generation bit flag.
726  *
727  *****************************************************************************/
728 #define ICP_QAT_FW_COMN_HDR_GENERATION_FLAG_SET(hdr_t, val)                    \
729 	ICP_QAT_FW_COMN_GENERATION_FLAG_SET(hdr_t, val)
730 
731 /**
732 ******************************************************************************
733 * @ingroup icp_qat_fw_comn
734 *
735 * @description
736 *      Common macro to set the generation bit in the common header
737 *
738 * @param hdr_t  Structure (request or response) containing the header
739 *               flags field, to allow the generation bit to be set.
740 * @param val    Value of the generation bit flag.
741 *
742 *****************************************************************************/
743 #define ICP_QAT_FW_COMN_GENERATION_FLAG_SET(hdr_t, val)                        \
744 	QAT_FIELD_SET((hdr_t.hdr_flags),                                       \
745 		      (val),                                                   \
746 		      ICP_QAT_FW_COMN_GEN_FLAG_BITPOS,                         \
747 		      ICP_QAT_FW_COMN_GEN_FLAG_MASK)
748 
749 /**
750 ******************************************************************************
751 * @ingroup icp_qat_fw_comn
752 *
753 * @description
754 *      Common macro to extract the generation flag from the header flags field
755 *      within the header structure (request or response).
756 *
757 * @param hdr_t  Structure (request or response) to extract the
758 *               generation bit from the 'hdr_flags' field.
759 *
760 *****************************************************************************/
761 
762 #define ICP_QAT_FW_COMN_HDR_GENERATION_FLAG_GET(hdr_flags)                     \
763 	QAT_FIELD_GET(hdr_flags,                                               \
764 		      ICP_QAT_FW_COMN_GEN_FLAG_BITPOS,                         \
765 		      ICP_QAT_FW_COMN_GEN_FLAG_MASK)
766 /**
767  ******************************************************************************
768  * @ingroup icp_qat_fw_comn
769  *
770  * @description
771  *      Common macro to extract the remaining reserved flags from the header
772 	flags field within the header structure (request or response).
773  *
774  * @param hdr_t  Structure (request or response) to extract the
775  *               remaining bits from the 'hdr_flags' field (excluding the
776  *               valid flag).
777  *
778  *****************************************************************************/
779 #define ICP_QAT_FW_COMN_HDR_RESRVD_FLD_GET(hdr_flags)                          \
780 	(hdr_flags & ICP_QAT_FW_COMN_HDR_RESRVD_FLD_MASK)
781 
782 /**
783  ******************************************************************************
784  * @ingroup icp_qat_fw_comn
785  *
786  * @description
787  *      Common macro to set the valid bit in the header flags field within
788  *      the header structure (request or response).
789  *
790  * @param hdr_t  Structure (request or response) containing the header
791  *               flags field, to allow the valid bit to be set.
792  * @param val    Value of the valid bit flag.
793  *
794  *****************************************************************************/
795 #define ICP_QAT_FW_COMN_VALID_FLAG_SET(hdr_t, val)                             \
796 	QAT_FIELD_SET((hdr_t.hdr_flags),                                       \
797 		      (val),                                                   \
798 		      ICP_QAT_FW_COMN_VALID_FLAG_BITPOS,                       \
799 		      ICP_QAT_FW_COMN_VALID_FLAG_MASK)
800 
801 /**
802 ******************************************************************************
803 * @ingroup icp_qat_fw_comn
804 *
805 * @description
806 *      Macro that must be used when building the common header flags.
807 *      Note that all bits reserved field bits 0-6 (LW0) need to be forced to 0.
808 *
809 * @param ptr   Value of the valid flag
810 *****************************************************************************/
811 
812 #define ICP_QAT_FW_COMN_HDR_FLAGS_BUILD(valid)                                 \
813 	(((valid)&ICP_QAT_FW_COMN_VALID_FLAG_MASK)                             \
814 	 << ICP_QAT_FW_COMN_VALID_FLAG_BITPOS)
815 
816 /*
817  *  < @ingroup icp_qat_fw_comn
818  *  Common Request Flags Definition
819  *  The bit offsets below are within the flags field. These are NOT relative to
820  *  the memory word. Unused fields e.g. reserved bits, must be zeroed.
821  *
822  *  + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- +
823  *  | Bits [15:8]    |  15 |  14 |  13 |  12 |  11 |  10 |  9  |  8  |
824  *  + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- +
825  *  | Flags[15:8]    | Rsv | Rsv | Rsv | Rsv | Rsv | Rsv | Rsv | Rsv |
826  *  + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- +
827  *  | Bits  [7:0]    |  7  |  6  |  5  |  4  |  3  |  2  |  1  |  0  |
828  *  + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- +
829  *  | Flags [7:0]    | Rsv | Rsv | Rsv | Rsv | Rsv | BnP | Cdt | Ptr |
830  *  + ===== + ------ + --- + --- + --- + --- + --- + --- + --- + --- +
831  */
832 
833 #define QAT_COMN_PTR_TYPE_BITPOS 0
834 /**< @ingroup icp_qat_fw_comn
835  * Common Request Flags - Starting bit position indicating
836  * Src&Dst Buffer Pointer type  */
837 
838 #define QAT_COMN_PTR_TYPE_MASK 0x1
839 /**< @ingroup icp_qat_fw_comn
840  * Common Request Flags - One bit mask used to determine
841  * Src&Dst Buffer Pointer type */
842 
843 #define QAT_COMN_CD_FLD_TYPE_BITPOS 1
844 /**< @ingroup icp_qat_fw_comn
845  * Common Request Flags - Starting bit position indicating
846  * CD Field type  */
847 
848 #define QAT_COMN_CD_FLD_TYPE_MASK 0x1
849 /**< @ingroup icp_qat_fw_comn
850  * Common Request Flags - One bit mask used to determine
851  * CD Field type */
852 
853 #define QAT_COMN_BNP_ENABLED_BITPOS 2
854 /**< @ingroup icp_qat_fw_comn
855  * Common Request Flags - Starting bit position indicating
856  * the source buffer contains batch of requests. if this
857  * bit is set, source buffer is type of Batch And Pack OpData List
858  * and the Ptr Type Bit only applies to Destination buffer. */
859 
860 #define QAT_COMN_BNP_ENABLED_MASK 0x1
861 /**< @ingroup icp_qat_fw_comn
862  * Batch And Pack Enabled Flag Mask - One bit mask used to determine
863  * the source buffer is in Batch and Pack OpData Link List Mode. */
864 
865 /* ========================================================================= */
866 /*                                       Pointer Type Flag definitions       */
867 /* ========================================================================= */
868 #define QAT_COMN_PTR_TYPE_FLAT 0x0
869 /**< @ingroup icp_qat_fw_comn
870  * Constant value indicating Src&Dst Buffer Pointer type is flat
871  * If Batch and Pack mode is enabled, only applies to Destination buffer.*/
872 
873 #define QAT_COMN_PTR_TYPE_SGL 0x1
874 /**< @ingroup icp_qat_fw_comn
875  * Constant value indicating Src&Dst Buffer Pointer type is SGL type
876  * If Batch and Pack mode is enabled, only applies to Destination buffer.*/
877 
878 #define QAT_COMN_PTR_TYPE_BATCH 0x2
879 /**< @ingroup icp_qat_fw_comn
880  * Constant value indicating Src is a batch request
881  * and Dst Buffer Pointer type is SGL type */
882 
883 /* ========================================================================= */
884 /*                                       CD Field Flag definitions           */
885 /* ========================================================================= */
886 #define QAT_COMN_CD_FLD_TYPE_64BIT_ADR 0x0
887 /**< @ingroup icp_qat_fw_comn
888  * Constant value indicating CD Field contains 64-bit address */
889 
890 #define QAT_COMN_CD_FLD_TYPE_16BYTE_DATA 0x1
891 /**< @ingroup icp_qat_fw_comn
892  * Constant value indicating CD Field contains 16 bytes of setup data */
893 
894 /* ========================================================================= */
895 /*                       Batch And Pack Enable/Disable Definitions           */
896 /* ========================================================================= */
897 #define QAT_COMN_BNP_ENABLED 0x1
898 /**< @ingroup icp_qat_fw_comn
899  * Constant value indicating Source buffer will point to Batch And Pack OpData
900  * List */
901 
902 #define QAT_COMN_BNP_DISABLED 0x0
903 /**< @ingroup icp_qat_fw_comn
904  * Constant value indicating Source buffer will point to Batch And Pack OpData
905  * List */
906 
907 /**
908 ******************************************************************************
909 * @ingroup icp_qat_fw_comn
910 *
911 * @description
912 *      Macro that must be used when building the common request flags (for all
913 *      requests but comp BnP).
914 *      Note that all bits reserved field bits 2-15 (LW1) need to be forced to 0.
915 *
916 * @param ptr   Value of the pointer type flag
917 * @param cdt   Value of the cd field type flag
918 *****************************************************************************/
919 #define ICP_QAT_FW_COMN_FLAGS_BUILD(cdt, ptr)                                  \
920 	((((cdt)&QAT_COMN_CD_FLD_TYPE_MASK) << QAT_COMN_CD_FLD_TYPE_BITPOS) |  \
921 	 (((ptr)&QAT_COMN_PTR_TYPE_MASK) << QAT_COMN_PTR_TYPE_BITPOS))
922 
923 /**
924 ******************************************************************************
925 * @ingroup icp_qat_fw_comn
926 *
927 * @description
928 *      Macro that must be used when building the common request flags for comp
929 *      BnP service.
930 *      Note that all bits reserved field bits 3-15 (LW1) need to be forced to 0.
931 *
932 * @param ptr   Value of the pointer type flag
933 * @param cdt   Value of the cd field type flag
934 * @param bnp   Value of the bnp enabled flag
935 *****************************************************************************/
936 #define ICP_QAT_FW_COMN_FLAGS_BUILD_BNP(cdt, ptr, bnp)                         \
937 	((((cdt)&QAT_COMN_CD_FLD_TYPE_MASK) << QAT_COMN_CD_FLD_TYPE_BITPOS) |  \
938 	 (((ptr)&QAT_COMN_PTR_TYPE_MASK) << QAT_COMN_PTR_TYPE_BITPOS) |        \
939 	 (((bnp)&QAT_COMN_BNP_ENABLED_MASK) << QAT_COMN_BNP_ENABLED_BITPOS))
940 
941 /**
942  ******************************************************************************
943  * @ingroup icp_qat_fw_comn
944  *
945  * @description
946  *      Macro for extraction of the pointer type bit from the common flags
947  *
948  * @param flags      Flags to extract the pointer type bit from
949  *
950  *****************************************************************************/
951 #define ICP_QAT_FW_COMN_PTR_TYPE_GET(flags)                                    \
952 	QAT_FIELD_GET(flags, QAT_COMN_PTR_TYPE_BITPOS, QAT_COMN_PTR_TYPE_MASK)
953 
954 /**
955  ******************************************************************************
956  * @ingroup icp_qat_fw_comn
957  *
958  * @description
959  *      Macro for extraction of the cd field type bit from the common flags
960  *
961  * @param flags      Flags to extract the cd field type type bit from
962  *
963  *****************************************************************************/
964 #define ICP_QAT_FW_COMN_CD_FLD_TYPE_GET(flags)                                 \
965 	QAT_FIELD_GET(flags,                                                   \
966 		      QAT_COMN_CD_FLD_TYPE_BITPOS,                             \
967 		      QAT_COMN_CD_FLD_TYPE_MASK)
968 
969 /**
970  ******************************************************************************
971  * @ingroup icp_qat_fw_comn
972  *
973  * @description
974  *      Macro for extraction of the bnp field type bit from the common flags
975  *
976  * @param flags      Flags to extract the bnp field type type bit from
977  *
978  *****************************************************************************/
979 #define ICP_QAT_FW_COMN_BNP_ENABLED_GET(flags)                                 \
980 	QAT_FIELD_GET(flags,                                                   \
981 		      QAT_COMN_BNP_ENABLED_BITPOS,                             \
982 		      QAT_COMN_BNP_ENABLED_MASK)
983 
984 /**
985  ******************************************************************************
986  * @ingroup icp_qat_fw_comn
987  *
988  * @description
989  *      Macro for setting the pointer type bit in the common flags
990  *
991  * @param flags      Flags in which Pointer Type bit will be set
992  * @param val        Value of the bit to be set in flags
993  *
994  *****************************************************************************/
995 #define ICP_QAT_FW_COMN_PTR_TYPE_SET(flags, val)                               \
996 	QAT_FIELD_SET(flags,                                                   \
997 		      val,                                                     \
998 		      QAT_COMN_PTR_TYPE_BITPOS,                                \
999 		      QAT_COMN_PTR_TYPE_MASK)
1000 
1001 /**
1002  ******************************************************************************
1003  * @ingroup icp_qat_fw_comn
1004  *
1005  * @description
1006  *      Macro for setting the cd field type bit in the common flags
1007  *
1008  * @param flags      Flags in which Cd Field Type bit will be set
1009  * @param val        Value of the bit to be set in flags
1010  *
1011  *****************************************************************************/
1012 #define ICP_QAT_FW_COMN_CD_FLD_TYPE_SET(flags, val)                            \
1013 	QAT_FIELD_SET(flags,                                                   \
1014 		      val,                                                     \
1015 		      QAT_COMN_CD_FLD_TYPE_BITPOS,                             \
1016 		      QAT_COMN_CD_FLD_TYPE_MASK)
1017 
1018 /**
1019  ******************************************************************************
1020  * @ingroup icp_qat_fw_comn
1021  *
1022  * @description
1023  *      Macro for setting the bnp field type bit in the common flags
1024  *
1025  * @param flags      Flags in which Bnp Field Type bit will be set
1026  * @param val        Value of the bit to be set in flags
1027  *
1028  *****************************************************************************/
1029 #define ICP_QAT_FW_COMN_BNP_ENABLE_SET(flags, val)                             \
1030 	QAT_FIELD_SET(flags,                                                   \
1031 		      val,                                                     \
1032 		      QAT_COMN_BNP_ENABLED_BITPOS,                             \
1033 		      QAT_COMN_BNP_ENABLED_MASK)
1034 
1035 /**
1036  ******************************************************************************
1037  * @ingroup icp_qat_fw_comn
1038  *
1039  * @description
1040  *      Macros using the bit position and mask to set/extract the next
1041  *      and current id nibbles within the next_curr_id field of the
1042  *      content descriptor header block. Note that these are defined
1043  *      in the common header file, as they are used by compression, cipher
1044  *      and authentication.
1045  *
1046  * @param cd_ctrl_hdr_t      Content descriptor control block header pointer.
1047  * @param val                Value of the field being set.
1048  *
1049  *****************************************************************************/
1050 #define ICP_QAT_FW_COMN_NEXT_ID_BITPOS 4
1051 #define ICP_QAT_FW_COMN_NEXT_ID_MASK 0xF0
1052 #define ICP_QAT_FW_COMN_CURR_ID_BITPOS 0
1053 #define ICP_QAT_FW_COMN_CURR_ID_MASK 0x0F
1054 
1055 #define ICP_QAT_FW_COMN_NEXT_ID_GET(cd_ctrl_hdr_t)                             \
1056 	((((cd_ctrl_hdr_t)->next_curr_id) & ICP_QAT_FW_COMN_NEXT_ID_MASK) >>   \
1057 	 (ICP_QAT_FW_COMN_NEXT_ID_BITPOS))
1058 
1059 #define ICP_QAT_FW_COMN_NEXT_ID_SET(cd_ctrl_hdr_t, val)                        \
1060 	((cd_ctrl_hdr_t)->next_curr_id) =                                      \
1061 	    ((((cd_ctrl_hdr_t)->next_curr_id) &                                \
1062 	      ICP_QAT_FW_COMN_CURR_ID_MASK) |                                  \
1063 	     ((val << ICP_QAT_FW_COMN_NEXT_ID_BITPOS) &                        \
1064 	      ICP_QAT_FW_COMN_NEXT_ID_MASK))
1065 
1066 #define ICP_QAT_FW_COMN_CURR_ID_GET(cd_ctrl_hdr_t)                             \
1067 	(((cd_ctrl_hdr_t)->next_curr_id) & ICP_QAT_FW_COMN_CURR_ID_MASK)
1068 
1069 #define ICP_QAT_FW_COMN_CURR_ID_SET(cd_ctrl_hdr_t, val)                        \
1070 	((cd_ctrl_hdr_t)->next_curr_id) =                                      \
1071 	    ((((cd_ctrl_hdr_t)->next_curr_id) &                                \
1072 	      ICP_QAT_FW_COMN_NEXT_ID_MASK) |                                  \
1073 	     ((val)&ICP_QAT_FW_COMN_CURR_ID_MASK))
1074 
1075 /*
1076  *  < @ingroup icp_qat_fw_comn
1077  *  Common Status Field Definition  The bit offsets below are within the COMMON
1078  *  RESPONSE status field, assumed to be 8 bits wide. In the case of the PKE
1079  *  response (which follows the CPM 1.5 message format), the status field is 16
1080  *  bits wide.
1081  *  The status flags are contained within the most significant byte and align
1082  *  with the diagram below. Please therefore refer to the service-specific PKE
1083  *  header file for the appropriate macro definition to extract the PKE status
1084  *  flag from the PKE response, which assumes that a word is passed to the
1085  *  macro.
1086  *  + ===== + ------ + --- + --- + ---- + ---- + -------- + ---- + ---------- +
1087  *  |  Bit  |   7    |  6  |  5  |  4   |  3   |    2     |   1  |      0     |
1088  *  + ===== + ------ + --- + --- + ---- + ---- + -------- + ---- + ---------- +
1089  *  | Flags | Crypto | Pke | Cmp | Xlat | EOLB | UnSupReq | Rsvd | XltWaApply |
1090  *  + ===== + ------ + --- + --- + ---- + ---- + -------- + ---- + ---------- +
1091  * Note:
1092  * For the service specific status bit definitions refer to service header files
1093  * Eg. Crypto Status bit refers to Symmetric Crypto, Key Generation, and NRBG
1094  * Requests' Status. Unused bits e.g. reserved bits need to have been forced to
1095  * 0.
1096  */
1097 
1098 #define QAT_COMN_RESP_CRYPTO_STATUS_BITPOS 7
1099 /**< @ingroup icp_qat_fw_comn
1100  * Starting bit position indicating Response for Crypto service Flag */
1101 
1102 #define QAT_COMN_RESP_CRYPTO_STATUS_MASK 0x1
1103 /**< @ingroup icp_qat_fw_comn
1104  * One bit mask used to determine Crypto status mask */
1105 
1106 #define QAT_COMN_RESP_PKE_STATUS_BITPOS 6
1107 /**< @ingroup icp_qat_fw_comn
1108  * Starting bit position indicating Response for PKE service Flag */
1109 
1110 #define QAT_COMN_RESP_PKE_STATUS_MASK 0x1
1111 /**< @ingroup icp_qat_fw_comn
1112  * One bit mask used to determine PKE status mask */
1113 
1114 #define QAT_COMN_RESP_CMP_STATUS_BITPOS 5
1115 /**< @ingroup icp_qat_fw_comn
1116  * Starting bit position indicating Response for Compression service Flag */
1117 
1118 #define QAT_COMN_RESP_CMP_STATUS_MASK 0x1
1119 /**< @ingroup icp_qat_fw_comn
1120  * One bit mask used to determine Compression status mask */
1121 
1122 #define QAT_COMN_RESP_XLAT_STATUS_BITPOS 4
1123 /**< @ingroup icp_qat_fw_comn
1124  * Starting bit position indicating Response for Xlat service Flag */
1125 
1126 #define QAT_COMN_RESP_XLAT_STATUS_MASK 0x1
1127 /**< @ingroup icp_qat_fw_comn
1128  * One bit mask used to determine Translator status mask */
1129 
1130 #define QAT_COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS 3
1131 /**< @ingroup icp_qat_fw_comn
1132  * Starting bit position indicating the last block in a deflate stream for
1133   the compression service Flag */
1134 
1135 #define QAT_COMN_RESP_CMP_END_OF_LAST_BLK_MASK 0x1
1136 /**< @ingroup icp_qat_fw_comn
1137  * One bit mask used to determine the last block in a deflate stream
1138    status mask */
1139 
1140 #define QAT_COMN_RESP_UNSUPPORTED_REQUEST_BITPOS 2
1141 /**< @ingroup icp_qat_fw_comn
1142  * Starting bit position indicating when an unsupported service request Flag */
1143 
1144 #define QAT_COMN_RESP_UNSUPPORTED_REQUEST_MASK 0x1
1145 /**< @ingroup icp_qat_fw_comn
1146  * One bit mask used to determine the unsupported service request status mask */
1147 
1148 #define QAT_COMN_RESP_XLT_INV_APPLIED_BITPOS 0
1149 /**< @ingroup icp_qat_fw_comn
1150  * Bit position indicating that firmware detected an invalid translation during
1151  * dynamic compression and took measures to overcome this
1152  *
1153  */
1154 
1155 #define QAT_COMN_RESP_XLT_INV_APPLIED_MASK 0x1
1156 /**< @ingroup icp_qat_fw_comn
1157  * One bit mask */
1158 
1159 /**
1160  ******************************************************************************
1161  * @description
1162  *      Macro that must be used when building the status
1163  *      for the common response
1164  *
1165  * @param crypto   Value of the Crypto Service status flag
1166  * @param comp     Value of the Compression Service Status flag
1167  * @param xlat     Value of the Xlator Status flag
1168  * @param eolb     Value of the Compression End of Last Block Status flag
1169  * @param unsupp   Value of the Unsupported Request flag
1170  * @param xlt_inv  Value of the Invalid Translation flag
1171  *****************************************************************************/
1172 #define ICP_QAT_FW_COMN_RESP_STATUS_BUILD(                                     \
1173     crypto, pke, comp, xlat, eolb, unsupp, xlt_inv)                            \
1174 	((((crypto)&QAT_COMN_RESP_CRYPTO_STATUS_MASK)                          \
1175 	  << QAT_COMN_RESP_CRYPTO_STATUS_BITPOS) |                             \
1176 	 (((pke)&QAT_COMN_RESP_PKE_STATUS_MASK)                                \
1177 	  << QAT_COMN_RESP_PKE_STATUS_BITPOS) |                                \
1178 	 (((xlt_inv)&QAT_COMN_RESP_XLT_INV_APPLIED_MASK)                       \
1179 	  << QAT_COMN_RESP_XLT_INV_APPLIED_BITPOS) |                           \
1180 	 (((comp)&QAT_COMN_RESP_CMP_STATUS_MASK)                               \
1181 	  << QAT_COMN_RESP_CMP_STATUS_BITPOS) |                                \
1182 	 (((xlat)&QAT_COMN_RESP_XLAT_STATUS_MASK)                              \
1183 	  << QAT_COMN_RESP_XLAT_STATUS_BITPOS) |                               \
1184 	 (((eolb)&QAT_COMN_RESP_CMP_END_OF_LAST_BLK_MASK)                      \
1185 	  << QAT_COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS) |                       \
1186 	 (((unsupp)&QAT_COMN_RESP_UNSUPPORTED_REQUEST_BITPOS)                  \
1187 	  << QAT_COMN_RESP_UNSUPPORTED_REQUEST_MASK))
1188 
1189 /* ========================================================================= */
1190 /*                                                                   GETTERS */
1191 /* ========================================================================= */
1192 /**
1193  ******************************************************************************
1194  * @ingroup icp_qat_fw_comn
1195  *
1196  * @description
1197  *      Macro for extraction of the Crypto bit from the status
1198  *
1199  * @param status
1200  *      Status to extract the status bit from
1201  *
1202  *****************************************************************************/
1203 #define ICP_QAT_FW_COMN_RESP_CRYPTO_STAT_GET(status)                           \
1204 	QAT_FIELD_GET(status,                                                  \
1205 		      QAT_COMN_RESP_CRYPTO_STATUS_BITPOS,                      \
1206 		      QAT_COMN_RESP_CRYPTO_STATUS_MASK)
1207 
1208 /**
1209  ******************************************************************************
1210  * @ingroup icp_qat_fw_comn
1211  *
1212  * @description
1213  *      Macro for extraction of the PKE bit from the status
1214  *
1215  * @param status
1216  *      Status to extract the status bit from
1217  *
1218  *****************************************************************************/
1219 #define ICP_QAT_FW_COMN_RESP_PKE_STAT_GET(status)                              \
1220 	QAT_FIELD_GET(status,                                                  \
1221 		      QAT_COMN_RESP_PKE_STATUS_BITPOS,                         \
1222 		      QAT_COMN_RESP_PKE_STATUS_MASK)
1223 
1224 /**
1225  ******************************************************************************
1226  * @ingroup icp_qat_fw_comn
1227  *
1228  * @description
1229  *      Macro for extraction of the Compression bit from the status
1230  *
1231  * @param status
1232  *      Status to extract the status bit from
1233  *
1234  *****************************************************************************/
1235 #define ICP_QAT_FW_COMN_RESP_CMP_STAT_GET(status)                              \
1236 	QAT_FIELD_GET(status,                                                  \
1237 		      QAT_COMN_RESP_CMP_STATUS_BITPOS,                         \
1238 		      QAT_COMN_RESP_CMP_STATUS_MASK)
1239 
1240 /**
1241  ******************************************************************************
1242  * @ingroup icp_qat_fw_comn
1243  *
1244  * @description
1245  *      Macro for extraction of the Translator bit from the status
1246  *
1247  * @param status
1248  *      Status to extract the status bit from
1249  *
1250  *****************************************************************************/
1251 #define ICP_QAT_FW_COMN_RESP_XLAT_STAT_GET(status)                             \
1252 	QAT_FIELD_GET(status,                                                  \
1253 		      QAT_COMN_RESP_XLAT_STATUS_BITPOS,                        \
1254 		      QAT_COMN_RESP_XLAT_STATUS_MASK)
1255 
1256 /**
1257  ******************************************************************************
1258  * @ingroup icp_qat_fw_comn
1259  *
1260  * @description
1261  *      Macro for extraction of the Translation Invalid bit
1262  *      from the status
1263  *
1264  * @param status
1265  *      Status to extract the status bit from
1266  *
1267  *****************************************************************************/
1268 #define ICP_QAT_FW_COMN_RESP_XLT_INV_APPLIED_GET(status)                       \
1269 	QAT_FIELD_GET(status,                                                  \
1270 		      QAT_COMN_RESP_XLT_INV_APPLIED_BITPOS,                    \
1271 		      QAT_COMN_RESP_XLT_INV_APPLIED_MASK)
1272 
1273 /**
1274  ******************************************************************************
1275  * @ingroup icp_qat_fw_comn
1276  *
1277  * @description
1278  *      Macro for extraction of the end of compression block bit from the
1279  *      status
1280  *
1281  * @param status
1282  *      Status to extract the status bit from
1283  *
1284  *****************************************************************************/
1285 #define ICP_QAT_FW_COMN_RESP_CMP_END_OF_LAST_BLK_FLAG_GET(status)              \
1286 	QAT_FIELD_GET(status,                                                  \
1287 		      QAT_COMN_RESP_CMP_END_OF_LAST_BLK_BITPOS,                \
1288 		      QAT_COMN_RESP_CMP_END_OF_LAST_BLK_MASK)
1289 
1290 /**
1291  ******************************************************************************
1292  * @ingroup icp_qat_fw_comn
1293  *
1294  * @description
1295  *      Macro for extraction of the Unsupported request from the status
1296  *
1297  * @param status
1298  *      Status to extract the status bit from
1299  *
1300  *****************************************************************************/
1301 #define ICP_QAT_FW_COMN_RESP_UNSUPPORTED_REQUEST_STAT_GET(status)              \
1302 	QAT_FIELD_GET(status,                                                  \
1303 		      QAT_COMN_RESP_UNSUPPORTED_REQUEST_BITPOS,                \
1304 		      QAT_COMN_RESP_UNSUPPORTED_REQUEST_MASK)
1305 
1306 /* ========================================================================= */
1307 /*                                        Status Flag definitions */
1308 /* ========================================================================= */
1309 
1310 #define ICP_QAT_FW_COMN_STATUS_FLAG_OK 0
1311 /**< @ingroup icp_qat_fw_comn
1312  * Definition of successful processing of a request */
1313 
1314 #define ICP_QAT_FW_COMN_STATUS_FLAG_ERROR 1
1315 /**< @ingroup icp_qat_fw_comn
1316  * Definition of erroneous processing of a request */
1317 
1318 #define ICP_QAT_FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_CLR 0
1319 /**< @ingroup icp_qat_fw_comn
1320  * Final Deflate block of a compression request not completed */
1321 
1322 #define ICP_QAT_FW_COMN_STATUS_CMP_END_OF_LAST_BLK_FLAG_SET 1
1323 /**< @ingroup icp_qat_fw_comn
1324  * Final Deflate block of a compression request completed */
1325 
1326 #define ERR_CODE_NO_ERROR 0
1327 /**< Error Code constant value for no error  */
1328 
1329 #define ERR_CODE_INVALID_BLOCK_TYPE -1
1330 /* Invalid block type (type == 3)*/
1331 
1332 #define ERR_CODE_NO_MATCH_ONES_COMP -2
1333 /* Stored block length does not match one's complement */
1334 
1335 #define ERR_CODE_TOO_MANY_LEN_OR_DIS -3
1336 /* Too many length or distance codes */
1337 
1338 #define ERR_CODE_INCOMPLETE_LEN -4
1339 /* Code lengths codes incomplete */
1340 
1341 #define ERR_CODE_RPT_LEN_NO_FIRST_LEN -5
1342 /* Repeat lengths with no first length */
1343 
1344 #define ERR_CODE_RPT_GT_SPEC_LEN -6
1345 /* Repeat more than specified lengths */
1346 
1347 #define ERR_CODE_INV_LIT_LEN_CODE_LEN -7
1348 /* Invalid lit/len code lengths */
1349 
1350 #define ERR_CODE_INV_DIS_CODE_LEN -8
1351 /* Invalid distance code lengths */
1352 
1353 #define ERR_CODE_INV_LIT_LEN_DIS_IN_BLK -9
1354 /* Invalid lit/len or distance code in fixed/dynamic block */
1355 
1356 #define ERR_CODE_DIS_TOO_FAR_BACK -10
1357 /* Distance too far back in fixed or dynamic block */
1358 
1359 /* Common Error code definitions */
1360 #define ERR_CODE_OVERFLOW_ERROR -11
1361 /**< Error Code constant value for overflow error  */
1362 
1363 #define ERR_CODE_SOFT_ERROR -12
1364 /**< Error Code constant value for soft error  */
1365 
1366 #define ERR_CODE_FATAL_ERROR -13
1367 /**< Error Code constant value for hard/fatal error  */
1368 
1369 #define ERR_CODE_COMP_OUTPUT_CORRUPTION -14
1370 /**< Error Code constant for compression output corruption */
1371 
1372 #define ERR_CODE_HW_INCOMPLETE_FILE -15
1373 /**< Error Code constant value for incomplete file hardware error  */
1374 
1375 #define ERR_CODE_SSM_ERROR -16
1376 /**< Error Code constant value for error detected by SSM e.g. slice hang  */
1377 
1378 #define ERR_CODE_ENDPOINT_ERROR -17
1379 /**< Error Code constant value for error detected by PCIe Endpoint, e.g. push
1380  * data error  */
1381 
1382 #define ERR_CODE_CNV_ERROR -18
1383 /**< Error Code constant value for cnv failure  */
1384 
1385 #define ERR_CODE_EMPTY_DYM_BLOCK -19
1386 /**< Error Code constant value for submission of empty dynamic stored block to
1387  * slice  */
1388 
1389 #define ERR_CODE_REGION_OUT_OF_BOUNDS -21
1390 /**< Error returned when decompression ends before the specified partial
1391  * decompression region was produced */
1392 
1393 #define ERR_CODE_MISC_ERROR -50
1394 /**< Error Code constant for error detected but the source
1395  * of error is not recognized */
1396 
1397 /**
1398  *****************************************************************************
1399  * @ingroup icp_qat_fw_comn
1400  *      Slice types for building of the processing chain within the content
1401  *      descriptor
1402  *
1403  * @description
1404  *      Enumeration used to indicate the ids of the slice types through which
1405  *      data will pass.
1406  *
1407  *      A logical slice is not a hardware slice but is a software FSM
1408  *      performing the actions of a slice
1409  *
1410  *****************************************************************************/
1411 
1412 typedef enum {
1413 	ICP_QAT_FW_SLICE_NULL = 0,    /**< NULL slice type */
1414 	ICP_QAT_FW_SLICE_CIPHER = 1,  /**< CIPHER slice type */
1415 	ICP_QAT_FW_SLICE_AUTH = 2,    /**< AUTH slice type */
1416 	ICP_QAT_FW_SLICE_DRAM_RD = 3, /**< DRAM_RD Logical slice type */
1417 	ICP_QAT_FW_SLICE_DRAM_WR = 4, /**< DRAM_WR Logical slice type */
1418 	ICP_QAT_FW_SLICE_COMP = 5,    /**< Compression slice type */
1419 	ICP_QAT_FW_SLICE_XLAT = 6,    /**< Translator slice type */
1420 	ICP_QAT_FW_SLICE_DELIMITER    /**< End delimiter */
1421 
1422 } icp_qat_fw_slice_t;
1423 
1424 #endif /* _ICP_QAT_FW_H_ */
1425