xref: /illumos-gate/usr/src/cmd/fwflash/plugins/hdrs/tavor_ib.h (revision 9e39c5ba00a55fa05777cc94b148296af305e135)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _TAVOR_IB_H
28 #define	_TAVOR_IB_H
29 
30 /*
31  * tavor_ib.h
32  */
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #include <sys/types.h>
39 #include <sys/ib/adapters/tavor/tavor_ioctl.h>
40 
41 #define	FWFLASH_IB_DRIVER_NAME		"tavor"
42 
43 #define	NODE_GUID_OFFSET		0x0
44 #define	PORT1_GUID_OFFSET		0x08
45 #define	PORT2_GUID_OFFSET		0x10
46 #define	FLASH_SIZE_OFFSET		0x20
47 #define	FLASH_GUID_PTR			0x24
48 
49 typedef struct fw_rev_s {
50 	uint32_t	major;
51 	uint32_t	minor;
52 	uint32_t	subminor;
53 	uint32_t	holder;
54 } fw_rev_t;
55 
56 
57 typedef struct mlx_is {
58 	uint8_t		isresv1[16];
59 	uint8_t		hwrev; /* hardware version */
60 	uint8_t		isver; /* Invariant Sector version */
61 	uint32_t	isresv2;
62 	/* offset from 0x32 to get log2sectsz */
63 	uint16_t	log2sectszp;
64 	/*
65 	 * 3rd lot of reserved bytes CAN BE variable length,
66 	 * but defaults to 0x18 bytes
67 	 */
68 	uint8_t		isresv3[0x18];
69 	uint16_t	log2sectsz; /* log_2 of flash sector size */
70 	uint8_t		*isresv4; /* remainder of IS */
71 } mlx_is_t;
72 
73 typedef struct mlx_xps {
74 	uint32_t	fia; /* fw image addr */
75 	uint32_t	fis; /* fw image size */
76 	uint32_t	signature; /* firmware signature */
77 	uint8_t		xpsresv1[20];
78 	uint8_t		vsdpsid[224]; /* VSD and PSID */
79 	uint32_t	xpsresv2;
80 	uint16_t	xpsresv3; /* MUST be zero */
81 	uint16_t	crc16;
82 	uint8_t		*xpsresv4; /* from 0x108 to END OF SECTOR */
83 } mlx_xps_t;
84 
85 
86 #define	XFI_IMGINFO_OFFSET	28
87 #define	XFI_IMGINFO_CKSUM_MASK	0xFF000000
88 #define	XFI_IMGINFO_PTR_MASK	0x00FFFFFF
89 
90 typedef struct mlx_xfi {
91 	uint8_t		xfiresv1[28];
92 	uint32_t	imageinfoptr;
93 	uint32_t	xfiresv2;
94 	uint32_t	nguidptr;
95 	uint8_t		*xfiremainder;
96 } mlx_xfi_t;
97 
98 /*
99  * Of all the structures we poke around with, we're packing
100  * these because we frequently have to operate on them as
101  * plain old byte arrays. If we don't pack it then the compiler
102  * will "properly" align it for us - which results in a
103  * structure that's a l l  s p r e a d  o u t.
104  */
105 #pragma pack(1)
106 typedef struct mlx_guid_sect
107 {
108 	uint8_t		guidresv[16];
109 	uint64_t	nodeguid;
110 	uint64_t	port1guid;
111 	uint64_t	port2guid;
112 	uint64_t	sysimguid;
113 	uint16_t	guidresv2;
114 	uint16_t	guidcrc;
115 } mlx_guid_sect_t;
116 #pragma pack()
117 
118 /* this is 13x 32bit words */
119 #define	GUIDSECTION_SZ	sizeof (struct mlx_guid_sect)
120 
121 /* we hook this struct into vpr->encap_ident */
122 typedef struct ib_encap_ident {
123 	uint_t		magic;
124 	int		fd;
125 	fw_rev_t	fw_rev;
126 	uint32_t	hwrev;
127 	uint32_t	sector_sz;
128 	uint32_t	device_sz;
129 	uint32_t	state;
130 	int		cmd_set;
131 	mlx_mdr_t	info;
132 	int		pn_len;
133 	int		hwfw_match;
134 	uint32_t	pfi_guid_addr; /* addr of the offset */
135 	uint32_t	sfi_guid_addr;
136 	uint32_t	pri_guid_section[GUIDSECTION_SZ];
137 	uint32_t	sec_guid_section[GUIDSECTION_SZ];
138 	uint64_t	ibguids[4];
139 	uint8_t		*inv; /* Invariant Sector */
140 	uint8_t		*pps; /* Primary Pointer Sector */
141 	uint8_t		*sps; /* Secondary Pointer Sector */
142 	uint8_t		*pfi; /* Primary Firmware Image */
143 	uint8_t		*sfi; /* Secondary Firmware Image */
144 	uint8_t		mlx_psid[16];
145 	uint8_t		mlx_vsd[208];
146 } ib_encap_ident_t;
147 
148 #define	FLASH_PS_SIGNATURE				0x5a445a44
149 
150 #define	FLASH_IS_SECTOR_SIZE_OFFSET			0x32
151 #define	FLASH_IS_SECTOR_SIZE_MASK			0x0000FFFF
152 #define	FLASH_IS_HWVER_OFFSET				0x10
153 #define	FLASH_IS_HWVER_MASK				0xFF000000
154 #define	FLASH_IS_ISVER_MASK				0x00FF0000
155 
156 #define	FLASH_IS_SECT_SIZE_PTR				0x16
157 #define	FLASH_IS_SECT_SIZE_PTR_MASK			0x0000FFFF
158 
159 #define	FLASH_PS_FI_ADDR_OFFSET				0x00
160 #define	FLASH_PS_FW_SIZE_OFFSET				0x04
161 #define	FLASH_PS_SIGNATURE_OFFSET			0x08
162 /* Vendor Specific Data (VSD) */
163 #define	FLASH_PS_VSD_OFFSET				0x20
164 /* VSD length in bytes */
165 #define	FLASH_PS_VSD_LENGTH				0xE0
166 #define	FLASH_PS_VSD_LENGTH_4				0x38
167 /* PSID is the last 16B of VSD */
168 #define	FLASH_PS_PSID_OFFSET				0xF0
169 
170 /* For use with Cisco's VSD */
171 #define	FLASH_VSD_CISCO_SIGNATURE			0x05ad
172 #define	FLASH_VSD_CISCO_BOOT_OPTIONS			0x00000004
173 #define	FLASH_VSD_CISCO_FLAG_AUTOUPGRADE		0x01000000
174 #define	FLASH_VSD_CISCO_FLAG_BOOT_ENABLE_PORT_1		0x00010000
175 #define	FLASH_VSD_CISCO_FLAG_BOOT_ENABLE_PORT_2		0x00020000
176 #define	FLASH_VSD_CISCO_FLAG_BOOT_ENABLE_SCAN		0x00040000
177 #define	FLASH_VSD_CISCO_FLAG_BOOT_TYPE_WELL_KNOWN	0x00000000
178 #define	FLASH_VSD_CISCO_FLAG_BOOT_TRY_FOREVER		0x00001000
179 #define	FLASH_VSD_CISCO_BOOT_VERSION			2
180 /* For use with Cisco's VSD */
181 
182 #define	MLX_CISCO_CHECK					1
183 #define	MLX_CISCO_SET					2
184 
185 #define	FLASH_PS_CRC16_SIZE				0x104
186 #define	FLASH_PS_CRC16_OFFSET				0x106
187 
188 #define	FLASH_FI_NGUID_OFFSET				0x0
189 #define	FLASH_FI_P1GUID_OFFSET				0x08
190 #define	FLASH_FI_P2GUID_OFFSET				0x10
191 #define	FLASH_FI_SYSIMGUID_OFFSET			0x18
192 #define	FLASH_GUID_CRC16_SIZE				0x30
193 #define	FLASH_GUID_CRC16_OFFSET				0x32
194 #define	FLASH_GUID_SIZE					0x34
195 
196 #define	FLASH_GUID_CRC_LEN				0x2F
197 /*
198  * Used during read/write ioctl calls to setup the offset into the firmware
199  * image memory for that particular sector.
200  */
201 #define	FLASH_SECTOR_OFFSET(fw, sect, sz)		\
202 	(caddr_t)((uintptr_t)fw + (sect << sz))
203 
204 /*
205  * Vital System Data from PCI config space.
206  */
207 uint32_t vsd_int[FLASH_PS_VSD_LENGTH_4];
208 
209 
210 /*
211  * Common Flash Interface data.
212  */
213 typedef union cfi_u {
214 	uchar_t cfi_char[TAVOR_CFI_INFO_SIZE];
215 	uint32_t cfi_int[TAVOR_CFI_INFO_QSIZE];
216 } cfi_t;
217 
218 
219 #ifdef __cplusplus
220 }
221 #endif
222 
223 
224 
225 
226 #endif /* _TAVOR_IB_H */
227