xref: /freebsd/sys/dev/qat_c2xxx/qatreg.h (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1 /* SPDX-License-Identifier: BSD-2-Clause AND BSD-3-Clause */
2 /*	$NetBSD: qatreg.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) 2007-2019 Intel Corporation. All rights reserved.
32  *
33  *   Redistribution and use in source and binary forms, with or without
34  *   modification, are permitted provided that the following conditions
35  *   are met:
36  *
37  *     * Redistributions of source code must retain the above copyright
38  *       notice, this list of conditions and the following disclaimer.
39  *     * Redistributions in binary form must reproduce the above copyright
40  *       notice, this list of conditions and the following disclaimer in
41  *       the documentation and/or other materials provided with the
42  *       distribution.
43  *     * Neither the name of Intel Corporation nor the names of its
44  *       contributors may be used to endorse or promote products derived
45  *       from this software without specific prior written permission.
46  *
47  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
51  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58  */
59 
60 
61 #ifndef _DEV_PCI_QATREG_H_
62 #define _DEV_PCI_QATREG_H_
63 
64 #define	__BIT(__n)						\
65 	(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 :	\
66 	((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1))))
67 #define	__BITS(__m, __n)		\
68 	((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
69 
70 #define	__LOWEST_SET_BIT(__mask)	((((__mask) - 1) & (__mask)) ^ (__mask))
71 #define	__SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask))
72 #define	__SHIFTIN(__x, __mask)		((__x) * __LOWEST_SET_BIT(__mask))
73 
74 /* Limits */
75 #define MAX_NUM_AE		0x10
76 #define MAX_NUM_ACCEL		6
77 #define MAX_AE			0x18
78 #define MAX_AE_CTX		8
79 #define MAX_ARB			4
80 
81 #define MAX_USTORE_PER_SEG	0x8000	/* 16k * 2 */
82 #define MAX_USTORE		MAX_USTORE_PER_SEG
83 
84 #define MAX_AE_PER_ACCEL	4	/* XXX */
85 #define MAX_BANK_PER_ACCEL	16	/* XXX */
86 #define MAX_RING_PER_BANK	16
87 
88 #define MAX_XFER_REG		128
89 #define MAX_GPR_REG		128
90 #define MAX_NN_REG		128
91 #define MAX_LMEM_REG		1024
92 #define MAX_INP_STATE		16
93 #define MAX_CAM_REG		16
94 #define MAX_FIFO_QWADDR		160
95 
96 #define MAX_EXEC_INST		100
97 #define UWORD_CPYBUF_SIZE	1024	/* micro-store copy buffer (bytes) */
98 #define INVLD_UWORD		0xffffffffffull	/* invalid micro-instruction */
99 #define AEV2_PACKED_UWORD_BYTES	6	/* version 2 packed uword size */
100 #define UWORD_MASK		0xbffffffffffull  /* micro-word mask without parity */
101 
102 #define AE_ALL_CTX		0xff
103 
104 /* PCIe configuration space parameter */
105 #define NO_PCI_REG			(-1)
106 #define NO_REG_OFFSET			0
107 
108 #define MAX_BARS			3
109 
110 /* Fuse Control */
111 #define FUSECTL_REG			0x40
112 #define FUSECTL_MASK			__BIT(31)
113 
114 #define LEGFUSE_REG			0x4c
115 #define LEGFUSE_ACCEL_MASK_CIPHER_SLICE		__BIT(0)
116 #define LEGFUSE_ACCEL_MASK_AUTH_SLICE		__BIT(1)
117 #define LEGFUSE_ACCEL_MASK_PKE_SLICE		__BIT(2)
118 #define LEGFUSE_ACCEL_MASK_COMPRESS_SLICE	__BIT(3)
119 #define LEGFUSE_ACCEL_MASK_LZS_SLICE		__BIT(4)
120 #define LEGFUSE_ACCEL_MASK_EIA3_SLICE		__BIT(5)
121 #define LEGFUSE_ACCEL_MASK_SHA3_SLICE		__BIT(6)
122 
123 /* -------------------------------------------------------------------------- */
124 /* PETRINGCSR region */
125 
126 /* ETR parameters */
127 #define ETR_MAX_RINGS_PER_BANK	16
128 
129 /* ETR registers */
130 #define ETR_RING_CONFIG		0x0000
131 #define ETR_RING_LBASE		0x0040
132 #define ETR_RING_UBASE		0x0080
133 #define ETR_RING_HEAD_OFFSET	0x00C0
134 #define ETR_RING_TAIL_OFFSET	0x0100
135 #define ETR_RING_STAT		0x0140
136 #define ETR_UO_STAT		0x0148
137 #define ETR_E_STAT		0x014C
138 #define ETR_NE_STAT		0x0150
139 #define ETR_NF_STAT		0x0154
140 #define ETR_F_STAT		0x0158
141 #define ETR_C_STAT		0x015C
142 #define ETR_INT_EN		0x016C
143 #define ETR_INT_REG		0x0170
144 #define ETR_INT_SRCSEL		0x0174
145 #define ETR_INT_SRCSEL_2	0x0178
146 #define ETR_INT_COL_EN		0x017C
147 #define ETR_INT_COL_CTL		0x0180
148 #define ETR_AP_NF_MASK		0x2000
149 #define ETR_AP_NF_DEST		0x2020
150 #define ETR_AP_NE_MASK		0x2040
151 #define ETR_AP_NE_DEST		0x2060
152 #define ETR_AP_DELAY		0x2080
153 
154 /* ARB registers */
155 #define ARB_OFFSET			0x30000
156 #define ARB_REG_SIZE			0x4
157 #define ARB_WTR_SIZE			0x20
158 #define ARB_REG_SLOT			0x1000
159 #define ARB_WTR_OFFSET			0x010
160 #define ARB_RO_EN_OFFSET		0x090
161 #define ARB_WRK_2_SER_MAP_OFFSET	0x180
162 #define ARB_RINGSRVARBEN_OFFSET		0x19c
163 
164 /* Ring Config */
165 #define ETR_RING_CONFIG_LATE_HEAD_POINTER_MODE		__BIT(31)
166 #define ETR_RING_CONFIG_NEAR_FULL_WM			__BITS(14, 10)
167 #define ETR_RING_CONFIG_NEAR_EMPTY_WM			__BITS(9, 5)
168 #define ETR_RING_CONFIG_RING_SIZE			__BITS(4, 0)
169 
170 #define ETR_RING_CONFIG_NEAR_WM_0		0x00
171 #define ETR_RING_CONFIG_NEAR_WM_4		0x01
172 #define ETR_RING_CONFIG_NEAR_WM_8		0x02
173 #define ETR_RING_CONFIG_NEAR_WM_16		0x03
174 #define ETR_RING_CONFIG_NEAR_WM_32		0x04
175 #define ETR_RING_CONFIG_NEAR_WM_64		0x05
176 #define ETR_RING_CONFIG_NEAR_WM_128		0x06
177 #define ETR_RING_CONFIG_NEAR_WM_256		0x07
178 #define ETR_RING_CONFIG_NEAR_WM_512		0x08
179 #define ETR_RING_CONFIG_NEAR_WM_1K		0x09
180 #define ETR_RING_CONFIG_NEAR_WM_2K		0x0A
181 #define ETR_RING_CONFIG_NEAR_WM_4K		0x0B
182 #define ETR_RING_CONFIG_NEAR_WM_8K		0x0C
183 #define ETR_RING_CONFIG_NEAR_WM_16K		0x0D
184 #define ETR_RING_CONFIG_NEAR_WM_32K		0x0E
185 #define ETR_RING_CONFIG_NEAR_WM_64K		0x0F
186 #define ETR_RING_CONFIG_NEAR_WM_128K		0x10
187 #define ETR_RING_CONFIG_NEAR_WM_256K		0x11
188 #define ETR_RING_CONFIG_NEAR_WM_512K		0x12
189 #define ETR_RING_CONFIG_NEAR_WM_1M		0x13
190 #define ETR_RING_CONFIG_NEAR_WM_2M		0x14
191 #define ETR_RING_CONFIG_NEAR_WM_4M		0x15
192 
193 #define ETR_RING_CONFIG_SIZE_64			0x00
194 #define ETR_RING_CONFIG_SIZE_128		0x01
195 #define ETR_RING_CONFIG_SIZE_256		0x02
196 #define ETR_RING_CONFIG_SIZE_512		0x03
197 #define ETR_RING_CONFIG_SIZE_1K			0x04
198 #define ETR_RING_CONFIG_SIZE_2K			0x05
199 #define ETR_RING_CONFIG_SIZE_4K			0x06
200 #define ETR_RING_CONFIG_SIZE_8K			0x07
201 #define ETR_RING_CONFIG_SIZE_16K		0x08
202 #define ETR_RING_CONFIG_SIZE_32K		0x09
203 #define ETR_RING_CONFIG_SIZE_64K		0x0A
204 #define ETR_RING_CONFIG_SIZE_128K		0x0B
205 #define ETR_RING_CONFIG_SIZE_256K		0x0C
206 #define ETR_RING_CONFIG_SIZE_512K		0x0D
207 #define ETR_RING_CONFIG_SIZE_1M			0x0E
208 #define ETR_RING_CONFIG_SIZE_2M			0x0F
209 #define ETR_RING_CONFIG_SIZE_4M			0x10
210 
211 /* Default Ring Config is Nearly Full = Full and Nearly Empty = Empty */
212 #define ETR_RING_CONFIG_BUILD(size)					\
213 		(__SHIFTIN(ETR_RING_CONFIG_NEAR_WM_0,			\
214 		    ETR_RING_CONFIG_NEAR_FULL_WM) |			\
215 		__SHIFTIN(ETR_RING_CONFIG_NEAR_WM_0,			\
216 		    ETR_RING_CONFIG_NEAR_EMPTY_WM) |			\
217 		__SHIFTIN((size), ETR_RING_CONFIG_RING_SIZE))
218 
219 /* Response Ring Configuration */
220 #define ETR_RING_CONFIG_BUILD_RESP(size, wm_nf, wm_ne)			\
221 		(__SHIFTIN((wm_nf), ETR_RING_CONFIG_NEAR_FULL_WM) |	\
222 		__SHIFTIN((wm_ne), ETR_RING_CONFIG_NEAR_EMPTY_WM) |	\
223 		__SHIFTIN((size), ETR_RING_CONFIG_RING_SIZE))
224 
225 /* Ring Base */
226 #define ETR_RING_BASE_BUILD(addr, size)					\
227 		(((addr) >> 6) & (0xFFFFFFFFFFFFFFFFULL << (size)))
228 
229 #define ETR_INT_REG_CLEAR_MASK	0xffff
230 
231 /* Initial bank Interrupt Source mask */
232 #define ETR_INT_SRCSEL_MASK	0x44444444UL
233 
234 #define ETR_INT_SRCSEL_NEXT_OFFSET	4
235 
236 #define ETR_RINGS_PER_INT_SRCSEL	8
237 
238 #define ETR_INT_COL_CTL_ENABLE	__BIT(31)
239 
240 #define ETR_AP_NF_MASK_INIT	0xAAAAAAAA
241 #define ETR_AP_NE_MASK_INIT	0x55555555
242 
243 /* Autopush destination AE bit */
244 #define ETR_AP_DEST_ENABLE	__BIT(7)
245 #define ETR_AP_DEST_AE		__BITS(6, 2)
246 #define ETR_AP_DEST_MAILBOX	__BITS(1, 0)
247 
248 /* Autopush destination enable bit */
249 
250 /* Autopush CSR Offset */
251 #define ETR_AP_BANK_OFFSET		4
252 
253 /* Autopush maximum rings per bank */
254 #define ETR_MAX_RINGS_PER_AP_BANK		32
255 
256 /* Maximum mailbox per acclerator */
257 #define ETR_MAX_MAILBOX_PER_ACCELERATOR		4
258 
259 /* Maximum AEs per mailbox */
260 #define ETR_MAX_AE_PER_MAILBOX			4
261 
262 /* Macro to get the ring's autopush bank number */
263 #define ETR_RING_AP_BANK_NUMBER(ring)	((ring) >> 5)
264 
265 /* Macro to get the ring's autopush mailbox number */
266 #define ETR_RING_AP_MAILBOX_NUMBER(ring)		\
267     (ETR_RING_AP_BANK_NUMBER(ring) % ETR_MAX_MAILBOX_PER_ACCELERATOR)
268 
269 /* Macro to get the ring number in the autopush bank */
270 #define ETR_RING_NUMBER_IN_AP_BANK(ring)	\
271 	((ring) % ETR_MAX_RINGS_PER_AP_BANK)
272 
273 #define ETR_RING_EMPTY_ENTRY_SIG	(0x7F7F7F7F)
274 
275 /* -------------------------------------------------------------------------- */
276 /* CAP_GLOBAL_CTL region */
277 
278 #define FCU_CTRL			0x8c0
279 #define FCU_CTRL_CMD_NOOP		0
280 #define FCU_CTRL_CMD_AUTH		1
281 #define FCU_CTRL_CMD_LOAD		2
282 #define FCU_CTRL_CMD_START		3
283 #define FCU_CTRL_AE			__BITS(8, 31)
284 
285 #define FCU_STATUS			0x8c4
286 #define FCU_STATUS_STS			__BITS(0, 2)
287 #define FCU_STATUS_STS_NO		0
288 #define FCU_STATUS_STS_VERI_DONE	1
289 #define FCU_STATUS_STS_LOAD_DONE	2
290 #define FCU_STATUS_STS_VERI_FAIL	3
291 #define FCU_STATUS_STS_LOAD_FAIL	4
292 #define FCU_STATUS_STS_BUSY		5
293 #define FCU_STATUS_AUTHFWLD		__BIT(8)
294 #define FCU_STATUS_DONE			__BIT(9)
295 #define FCU_STATUS_LOADED_AE		__BITS(22, 31)
296 
297 #define FCU_STATUS1			0x8c8
298 
299 #define FCU_DRAM_ADDR_LO	0x8cc
300 #define FCU_DRAM_ADDR_HI	0x8d0
301 #define FCU_RAMBASE_ADDR_HI	0x8d4
302 #define FCU_RAMBASE_ADDR_LO	0x8d8
303 
304 #define FW_AUTH_WAIT_PERIOD 10
305 #define FW_AUTH_MAX_RETRY   300
306 
307 #define CAP_GLOBAL_CTL_BASE			0xa00
308 #define CAP_GLOBAL_CTL_MISC			CAP_GLOBAL_CTL_BASE + 0x04
309 #define CAP_GLOBAL_CTL_MISC_TIMESTAMP_EN	__BIT(7)
310 #define CAP_GLOBAL_CTL_RESET			CAP_GLOBAL_CTL_BASE + 0x0c
311 #define CAP_GLOBAL_CTL_RESET_MASK		__BITS(31, 26)
312 #define CAP_GLOBAL_CTL_RESET_ACCEL_MASK		__BITS(25, 20)
313 #define CAP_GLOBAL_CTL_RESET_AE_MASK		__BITS(19, 0)
314 #define CAP_GLOBAL_CTL_CLK_EN			CAP_GLOBAL_CTL_BASE + 0x50
315 #define CAP_GLOBAL_CTL_CLK_EN_ACCEL_MASK	__BITS(25, 20)
316 #define CAP_GLOBAL_CTL_CLK_EN_AE_MASK		__BITS(19, 0)
317 
318 /* -------------------------------------------------------------------------- */
319 /* AE region */
320 #define UPC_MASK		0x1ffff
321 #define USTORE_SIZE		QAT_16K
322 
323 #define AE_LOCAL_AE_MASK			__BITS(31, 12)
324 #define AE_LOCAL_CSR_MASK			__BITS(9, 0)
325 
326 /* AE_LOCAL registers */
327 /* Control Store Address Register */
328 #define USTORE_ADDRESS				0x000
329 #define USTORE_ADDRESS_ECS			__BIT(31)
330 
331 #define USTORE_ECC_BIT_0	44
332 #define USTORE_ECC_BIT_1	45
333 #define USTORE_ECC_BIT_2	46
334 #define USTORE_ECC_BIT_3	47
335 #define USTORE_ECC_BIT_4	48
336 #define USTORE_ECC_BIT_5	49
337 #define USTORE_ECC_BIT_6	50
338 
339 /* Control Store Data Lower Register */
340 #define USTORE_DATA_LOWER			0x004
341 /* Control Store Data Upper Register */
342 #define USTORE_DATA_UPPER			0x008
343 /* Control Store Error Status Register */
344 #define USTORE_ERROR_STATUS			0x00c
345 /* Arithmetic Logic Unit Output Register */
346 #define ALU_OUT					0x010
347 /* Context Arbiter Control Register */
348 #define CTX_ARB_CNTL				0x014
349 #define CTX_ARB_CNTL_INIT			0x00000000
350 /* Context Enables Register */
351 #define CTX_ENABLES				0x018
352 #define CTX_ENABLES_INIT			0
353 #define CTX_ENABLES_INUSE_CONTEXTS		__BIT(31)
354 #define CTX_ENABLES_CNTL_STORE_PARITY_ERROR	__BIT(29)
355 #define CTX_ENABLES_CNTL_STORE_PARITY_ENABLE	__BIT(28)
356 #define CTX_ENABLES_BREAKPOINT			__BIT(27)
357 #define CTX_ENABLES_PAR_ERR			__BIT(25)
358 #define CTX_ENABLES_NN_MODE			__BIT(20)
359 #define CTX_ENABLES_NN_RING_EMPTY		__BIT(18)
360 #define CTX_ENABLES_LMADDR_1_GLOBAL		__BIT(17)
361 #define CTX_ENABLES_LMADDR_0_GLOBAL		__BIT(16)
362 #define CTX_ENABLES_ENABLE			__BITS(15,8)
363 
364 #define CTX_ENABLES_IGNORE_W1C_MASK		\
365 		(~(CTX_ENABLES_PAR_ERR |	\
366 		CTX_ENABLES_BREAKPOINT |	\
367 		CTX_ENABLES_CNTL_STORE_PARITY_ERROR))
368 
369 /* cycles from CTX_ENABLE high to CTX entering executing state */
370 #define CYCLES_FROM_READY2EXE	8
371 
372 /* Condition Code Enable Register */
373 #define CC_ENABLE				0x01c
374 #define CC_ENABLE_INIT				0x2000
375 
376 /* CSR Context Pointer Register */
377 #define CSR_CTX_POINTER				0x020
378 #define CSR_CTX_POINTER_CONTEXT			__BITS(2,0)
379 /* Register Error Status Register */
380 #define REG_ERROR_STATUS			0x030
381 /* Indirect Context Status Register */
382 #define CTX_STS_INDIRECT			0x040
383 #define CTX_STS_INDIRECT_UPC_INIT		0x00000000
384 
385 /* Active Context Status Register */
386 #define ACTIVE_CTX_STATUS			0x044
387 #define ACTIVE_CTX_STATUS_ABO			__BIT(31)
388 #define ACTIVE_CTX_STATUS_ACNO			__BITS(0, 2)
389 /* Indirect Context Signal Events Register */
390 #define CTX_SIG_EVENTS_INDIRECT			0x048
391 #define CTX_SIG_EVENTS_INDIRECT_INIT		0x00000001
392 /* Active Context Signal Events Register */
393 #define CTX_SIG_EVENTS_ACTIVE			0x04c
394 /* Indirect Context Wakeup Events Register */
395 #define CTX_WAKEUP_EVENTS_INDIRECT		0x050
396 #define CTX_WAKEUP_EVENTS_INDIRECT_VOLUNTARY	0x00000001
397 #define CTX_WAKEUP_EVENTS_INDIRECT_SLEEP	0x00010000
398 
399 #define CTX_WAKEUP_EVENTS_INDIRECT_INIT		0x00000001
400 
401 /* Active Context Wakeup Events Register */
402 #define CTX_WAKEUP_EVENTS_ACTIVE		0x054
403 /* Indirect Context Future Count Register */
404 #define CTX_FUTURE_COUNT_INDIRECT		0x058
405 /* Active Context Future Count Register */
406 #define CTX_FUTURE_COUNT_ACTIVE		0x05c
407 /* Indirect Local Memory Address 0 Register */
408 #define LM_ADDR_0_INDIRECT			0x060
409 /* Active Local Memory Address 0 Register */
410 #define LM_ADDR_0_ACTIVE			0x064
411 /* Indirect Local Memory Address 1 Register */
412 #define LM_ADDR_1_INDIRECT			0x068
413 /* Active Local Memory Address 1 Register */
414 #define LM_ADDR_1_ACTIVE			0x06c
415 /* Byte Index Register */
416 #define BYTE_INDEX				0x070
417 /* Indirect Local Memory Address 0 Byte Index Register */
418 #define INDIRECT_LM_ADDR_0_BYTE_INDEX		0x0e0
419 /* Active Local Memory Address 0 Byte Index Register */
420 #define ACTIVE_LM_ADDR_0_BYTE_INDEX		0x0e4
421 /* Indirect Local Memory Address 1 Byte Index Register */
422 #define INDIRECT_LM_ADDR_1_BYTE_INDEX		0x0e8
423 /* Active Local Memory Address 1 Byte Index Register */
424 #define ACTIVE_LM_ADDR_1_BYTE_INDEX		0x0ec
425 /* Transfer Index Concatenated with Byte Index Register */
426 #define T_INDEX_BYTE_INDEX			0x0f4
427 /* Transfer Index Register */
428 #define T_INDEX				0x074
429 /* Indirect Future Count Signal Signal Register */
430 #define FUTURE_COUNT_SIGNAL_INDIRECT		0x078
431 /* Active Context Future Count Register */
432 #define FUTURE_COUNT_SIGNAL_ACTIVE		0x07c
433 /* Next Neighbor Put Register */
434 #define NN_PUT					0x080
435 /* Next Neighbor Get Register */
436 #define NN_GET					0x084
437 /* Timestamp Low Register */
438 #define TIMESTAMP_LOW				0x0c0
439 /* Timestamp High Register */
440 #define TIMESTAMP_HIGH				0x0c4
441 /* Next Neighbor Signal Register */
442 #define NEXT_NEIGHBOR_SIGNAL			0x100
443 /* Previous Neighbor Signal Register */
444 #define PREV_NEIGHBOR_SIGNAL			0x104
445 /* Same AccelEngine Signal Register */
446 #define SAME_AE_SIGNAL				0x108
447 /* Cyclic Redundancy Check Remainder Register */
448 #define CRC_REMAINDER				0x140
449 /* Profile Count Register */
450 #define PROFILE_COUNT				0x144
451 /* Pseudorandom Number Register */
452 #define PSEUDO_RANDOM_NUMBER			0x148
453 /* Signature Enable Register */
454 #define SIGNATURE_ENABLE			0x150
455 /* Miscellaneous Control Register */
456 #define AE_MISC_CONTROL			0x160
457 #define AE_MISC_CONTROL_PARITY_ENABLE		__BIT(24)
458 #define AE_MISC_CONTROL_FORCE_BAD_PARITY	__BIT(23)
459 #define AE_MISC_CONTROL_ONE_CTX_RELOAD		__BIT(22)
460 #define AE_MISC_CONTROL_CS_RELOAD		__BITS(21, 20)
461 #define AE_MISC_CONTROL_SHARE_CS		__BIT(2)
462 /* Control Store Address 1 Register */
463 #define USTORE_ADDRESS1			0x158
464 /* Local CSR Status Register */
465 #define LOCAL_CSR_STATUS					0x180
466 #define LOCAL_CSR_STATUS_STATUS				0x1
467 /* NULL Register */
468 #define NULL_CSR				0x3fc
469 
470 /* AE_XFER macros */
471 #define AE_XFER_AE_MASK					__BITS(31, 12)
472 #define AE_XFER_CSR_MASK				__BITS(9, 2)
473 
474 #define AEREG_BAD_REGADDR	0xffff		/* bad register address */
475 
476 /* -------------------------------------------------------------------------- */
477 
478 #define SSMWDT(i)				((i) * 0x4000 + 0x54)
479 #define SSMWDTPKE(i)				((i) * 0x4000 + 0x58)
480 #define INTSTATSSM(i)				((i) * 0x4000 + 0x04)
481 #define INTSTATSSM_SHANGERR			__BIT(13)
482 #define PPERR(i)				((i) * 0x4000 + 0x08)
483 #define PPERRID(i)				((i) * 0x4000 + 0x0C)
484 #define CERRSSMSH(i)				((i) * 0x4000 + 0x10)
485 #define UERRSSMSH(i)				((i) * 0x4000 + 0x18)
486 #define UERRSSMSHAD(i)				((i) * 0x4000 + 0x1C)
487 #define SLICEHANGSTATUS(i)			((i) * 0x4000 + 0x4C)
488 #define SLICE_HANG_AUTH0_MASK			__BIT(0)
489 #define SLICE_HANG_AUTH1_MASK			__BIT(1)
490 #define SLICE_HANG_CPHR0_MASK			__BIT(4)
491 #define SLICE_HANG_CPHR1_MASK			__BIT(5)
492 #define SLICE_HANG_CMP0_MASK			__BIT(8)
493 #define SLICE_HANG_CMP1_MASK			__BIT(9)
494 #define SLICE_HANG_XLT0_MASK			__BIT(12)
495 #define SLICE_HANG_XLT1_MASK			__BIT(13)
496 #define SLICE_HANG_MMP0_MASK			__BIT(16)
497 #define SLICE_HANG_MMP1_MASK			__BIT(17)
498 #define SLICE_HANG_MMP2_MASK			__BIT(18)
499 #define SLICE_HANG_MMP3_MASK			__BIT(19)
500 #define SLICE_HANG_MMP4_MASK			__BIT(20)
501 
502 #define SHINTMASKSSM(i)				((i) * 0x4000 + 0x1018)
503 #define ENABLE_SLICE_HANG			0x000000
504 #define MAX_MMP (5)
505 #define MMP_BASE(i)				((i) * 0x1000 % 0x3800)
506 #define CERRSSMMMP(i, n)			((i) * 0x4000 + MMP_BASE(n) + 0x380)
507 #define UERRSSMMMP(i, n)			((i) * 0x4000 + MMP_BASE(n) + 0x388)
508 #define UERRSSMMMPAD(i, n)			((i) * 0x4000 + MMP_BASE(n) + 0x38C)
509 
510 #define CPP_CFC_ERR_STATUS			(0x30000 + 0xC04)
511 #define CPP_CFC_ERR_PPID			(0x30000 + 0xC08)
512 
513 #define ERRSOU0					(0x3A000 + 0x00)
514 #define ERRSOU1					(0x3A000 + 0x04)
515 #define ERRSOU2					(0x3A000 + 0x08)
516 #define ERRSOU3					(0x3A000 + 0x0C)
517 #define ERRSOU4					(0x3A000 + 0xD0)
518 #define ERRSOU5					(0x3A000 + 0xD8)
519 #define ERRMSK0					(0x3A000 + 0x10)
520 #define ERRMSK1					(0x3A000 + 0x14)
521 #define ERRMSK2					(0x3A000 + 0x18)
522 #define ERRMSK3					(0x3A000 + 0x1C)
523 #define ERRMSK4					(0x3A000 + 0xD4)
524 #define ERRMSK5					(0x3A000 + 0xDC)
525 #define EMSK3_CPM0_MASK				__BIT(2)
526 #define EMSK3_CPM1_MASK				__BIT(3)
527 #define EMSK5_CPM2_MASK				__BIT(16)
528 #define EMSK5_CPM3_MASK				__BIT(17)
529 #define EMSK5_CPM4_MASK				__BIT(18)
530 #define RICPPINTSTS				(0x3A000 + 0x114)
531 #define RIERRPUSHID				(0x3A000 + 0x118)
532 #define RIERRPULLID				(0x3A000 + 0x11C)
533 
534 #define TICPPINTSTS				(0x3A400 + 0x13C)
535 #define TIERRPUSHID				(0x3A400 + 0x140)
536 #define TIERRPULLID				(0x3A400 + 0x144)
537 #define SECRAMUERR				(0x3AC00 + 0x04)
538 #define SECRAMUERRAD				(0x3AC00 + 0x0C)
539 #define CPPMEMTGTERR				(0x3AC00 + 0x10)
540 #define ERRPPID					(0x3AC00 + 0x14)
541 
542 #define ADMINMSGUR				0x3a574
543 #define ADMINMSGLR				0x3a578
544 #define MAILBOX_BASE				0x20970
545 #define MAILBOX_STRIDE				0x1000
546 #define ADMINMSG_LEN				32
547 
548 /* -------------------------------------------------------------------------- */
549 static const uint8_t mailbox_const_tab[1024] __aligned(1024) = {
550 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
551 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
552 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
553 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
554 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
555 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
556 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00,
557 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
558 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
559 0x00, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01,
560 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
561 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x02, 0x00, 0x00,
562 0x00, 0x00, 0x00, 0x00, 0x13, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13,
563 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00,
564 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
565 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
566 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
567 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
568 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
569 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
570 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
571 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
572 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
573 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
574 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76,
575 0x54, 0x32, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
576 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab,
577 0x89, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0xc3, 0xd2, 0xe1, 0xf0,
578 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
579 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
580 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x05, 0x9e,
581 0xd8, 0x36, 0x7c, 0xd5, 0x07, 0x30, 0x70, 0xdd, 0x17, 0xf7, 0x0e, 0x59, 0x39,
582 0xff, 0xc0, 0x0b, 0x31, 0x68, 0x58, 0x15, 0x11, 0x64, 0xf9, 0x8f, 0xa7, 0xbe,
583 0xfa, 0x4f, 0xa4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
584 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x09, 0xe6, 0x67, 0xbb, 0x67, 0xae,
585 0x85, 0x3c, 0x6e, 0xf3, 0x72, 0xa5, 0x4f, 0xf5, 0x3a, 0x51, 0x0e, 0x52, 0x7f,
586 0x9b, 0x05, 0x68, 0x8c, 0x1f, 0x83, 0xd9, 0xab, 0x5b, 0xe0, 0xcd, 0x19, 0x05,
587 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
588 0x00, 0x00, 0xcb, 0xbb, 0x9d, 0x5d, 0xc1, 0x05, 0x9e, 0xd8, 0x62, 0x9a, 0x29,
589 0x2a, 0x36, 0x7c, 0xd5, 0x07, 0x91, 0x59, 0x01, 0x5a, 0x30, 0x70, 0xdd, 0x17,
590 0x15, 0x2f, 0xec, 0xd8, 0xf7, 0x0e, 0x59, 0x39, 0x67, 0x33, 0x26, 0x67, 0xff,
591 0xc0, 0x0b, 0x31, 0x8e, 0xb4, 0x4a, 0x87, 0x68, 0x58, 0x15, 0x11, 0xdb, 0x0c,
592 0x2e, 0x0d, 0x64, 0xf9, 0x8f, 0xa7, 0x47, 0xb5, 0x48, 0x1d, 0xbe, 0xfa, 0x4f,
593 0xa4, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
594 0x00, 0x00, 0x00, 0x00, 0x6a, 0x09, 0xe6, 0x67, 0xf3, 0xbc, 0xc9, 0x08, 0xbb,
595 0x67, 0xae, 0x85, 0x84, 0xca, 0xa7, 0x3b, 0x3c, 0x6e, 0xf3, 0x72, 0xfe, 0x94,
596 0xf8, 0x2b, 0xa5, 0x4f, 0xf5, 0x3a, 0x5f, 0x1d, 0x36, 0xf1, 0x51, 0x0e, 0x52,
597 0x7f, 0xad, 0xe6, 0x82, 0xd1, 0x9b, 0x05, 0x68, 0x8c, 0x2b, 0x3e, 0x6c, 0x1f,
598 0x1f, 0x83, 0xd9, 0xab, 0xfb, 0x41, 0xbd, 0x6b, 0x5b, 0xe0, 0xcd, 0x19, 0x13,
599 0x7e, 0x21, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
600 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
601 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
602 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
603 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
604 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
605 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
606 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
607 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
608 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
609 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
610 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
611 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
612 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
613 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
614 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
615 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
616 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
617 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
618 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
619 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
620 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
621 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
622 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
623 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
624 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
625 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
626 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
627 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
628 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
629 
630 /* -------------------------------------------------------------------------- */
631 /* Microcode */
632 
633 /* Clear GPR of AE */
634 static const uint64_t ae_clear_gprs_inst[] = {
635 	0x0F0000C0000ull,  /* .0 l0000!val = 0 ; immed[l0000!val, 0x0] */
636 	0x0F000000380ull,  /* .1 l0000!count = 128 ; immed[l0000!count, 0x80] */
637 	0x0D805000011ull,  /* .2 br!=ctx[0, ctx_init#] */
638 	0x0FC082C0300ull,  /* .3 local_csr_wr[nn_put, 0] */
639 	0x0F0000C0300ull,  /* .4 nop */
640 	0x0F0000C0300ull,  /* .5 nop */
641 	0x0F0000C0300ull,  /* .6 nop */
642 	0x0F0000C0300ull,  /* .7 nop */
643 	0x0A0643C0000ull,  /* .8 init_nn#:alu[*n$index++, --, b, l0000!val] */
644 	0x0BAC0000301ull,  /* .9 alu[l0000!count, l0000!count, -, 1] */
645 	0x0D802000101ull,  /* .10 bne[init_nn#] */
646 	0x0F0000C0001ull,  /* .11 l0000!indx = 0 ; immed[l0000!indx, 0x0] */
647 	0x0FC066C0001ull,  /* .12 local_csr_wr[active_lm_addr_0, l0000!indx];
648 			    * put indx to lm_addr */
649 	0x0F0000C0300ull,  /* .13 nop */
650 	0x0F0000C0300ull,  /* .14 nop */
651 	0x0F0000C0300ull,  /* .15 nop */
652 	0x0F000400300ull,  /* .16 l0000!count = 1024 ; immed[l0000!count, 0x400] */
653 	0x0A0610C0000ull,  /* .17 init_lm#:alu[*l$index0++, --, b, l0000!val] */
654 	0x0BAC0000301ull,  /* .18 alu[l0000!count, l0000!count, -, 1] */
655 	0x0D804400101ull,  /* .19 bne[init_lm#] */
656 	0x0A0580C0000ull,  /* .20 ctx_init#:alu[$l0000!xfers[0], --, b, l0000!val] */
657 	0x0A0581C0000ull,  /* .21 alu[$l0000!xfers[1], --, b, l0000!val] */
658 	0x0A0582C0000ull,  /* .22 alu[$l0000!xfers[2], --, b, l0000!val] */
659 	0x0A0583C0000ull,  /* .23 alu[$l0000!xfers[3], --, b, l0000!val] */
660 	0x0A0584C0000ull,  /* .24 alu[$l0000!xfers[4], --, b, l0000!val] */
661 	0x0A0585C0000ull,  /* .25 alu[$l0000!xfers[5], --, b, l0000!val] */
662 	0x0A0586C0000ull,  /* .26 alu[$l0000!xfers[6], --, b, l0000!val] */
663 	0x0A0587C0000ull,  /* .27 alu[$l0000!xfers[7], --, b, l0000!val] */
664 	0x0A0588C0000ull,  /* .28 alu[$l0000!xfers[8], --, b, l0000!val] */
665 	0x0A0589C0000ull,  /* .29 alu[$l0000!xfers[9], --, b, l0000!val] */
666 	0x0A058AC0000ull,  /* .30 alu[$l0000!xfers[10], --, b, l0000!val] */
667 	0x0A058BC0000ull,  /* .31 alu[$l0000!xfers[11], --, b, l0000!val] */
668 	0x0A058CC0000ull,  /* .32 alu[$l0000!xfers[12], --, b, l0000!val] */
669 	0x0A058DC0000ull,  /* .33 alu[$l0000!xfers[13], --, b, l0000!val] */
670 	0x0A058EC0000ull,  /* .34 alu[$l0000!xfers[14], --, b, l0000!val] */
671 	0x0A058FC0000ull,  /* .35 alu[$l0000!xfers[15], --, b, l0000!val] */
672 	0x0A05C0C0000ull,  /* .36 alu[$l0000!xfers[16], --, b, l0000!val] */
673 	0x0A05C1C0000ull,  /* .37 alu[$l0000!xfers[17], --, b, l0000!val] */
674 	0x0A05C2C0000ull,  /* .38 alu[$l0000!xfers[18], --, b, l0000!val] */
675 	0x0A05C3C0000ull,  /* .39 alu[$l0000!xfers[19], --, b, l0000!val] */
676 	0x0A05C4C0000ull,  /* .40 alu[$l0000!xfers[20], --, b, l0000!val] */
677 	0x0A05C5C0000ull,  /* .41 alu[$l0000!xfers[21], --, b, l0000!val] */
678 	0x0A05C6C0000ull,  /* .42 alu[$l0000!xfers[22], --, b, l0000!val] */
679 	0x0A05C7C0000ull,  /* .43 alu[$l0000!xfers[23], --, b, l0000!val] */
680 	0x0A05C8C0000ull,  /* .44 alu[$l0000!xfers[24], --, b, l0000!val] */
681 	0x0A05C9C0000ull,  /* .45 alu[$l0000!xfers[25], --, b, l0000!val] */
682 	0x0A05CAC0000ull,  /* .46 alu[$l0000!xfers[26], --, b, l0000!val] */
683 	0x0A05CBC0000ull,  /* .47 alu[$l0000!xfers[27], --, b, l0000!val] */
684 	0x0A05CCC0000ull,  /* .48 alu[$l0000!xfers[28], --, b, l0000!val] */
685 	0x0A05CDC0000ull,  /* .49 alu[$l0000!xfers[29], --, b, l0000!val] */
686 	0x0A05CEC0000ull,  /* .50 alu[$l0000!xfers[30], --, b, l0000!val] */
687 	0x0A05CFC0000ull,  /* .51 alu[$l0000!xfers[31], --, b, l0000!val] */
688 	0x0A0400C0000ull,  /* .52 alu[l0000!gprega[0], --, b, l0000!val] */
689 	0x0B0400C0000ull,  /* .53 alu[l0000!gpregb[0], --, b, l0000!val] */
690 	0x0A0401C0000ull,  /* .54 alu[l0000!gprega[1], --, b, l0000!val] */
691 	0x0B0401C0000ull,  /* .55 alu[l0000!gpregb[1], --, b, l0000!val] */
692 	0x0A0402C0000ull,  /* .56 alu[l0000!gprega[2], --, b, l0000!val] */
693 	0x0B0402C0000ull,  /* .57 alu[l0000!gpregb[2], --, b, l0000!val] */
694 	0x0A0403C0000ull,  /* .58 alu[l0000!gprega[3], --, b, l0000!val] */
695 	0x0B0403C0000ull,  /* .59 alu[l0000!gpregb[3], --, b, l0000!val] */
696 	0x0A0404C0000ull,  /* .60 alu[l0000!gprega[4], --, b, l0000!val] */
697 	0x0B0404C0000ull,  /* .61 alu[l0000!gpregb[4], --, b, l0000!val] */
698 	0x0A0405C0000ull,  /* .62 alu[l0000!gprega[5], --, b, l0000!val] */
699 	0x0B0405C0000ull,  /* .63 alu[l0000!gpregb[5], --, b, l0000!val] */
700 	0x0A0406C0000ull,  /* .64 alu[l0000!gprega[6], --, b, l0000!val] */
701 	0x0B0406C0000ull,  /* .65 alu[l0000!gpregb[6], --, b, l0000!val] */
702 	0x0A0407C0000ull,  /* .66 alu[l0000!gprega[7], --, b, l0000!val] */
703 	0x0B0407C0000ull,  /* .67 alu[l0000!gpregb[7], --, b, l0000!val] */
704 	0x0A0408C0000ull,  /* .68 alu[l0000!gprega[8], --, b, l0000!val] */
705 	0x0B0408C0000ull,  /* .69 alu[l0000!gpregb[8], --, b, l0000!val] */
706 	0x0A0409C0000ull,  /* .70 alu[l0000!gprega[9], --, b, l0000!val] */
707 	0x0B0409C0000ull,  /* .71 alu[l0000!gpregb[9], --, b, l0000!val] */
708 	0x0A040AC0000ull,  /* .72 alu[l0000!gprega[10], --, b, l0000!val] */
709 	0x0B040AC0000ull,  /* .73 alu[l0000!gpregb[10], --, b, l0000!val] */
710 	0x0A040BC0000ull,  /* .74 alu[l0000!gprega[11], --, b, l0000!val] */
711 	0x0B040BC0000ull,  /* .75 alu[l0000!gpregb[11], --, b, l0000!val] */
712 	0x0A040CC0000ull,  /* .76 alu[l0000!gprega[12], --, b, l0000!val] */
713 	0x0B040CC0000ull,  /* .77 alu[l0000!gpregb[12], --, b, l0000!val] */
714 	0x0A040DC0000ull,  /* .78 alu[l0000!gprega[13], --, b, l0000!val] */
715 	0x0B040DC0000ull,  /* .79 alu[l0000!gpregb[13], --, b, l0000!val] */
716 	0x0A040EC0000ull,  /* .80 alu[l0000!gprega[14], --, b, l0000!val] */
717 	0x0B040EC0000ull,  /* .81 alu[l0000!gpregb[14], --, b, l0000!val] */
718 	0x0A040FC0000ull,  /* .82 alu[l0000!gprega[15], --, b, l0000!val] */
719 	0x0B040FC0000ull,  /* .83 alu[l0000!gpregb[15], --, b, l0000!val] */
720 	0x0D81581C010ull,  /* .84 br=ctx[7, exit#] */
721 	0x0E000010000ull,  /* .85 ctx_arb[kill], any */
722 	0x0E000010000ull,  /* .86 exit#:ctx_arb[kill], any */
723 };
724 
725 static const uint64_t ae_inst_4b[] = {
726 	0x0F0400C0000ull,  /* .0 immed_w0[l0000!indx, 0] */
727 	0x0F4400C0000ull,  /* .1 immed_w1[l0000!indx, 0] */
728 	0x0F040000300ull,  /* .2 immed_w0[l0000!myvalue, 0x0] */
729 	0x0F440000300ull,  /* .3 immed_w1[l0000!myvalue, 0x0] */
730 	0x0FC066C0000ull,  /* .4 local_csr_wr[active_lm_addr_0,
731 	                                l0000!indx]; put indx to lm_addr */
732 	0x0F0000C0300ull,  /* .5 nop */
733 	0x0F0000C0300ull,  /* .6 nop */
734 	0x0F0000C0300ull,  /* .7 nop */
735 	0x0A021000000ull,  /* .8 alu[*l$index0++, --, b, l0000!myvalue] */
736 };
737 
738 static const uint64_t ae_inst_1b[] = {
739 	0x0F0400C0000ull,  /* .0 immed_w0[l0000!indx, 0] */
740 	0x0F4400C0000ull,  /* .1 immed_w1[l0000!indx, 0] */
741 	0x0F040000300ull,  /* .2 immed_w0[l0000!myvalue, 0x0] */
742 	0x0F440000300ull,  /* .3 immed_w1[l0000!myvalue, 0x0] */
743 	0x0FC066C0000ull,  /* .4 local_csr_wr[active_lm_addr_0,
744 	                               l0000!indx]; put indx to lm_addr */
745 	0x0F0000C0300ull,  /* .5 nop */
746 	0x0F0000C0300ull,  /* .6 nop */
747 	0x0F0000C0300ull,  /* .7 nop */
748 	0x0A000180000ull,  /* .8 alu[l0000!val, --, b, *l$index0] */
749 	0x09080000200ull,  /* .9 alu_shf[l0000!myvalue, --, b,
750 	                                  l0000!myvalue,  <<24 ] */
751 	0x08180280201ull,  /* .10 alu_shf[l0000!val1, --, b, l0000!val,  <<8 ] */
752 	0x08080280102ull,  /* .11 alu_shf[l0000!val1, --, b, l0000!val1 , >>8 ] */
753 	0x0BA00100002ull,  /* .12 alu[l0000!val2, l0000!val1, or, l0000!myvalue] */
754 
755 };
756 
757 static const uint64_t ae_inst_2b[] = {
758 	0x0F0400C0000ull,  /* .0 immed_w0[l0000!indx, 0] */
759 	0x0F4400C0000ull,  /* .1 immed_w1[l0000!indx, 0] */
760 	0x0F040000300ull,  /* .2 immed_w0[l0000!myvalue, 0x0] */
761 	0x0F440000300ull,  /* .3 immed_w1[l0000!myvalue, 0x0] */
762 	0x0FC066C0000ull,  /* .4 local_csr_wr[active_lm_addr_0,
763 	                               l0000!indx]; put indx to lm_addr */
764 	0x0F0000C0300ull,  /* .5 nop */
765 	0x0F0000C0300ull,  /* .6 nop */
766 	0x0F0000C0300ull,  /* .7 nop */
767 	0x0A000180000ull,  /* .8 alu[l0000!val, --, b, *l$index0] */
768 	0x09100000200ull,  /* .9 alu_shf[l0000!myvalue, --, b,
769 	                                      l0000!myvalue,  <<16 ] */
770 	0x08100280201ull,  /* .10 alu_shf[l0000!val1, --, b, l0000!val,  <<16 ] */
771 	0x08100280102ull,  /* .11 alu_shf[l0000!val1, --, b, l0000!val1 , >>16 ] */
772 	0x0BA00100002ull,  /* .12 alu[l0000!val2, l0000!val1, or, l0000!myvalue] */
773 };
774 
775 static const uint64_t ae_inst_3b[] = {
776 	0x0F0400C0000ull,  /* .0 immed_w0[l0000!indx, 0] */
777 	0x0F4400C0000ull,  /* .1 immed_w1[l0000!indx, 0] */
778 	0x0F040000300ull,  /* .2 immed_w0[l0000!myvalue, 0x0] */
779 	0x0F440000300ull,  /* .3 immed_w1[l0000!myvalue, 0x0] */
780 	0x0FC066C0000ull,  /* .4 local_csr_wr[active_lm_addr_0,
781 	                               l0000!indx]; put indx to lm_addr */
782 	0x0F0000C0300ull,  /* .5 nop */
783 	0x0F0000C0300ull,  /* .6 nop */
784 	0x0F0000C0300ull,  /* .7 nop */
785 	0x0A000180000ull,  /* .8 alu[l0000!val, --, b, *l$index0] */
786 	0x09180000200ull,  /* .9 alu_shf[l0000!myvalue, --,
787 	                                b, l0000!myvalue,  <<8 ] */
788 	0x08080280201ull,  /* .10 alu_shf[l0000!val1, --, b, l0000!val,  <<24 ] */
789 	0x08180280102ull,  /* .11 alu_shf[l0000!val1, --, b, l0000!val1 , >>24 ] */
790 	0x0BA00100002ull,  /* .12 alu[l0000!val2, l0000!val1, or, l0000!myvalue] */
791 };
792 
793 /* micro-instr fixup */
794 #define INSERT_IMMED_GPRA_CONST(inst, const_val)		\
795 		inst = (inst & 0xFFFF00C03FFull) |		\
796 		((((const_val) << 12) & 0x0FF00000ull) |	\
797 		(((const_val) << 10) & 0x0003FC00ull))
798 #define INSERT_IMMED_GPRB_CONST(inst, const_val)		\
799 		inst = (inst & 0xFFFF00FFF00ull) |		\
800 		((((const_val) << 12) & 0x0FF00000ull) |	\
801 		(((const_val) << 0) & 0x000000FFull))
802 
803 enum aereg_type {
804 	AEREG_NO_DEST,		/* no destination */
805 	AEREG_GPA_REL,		/* general-purpose A register under relative mode */
806 	AEREG_GPA_ABS,		/* general-purpose A register under absolute mode */
807 	AEREG_GPB_REL,		/* general-purpose B register under relative mode */
808 	AEREG_GPB_ABS,		/* general-purpose B register under absolute mode */
809 	AEREG_SR_REL,		/* sram register under relative mode */
810 	AEREG_SR_RD_REL,	/* sram read register under relative mode */
811 	AEREG_SR_WR_REL,	/* sram write register under relative mode */
812 	AEREG_SR_ABS,		/* sram register under absolute mode */
813 	AEREG_SR_RD_ABS,	/* sram read register under absolute mode */
814 	AEREG_SR_WR_ABS,	/* sram write register under absolute mode */
815 	AEREG_SR0_SPILL,	/* sram0 spill register */
816 	AEREG_SR1_SPILL,	/* sram1 spill register */
817 	AEREG_SR2_SPILL,	/* sram2 spill register */
818 	AEREG_SR3_SPILL,	/* sram3 spill register */
819 	AEREG_SR0_MEM_ADDR,	/* sram0 memory address register */
820 	AEREG_SR1_MEM_ADDR,	/* sram1 memory address register */
821 	AEREG_SR2_MEM_ADDR,	/* sram2 memory address register */
822 	AEREG_SR3_MEM_ADDR,	/* sram3 memory address register */
823 	AEREG_DR_REL,		/* dram register under relative mode */
824 	AEREG_DR_RD_REL,	/* dram read register under relative mode */
825 	AEREG_DR_WR_REL,	/* dram write register under relative mode */
826 	AEREG_DR_ABS,		/* dram register under absolute mode */
827 	AEREG_DR_RD_ABS,	/* dram read register under absolute mode */
828 	AEREG_DR_WR_ABS,	/* dram write register under absolute mode */
829 	AEREG_DR_MEM_ADDR,	/* dram memory address register */
830 	AEREG_LMEM,		/* local memory */
831 	AEREG_LMEM0,		/* local memory bank0 */
832 	AEREG_LMEM1,		/* local memory bank1 */
833 	AEREG_LMEM_SPILL,	/* local memory spill */
834 	AEREG_LMEM_ADDR,	/* local memory address */
835 	AEREG_NEIGH_REL,	/* next neighbour register under relative mode */
836 	AEREG_NEIGH_INDX,	/* next neighbour register under index mode */
837 	AEREG_SIG_REL,		/* signal register under relative mode */
838 	AEREG_SIG_INDX,		/* signal register under index mode */
839 	AEREG_SIG_DOUBLE,	/* signal register */
840 	AEREG_SIG_SINGLE,	/* signal register */
841 	AEREG_SCRATCH_MEM_ADDR,	/* scratch memory address */
842 	AEREG_UMEM0,		/* ustore memory bank0 */
843 	AEREG_UMEM1,		/* ustore memory bank1 */
844 	AEREG_UMEM_SPILL,	/* ustore memory spill */
845 	AEREG_UMEM_ADDR,	/* ustore memory address */
846 	AEREG_DR1_MEM_ADDR,	/* dram segment1 address */
847 	AEREG_SR0_IMPORTED,	/* sram segment0 imported data */
848 	AEREG_SR1_IMPORTED,	/* sram segment1 imported data */
849 	AEREG_SR2_IMPORTED,	/* sram segment2 imported data */
850 	AEREG_SR3_IMPORTED,	/* sram segment3 imported data */
851 	AEREG_DR_IMPORTED,	/* dram segment0 imported data */
852 	AEREG_DR1_IMPORTED,	/* dram segment1 imported data */
853 	AEREG_SCRATCH_IMPORTED,	/* scratch imported data */
854 	AEREG_XFER_RD_ABS,	/* transfer read register under absolute mode */
855 	AEREG_XFER_WR_ABS,	/* transfer write register under absolute mode */
856 	AEREG_CONST_VALUE,	/* const alue */
857 	AEREG_ADDR_TAKEN,	/* address taken */
858 	AEREG_OPTIMIZED_AWAY,	/* optimized away */
859 	AEREG_SHRAM_ADDR,	/* shared ram0 address */
860 	AEREG_SHRAM1_ADDR,	/* shared ram1 address */
861 	AEREG_SHRAM2_ADDR,	/* shared ram2 address */
862 	AEREG_SHRAM3_ADDR,	/* shared ram3 address */
863 	AEREG_SHRAM4_ADDR,	/* shared ram4 address */
864 	AEREG_SHRAM5_ADDR,	/* shared ram5 address */
865 	AEREG_ANY = 0xffff	/* any register */
866 };
867 #define AEREG_SR_INDX	AEREG_SR_ABS
868 				/* sram transfer register under index mode */
869 #define AEREG_DR_INDX	AEREG_DR_ABS
870 				/* dram transfer register under index mode */
871 #define AEREG_NEIGH_ABS	AEREG_NEIGH_INDX
872 				/* next neighbor register under absolute mode */
873 
874 
875 #define QAT_2K			0x0800
876 #define QAT_4K			0x1000
877 #define QAT_6K			0x1800
878 #define QAT_8K			0x2000
879 #define QAT_16K			0x4000
880 
881 #define MOF_OBJ_ID_LEN		8
882 #define MOF_FID			0x00666f6d
883 #define MOF_MIN_VER		0x1
884 #define MOF_MAJ_VER		0x0
885 #define SYM_OBJS		"SYM_OBJS"	/* symbol object string */
886 #define UOF_OBJS		"UOF_OBJS"	/* uof object string */
887 #define SUOF_OBJS		"SUF_OBJS"	/* suof object string */
888 #define SUOF_IMAG		"SUF_IMAG"	/* suof chunk ID string */
889 
890 #define UOF_STRT		"UOF_STRT"	/* string table section ID */
891 #define UOF_GTID		"UOF_GTID"	/* GTID section ID */
892 #define UOF_IMAG		"UOF_IMAG"	/* image section ID */
893 #define UOF_IMEM		"UOF_IMEM"	/* import section ID */
894 #define UOF_MSEG		"UOF_MSEG"	/* memory section ID */
895 
896 #define CRC_POLY		0x1021
897 #define CRC_WIDTH		16
898 #define CRC_BITMASK(x)		(1L << (x))
899 #define CRC_WIDTHMASK(width)	((((1L<<(width-1))-1L)<<1)|1L)
900 
901 struct mof_file_hdr {
902 	u_int mfh_fid;
903 	u_int mfh_csum;
904 	char mfh_min_ver;
905 	char mfh_maj_ver;
906 	u_short mfh_reserved;
907 	u_short mfh_max_chunks;
908 	u_short mfh_num_chunks;
909 };
910 
911 struct mof_file_chunk_hdr {
912 	char mfch_id[MOF_OBJ_ID_LEN];
913 	uint64_t mfch_offset;
914 	uint64_t mfch_size;
915 };
916 
917 struct mof_uof_hdr {
918 	u_short muh_max_chunks;
919 	u_short muh_num_chunks;
920 	u_int muh_reserved;
921 };
922 
923 struct mof_uof_chunk_hdr {
924 	char much_id[MOF_OBJ_ID_LEN];	/* should be UOF_IMAG */
925 	uint64_t much_offset;		/* uof image */
926 	uint64_t much_size;		/* uof image size */
927 	u_int much_name;		/* uof name string-table offset */
928 	u_int much_reserved;
929 };
930 
931 #define UOF_MAX_NUM_OF_AE	16	/* maximum number of AE */
932 
933 #define UOF_OBJ_ID_LEN		8	/* length of object ID */
934 #define UOF_FIELD_POS_SIZE	12	/* field postion size */
935 #define MIN_UOF_SIZE		24	/* minimum .uof file size */
936 #define UOF_FID			0xc6c2	/* uof magic number */
937 #define UOF_MIN_VER		0x11
938 #define UOF_MAJ_VER		0x4
939 
940 struct uof_file_hdr {
941 	u_short ufh_id;			/* file id and endian indicator */
942 	u_short ufh_reserved1;		/* reserved for future use */
943 	char ufh_min_ver;		/* file format minor version */
944 	char ufh_maj_ver;		/* file format major version */
945 	u_short ufh_reserved2;		/* reserved for future use */
946 	u_short ufh_max_chunks;		/* max chunks in file */
947 	u_short ufh_num_chunks;		/* num of actual chunks */
948 };
949 
950 struct uof_file_chunk_hdr {
951 	char ufch_id[UOF_OBJ_ID_LEN];	/* chunk identifier */
952 	u_int ufch_csum;		/* chunk checksum */
953 	u_int ufch_offset;		/* offset of the chunk in the file */
954 	u_int ufch_size;		/* size of the chunk */
955 };
956 
957 struct uof_obj_hdr {
958 	u_int uoh_cpu_type;		/* CPU type */
959 	u_short uoh_min_cpu_ver;	/* starting CPU version */
960 	u_short uoh_max_cpu_ver;	/* ending CPU version */
961 	short uoh_max_chunks;		/* max chunks in chunk obj */
962 	short uoh_num_chunks;		/* num of actual chunks */
963 	u_int uoh_reserved1;
964 	u_int uoh_reserved2;
965 };
966 
967 struct uof_chunk_hdr {
968 	char uch_id[UOF_OBJ_ID_LEN];
969 	u_int uch_offset;
970 	u_int uch_size;
971 };
972 
973 struct uof_str_tab {
974 	u_int ust_table_len;		/* length of table */
975 	u_int ust_reserved;		/* reserved for future use */
976 	uint64_t ust_strings;		/* pointer to string table.
977 					 * NULL terminated strings */
978 };
979 
980 #define AE_MODE_RELOAD_CTX_SHARED	__BIT(12)
981 #define AE_MODE_SHARED_USTORE		__BIT(11)
982 #define AE_MODE_LMEM1			__BIT(9)
983 #define AE_MODE_LMEM0			__BIT(8)
984 #define AE_MODE_NN_MODE			__BITS(7, 4)
985 #define AE_MODE_CTX_MODE		__BITS(3, 0)
986 
987 #define AE_MODE_NN_MODE_NEIGH		0
988 #define AE_MODE_NN_MODE_SELF		1
989 #define AE_MODE_NN_MODE_DONTCARE	0xff
990 
991 struct uof_image {
992 	u_int ui_name;			/* image name */
993 	u_int ui_ae_assigned;		/* AccelEngines assigned */
994 	u_int ui_ctx_assigned;		/* AccelEngine contexts assigned */
995 	u_int ui_cpu_type;		/* cpu type */
996 	u_int ui_entry_address;		/* entry uaddress */
997 	u_int ui_fill_pattern[2];	/* uword fill value */
998 	u_int ui_reloadable_size;	/* size of reloadable ustore section */
999 
1000 	u_char ui_sensitivity;		/*
1001 					 * case sensitivity: 0 = insensitive,
1002 					 * 1 = sensitive
1003 					 */
1004 	u_char ui_reserved;		/* reserved for future use */
1005 	u_short ui_ae_mode;		/*
1006 					 * unused<15:14>, legacyMode<13>,
1007 					 * reloadCtxShared<12>, sharedUstore<11>,
1008 					 * ecc<10>, locMem1<9>, locMem0<8>,
1009 					 * nnMode<7:4>, ctx<3:0>
1010 					 */
1011 
1012 	u_short ui_max_ver;		/* max cpu ver on which the image can run */
1013 	u_short ui_min_ver;		/* min cpu ver on which the image can run */
1014 
1015 	u_short ui_image_attrib;	/* image attributes */
1016 	u_short ui_reserved2;		/* reserved for future use */
1017 
1018 	u_short ui_num_page_regions;	/* number of page regions */
1019 	u_short ui_num_pages;		/* number of pages */
1020 
1021 	u_int ui_reg_tab;		/* offset to register table */
1022 	u_int ui_init_reg_sym_tab;	/* reg/sym init table */
1023 	u_int ui_sbreak_tab;		/* offset to sbreak table */
1024 
1025 	u_int ui_app_metadata;		/* application meta-data */
1026 	/* ui_npages of code page follows this header */
1027 };
1028 
1029 struct uof_obj_table {
1030 	u_int uot_nentries;		/* number of table entries */
1031 	/* uot_nentries of object follows */
1032 };
1033 
1034 struct uof_ae_reg {
1035 	u_int uar_name;			/* reg name string-table offset */
1036 	u_int uar_vis_name;		/* reg visible name string-table offset */
1037 	u_short uar_type;		/* reg type */
1038 	u_short uar_addr;		/* reg address */
1039 	u_short uar_access_mode;	/* uof_RegAccessMode_T: read/write/both/undef */
1040 	u_char uar_visible;		/* register visibility */
1041 	u_char uar_reserved1;		/* reserved for future use */
1042 	u_short uar_ref_count;		/* number of contiguous registers allocated */
1043 	u_short uar_reserved2;		/* reserved for future use */
1044 	u_int uar_xoid;			/* xfer order ID */
1045 };
1046 
1047 enum uof_value_kind {
1048 	UNDEF_VAL,	/* undefined value */
1049 	CHAR_VAL,	/* character value */
1050 	SHORT_VAL,	/* short value */
1051 	INT_VAL,	/* integer value */
1052 	STR_VAL,	/* string value */
1053 	STRTAB_VAL,	/* string table value */
1054 	NUM_VAL,	/* number value */
1055 	EXPR_VAL	/* expression value */
1056 };
1057 
1058 enum uof_init_type {
1059 	INIT_EXPR,
1060 	INIT_REG,
1061 	INIT_REG_CTX,
1062 	INIT_EXPR_ENDIAN_SWAP
1063 };
1064 
1065 struct uof_init_reg_sym {
1066 	u_int uirs_name;		/* symbol name */
1067 	char uirs_init_type;		/* 0=expr, 1=register, 2=ctxReg,
1068 					 * 3=expr_endian_swap */
1069 	char uirs_value_type;		/* EXPR_VAL, STRTAB_VAL */
1070 	char uirs_reg_type;		/* register type: ae_reg_type */
1071 	u_char uirs_ctx;		/* AE context when initType=2 */
1072 	u_int uirs_addr_offset;		/* reg address, or sym-value offset */
1073 	u_int uirs_value;		/* integer value, or expression */
1074 };
1075 
1076 struct uof_sbreak {
1077 	u_int us_page_num;		/* page number */
1078 	u_int us_virt_uaddr;		/* virt uaddress */
1079 	u_char us_sbreak_type;		/* sbreak type */
1080 	u_char us_reg_type;		/* register type: ae_reg_type */
1081 	u_short us_reserved1;		/* reserved for future use */
1082 	u_int us_addr_offset;		/* branch target address or offset
1083 					 * to be used with the reg value to
1084 					 * calculate the target address */
1085 	u_int us_reg_rddr;		/* register address */
1086 };
1087 struct uof_code_page {
1088 	u_int ucp_page_region;		/* page associated region */
1089 	u_int ucp_page_num;		/* code-page number */
1090 	u_char ucp_def_page;		/* default page indicator */
1091 	u_char ucp_reserved2;		/* reserved for future use */
1092 	u_short ucp_reserved1;		/* reserved for future use */
1093 	u_int ucp_beg_vaddr;		/* starting virtual uaddr */
1094 	u_int ucp_beg_paddr;		/* starting physical uaddr */
1095 	u_int ucp_neigh_reg_tab;	/* offset to neighbour-reg table */
1096 	u_int ucp_uc_var_tab;		/* offset to uC var table */
1097 	u_int ucp_imp_var_tab;		/* offset to import var table */
1098 	u_int ucp_imp_expr_tab;		/* offset to import expression table */
1099 	u_int ucp_code_area;		/* offset to code area */
1100 };
1101 
1102 struct uof_code_area {
1103 	u_int uca_num_micro_words;	/* number of micro words */
1104 	u_int uca_uword_block_tab;	/* offset to ublock table */
1105 };
1106 
1107 struct uof_uword_block {
1108 	u_int uub_start_addr;		/* start address */
1109 	u_int uub_num_words;		/* number of microwords */
1110 	u_int uub_uword_offset;		/* offset to the uwords */
1111 	u_int uub_reserved;		/* reserved for future use */
1112 };
1113 
1114 struct uof_uword_fixup {
1115 	u_int uuf_name;			/* offset to string table */
1116 	u_int uuf_uword_address;	/* micro word address */
1117 	u_int uuf_expr_value;		/* string table offset of expr string, or value */
1118 	u_char uuf_val_type;		/* VALUE_UNDEF, VALUE_NUM, VALUE_EXPR */
1119 	u_char uuf_value_attrs;		/* bit<0> (Scope: 0=global, 1=local),
1120 					 * bit<1> (init: 0=no, 1=yes) */
1121 	u_short uuf_reserved1;		/* reserved for future use */
1122 	char uuf_field_attrs[UOF_FIELD_POS_SIZE];
1123 					/* field pos, size, and right shift value */
1124 };
1125 
1126 struct uof_import_var {
1127 	u_int uiv_name;			/* import var name string-table offset */
1128 	u_char uiv_value_attrs;		/* bit<0> (Scope: 0=global),
1129 					 * bit<1> (init: 0=no, 1=yes) */
1130 	u_char uiv_reserved1;		/* reserved for future use */
1131 	u_short uiv_reserved2;		/* reserved for future use */
1132 	uint64_t uiv_value;		/* 64-bit imported value */
1133 };
1134 
1135 struct uof_mem_val_attr {
1136 	u_int umva_byte_offset;		/* byte-offset from the allocated memory */
1137 	u_int umva_value;		/* memory value */
1138 };
1139 
1140 enum uof_mem_region {
1141 	SRAM_REGION,	/* SRAM region */
1142 	DRAM_REGION,	/* DRAM0 region */
1143 	DRAM1_REGION,	/* DRAM1 region */
1144 	LMEM_REGION,	/* local memory region */
1145 	SCRATCH_REGION,	/* SCRATCH region */
1146 	UMEM_REGION,	/* micro-store region */
1147 	RAM_REGION,	/* RAM region */
1148 	SHRAM_REGION,	/* shared memory-0 region */
1149 	SHRAM1_REGION,	/* shared memory-1 region */
1150 	SHRAM2_REGION,	/* shared memory-2 region */
1151 	SHRAM3_REGION,	/* shared memory-3 region */
1152 	SHRAM4_REGION,	/* shared memory-4 region */
1153 	SHRAM5_REGION	/* shared memory-5 region */
1154 };
1155 
1156 #define UOF_SCOPE_GLOBAL	0
1157 #define UOF_SCOPE_LOCAL		1
1158 
1159 struct uof_init_mem {
1160 	u_int uim_sym_name;		/* symbol name */
1161 	char uim_region;		/* memory region -- uof_mem_region */
1162 	char uim_scope;			/* visibility scope */
1163 	u_short uim_reserved1;		/* reserved for future use */
1164 	u_int uim_addr;			/* memory address */
1165 	u_int uim_num_bytes;		/* number of bytes */
1166 	u_int uim_num_val_attr;		/* number of values attributes */
1167 
1168 	/* uim_num_val_attr of uof_mem_val_attr follows this header */
1169 };
1170 
1171 struct uof_var_mem_seg {
1172 	u_int uvms_sram_base;		/* SRAM memory segment base addr */
1173 	u_int uvms_sram_size;		/* SRAM segment size bytes */
1174 	u_int uvms_sram_alignment;	/* SRAM segment alignment bytes */
1175 	u_int uvms_sdram_base;		/* DRAM0 memory segment base addr */
1176 	u_int uvms_sdram_size;		/* DRAM0 segment size bytes */
1177 	u_int uvms_sdram_alignment;	/* DRAM0 segment alignment bytes */
1178 	u_int uvms_sdram1_base;		/* DRAM1 memory segment base addr */
1179 	u_int uvms_sdram1_size;		/* DRAM1 segment size bytes */
1180 	u_int uvms_sdram1_alignment;	/* DRAM1 segment alignment bytes */
1181 	u_int uvms_scratch_base;	/* SCRATCH memory segment base addr */
1182 	u_int uvms_scratch_size;	/* SCRATCH segment size bytes */
1183 	u_int uvms_scratch_alignment;	/* SCRATCH segment alignment bytes */
1184 };
1185 
1186 #define SUOF_OBJ_ID_LEN		8
1187 #define SUOF_FID		0x53554f46
1188 #define SUOF_MAJ_VER		0x0
1189 #define SUOF_MIN_VER		0x1
1190 #define SIMG_AE_INIT_SEQ_LEN	(50 * sizeof(unsigned long long))
1191 #define SIMG_AE_INSTS_LEN	(0x4000 * sizeof(unsigned long long))
1192 #define CSS_FWSK_MODULUS_LEN	256
1193 #define CSS_FWSK_EXPONENT_LEN	4
1194 #define CSS_FWSK_PAD_LEN	252
1195 #define CSS_FWSK_PUB_LEN	(CSS_FWSK_MODULUS_LEN + \
1196 				    CSS_FWSK_EXPONENT_LEN + \
1197 				    CSS_FWSK_PAD_LEN)
1198 #define CSS_SIGNATURE_LEN	256
1199 #define CSS_AE_IMG_LEN		(sizeof(struct simg_ae_mode) + \
1200 				    SIMG_AE_INIT_SEQ_LEN +         \
1201 				    SIMG_AE_INSTS_LEN)
1202 #define CSS_AE_SIMG_LEN		(sizeof(struct css_hdr) + \
1203 				    CSS_FWSK_PUB_LEN + \
1204 				    CSS_SIGNATURE_LEN + \
1205 				    CSS_AE_IMG_LEN)
1206 #define AE_IMG_OFFSET		(sizeof(struct css_hdr) + \
1207 				    CSS_FWSK_MODULUS_LEN + \
1208 				    CSS_FWSK_EXPONENT_LEN + \
1209 				    CSS_SIGNATURE_LEN)
1210 #define CSS_MAX_IMAGE_LEN	0x40000
1211 
1212 struct fw_auth_desc {
1213 	u_int fad_img_len;
1214 	u_int fad_reserved;
1215 	u_int fad_css_hdr_high;
1216 	u_int fad_css_hdr_low;
1217 	u_int fad_img_high;
1218 	u_int fad_img_low;
1219 	u_int fad_signature_high;
1220 	u_int fad_signature_low;
1221 	u_int fad_fwsk_pub_high;
1222 	u_int fad_fwsk_pub_low;
1223 	u_int fad_img_ae_mode_data_high;
1224 	u_int fad_img_ae_mode_data_low;
1225 	u_int fad_img_ae_init_data_high;
1226 	u_int fad_img_ae_init_data_low;
1227 	u_int fad_img_ae_insts_high;
1228 	u_int fad_img_ae_insts_low;
1229 };
1230 
1231 struct auth_chunk {
1232 	struct fw_auth_desc ac_fw_auth_desc;
1233 	uint64_t ac_chunk_size;
1234 	uint64_t ac_chunk_bus_addr;
1235 };
1236 
1237 enum css_fwtype {
1238 	CSS_AE_FIRMWARE = 0,
1239 	CSS_MMP_FIRMWARE = 1
1240 };
1241 
1242 struct css_hdr {
1243 	u_int css_module_type;
1244 	u_int css_header_len;
1245 	u_int css_header_ver;
1246 	u_int css_module_id;
1247 	u_int css_module_vendor;
1248 	u_int css_date;
1249 	u_int css_size;
1250 	u_int css_key_size;
1251 	u_int css_module_size;
1252 	u_int css_exponent_size;
1253 	u_int css_fw_type;
1254 	u_int css_reserved[21];
1255 };
1256 
1257 struct simg_ae_mode {
1258 	u_int sam_file_id;
1259 	u_short sam_maj_ver;
1260 	u_short sam_min_ver;
1261 	u_int sam_dev_type;
1262 	u_short sam_devmax_ver;
1263 	u_short sam_devmin_ver;
1264 	u_int sam_ae_mask;
1265 	u_int sam_ctx_enables;
1266 	char sam_fw_type;
1267 	char sam_ctx_mode;
1268 	char sam_nn_mode;
1269 	char sam_lm0_mode;
1270 	char sam_lm1_mode;
1271 	char sam_scs_mode;
1272 	char sam_lm2_mode;
1273 	char sam_lm3_mode;
1274 	char sam_tindex_mode;
1275 	u_char sam_reserved[7];
1276 	char sam_simg_name[256];
1277 	char sam_appmeta_data[256];
1278 };
1279 
1280 struct suof_file_hdr {
1281 	u_int sfh_file_id;
1282 	u_int sfh_check_sum;
1283 	char sfh_min_ver;
1284 	char sfh_maj_ver;
1285 	char sfh_fw_type;
1286 	char sfh_reserved;
1287 	u_short sfh_max_chunks;
1288 	u_short sfh_num_chunks;
1289 };
1290 
1291 struct suof_chunk_hdr {
1292 	char sch_chunk_id[SUOF_OBJ_ID_LEN];
1293 	uint64_t sch_offset;
1294 	uint64_t sch_size;
1295 };
1296 
1297 struct suof_str_tab {
1298 	u_int sst_tab_length;
1299 	u_int sst_strings;
1300 };
1301 
1302 struct suof_obj_hdr {
1303 	u_int soh_img_length;
1304 	u_int soh_reserved;
1305 };
1306 
1307 /* -------------------------------------------------------------------------- */
1308 /* accel */
1309 
1310 enum fw_slice {
1311 	FW_SLICE_NULL = 0,	/* NULL slice type */
1312 	FW_SLICE_CIPHER = 1,	/* CIPHER slice type */
1313 	FW_SLICE_AUTH = 2,	/* AUTH slice type */
1314 	FW_SLICE_DRAM_RD = 3,	/* DRAM_RD Logical slice type */
1315 	FW_SLICE_DRAM_WR = 4,	/* DRAM_WR Logical slice type */
1316 	FW_SLICE_COMP = 5,	/* Compression slice type */
1317 	FW_SLICE_XLAT = 6,	/* Translator slice type */
1318 	FW_SLICE_DELIMITER	/* End delimiter */
1319 };
1320 #define MAX_FW_SLICE	FW_SLICE_DELIMITER
1321 
1322 #define QAT_OPTIMAL_ALIGN_SHIFT			6
1323 #define QAT_OPTIMAL_ALIGN			(1 << QAT_OPTIMAL_ALIGN_SHIFT)
1324 
1325 enum hw_auth_algo {
1326 	HW_AUTH_ALGO_NULL = 0,		/* Null hashing */
1327 	HW_AUTH_ALGO_SHA1 = 1,		/* SHA1 hashing */
1328 	HW_AUTH_ALGO_MD5 = 2,		/* MD5 hashing */
1329 	HW_AUTH_ALGO_SHA224 = 3,	/* SHA-224 hashing */
1330 	HW_AUTH_ALGO_SHA256 = 4,	/* SHA-256 hashing */
1331 	HW_AUTH_ALGO_SHA384 = 5,	/* SHA-384 hashing */
1332 	HW_AUTH_ALGO_SHA512 = 6,	/* SHA-512 hashing */
1333 	HW_AUTH_ALGO_AES_XCBC_MAC = 7,	/* AES-XCBC-MAC hashing */
1334 	HW_AUTH_ALGO_AES_CBC_MAC = 8,	/* AES-CBC-MAC hashing */
1335 	HW_AUTH_ALGO_AES_F9 = 9,	/* AES F9 hashing */
1336 	HW_AUTH_ALGO_GALOIS_128 = 10,	/* Galois 128 bit hashing */
1337 	HW_AUTH_ALGO_GALOIS_64 = 11,	/* Galois 64 hashing */
1338 	HW_AUTH_ALGO_KASUMI_F9 = 12,	/* Kasumi F9 hashing */
1339 	HW_AUTH_ALGO_SNOW_3G_UIA2 = 13,	/* UIA2/SNOW_3H F9 hashing */
1340 	HW_AUTH_ALGO_ZUC_3G_128_EIA3 = 14,
1341 	HW_AUTH_RESERVED_1 = 15,
1342 	HW_AUTH_RESERVED_2 = 16,
1343 	HW_AUTH_ALGO_SHA3_256 = 17,
1344 	HW_AUTH_RESERVED_3 = 18,
1345 	HW_AUTH_ALGO_SHA3_512 = 19,
1346 	HW_AUTH_ALGO_DELIMITER = 20
1347 };
1348 
1349 enum hw_auth_mode {
1350 	HW_AUTH_MODE0,
1351 	HW_AUTH_MODE1,
1352 	HW_AUTH_MODE2,
1353 	HW_AUTH_MODE_DELIMITER
1354 };
1355 
1356 struct hw_auth_config {
1357 	uint32_t config;
1358 	/* Configuration used for setting up the slice */
1359 	uint32_t reserved;
1360 	/* Reserved */
1361 };
1362 
1363 #define HW_AUTH_CONFIG_SHA3_ALGO	__BITS(22, 23)
1364 #define HW_AUTH_CONFIG_SHA3_PADDING	__BIT(16)
1365 #define HW_AUTH_CONFIG_CMPLEN		__BITS(14, 8)
1366 	/* The length of the digest if the QAT is to the check*/
1367 #define HW_AUTH_CONFIG_MODE		__BITS(7, 4)
1368 #define HW_AUTH_CONFIG_ALGO		__BITS(3, 0)
1369 
1370 #define HW_AUTH_CONFIG_BUILD(mode, algo, cmp_len)	\
1371 	    __SHIFTIN(mode, HW_AUTH_CONFIG_MODE) |	\
1372 	    __SHIFTIN(algo, HW_AUTH_CONFIG_ALGO) |	\
1373 	    __SHIFTIN(cmp_len, HW_AUTH_CONFIG_CMPLEN)
1374 
1375 struct hw_auth_counter {
1376 	uint32_t counter;		/* Counter value */
1377 	uint32_t reserved;		/* Reserved */
1378 };
1379 
1380 struct hw_auth_setup {
1381 	struct hw_auth_config auth_config;
1382 	/* Configuration word for the auth slice */
1383 	struct hw_auth_counter auth_counter;
1384 	/* Auth counter value for this request */
1385 };
1386 
1387 #define HW_NULL_STATE1_SZ		32
1388 #define HW_MD5_STATE1_SZ		16
1389 #define HW_SHA1_STATE1_SZ		20
1390 #define HW_SHA224_STATE1_SZ		32
1391 #define HW_SHA256_STATE1_SZ		32
1392 #define HW_SHA3_256_STATE1_SZ		32
1393 #define HW_SHA384_STATE1_SZ		64
1394 #define HW_SHA512_STATE1_SZ		64
1395 #define HW_SHA3_512_STATE1_SZ		64
1396 #define HW_SHA3_224_STATE1_SZ		28
1397 #define HW_SHA3_384_STATE1_SZ		48
1398 #define HW_AES_XCBC_MAC_STATE1_SZ	16
1399 #define HW_AES_CBC_MAC_STATE1_SZ	16
1400 #define HW_AES_F9_STATE1_SZ		32
1401 #define HW_KASUMI_F9_STATE1_SZ		16
1402 #define HW_GALOIS_128_STATE1_SZ		16
1403 #define HW_SNOW_3G_UIA2_STATE1_SZ	8
1404 #define HW_ZUC_3G_EIA3_STATE1_SZ	8
1405 #define HW_NULL_STATE2_SZ		32
1406 #define HW_MD5_STATE2_SZ		16
1407 #define HW_SHA1_STATE2_SZ		20
1408 #define HW_SHA224_STATE2_SZ		32
1409 #define HW_SHA256_STATE2_SZ		32
1410 #define HW_SHA3_256_STATE2_SZ		0
1411 #define HW_SHA384_STATE2_SZ		64
1412 #define HW_SHA512_STATE2_SZ		64
1413 #define HW_SHA3_512_STATE2_SZ		0
1414 #define HW_SHA3_224_STATE2_SZ		0
1415 #define HW_SHA3_384_STATE2_SZ		0
1416 #define HW_AES_XCBC_MAC_KEY_SZ		16
1417 #define HW_AES_CBC_MAC_KEY_SZ		16
1418 #define HW_AES_CCM_CBC_E_CTR0_SZ	16
1419 #define HW_F9_IK_SZ			16
1420 #define HW_F9_FK_SZ			16
1421 #define HW_KASUMI_F9_STATE2_SZ		(HW_F9_IK_SZ + HW_F9_FK_SZ)
1422 #define HW_AES_F9_STATE2_SZ		HW_KASUMI_F9_STATE2_SZ
1423 #define HW_SNOW_3G_UIA2_STATE2_SZ	24
1424 #define HW_ZUC_3G_EIA3_STATE2_SZ	32
1425 #define HW_GALOIS_H_SZ			16
1426 #define HW_GALOIS_LEN_A_SZ		8
1427 #define HW_GALOIS_E_CTR0_SZ		16
1428 
1429 struct hw_auth_sha512 {
1430 	struct hw_auth_setup inner_setup;
1431 	/* Inner loop configuration word for the slice */
1432 	uint8_t state1[HW_SHA512_STATE1_SZ];
1433 	/* Slice state1 variable */
1434 	struct hw_auth_setup outer_setup;
1435 	/* Outer configuration word for the slice */
1436 	uint8_t state2[HW_SHA512_STATE2_SZ];
1437 	/* Slice state2 variable */
1438 };
1439 
1440 union hw_auth_algo_blk {
1441 	struct hw_auth_sha512 max;
1442 	/* This is the largest possible auth setup block size */
1443 };
1444 
1445 enum hw_cipher_algo {
1446 	HW_CIPHER_ALGO_NULL = 0,		/* Null ciphering */
1447 	HW_CIPHER_ALGO_DES = 1,			/* DES ciphering */
1448 	HW_CIPHER_ALGO_3DES = 2,		/* 3DES ciphering */
1449 	HW_CIPHER_ALGO_AES128 = 3,		/* AES-128 ciphering */
1450 	HW_CIPHER_ALGO_AES192 = 4,		/* AES-192 ciphering */
1451 	HW_CIPHER_ALGO_AES256 = 5,		/* AES-256 ciphering */
1452 	HW_CIPHER_ALGO_ARC4 = 6,		/* ARC4 ciphering */
1453 	HW_CIPHER_ALGO_KASUMI = 7,		/* Kasumi */
1454 	HW_CIPHER_ALGO_SNOW_3G_UEA2 = 8,	/* Snow_3G */
1455 	HW_CIPHER_ALGO_ZUC_3G_128_EEA3 = 9,
1456 	HW_CIPHER_DELIMITER = 10		/* Delimiter type */
1457 };
1458 
1459 enum hw_cipher_mode {
1460 	HW_CIPHER_ECB_MODE = 0,		/* ECB mode */
1461 	HW_CIPHER_CBC_MODE = 1,		/* CBC mode */
1462 	HW_CIPHER_CTR_MODE = 2,		/* CTR mode */
1463 	HW_CIPHER_F8_MODE = 3,		/* F8 mode */
1464 	HW_CIPHER_XTS_MODE = 6,
1465 	HW_CIPHER_MODE_DELIMITER = 7	/* Delimiter type */
1466 };
1467 
1468 struct hw_cipher_config {
1469 	uint32_t val;			/* Cipher slice configuration */
1470 	uint32_t reserved;		/* Reserved */
1471 };
1472 
1473 #define CIPHER_CONFIG_CONVERT		__BIT(9)
1474 #define CIPHER_CONFIG_DIR		__BIT(8)
1475 #define CIPHER_CONFIG_MODE		__BITS(7, 4)
1476 #define CIPHER_CONFIG_ALGO		__BITS(3, 0)
1477 #define HW_CIPHER_CONFIG_BUILD(mode, algo, convert, dir)	\
1478 	    __SHIFTIN(mode, CIPHER_CONFIG_MODE) |		\
1479 	    __SHIFTIN(algo, CIPHER_CONFIG_ALGO) |		\
1480 	    __SHIFTIN(convert, CIPHER_CONFIG_CONVERT) |		\
1481 	    __SHIFTIN(dir, CIPHER_CONFIG_DIR)
1482 
1483 enum hw_cipher_dir {
1484 	HW_CIPHER_ENCRYPT = 0,		/* encryption is required */
1485 	HW_CIPHER_DECRYPT = 1,		/* decryption is required */
1486 };
1487 
1488 enum hw_cipher_convert {
1489 	HW_CIPHER_NO_CONVERT = 0,	/* no key convert is required*/
1490 	HW_CIPHER_KEY_CONVERT = 1,	/* key conversion is required*/
1491 };
1492 
1493 #define CIPHER_MODE_F8_KEY_SZ_MULT	2
1494 #define CIPHER_MODE_XTS_KEY_SZ_MULT	2
1495 
1496 #define HW_DES_BLK_SZ			8
1497 #define HW_3DES_BLK_SZ			8
1498 #define HW_NULL_BLK_SZ			8
1499 #define HW_AES_BLK_SZ			16
1500 #define HW_KASUMI_BLK_SZ		8
1501 #define HW_SNOW_3G_BLK_SZ		8
1502 #define HW_ZUC_3G_BLK_SZ		8
1503 #define HW_NULL_KEY_SZ			256
1504 #define HW_DES_KEY_SZ			8
1505 #define HW_3DES_KEY_SZ			24
1506 #define HW_AES_128_KEY_SZ		16
1507 #define HW_AES_192_KEY_SZ		24
1508 #define HW_AES_256_KEY_SZ		32
1509 #define HW_AES_128_F8_KEY_SZ		(HW_AES_128_KEY_SZ *	\
1510 					    CIPHER_MODE_F8_KEY_SZ_MULT)
1511 #define HW_AES_192_F8_KEY_SZ		(HW_AES_192_KEY_SZ *	\
1512 					    CIPHER_MODE_F8_KEY_SZ_MULT)
1513 #define HW_AES_256_F8_KEY_SZ		(HW_AES_256_KEY_SZ *	\
1514 					    CIPHER_MODE_F8_KEY_SZ_MULT)
1515 #define HW_AES_128_XTS_KEY_SZ		(HW_AES_128_KEY_SZ *	\
1516 					    CIPHER_MODE_XTS_KEY_SZ_MULT)
1517 #define HW_AES_256_XTS_KEY_SZ		(HW_AES_256_KEY_SZ *	\
1518 					    CIPHER_MODE_XTS_KEY_SZ_MULT)
1519 #define HW_KASUMI_KEY_SZ		16
1520 #define HW_KASUMI_F8_KEY_SZ		(HW_KASUMI_KEY_SZ *	\
1521 					    CIPHER_MODE_F8_KEY_SZ_MULT)
1522 #define HW_AES_128_XTS_KEY_SZ		(HW_AES_128_KEY_SZ *	\
1523 					    CIPHER_MODE_XTS_KEY_SZ_MULT)
1524 #define HW_AES_256_XTS_KEY_SZ		(HW_AES_256_KEY_SZ *	\
1525 					    CIPHER_MODE_XTS_KEY_SZ_MULT)
1526 #define HW_ARC4_KEY_SZ			256
1527 #define HW_SNOW_3G_UEA2_KEY_SZ		16
1528 #define HW_SNOW_3G_UEA2_IV_SZ		16
1529 #define HW_ZUC_3G_EEA3_KEY_SZ		16
1530 #define HW_ZUC_3G_EEA3_IV_SZ		16
1531 #define HW_MODE_F8_NUM_REG_TO_CLEAR	2
1532 
1533 struct hw_cipher_aes256_f8 {
1534 	struct hw_cipher_config cipher_config;
1535 	/* Cipher configuration word for the slice set to
1536 	 * AES-256 and the F8 mode */
1537 	uint8_t key[HW_AES_256_F8_KEY_SZ];
1538 	/* Cipher key */
1539 };
1540 
1541 union hw_cipher_algo_blk {
1542 	struct hw_cipher_aes256_f8 max;		/* AES-256 F8 Cipher */
1543 	/* This is the largest possible cipher setup block size */
1544 };
1545 
1546 struct flat_buffer_desc {
1547 	uint32_t data_len_in_bytes;
1548 	uint32_t reserved;
1549 	uint64_t phy_buffer;
1550 };
1551 
1552 #define	HW_MAXSEG	32
1553 
1554 struct buffer_list_desc {
1555 	uint64_t resrvd;
1556 	uint32_t num_buffers;
1557 	uint32_t reserved;
1558 	struct flat_buffer_desc flat_bufs[HW_MAXSEG];
1559 };
1560 
1561 /* -------------------------------------------------------------------------- */
1562 /* look aside */
1563 
1564 enum fw_la_cmd_id {
1565 	FW_LA_CMD_CIPHER,			/* Cipher Request */
1566 	FW_LA_CMD_AUTH,			/* Auth Request */
1567 	FW_LA_CMD_CIPHER_HASH,		/* Cipher-Hash Request */
1568 	FW_LA_CMD_HASH_CIPHER,		/* Hash-Cipher Request */
1569 	FW_LA_CMD_TRNG_GET_RANDOM,		/* TRNG Get Random Request */
1570 	FW_LA_CMD_TRNG_TEST,		/* TRNG Test Request */
1571 	FW_LA_CMD_SSL3_KEY_DERIVE,		/* SSL3 Key Derivation Request */
1572 	FW_LA_CMD_TLS_V1_1_KEY_DERIVE,	/* TLS Key Derivation Request */
1573 	FW_LA_CMD_TLS_V1_2_KEY_DERIVE,	/* TLS Key Derivation Request */
1574 	FW_LA_CMD_MGF1,			/* MGF1 Request */
1575 	FW_LA_CMD_AUTH_PRE_COMP,		/* Auth Pre-Compute Request */
1576 #if 0 /* incompatible between qat 1.5 and 1.7 */
1577 	FW_LA_CMD_CIPHER_CIPHER,		/* Cipher-Cipher Request */
1578 	FW_LA_CMD_HASH_HASH,		/* Hash-Hash Request */
1579 	FW_LA_CMD_CIPHER_PRE_COMP,		/* Auth Pre-Compute Request */
1580 #endif
1581 	FW_LA_CMD_DELIMITER,		/* Delimiter type */
1582 };
1583 
1584 #endif
1585