Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
/*	$NetBSD: qat_hw15reg.h,v 1.1 2019/11/20 09:37:46 hikaru Exp $	*/

/*
 * Copyright (c) 2019 Internet Initiative Japan, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 *   Copyright(c) 2007-2013 Intel Corporation. All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
 *   are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in
 *       the documentation and/or other materials provided with the
 *       distribution.
 *     * Neither the name of Intel Corporation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef _DEV_PCI_QAT_HW15REG_H_
#define _DEV_PCI_QAT_HW15REG_H_

/* Default message size in bytes */
#define FW_REQ_DEFAULT_SZ_HW15		64
#define FW_RESP_DEFAULT_SZ_HW15		64

#define ADMIN_RING_SIZE		256
#define RING_NUM_ADMIN_TX	0
#define RING_NUM_ADMIN_RX	1

/* -------------------------------------------------------------------------- */
/* accel */

#define ARCH_IF_FLAGS_VALID_FLAG		__BIT(7)
#define ARCH_IF_FLAGS_RESP_RING_TYPE		__BITS(4, 3)
#define  ARCH_IF_FLAGS_RESP_RING_TYPE_SHIFT	3
#define  ARCH_IF_FLAGS_RESP_RING_TYPE_SCRATCH	(0 << ARCH_IF_FLAGS_RESP_RING_TYPE_SHIFT)
#define  ARCH_IF_FLAGS_RESP_RING_TYPE_NN	(1 << ARCH_IF_FLAGS_RESP_RING_TYPE_SHIFT)
#define  ARCH_IF_FLAGS_RESP_RING_TYPE_ET	(2 << ARCH_IF_FLAGS_RESP_RING_TYPE_SHIFT)
#define ARCH_IF_FLAGS_RESP_TYPE			__BITS(2, 0)
#define  ARCH_IF_FLAGS_RESP_TYPE_SHIFT		0
#define   ARCH_IF_FLAGS_RESP_TYPE_A		(0 << ARCH_IF_FLAGS_RESP_TYPE_SHIFT)
#define   ARCH_IF_FLAGS_RESP_TYPE_B		(1 << ARCH_IF_FLAGS_RESP_TYPE_SHIFT)
#define   ARCH_IF_FLAGS_RESP_TYPE_C		(2 << ARCH_IF_FLAGS_RESP_TYPE_SHIFT)
#define   ARCH_IF_FLAGS_RESP_TYPE_S		(3 << ARCH_IF_FLAGS_RESP_TYPE_SHIFT)

enum arch_if_req {
	ARCH_IF_REQ_NULL,		/* NULL request type */

	/* QAT-AE Service Request Type IDs - 01 to 20 */
	ARCH_IF_REQ_QAT_FW_INIT,	/* QAT-FW Initialization Request */
	ARCH_IF_REQ_QAT_FW_ADMIN,	/* QAT-FW Administration Request */
	ARCH_IF_REQ_QAT_FW_PKE,		/* QAT-FW PKE Request */
	ARCH_IF_REQ_QAT_FW_LA,		/* QAT-FW Lookaside Request */
	ARCH_IF_REQ_QAT_FW_IPSEC,	/* QAT-FW IPSec Request */
	ARCH_IF_REQ_QAT_FW_SSL,		/* QAT-FW SSL Request */
	ARCH_IF_REQ_QAT_FW_DMA,		/* QAT-FW DMA Request */
	ARCH_IF_REQ_QAT_FW_STORAGE,	/* QAT-FW Storage Request */
	ARCH_IF_REQ_QAT_FW_COMPRESS,	/* QAT-FW Compression Request */
	ARCH_IF_REQ_QAT_FW_PATMATCH,	/* QAT-FW Pattern Matching Request */

	/* IP Service (Range Match and Exception) Blocks Request Type IDs 21 - 30 */
	ARCH_IF_REQ_RM_FLOW_MISS = 21,	/* RM flow miss request */
	ARCH_IF_REQ_RM_FLOW_TIMER_EXP,	/* RM flow timer exp Request */
	ARCH_IF_REQ_IP_SERVICES_RFC_LOOKUP_UPDATE, /* RFC Lookup request */
	ARCH_IF_REQ_IP_SERVICES_CONFIG_UPDATE,	/* Config Update request */
	ARCH_IF_REQ_IP_SERVICES_FCT_CONFIG,	/* FCT Config request */
	ARCH_IF_REQ_IP_SERVICES_NEXT_HOP_TIMER_EXPIRY, /* NH Timer expiry request */
	ARCH_IF_REQ_IP_SERVICES_EXCEPTION,	/* Exception processign request */
	ARCH_IF_REQ_IP_SERVICES_STACK_DRIVER,	/* Send to SD request */
	ARCH_IF_REQ_IP_SERVICES_ACTION_HANDLER,	/* Send to AH request */
	ARCH_IF_REQ_IP_SERVICES_EVENT_HANDLER,	/* Send to EH request */
	ARCH_IF_REQ_DELIMITER			/* End delimiter */
};

struct arch_if_req_hdr {
	uint8_t resp_dest_id;
	/* Opaque identifier passed from the request to response to allow
	 * response handler perform any further processing */
	uint8_t resp_pipe_id;
	/* Response pipe to write the response associated with this request to */
	uint8_t req_type;
	/* Definition of the service described by the request */
	uint8_t flags;
	/* Request and response control flags */
};

struct arch_if_resp_hdr {
	uint8_t dest_id;
	/* Opaque identifier passed from the request to response to allow
	 * response handler perform any further processing */
	uint8_t serv_id;
	/* Definition of the service id generating the response */
	uint8_t resp_type;
	/* Definition of the service described by the request */
	uint8_t flags;
	/* Request and response control flags */
};

struct fw_comn_req_hdr {
	struct arch_if_req_hdr arch_if;
	/* Common arch fields used by all ICP interface requests. Remaining
	 * fields are specific to the common QAT FW service. */
	uint16_t comn_req_flags;
	/* Flags used to describe common processing required by the request and
	 * the meaning of parameters in it i.e. differentiating between a buffer
	 * descriptor and a flat buffer pointer in the source (src) and destination
	 * (dest) data address fields. Full definition of the fields is given
	 * below */
	uint8_t content_desc_params_sz;
	/* Size of the content descriptor parameters in quad words. These
	 * parameters describe the session setup configuration info for the
	 * slices that this request relies upon i.e. the configuration word and
	 * cipher key needed by the cipher slice if there is a request for cipher
	 * processing. The format of the parameters are contained in icp_qat_hw.h
	 * and vary depending on the algorithm and mode being used. It is the
	 * clients responsibility to ensure this structure is correctly packed */
	uint8_t content_desc_hdr_sz;
	/* Size of the content descriptor header in quad words. This information
	 * is read into the QAT AE xfr registers */
	uint64_t content_desc_addr;
	/* Address of the content descriptor containing both the content header
	 * the size of which is defined by content_desc_hdr_sz followed by the
	 * content parameters whose size is described bycontent_desc_params_sz
	 */
};

struct fw_comn_req_mid {
	uint64_t opaque_data;
	/* Opaque data passed unmodified from the request to response messages
	 * by firmware (fw) */
	uint64_t src_data_addr;
	/* Generic definition of the source data supplied to the QAT AE. The
	 * common flags are used to further describe the attributes of this
	 * field */
	uint64_t dest_data_addr;
	/* Generic definition of the destination data supplied to the QAT AE.
	 * The common flags are used to further describe the attributes of this
	 * field */
};

union fw_comn_req_ftr {
	uint64_t next_request_addr;
	/* Overloaded field, for stateful requests, this field is the pointer to 
	   next request descriptor */
	struct {
		uint32_t src_length;
		/* Length of source flat buffer incase src buffer type is flat */
		uint32_t dst_length;
		/* Length of source flat buffer incase dst buffer type is flat */
	} s;
};

union fw_comn_error {
	struct {
		uint8_t resrvd;		/* 8 bit reserved field */
		uint8_t comn_err_code;	/**< 8 bit common error code */
	} s;
	/* Structure which is used for non-compression responses */

	struct {
		uint8_t xlat_err_code;	/* 8 bit translator error field */
		uint8_t cmp_err_code;	/* 8 bit compression error field */
	} s1;
	/* Structure which is used for compression responses */
};

struct fw_comn_resp_hdr {
	struct arch_if_resp_hdr arch_if;
	/* Common arch fields used by all ICP interface response messages. The
	 * remaining fields are specific to the QAT FW */
	union fw_comn_error comn_error;
	/* This field is overloaded to allow for one 8 bit common error field
	 * or two 8 bit error fields from compression and translator  */
	uint8_t comn_status;
	/* Status field which specifies which slice(s) report an error */
	uint8_t serv_cmd_id;
	/* For services that define multiple commands this field represents the
	 * command. If only 1 command is supported then this field will be 0 */
	uint64_t opaque_data;
	/* Opaque data passed from the request to the response message */
};


#define RING_MASK_TABLE_ENTRY_LOG_SZ			(5)

#define FW_INIT_RING_MASK_SET(table, id)			\
		table->firt_ring_mask[id >> RING_MASK_TABLE_ENTRY_LOG_SZ] =\
		table->firt_ring_mask[id >> RING_MASK_TABLE_ENTRY_LOG_SZ] | \
		(1 << (id & 0x1f))

struct fw_init_ring_params {
	uint8_t firp_curr_weight;	/* Current ring weight (working copy),
					 * has to be equal to init_weight */
	uint8_t firp_init_weight;	/* Initial ring weight: -1 ... 0
					 * -1 is equal to FF, -2 is equal to FE,
					 * the weighting uses negative logic
					 * where FF means poll the ring once,
					 * -2 is poll the ring twice,
					 * 0 is poll the ring 255 times */
	uint8_t firp_ring_pvl;		/* Ring Privilege Level. */
	uint8_t firp_reserved;		/* Reserved field which must be set
					 * to 0 by the client */
};

#define INIT_RING_TABLE_SZ		128
#define INIT_RING_TABLE_LW_SZ		4

struct fw_init_ring_table {
	struct fw_init_ring_params firt_bulk_rings[INIT_RING_TABLE_SZ];
					/* array of ring parameters */
	uint32_t firt_ring_mask[INIT_RING_TABLE_LW_SZ];
					/* Structure to hold the bit masks for
					 * 128 rings. */
};

struct fw_init_set_ae_info_hdr {
	uint16_t init_slice_mask;	/* Init time flags to set the ownership of the slices */
	uint16_t resrvd;		/* Reserved field and must be set to 0 by the client */
	uint8_t init_qat_id;		/* Init time qat id described in the request */
	uint8_t init_ring_cluster_id;	/* Init time ring cluster Id */
	uint8_t init_trgt_id;		/* Init time target AE id described in the request */
	uint8_t init_cmd_id;		/* Init time command that is described in the request */
};

struct fw_init_set_ae_info {
	uint64_t init_shram_mask;	/* Init time shram mask to set the page ownership in page pool of AE*/
	uint64_t resrvd;		/* Reserved field and must be set to 0 by the client */
};

struct fw_init_set_ring_info_hdr {
	uint32_t resrvd;		/* Reserved field and must be set to 0 by the client */
	uint16_t init_ring_tbl_sz;	/* Init time information to state size of the ring table */
	uint8_t init_trgt_id;		/* Init time target AE id described in the request */
	uint8_t init_cmd_id;		/* Init time command that is described in the request */
};

struct fw_init_set_ring_info {
	uint64_t init_ring_table_ptr;	/* Pointer to weighting information for 128 rings  */
	uint64_t resrvd;		/* Reserved field and must be set to 0 by the client */
};

struct fw_init_trng_hdr {
	uint32_t resrvd;	/* Reserved field and must be set to 0 by the client */
	union {
		uint8_t resrvd;	/* Reserved field set to if cmd type is trng disable */
		uint8_t init_trng_cfg_sz;	/* Size of the trng config word in QW*/
	} u;
	uint8_t resrvd1;	/* Reserved field and must be set to 0 by the client */
	uint8_t init_trgt_id;	/* Init time target AE id described in the request */
	uint8_t init_cmd_id;	/* Init time command that is described in the request */
};

struct fw_init_trng {
	union {
		uint64_t resrvd;	/* Reserved field set to 0 if cmd type is trng disable */
		uint64_t init_trng_cfg_ptr;	/* Pointer to TRNG Slice config word*/
	} u;
	uint64_t resrvd;		/* Reserved field and must be set to 0 by the client */
};

struct fw_init_req {
	struct fw_comn_req_hdr comn_hdr;	/* Common request header */
	union {
		struct fw_init_set_ae_info_hdr set_ae_info;
		/* INIT SET_AE_INFO request header structure */
		struct fw_init_set_ring_info_hdr set_ring_info;
		/* INIT SET_RING_INFO request header structure */
		struct fw_init_trng_hdr init_trng;
		/* INIT TRNG ENABLE/DISABLE request header structure */
	} u;
	struct fw_comn_req_mid comn_mid;	/* Common request middle section */
	union {
		struct fw_init_set_ae_info set_ae_info;
		/* INIT SET_AE_INFO request data structure */
		struct fw_init_set_ring_info set_ring_info;
		/* INIT SET_RING_INFO request data structure */
		struct fw_init_trng init_trng;
		/* INIT TRNG ENABLE/DISABLE request data structure */
	} u1;
};

enum fw_init_cmd_id {
	FW_INIT_CMD_SET_AE_INFO,	/* Setup AE Info command type */
	FW_INIT_CMD_SET_RING_INFO,	/* Setup Ring Info command type */
	FW_INIT_CMD_TRNG_ENABLE,	/* TRNG Enable command type */
	FW_INIT_CMD_TRNG_DISABLE,	/* TRNG Disable command type */
	FW_INIT_CMD_DELIMITER		/* Delimiter type */
};

struct fw_init_resp {
	struct fw_comn_resp_hdr comn_resp;	/* Common interface response */
	uint8_t resrvd[64 - sizeof(struct fw_comn_resp_hdr)];
	/* XXX FW_RESP_DEFAULT_SZ_HW15 */
	/* Reserved padding out to the default response size */
};


/* -------------------------------------------------------------------------- */
/* look aside */

#define COMN_REQ_ORD				UINT16_C(0x8000)
#define  COMN_REQ_ORD_SHIFT			15
#define   COMN_REQ_ORD_NONE			(0 << COMN_REQ_ORD_SHIFT)
#define   COMN_REQ_ORD_STRICT			(1 << COMN_REQ_ORD_SHIFT)
#define COMN_REQ_PTR_TYPE			UINT16_C(0x4000)
#define  COMN_REQ_PTR_TYPE_SHIFT		14
#define   COMN_REQ_PTR_TYPE_FLAT		(0 << COMN_REQ_PTR_TYPE_SHIFT)
#define   COMN_REQ_PTR_TYPE_SGL			(1 << COMN_REQ_PTR_TYPE_SHIFT)
#define COMN_REQ_RESERVED			UINT16_C(0x2000)
#define COMN_REQ_SHRAM_INIT			UINT16_C(0x1000)
#define  COMN_REQ_SHRAM_INIT_SHIFT		12
#define  COMN_REQ_SHRAM_INIT_REQUIRED		(1 << COMN_REQ_SHRAM_INIT_SHIFT)
#define COMN_REQ_REGEX_SLICE			UINT16_C(0x0800)
#define  COMN_REQ_REGEX_SLICE_SHIFT		11
#define   COMN_REQ_REGEX_SLICE_REQUIRED		(1 << COMN_REQ_REGEX_SLICE_SHIFT)
#define COMN_REQ_XLAT_SLICE			UINT16_C(0x0400)
#define  COMN_REQ_XLAT_SLICE_SHIFT		10
#define   COMN_REQ_XLAT_SLICE_REQUIRED		(1 << COMN_REQ_XLAT_SLICE_SHIFT)
#define COMN_REQ_CPR_SLICE			UINT16_C(0x0200)
#define  COMN_REQ_CPR_SLICE_SHIFT		9
#define   COMN_REQ_CPR_SLICE_REQUIRED		(1 << COMN_REQ_CPR_SLICE_SHIFT)
#define COMN_REQ_BULK_SLICE			UINT16_C(0x0100)
#define  COMN_REQ_BULK_SLICE_SHIFT		8
#define   COMN_REQ_BULK_SLICE_REQUIRED		(1 << COMN_REQ_BULK_SLICE_SHIFT)
#define COMN_REQ_STORAGE_SLICE			UINT16_C(0x0080)
#define  COMN_REQ_STORAGE_SLICE_SHIFT		7
#define   COMN_REQ_STORAGE_SLICE_REQUIRED	(1 << COMN_REQ_STORAGE_SLICE_SHIFT)
#define COMN_REQ_RND_SLICE			UINT16_C(0x0040)
#define  COMN_REQ_RND_SLICE_SHIFT		6
#define   COMN_REQ_RND_SLICE_REQUIRED		(1 << COMN_REQ_RND_SLICE_SHIFT)
#define COMN_REQ_PKE1_SLICE			UINT16_C(0x0020)
#define  COMN_REQ_PKE1_SLICE_SHIFT		5
#define   COMN_REQ_PKE1_SLICE_REQUIRED		(1 << COMN_REQ_PKE1_SLICE_SHIFT)
#define COMN_REQ_PKE0_SLICE			UINT16_C(0x0010)
#define  COMN_REQ_PKE0_SLICE_SHIFT		4
#define   COMN_REQ_PKE0_SLICE_REQUIRED		(1 << COMN_REQ_PKE0_SLICE_SHIFT)
#define COMN_REQ_AUTH1_SLICE			UINT16_C(0x0008)
#define  COMN_REQ_AUTH1_SLICE_SHIFT		3
#define   COMN_REQ_AUTH1_SLICE_REQUIRED		(1 << COMN_REQ_AUTH1_SLICE_SHIFT)
#define COMN_REQ_AUTH0_SLICE			UINT16_C(0x0004)
#define  COMN_REQ_AUTH0_SLICE_SHIFT		2
#define   COMN_REQ_AUTH0_SLICE_REQUIRED		(1 << COMN_REQ_AUTH0_SLICE_SHIFT)
#define COMN_REQ_CIPHER1_SLICE			UINT16_C(0x0002)
#define  COMN_REQ_CIPHER1_SLICE_SHIFT		1
#define   COMN_REQ_CIPHER1_SLICE_REQUIRED	(1 << COMN_REQ_CIPHER1_SLICE_SHIFT)
#define COMN_REQ_CIPHER0_SLICE			UINT16_C(0x0001)
#define  COMN_REQ_CIPHER0_SLICE_SHIFT		0
#define   COMN_REQ_CIPHER0_SLICE_REQUIRED	(1 << COMN_REQ_CIPHER0_SLICE_SHIFT)

#define COMN_REQ_CY0_ONLY(shram)			\
		COMN_REQ_ORD_STRICT |			\
		COMN_REQ_PTR_TYPE_FLAT |		\
		(shram) |				\
		COMN_REQ_RND_SLICE_REQUIRED | 		\
		COMN_REQ_PKE0_SLICE_REQUIRED |		\
		COMN_REQ_AUTH0_SLICE_REQUIRED |		\
		COMN_REQ_CIPHER0_SLICE_REQUIRED;
#define COMN_REQ_CY1_ONLY(shram)			\
		COMN_REQ_ORD_STRICT |			\
		COMN_REQ_PTR_TYPE_FLAT |		\
		(shram) |				\
		COMN_REQ_PKE1_SLICE_REQUIRED |		\
		COMN_REQ_AUTH1_SLICE_REQUIRED |		\
		COMN_REQ_CIPHER1_SLICE_REQUIRED;

#define COMN_RESP_CRYPTO_STATUS		__BIT(7)
#define COMN_RESP_PKE_STATUS		__BIT(6)
#define COMN_RESP_CMP_STATUS		__BIT(5)
#define COMN_RESP_XLAT_STATUS		__BIT(4)
#define COMN_RESP_PM_STATUS		__BIT(3)
#define COMN_RESP_INIT_ADMIN_STATUS	__BIT(2)

#define COMN_STATUS_FLAG_OK		0
#define COMN_STATUS_FLAG_ERROR		1

struct fw_la_ssl_tls_common {
	uint8_t out_len;	/* Number of bytes of key material to output. */
	uint8_t label_len;	/* Number of bytes of label for SSL and bytes
				 * for TLS key generation  */
};

struct fw_la_mgf_common {
	uint8_t hash_len;
	/* Number of bytes of hash output by the QAT per iteration */
	uint8_t seed_len;
	/* Number of bytes of seed provided in src buffer for MGF1 */
};

struct fw_cipher_hdr {
	uint8_t state_sz;
	/* State size in quad words of the cipher algorithm used in this session.
	 * Set to zero if the algorithm doesnt provide any state */
	uint8_t offset;
	/* Quad word offset from the content descriptor parameters address i.e.
	 * (content_address + (cd_hdr_sz << 3)) to the parameters for the cipher
	 * processing */
	uint8_t curr_id;
	/* Initialised with the cipher slice type */
	uint8_t next_id;
	/* Set to the next slice to pass the ciphered data through.
	 * Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go through
	 * anymore slices after cipher */
	uint16_t resrvd;
	/* Reserved padding byte to bring the struct to the word boundary. MUST be
	 * set to 0 */
	uint8_t state_padding_sz;
	/* State padding size in quad words. Set to 0 if no padding is required. */
	uint8_t key_sz;
	/* Key size in quad words of the cipher algorithm used in this session */
};

struct fw_auth_hdr {
	uint8_t hash_flags;
	/* General flags defining the processing to perform. 0 is normal processing
	 * and 1 means there is a nested hash processing loop to go through */
	uint8_t offset;
	/* Quad word offset from the content descriptor parameters address to the
	 * parameters for the auth processing */
	uint8_t curr_id;
	/* Initialised with the auth slice type */
	uint8_t next_id;
	/* Set to the next slice to pass data through.
	 * Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go through
	 * anymore slices after auth */
	union {
		uint8_t inner_prefix_sz;
		/* Size in bytes of the inner prefix data */
		uint8_t aad_sz;
		/* Size in bytes of padded AAD data to prefix to the packet for CCM
		 *  or GCM processing */
	} u;

	uint8_t outer_prefix_sz;
	/* Size in bytes of outer prefix data */
	uint8_t final_sz;
	/* Size in bytes of digest to be returned to the client if requested */
	uint8_t inner_res_sz;
	/* Size in bytes of the digest from the inner hash algorithm */
	uint8_t resrvd;
	/* This field is unused, assumed value is zero. */
	uint8_t inner_state1_sz;
	/* Size in bytes of inner hash state1 data. Must be a qword multiple */
	uint8_t inner_state2_off;
	/* Quad word offset from the content descriptor parameters pointer to the
	 * inner state2 value */
	uint8_t inner_state2_sz;
	/* Size in bytes of inner hash state2 data. Must be a qword multiple */
	uint8_t outer_config_off;
	/* Quad word offset from the content descriptor parameters pointer to the
	 * outer configuration information */
	uint8_t outer_state1_sz;
	/* Size in bytes of the outer state1 value */
	uint8_t outer_res_sz;
	/* Size in bytes of digest from the outer auth algorithm */
	uint8_t outer_prefix_off;
	/* Quad word offset from the start of the inner prefix data to the outer
	 * prefix information. Should equal the rounded inner prefix size, converted
	 * to qwords  */
};

#define FW_AUTH_HDR_FLAG_DO_NESTED	1
#define FW_AUTH_HDR_FLAG_NO_NESTED	0

struct fw_la_comn_req {
	union {
		uint16_t la_flags;
		/* Definition of the common LA processing flags used for the
		 * bulk processing */
		union {
			struct fw_la_ssl_tls_common ssl_tls_common;
			/* For TLS or SSL Key Generation, this field is
			 * overloaded with ssl_tls common information */
			struct fw_la_mgf_common mgf_common;
			/* For MGF Key Generation, this field is overloaded with
			   mgf information */
		} u;
	} u;

	union {
		uint8_t resrvd;
		/* If not useRd by a request this field must be set to 0 */
		uint8_t tls_seed_len;
		/* Byte Len of tls seed */
		uint8_t req_params_blk_sz;
		/* For bulk processing this field represents the request
		 * parameters block size */
		uint8_t trng_cfg_sz;
		/* This field is used for TRNG_ENABLE requests to indicate the
		 * size of the TRNG Slice configuration word. Size is in QW's */
	} u1;
	uint8_t la_cmd_id;
	/* Definition of the LA command defined by this request */

};

#define LA_FLAGS_GCM_IV_LEN_FLAG	__BIT(9)
#define LA_FLAGS_PROTO			__BITS(8, 6)
#define LA_FLAGS_PROTO_SNOW_3G		__SHIFTIN(4, LA_FLAGS_PROTO)
#define LA_FLAGS_PROTO_GCM		__SHIFTIN(2, LA_FLAGS_PROTO)
#define LA_FLAGS_PROTO_CCM		__SHIFTIN(1, LA_FLAGS_PROTO)
#define LA_FLAGS_PROTO_NO		__SHIFTIN(0, LA_FLAGS_PROTO)
#define LA_FLAGS_DIGEST_IN_BUFFER	__BIT(5)
#define LA_FLAGS_CMP_AUTH_RES		__BIT(4)
#define LA_FLAGS_RET_AUTH_RES		__BIT(3)
#define LA_FLAGS_UPDATE_STATE		__BIT(2)
#define LA_FLAGS_PARTIAL		__BITS(1, 0)


struct fw_la_bulk_req {
	struct fw_comn_req_hdr comn_hdr;
	/* Common request header */
	uint32_t flow_id;
	/* Field used by Firmware to limit the number of stateful requests
	 * for a session being processed at a given point of time */
	struct fw_la_comn_req comn_la_req;
	/* Common LA request parameters */
	struct fw_comn_req_mid comn_mid;
	/* Common request middle section */
	uint64_t req_params_addr;
	/* Memory address of the request parameters */
	union fw_comn_req_ftr comn_ftr;
	/* Common request footer */
};

struct fw_la_resp {
	struct fw_comn_resp_hdr comn_resp;
	uint8_t resrvd[64 - sizeof(struct fw_comn_resp_hdr)];
	/* FW_RESP_DEFAULT_SZ_HW15 */
};

struct fw_la_cipher_req_params {
	uint8_t resrvd;
	/* Reserved field and assumed set to 0 */
	uint8_t cipher_state_sz;
	/* Number of quad words of state data for the cipher algorithm */
	uint8_t curr_id;
	/* Initialised with the cipher slice type */
	uint8_t next_id;
	/* Set to the next slice to pass the ciphered data through.
	 * Set to ICP_QAT_FW_SLICE_DRAM_WR if the data is not to go through
	 * anymore slices after cipher */
	uint16_t resrvd1;
	/* Reserved field, should be set to zero*/
	uint8_t resrvd2;
	/* Reserved field, should be set to zero*/
	uint8_t next_offset;
	/* Offset in bytes to the next request parameter block */
	uint32_t cipher_off;
	/* Byte offset from the start of packet to the cipher data region */
	uint32_t cipher_len;
	/* Byte length of the cipher data region */
	uint64_t state_address;
	/* Flat buffer address in memory of the cipher state information. Unused
	 * if the state size is 0 */
};

struct fw_la_auth_req_params {
	uint8_t auth_res_sz;
	/* Size in quad words of digest information to validate */
	uint8_t hash_state_sz;
	/* Number of quad words of inner and outer hash prefix data to process */
	uint8_t curr_id;
	/* Initialised with the auth slice type */
	uint8_t next_id;
	/* Set to the next slice to pass the auth data through.
	 * Set to ICP_QAT_FW_SLICE_NULL for in-place auth-only requests
	 * Set to ICP_QAT_FW_SLICE_DRAM_WR for all other request types
	 * if the data is not to go through anymore slices after auth */
	union {
		uint16_t resrvd;
		/* Reserved field should be set to zero for bulk services */
		uint16_t tls_secret_len;
		/* Length of Secret information for TLS.   */
	} u;
	uint8_t resrvd;
	/* Reserved field, should be set to zero*/
	uint8_t next_offset;
	/* offset in bytes to the next request parameter block */
	uint32_t auth_off;
	/* Byte offset from the start of packet to the auth data region */
	uint32_t auth_len;
	/* Byte length of the auth data region */
	union {
		uint64_t prefix_addr;
		/* Address of the prefix information */
		uint64_t aad_addr;
		/* Address of the AAD info in DRAM. Used for the CCM and GCM
		 * protocols */
	} u1;
	uint64_t auth_res_address;
	/* Address of the auth result information to validate or the location to
	 * writeback the digest information to */
};


#endif