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