xref: /illumos-gate/usr/src/uts/common/io/mr_sas/mr_sas.h (revision 4b9db4f6425b1a08fca4390f446072c4a6aae8d5)
1dcda19f5SSusan Scheufele /*
2dcda19f5SSusan Scheufele  * mr_sas.h: header for mr_sas
3dcda19f5SSusan Scheufele  *
4dcda19f5SSusan Scheufele  * Solaris MegaRAID driver for SAS2.0 controllers
52ffc8bcaSDan McDonald  * Copyright (c) 2008-2012, LSI Logic Corporation.
6dcda19f5SSusan Scheufele  * All rights reserved.
7dcda19f5SSusan Scheufele  *
82ffc8bcaSDan McDonald  * Version:
92ffc8bcaSDan McDonald  * Author:
102ffc8bcaSDan McDonald  *		Swaminathan K S
112ffc8bcaSDan McDonald  *		Arun Chandrashekhar
122ffc8bcaSDan McDonald  *		Manju R
132ffc8bcaSDan McDonald  *		Rasheed
142ffc8bcaSDan McDonald  *		Shakeel Bukhari
152ffc8bcaSDan McDonald  *
16dcda19f5SSusan Scheufele  * Redistribution and use in source and binary forms, with or without
17dcda19f5SSusan Scheufele  * modification, are permitted provided that the following conditions are met:
18dcda19f5SSusan Scheufele  *
19dcda19f5SSusan Scheufele  * 1. Redistributions of source code must retain the above copyright notice,
20dcda19f5SSusan Scheufele  *    this list of conditions and the following disclaimer.
21dcda19f5SSusan Scheufele  *
22dcda19f5SSusan Scheufele  * 2. Redistributions in binary form must reproduce the above copyright notice,
23dcda19f5SSusan Scheufele  *    this list of conditions and the following disclaimer in the documentation
24dcda19f5SSusan Scheufele  *    and/or other materials provided with the distribution.
25dcda19f5SSusan Scheufele  *
26dcda19f5SSusan Scheufele  * 3. Neither the name of the author nor the names of its contributors may be
27dcda19f5SSusan Scheufele  *    used to endorse or promote products derived from this software without
28dcda19f5SSusan Scheufele  *    specific prior written permission.
29dcda19f5SSusan Scheufele  *
30dcda19f5SSusan Scheufele  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31dcda19f5SSusan Scheufele  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32dcda19f5SSusan Scheufele  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33dcda19f5SSusan Scheufele  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
34dcda19f5SSusan Scheufele  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
35dcda19f5SSusan Scheufele  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
36dcda19f5SSusan Scheufele  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
37dcda19f5SSusan Scheufele  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
38dcda19f5SSusan Scheufele  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
39dcda19f5SSusan Scheufele  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
40dcda19f5SSusan Scheufele  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
41dcda19f5SSusan Scheufele  * DAMAGE.
42dcda19f5SSusan Scheufele  */
43dcda19f5SSusan Scheufele 
44dcda19f5SSusan Scheufele /*
45e73d18e5SYu Wu - Sun Microsystems - Beijing China  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
46a1c36c8bSDan McDonald  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
47a1ed883aSGarrett D'Amore  * Copyright 2015 Garrett D'Amore <garrett@damore.org>
48df950592SHummyPkg  * Copyright 2017 Citrus IT Limited. All rights reserved.
49dcda19f5SSusan Scheufele  */
502ffc8bcaSDan McDonald 
51dcda19f5SSusan Scheufele #ifndef	_MR_SAS_H_
52dcda19f5SSusan Scheufele #define	_MR_SAS_H_
53dcda19f5SSusan Scheufele 
54dcda19f5SSusan Scheufele #ifdef	__cplusplus
55dcda19f5SSusan Scheufele extern "C" {
56dcda19f5SSusan Scheufele #endif
57dcda19f5SSusan Scheufele 
58dcda19f5SSusan Scheufele #include <sys/scsi/scsi.h>
59dcda19f5SSusan Scheufele #include "mr_sas_list.h"
602ffc8bcaSDan McDonald #include "ld_pd_map.h"
61dcda19f5SSusan Scheufele 
62dcda19f5SSusan Scheufele /*
63dcda19f5SSusan Scheufele  * MegaRAID SAS2.0 Driver meta data
64dcda19f5SSusan Scheufele  */
65eef6dbdfSAndy Fiddaman #define	MRSAS_VERSION				"6.503.00.00ILLUMOS-20170524"
66eef6dbdfSAndy Fiddaman #define	MRSAS_RELDATE				"May 24, 2017"
67dcda19f5SSusan Scheufele 
68dcda19f5SSusan Scheufele #define	MRSAS_TRUE				1
69dcda19f5SSusan Scheufele #define	MRSAS_FALSE				0
70dcda19f5SSusan Scheufele 
71e73d18e5SYu Wu - Sun Microsystems - Beijing China #define	ADAPTER_RESET_NOT_REQUIRED		0
72e73d18e5SYu Wu - Sun Microsystems - Beijing China #define	ADAPTER_RESET_REQUIRED			1
73e73d18e5SYu Wu - Sun Microsystems - Beijing China 
74dcda19f5SSusan Scheufele /*
75dcda19f5SSusan Scheufele  * MegaRAID SAS2.0 device id conversion definitions.
76dcda19f5SSusan Scheufele  */
77dcda19f5SSusan Scheufele #define	INST2LSIRDCTL(x)		((x) << INST_MINOR_SHIFT)
782ffc8bcaSDan McDonald #define	MRSAS_GET_BOUNDARY_ALIGNED_LEN(len, new_len, boundary_len)  { \
792ffc8bcaSDan McDonald 	int rem; \
802ffc8bcaSDan McDonald 	rem = (len / boundary_len); \
812ffc8bcaSDan McDonald 	if ((rem * boundary_len) != len) { \
822ffc8bcaSDan McDonald 		new_len = len + ((rem + 1) * boundary_len - len); \
832ffc8bcaSDan McDonald 	} else { \
842ffc8bcaSDan McDonald 		new_len = len; \
852ffc8bcaSDan McDonald 	} \
862ffc8bcaSDan McDonald }
872ffc8bcaSDan McDonald 
88dcda19f5SSusan Scheufele 
89dcda19f5SSusan Scheufele /*
90dcda19f5SSusan Scheufele  * MegaRAID SAS2.0 supported controllers
91dcda19f5SSusan Scheufele  */
92df950592SHummyPkg 
93df950592SHummyPkg /* Skinny */
94a1c36c8bSDan McDonald #define	PCI_DEVICE_ID_LSI_SKINNY		0x0071
95a1c36c8bSDan McDonald #define	PCI_DEVICE_ID_LSI_SKINNY_NEW		0x0073
96df950592SHummyPkg /* Liberator series (Gen2) */
97df950592SHummyPkg #define	PCI_DEVICE_ID_LSI_2108VDE		0x0078
98df950592SHummyPkg #define	PCI_DEVICE_ID_LSI_2108V			0x0079
99df950592SHummyPkg /* Thunderbolt series */
1002ffc8bcaSDan McDonald #define	PCI_DEVICE_ID_LSI_TBOLT			0x005b
101df950592SHummyPkg /* Invader series (Gen3) */
1022ffc8bcaSDan McDonald #define	PCI_DEVICE_ID_LSI_INVADER		0x005d
103a1ed883aSGarrett D'Amore #define	PCI_DEVICE_ID_LSI_FURY			0x005f
104df950592SHummyPkg #define	PCI_DEVICE_ID_LSI_INTRUDER		0x00ce
105df950592SHummyPkg #define	PCI_DEVICE_ID_LSI_INTRUDER_24		0x00cf
106df950592SHummyPkg #define	PCI_DEVICE_ID_LSI_CUTLASS_52		0x0052
107df950592SHummyPkg #define	PCI_DEVICE_ID_LSI_CUTLASS_53		0x0053
108df950592SHummyPkg /* Ventura series not yet supported */
109dcda19f5SSusan Scheufele 
110dcda19f5SSusan Scheufele /*
111dcda19f5SSusan Scheufele  * Register Index for 2108 Controllers.
112dcda19f5SSusan Scheufele  */
113dcda19f5SSusan Scheufele #define	REGISTER_SET_IO_2108			(2)
114dcda19f5SSusan Scheufele 
115dcda19f5SSusan Scheufele #define	MRSAS_MAX_SGE_CNT			0x50
1162ffc8bcaSDan McDonald #define	MRSAS_APP_RESERVED_CMDS			32
117a1c36c8bSDan McDonald #define	MRSAS_APP_MIN_RESERVED_CMDS		4
118dcda19f5SSusan Scheufele 
119dcda19f5SSusan Scheufele #define	MRSAS_IOCTL_DRIVER			0x12341234
120dcda19f5SSusan Scheufele #define	MRSAS_IOCTL_FIRMWARE			0x12345678
121dcda19f5SSusan Scheufele #define	MRSAS_IOCTL_AEN				0x87654321
122dcda19f5SSusan Scheufele 
123dcda19f5SSusan Scheufele #define	MRSAS_1_SECOND				1000000
124dcda19f5SSusan Scheufele 
1252ffc8bcaSDan McDonald #define	UNCONFIGURED_GOOD			0x0
1262ffc8bcaSDan McDonald #define	PD_SYSTEM				0x40
1272ffc8bcaSDan McDonald #define	MR_EVT_PD_STATE_CHANGE			0x0072
1282ffc8bcaSDan McDonald #define	MR_EVT_PD_REMOVED_EXT		0x00f8
1292ffc8bcaSDan McDonald #define	MR_EVT_PD_INSERTED_EXT		0x00f7
1302ffc8bcaSDan McDonald #define	MR_DCMD_PD_GET_INFO			0x02020000
1312ffc8bcaSDan McDonald #define	MRSAS_TBOLT_PD_LUN		1
1322ffc8bcaSDan McDonald #define	MRSAS_TBOLT_PD_TGT_MAX	255
1332ffc8bcaSDan McDonald #define	MRSAS_TBOLT_GET_PD_MAX(s)	((s)->mr_tbolt_pd_max)
1342ffc8bcaSDan McDonald 
1352ffc8bcaSDan McDonald /* Raid Context Flags */
1362ffc8bcaSDan McDonald #define	MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT 0x4
1372ffc8bcaSDan McDonald #define	MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_MASK 0x30
1382ffc8bcaSDan McDonald typedef enum MR_RAID_FLAGS_IO_SUB_TYPE {
1392ffc8bcaSDan McDonald 	MR_RAID_FLAGS_IO_SUB_TYPE_NONE = 0,
1402ffc8bcaSDan McDonald 	MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD = 1
1412ffc8bcaSDan McDonald } MR_RAID_FLAGS_IO_SUB_TYPE;
1422ffc8bcaSDan McDonald 
143dcda19f5SSusan Scheufele /* Dynamic Enumeration Flags */
144dcda19f5SSusan Scheufele #define	MRSAS_LD_LUN		0
145dcda19f5SSusan Scheufele #define	WWN_STRLEN		17
1462ffc8bcaSDan McDonald #define	LD_SYNC_BIT	1
1472ffc8bcaSDan McDonald #define	LD_SYNC_SHIFT	14
1482ffc8bcaSDan McDonald /* ThunderBolt (TB) specific */
1492ffc8bcaSDan McDonald #define	MRSAS_THUNDERBOLT_MSG_SIZE		256
1502ffc8bcaSDan McDonald #define	MRSAS_THUNDERBOLT_MAX_COMMANDS		1024
1512ffc8bcaSDan McDonald #define	MRSAS_THUNDERBOLT_MAX_REPLY_COUNT	1024
1522ffc8bcaSDan McDonald #define	MRSAS_THUNDERBOLT_REPLY_SIZE		8
1532ffc8bcaSDan McDonald #define	MRSAS_THUNDERBOLT_MAX_CHAIN_COUNT	1
1542ffc8bcaSDan McDonald 
1552ffc8bcaSDan McDonald #define	MPI2_FUNCTION_PASSTHRU_IO_REQUEST	0xF0
1562ffc8bcaSDan McDonald #define	MPI2_FUNCTION_LD_IO_REQUEST		0xF1
1572ffc8bcaSDan McDonald 
1582ffc8bcaSDan McDonald #define	MR_EVT_LD_FAST_PATH_IO_STATUS_CHANGED	(0xFFFF)
1592ffc8bcaSDan McDonald 
1602ffc8bcaSDan McDonald #define	MR_INTERNAL_MFI_FRAMES_SMID		1
1612ffc8bcaSDan McDonald #define	MR_CTRL_EVENT_WAIT_SMID			2
1622ffc8bcaSDan McDonald #define	MR_INTERNAL_DRIVER_RESET_SMID		3
1632ffc8bcaSDan McDonald 
1642ffc8bcaSDan McDonald 
165dcda19f5SSusan Scheufele /*
166dcda19f5SSusan Scheufele  * =====================================
167dcda19f5SSusan Scheufele  * MegaRAID SAS2.0 MFI firmware definitions
168dcda19f5SSusan Scheufele  * =====================================
169dcda19f5SSusan Scheufele  */
170dcda19f5SSusan Scheufele /*
171dcda19f5SSusan Scheufele  * MFI stands for  MegaRAID SAS2.0 FW Interface. This is just a moniker for
172dcda19f5SSusan Scheufele  * protocol between the software and firmware. Commands are issued using
173dcda19f5SSusan Scheufele  * "message frames"
174dcda19f5SSusan Scheufele  */
175dcda19f5SSusan Scheufele 
176dcda19f5SSusan Scheufele /*
177dcda19f5SSusan Scheufele  * FW posts its state in upper 4 bits of outbound_msg_0 register
178dcda19f5SSusan Scheufele  */
1792ffc8bcaSDan McDonald #define	MFI_STATE_MASK				0xF0000000
1802ffc8bcaSDan McDonald #define	MFI_STATE_UNDEFINED			0x00000000
1812ffc8bcaSDan McDonald #define	MFI_STATE_BB_INIT			0x10000000
1822ffc8bcaSDan McDonald #define	MFI_STATE_FW_INIT			0x40000000
1832ffc8bcaSDan McDonald #define	MFI_STATE_WAIT_HANDSHAKE		0x60000000
1842ffc8bcaSDan McDonald #define	MFI_STATE_FW_INIT_2			0x70000000
1852ffc8bcaSDan McDonald #define	MFI_STATE_DEVICE_SCAN			0x80000000
1862ffc8bcaSDan McDonald #define	MFI_STATE_BOOT_MESSAGE_PENDING		0x90000000
1872ffc8bcaSDan McDonald #define	MFI_STATE_FLUSH_CACHE			0xA0000000
1882ffc8bcaSDan McDonald #define	MFI_STATE_READY				0xB0000000
1892ffc8bcaSDan McDonald #define	MFI_STATE_OPERATIONAL			0xC0000000
1902ffc8bcaSDan McDonald #define	MFI_STATE_FAULT				0xF0000000
191dcda19f5SSusan Scheufele 
192dcda19f5SSusan Scheufele #define	MRMFI_FRAME_SIZE			64
193dcda19f5SSusan Scheufele 
194dcda19f5SSusan Scheufele /*
195dcda19f5SSusan Scheufele  * During FW init, clear pending cmds & reset state using inbound_msg_0
196dcda19f5SSusan Scheufele  *
197dcda19f5SSusan Scheufele  * ABORT	: Abort all pending cmds
198dcda19f5SSusan Scheufele  * READY	: Move from OPERATIONAL to READY state; discard queue info
199dcda19f5SSusan Scheufele  * MFIMODE	: Discard (possible) low MFA posted in 64-bit mode (??)
200dcda19f5SSusan Scheufele  * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
201dcda19f5SSusan Scheufele  */
202dcda19f5SSusan Scheufele #define	MFI_INIT_ABORT				0x00000001
203dcda19f5SSusan Scheufele #define	MFI_INIT_READY				0x00000002
204dcda19f5SSusan Scheufele #define	MFI_INIT_MFIMODE			0x00000004
205dcda19f5SSusan Scheufele #define	MFI_INIT_CLEAR_HANDSHAKE		0x00000008
206dcda19f5SSusan Scheufele #define	MFI_INIT_HOTPLUG			0x00000010
207dcda19f5SSusan Scheufele #define	MFI_STOP_ADP				0x00000020
208dcda19f5SSusan Scheufele #define	MFI_RESET_FLAGS		MFI_INIT_READY|MFI_INIT_MFIMODE|MFI_INIT_ABORT
209dcda19f5SSusan Scheufele 
210dcda19f5SSusan Scheufele /*
211dcda19f5SSusan Scheufele  * MFI frame flags
212dcda19f5SSusan Scheufele  */
213dcda19f5SSusan Scheufele #define	MFI_FRAME_POST_IN_REPLY_QUEUE		0x0000
214dcda19f5SSusan Scheufele #define	MFI_FRAME_DONT_POST_IN_REPLY_QUEUE	0x0001
215dcda19f5SSusan Scheufele #define	MFI_FRAME_SGL32				0x0000
216dcda19f5SSusan Scheufele #define	MFI_FRAME_SGL64				0x0002
217dcda19f5SSusan Scheufele #define	MFI_FRAME_SENSE32			0x0000
218dcda19f5SSusan Scheufele #define	MFI_FRAME_SENSE64			0x0004
219dcda19f5SSusan Scheufele #define	MFI_FRAME_DIR_NONE			0x0000
220dcda19f5SSusan Scheufele #define	MFI_FRAME_DIR_WRITE			0x0008
221dcda19f5SSusan Scheufele #define	MFI_FRAME_DIR_READ			0x0010
222dcda19f5SSusan Scheufele #define	MFI_FRAME_DIR_BOTH			0x0018
223062f0014SYu Wu - Sun Microsystems - Beijing China #define	MFI_FRAME_IEEE				0x0020
224dcda19f5SSusan Scheufele 
225dcda19f5SSusan Scheufele /*
226dcda19f5SSusan Scheufele  * Definition for cmd_status
227dcda19f5SSusan Scheufele  */
228dcda19f5SSusan Scheufele #define	MFI_CMD_STATUS_POLL_MODE		0xFF
229dcda19f5SSusan Scheufele #define	MFI_CMD_STATUS_SYNC_MODE		0xFF
230dcda19f5SSusan Scheufele 
231dcda19f5SSusan Scheufele /*
232dcda19f5SSusan Scheufele  * MFI command opcodes
233dcda19f5SSusan Scheufele  */
234dcda19f5SSusan Scheufele #define	MFI_CMD_OP_INIT				0x00
235dcda19f5SSusan Scheufele #define	MFI_CMD_OP_LD_READ			0x01
236dcda19f5SSusan Scheufele #define	MFI_CMD_OP_LD_WRITE			0x02
237dcda19f5SSusan Scheufele #define	MFI_CMD_OP_LD_SCSI			0x03
238dcda19f5SSusan Scheufele #define	MFI_CMD_OP_PD_SCSI			0x04
239dcda19f5SSusan Scheufele #define	MFI_CMD_OP_DCMD				0x05
240dcda19f5SSusan Scheufele #define	MFI_CMD_OP_ABORT			0x06
241dcda19f5SSusan Scheufele #define	MFI_CMD_OP_SMP				0x07
242dcda19f5SSusan Scheufele #define	MFI_CMD_OP_STP				0x08
243dcda19f5SSusan Scheufele 
244dcda19f5SSusan Scheufele #define	MR_DCMD_CTRL_GET_INFO			0x01010000
245dcda19f5SSusan Scheufele 
246dcda19f5SSusan Scheufele #define	MR_DCMD_CTRL_CACHE_FLUSH		0x01101000
247dcda19f5SSusan Scheufele #define	MR_FLUSH_CTRL_CACHE			0x01
248dcda19f5SSusan Scheufele #define	MR_FLUSH_DISK_CACHE			0x02
249dcda19f5SSusan Scheufele 
250dcda19f5SSusan Scheufele #define	MR_DCMD_CTRL_SHUTDOWN			0x01050000
251dcda19f5SSusan Scheufele #define	MRSAS_ENABLE_DRIVE_SPINDOWN		0x01
252dcda19f5SSusan Scheufele 
253dcda19f5SSusan Scheufele #define	MR_DCMD_CTRL_EVENT_GET_INFO		0x01040100
254dcda19f5SSusan Scheufele #define	MR_DCMD_CTRL_EVENT_GET			0x01040300
255dcda19f5SSusan Scheufele #define	MR_DCMD_CTRL_EVENT_WAIT			0x01040500
256dcda19f5SSusan Scheufele #define	MR_DCMD_LD_GET_PROPERTIES		0x03030000
257dcda19f5SSusan Scheufele 
258dcda19f5SSusan Scheufele /*
259dcda19f5SSusan Scheufele  * Solaris Specific MAX values
260dcda19f5SSusan Scheufele  */
261dcda19f5SSusan Scheufele #define	MAX_SGL					24
2622ffc8bcaSDan McDonald 
263dcda19f5SSusan Scheufele /*
264dcda19f5SSusan Scheufele  * MFI command completion codes
265dcda19f5SSusan Scheufele  */
266dcda19f5SSusan Scheufele enum MFI_STAT {
267dcda19f5SSusan Scheufele 	MFI_STAT_OK				= 0x00,
268dcda19f5SSusan Scheufele 	MFI_STAT_INVALID_CMD			= 0x01,
269dcda19f5SSusan Scheufele 	MFI_STAT_INVALID_DCMD			= 0x02,
270dcda19f5SSusan Scheufele 	MFI_STAT_INVALID_PARAMETER		= 0x03,
271dcda19f5SSusan Scheufele 	MFI_STAT_INVALID_SEQUENCE_NUMBER	= 0x04,
272dcda19f5SSusan Scheufele 	MFI_STAT_ABORT_NOT_POSSIBLE		= 0x05,
273dcda19f5SSusan Scheufele 	MFI_STAT_APP_HOST_CODE_NOT_FOUND	= 0x06,
274dcda19f5SSusan Scheufele 	MFI_STAT_APP_IN_USE			= 0x07,
275dcda19f5SSusan Scheufele 	MFI_STAT_APP_NOT_INITIALIZED		= 0x08,
276dcda19f5SSusan Scheufele 	MFI_STAT_ARRAY_INDEX_INVALID		= 0x09,
277dcda19f5SSusan Scheufele 	MFI_STAT_ARRAY_ROW_NOT_EMPTY		= 0x0a,
278dcda19f5SSusan Scheufele 	MFI_STAT_CONFIG_RESOURCE_CONFLICT	= 0x0b,
279dcda19f5SSusan Scheufele 	MFI_STAT_DEVICE_NOT_FOUND		= 0x0c,
280dcda19f5SSusan Scheufele 	MFI_STAT_DRIVE_TOO_SMALL		= 0x0d,
281dcda19f5SSusan Scheufele 	MFI_STAT_FLASH_ALLOC_FAIL		= 0x0e,
282dcda19f5SSusan Scheufele 	MFI_STAT_FLASH_BUSY			= 0x0f,
283dcda19f5SSusan Scheufele 	MFI_STAT_FLASH_ERROR			= 0x10,
284dcda19f5SSusan Scheufele 	MFI_STAT_FLASH_IMAGE_BAD		= 0x11,
285dcda19f5SSusan Scheufele 	MFI_STAT_FLASH_IMAGE_INCOMPLETE		= 0x12,
286dcda19f5SSusan Scheufele 	MFI_STAT_FLASH_NOT_OPEN			= 0x13,
287dcda19f5SSusan Scheufele 	MFI_STAT_FLASH_NOT_STARTED		= 0x14,
288dcda19f5SSusan Scheufele 	MFI_STAT_FLUSH_FAILED			= 0x15,
289dcda19f5SSusan Scheufele 	MFI_STAT_HOST_CODE_NOT_FOUNT		= 0x16,
290dcda19f5SSusan Scheufele 	MFI_STAT_LD_CC_IN_PROGRESS		= 0x17,
291dcda19f5SSusan Scheufele 	MFI_STAT_LD_INIT_IN_PROGRESS		= 0x18,
292dcda19f5SSusan Scheufele 	MFI_STAT_LD_LBA_OUT_OF_RANGE		= 0x19,
293dcda19f5SSusan Scheufele 	MFI_STAT_LD_MAX_CONFIGURED		= 0x1a,
294dcda19f5SSusan Scheufele 	MFI_STAT_LD_NOT_OPTIMAL			= 0x1b,
295dcda19f5SSusan Scheufele 	MFI_STAT_LD_RBLD_IN_PROGRESS		= 0x1c,
296dcda19f5SSusan Scheufele 	MFI_STAT_LD_RECON_IN_PROGRESS		= 0x1d,
297dcda19f5SSusan Scheufele 	MFI_STAT_LD_WRONG_RAID_LEVEL		= 0x1e,
298dcda19f5SSusan Scheufele 	MFI_STAT_MAX_SPARES_EXCEEDED		= 0x1f,
299dcda19f5SSusan Scheufele 	MFI_STAT_MEMORY_NOT_AVAILABLE		= 0x20,
300dcda19f5SSusan Scheufele 	MFI_STAT_MFC_HW_ERROR			= 0x21,
301dcda19f5SSusan Scheufele 	MFI_STAT_NO_HW_PRESENT			= 0x22,
302dcda19f5SSusan Scheufele 	MFI_STAT_NOT_FOUND			= 0x23,
303dcda19f5SSusan Scheufele 	MFI_STAT_NOT_IN_ENCL			= 0x24,
304dcda19f5SSusan Scheufele 	MFI_STAT_PD_CLEAR_IN_PROGRESS		= 0x25,
305dcda19f5SSusan Scheufele 	MFI_STAT_PD_TYPE_WRONG			= 0x26,
306dcda19f5SSusan Scheufele 	MFI_STAT_PR_DISABLED			= 0x27,
307dcda19f5SSusan Scheufele 	MFI_STAT_ROW_INDEX_INVALID		= 0x28,
308dcda19f5SSusan Scheufele 	MFI_STAT_SAS_CONFIG_INVALID_ACTION	= 0x29,
309dcda19f5SSusan Scheufele 	MFI_STAT_SAS_CONFIG_INVALID_DATA	= 0x2a,
310dcda19f5SSusan Scheufele 	MFI_STAT_SAS_CONFIG_INVALID_PAGE	= 0x2b,
311dcda19f5SSusan Scheufele 	MFI_STAT_SAS_CONFIG_INVALID_TYPE	= 0x2c,
312dcda19f5SSusan Scheufele 	MFI_STAT_SCSI_DONE_WITH_ERROR		= 0x2d,
313dcda19f5SSusan Scheufele 	MFI_STAT_SCSI_IO_FAILED			= 0x2e,
314dcda19f5SSusan Scheufele 	MFI_STAT_SCSI_RESERVATION_CONFLICT	= 0x2f,
315dcda19f5SSusan Scheufele 	MFI_STAT_SHUTDOWN_FAILED		= 0x30,
316dcda19f5SSusan Scheufele 	MFI_STAT_TIME_NOT_SET			= 0x31,
317dcda19f5SSusan Scheufele 	MFI_STAT_WRONG_STATE			= 0x32,
318dcda19f5SSusan Scheufele 	MFI_STAT_LD_OFFLINE			= 0x33,
319dcda19f5SSusan Scheufele 	MFI_STAT_INVALID_STATUS			= 0xFF
320dcda19f5SSusan Scheufele };
321dcda19f5SSusan Scheufele 
322dcda19f5SSusan Scheufele enum MR_EVT_CLASS {
323dcda19f5SSusan Scheufele 	MR_EVT_CLASS_DEBUG		= -2,
324dcda19f5SSusan Scheufele 	MR_EVT_CLASS_PROGRESS		= -1,
325dcda19f5SSusan Scheufele 	MR_EVT_CLASS_INFO		=  0,
326dcda19f5SSusan Scheufele 	MR_EVT_CLASS_WARNING		=  1,
327dcda19f5SSusan Scheufele 	MR_EVT_CLASS_CRITICAL		=  2,
328dcda19f5SSusan Scheufele 	MR_EVT_CLASS_FATAL		=  3,
329dcda19f5SSusan Scheufele 	MR_EVT_CLASS_DEAD		=  4
330dcda19f5SSusan Scheufele };
331dcda19f5SSusan Scheufele 
332dcda19f5SSusan Scheufele enum MR_EVT_LOCALE {
333dcda19f5SSusan Scheufele 	MR_EVT_LOCALE_LD		= 0x0001,
334dcda19f5SSusan Scheufele 	MR_EVT_LOCALE_PD		= 0x0002,
335dcda19f5SSusan Scheufele 	MR_EVT_LOCALE_ENCL		= 0x0004,
336dcda19f5SSusan Scheufele 	MR_EVT_LOCALE_BBU		= 0x0008,
337dcda19f5SSusan Scheufele 	MR_EVT_LOCALE_SAS		= 0x0010,
338dcda19f5SSusan Scheufele 	MR_EVT_LOCALE_CTRL		= 0x0020,
339dcda19f5SSusan Scheufele 	MR_EVT_LOCALE_CONFIG		= 0x0040,
340dcda19f5SSusan Scheufele 	MR_EVT_LOCALE_CLUSTER		= 0x0080,
341dcda19f5SSusan Scheufele 	MR_EVT_LOCALE_ALL		= 0xffff
342dcda19f5SSusan Scheufele };
343dcda19f5SSusan Scheufele 
3442ffc8bcaSDan McDonald enum MR_EVT_ARGS {
3452ffc8bcaSDan McDonald 	MR_EVT_ARGS_NONE,
3462ffc8bcaSDan McDonald 	MR_EVT_ARGS_CDB_SENSE,
3472ffc8bcaSDan McDonald 	MR_EVT_ARGS_LD,
3482ffc8bcaSDan McDonald 	MR_EVT_ARGS_LD_COUNT,
3492ffc8bcaSDan McDonald 	MR_EVT_ARGS_LD_LBA,
3502ffc8bcaSDan McDonald 	MR_EVT_ARGS_LD_OWNER,
3512ffc8bcaSDan McDonald 	MR_EVT_ARGS_LD_LBA_PD_LBA,
3522ffc8bcaSDan McDonald 	MR_EVT_ARGS_LD_PROG,
3532ffc8bcaSDan McDonald 	MR_EVT_ARGS_LD_STATE,
3542ffc8bcaSDan McDonald 	MR_EVT_ARGS_LD_STRIP,
3552ffc8bcaSDan McDonald 	MR_EVT_ARGS_PD,
3562ffc8bcaSDan McDonald 	MR_EVT_ARGS_PD_ERR,
3572ffc8bcaSDan McDonald 	MR_EVT_ARGS_PD_LBA,
3582ffc8bcaSDan McDonald 	MR_EVT_ARGS_PD_LBA_LD,
3592ffc8bcaSDan McDonald 	MR_EVT_ARGS_PD_PROG,
3602ffc8bcaSDan McDonald 	MR_EVT_ARGS_PD_STATE,
3612ffc8bcaSDan McDonald 	MR_EVT_ARGS_PCI,
3622ffc8bcaSDan McDonald 	MR_EVT_ARGS_RATE,
3632ffc8bcaSDan McDonald 	MR_EVT_ARGS_STR,
3642ffc8bcaSDan McDonald 	MR_EVT_ARGS_TIME,
3652ffc8bcaSDan McDonald 	MR_EVT_ARGS_ECC
3662ffc8bcaSDan McDonald };
3672ffc8bcaSDan McDonald 
368dcda19f5SSusan Scheufele #define	MR_EVT_CFG_CLEARED		0x0004
369dcda19f5SSusan Scheufele #define	MR_EVT_LD_CREATED		0x008a
370dcda19f5SSusan Scheufele #define	MR_EVT_LD_DELETED		0x008b
3712ffc8bcaSDan McDonald #define	MR_EVT_CFG_FP_CHANGE		0x017B
372dcda19f5SSusan Scheufele 
373dcda19f5SSusan Scheufele enum LD_STATE {
374dcda19f5SSusan Scheufele 	LD_OFFLINE		= 0,
375dcda19f5SSusan Scheufele 	LD_PARTIALLY_DEGRADED	= 1,
376dcda19f5SSusan Scheufele 	LD_DEGRADED		= 2,
377dcda19f5SSusan Scheufele 	LD_OPTIMAL		= 3,
378dcda19f5SSusan Scheufele 	LD_INVALID		= 0xFF
379dcda19f5SSusan Scheufele };
380dcda19f5SSusan Scheufele 
381dcda19f5SSusan Scheufele enum MRSAS_EVT {
382dcda19f5SSusan Scheufele 	MRSAS_EVT_CONFIG_TGT	= 0,
383dcda19f5SSusan Scheufele 	MRSAS_EVT_UNCONFIG_TGT	= 1,
384dcda19f5SSusan Scheufele 	MRSAS_EVT_UNCONFIG_SMP	= 2
385dcda19f5SSusan Scheufele };
386dcda19f5SSusan Scheufele 
387dcda19f5SSusan Scheufele #define	DMA_OBJ_ALLOCATED	1
388dcda19f5SSusan Scheufele #define	DMA_OBJ_REALLOCATED	2
389dcda19f5SSusan Scheufele #define	DMA_OBJ_FREED		3
390dcda19f5SSusan Scheufele 
391dcda19f5SSusan Scheufele /*
392dcda19f5SSusan Scheufele  * dma_obj_t	- Our DMA object
393dcda19f5SSusan Scheufele  * @param buffer	: kernel virtual address
394dcda19f5SSusan Scheufele  * @param size		: size of the data to be allocated
395dcda19f5SSusan Scheufele  * @param acc_handle	: access handle
396dcda19f5SSusan Scheufele  * @param dma_handle	: dma handle
397dcda19f5SSusan Scheufele  * @param dma_cookie	: scatter-gather list
398dcda19f5SSusan Scheufele  * @param dma_attr	: dma attributes for this buffer
3992ffc8bcaSDan McDonald  *
400dcda19f5SSusan Scheufele  * Our DMA object. The caller must initialize the size and dma attributes
401dcda19f5SSusan Scheufele  * (dma_attr) fields before allocating the resources.
402dcda19f5SSusan Scheufele  */
403dcda19f5SSusan Scheufele typedef struct {
404dcda19f5SSusan Scheufele 	caddr_t			buffer;
405dcda19f5SSusan Scheufele 	uint32_t		size;
406dcda19f5SSusan Scheufele 	ddi_acc_handle_t	acc_handle;
407dcda19f5SSusan Scheufele 	ddi_dma_handle_t	dma_handle;
408dcda19f5SSusan Scheufele 	ddi_dma_cookie_t	dma_cookie[MRSAS_MAX_SGE_CNT];
409dcda19f5SSusan Scheufele 	ddi_dma_attr_t		dma_attr;
410dcda19f5SSusan Scheufele 	uint8_t			status;
411dcda19f5SSusan Scheufele 	uint8_t			reserved[3];
412dcda19f5SSusan Scheufele } dma_obj_t;
413dcda19f5SSusan Scheufele 
414dcda19f5SSusan Scheufele struct mrsas_eventinfo {
415dcda19f5SSusan Scheufele 	struct mrsas_instance	*instance;
416dcda19f5SSusan Scheufele 	int 			tgt;
417dcda19f5SSusan Scheufele 	int 			lun;
418dcda19f5SSusan Scheufele 	int 			event;
4192ffc8bcaSDan McDonald 	uint64_t		wwn;
420dcda19f5SSusan Scheufele };
421dcda19f5SSusan Scheufele 
422dcda19f5SSusan Scheufele struct mrsas_ld {
423dcda19f5SSusan Scheufele 	dev_info_t		*dip;
424dcda19f5SSusan Scheufele 	uint8_t 		lun_type;
4252ffc8bcaSDan McDonald 	uint8_t			flag;
4262ffc8bcaSDan McDonald 	uint8_t 		reserved[2];
427dcda19f5SSusan Scheufele };
428dcda19f5SSusan Scheufele 
4292ffc8bcaSDan McDonald 
4302ffc8bcaSDan McDonald struct mrsas_tbolt_pd {
431dcda19f5SSusan Scheufele 	dev_info_t		*dip;
432dcda19f5SSusan Scheufele 	uint8_t 		lun_type;
433dcda19f5SSusan Scheufele 	uint8_t 		dev_id;
4342ffc8bcaSDan McDonald 	uint8_t 		flag;
435dcda19f5SSusan Scheufele 	uint8_t 		reserved;
436dcda19f5SSusan Scheufele };
4372ffc8bcaSDan McDonald struct mrsas_tbolt_pd_info {
438dcda19f5SSusan Scheufele 	uint16_t	deviceId;
439dcda19f5SSusan Scheufele 	uint16_t	seqNum;
440dcda19f5SSusan Scheufele 	uint8_t		inquiryData[96];
441dcda19f5SSusan Scheufele 	uint8_t		vpdPage83[64];
442dcda19f5SSusan Scheufele 	uint8_t		notSupported;
443dcda19f5SSusan Scheufele 	uint8_t		scsiDevType;
444dcda19f5SSusan Scheufele 	uint8_t		a;
445dcda19f5SSusan Scheufele 	uint8_t		device_speed;
446dcda19f5SSusan Scheufele 	uint32_t	mediaerrcnt;
447dcda19f5SSusan Scheufele 	uint32_t	other;
448dcda19f5SSusan Scheufele 	uint32_t	pred;
449dcda19f5SSusan Scheufele 	uint32_t	lastpred;
450dcda19f5SSusan Scheufele 	uint16_t	fwState;
451dcda19f5SSusan Scheufele 	uint8_t		disabled;
452dcda19f5SSusan Scheufele 	uint8_t		linkspwwd;
453dcda19f5SSusan Scheufele 	uint32_t	ddfType;
454dcda19f5SSusan Scheufele 	struct {
455dcda19f5SSusan Scheufele 		uint8_t	count;
456dcda19f5SSusan Scheufele 		uint8_t	isPathBroken;
457dcda19f5SSusan Scheufele 		uint8_t	connectorIndex[2];
458dcda19f5SSusan Scheufele 		uint8_t	reserved[4];
459dcda19f5SSusan Scheufele 		uint64_t sasAddr[2];
460dcda19f5SSusan Scheufele 		uint8_t	reserved2[16];
461dcda19f5SSusan Scheufele 	} pathInfo;
462dcda19f5SSusan Scheufele };
463dcda19f5SSusan Scheufele 
464dcda19f5SSusan Scheufele typedef struct mrsas_instance {
465dcda19f5SSusan Scheufele 	uint32_t	*producer;
466dcda19f5SSusan Scheufele 	uint32_t	*consumer;
467dcda19f5SSusan Scheufele 
468dcda19f5SSusan Scheufele 	uint32_t	*reply_queue;
469dcda19f5SSusan Scheufele 	dma_obj_t	mfi_internal_dma_obj;
470e73d18e5SYu Wu - Sun Microsystems - Beijing China 	uint16_t	adapterresetinprogress;
471e73d18e5SYu Wu - Sun Microsystems - Beijing China 	uint16_t	deadadapter;
4722ffc8bcaSDan McDonald 	/* ThunderBolt (TB) specific */
4732ffc8bcaSDan McDonald 	dma_obj_t	mpi2_frame_pool_dma_obj;
4742ffc8bcaSDan McDonald 	dma_obj_t	request_desc_dma_obj;
4752ffc8bcaSDan McDonald 	dma_obj_t	reply_desc_dma_obj;
4762ffc8bcaSDan McDonald 	dma_obj_t	ld_map_obj[2];
4772ffc8bcaSDan McDonald 
478dcda19f5SSusan Scheufele 	uint8_t		init_id;
479062f0014SYu Wu - Sun Microsystems - Beijing China 	uint8_t		flag_ieee;
480e73d18e5SYu Wu - Sun Microsystems - Beijing China 	uint8_t		disable_online_ctrl_reset;
481e73d18e5SYu Wu - Sun Microsystems - Beijing China 	uint8_t		fw_fault_count_after_ocr;
482dcda19f5SSusan Scheufele 
483dcda19f5SSusan Scheufele 	uint16_t	max_num_sge;
484dcda19f5SSusan Scheufele 	uint16_t	max_fw_cmds;
485dcda19f5SSusan Scheufele 	uint32_t	max_sectors_per_req;
486dcda19f5SSusan Scheufele 
487dcda19f5SSusan Scheufele 	struct mrsas_cmd **cmd_list;
4882ffc8bcaSDan McDonald 
489dcda19f5SSusan Scheufele 	mlist_t		cmd_pool_list;
490dcda19f5SSusan Scheufele 	kmutex_t	cmd_pool_mtx;
4912ffc8bcaSDan McDonald 	kmutex_t	sync_map_mtx;
492dcda19f5SSusan Scheufele 
493e73d18e5SYu Wu - Sun Microsystems - Beijing China 	mlist_t		app_cmd_pool_list;
494e73d18e5SYu Wu - Sun Microsystems - Beijing China 	kmutex_t	app_cmd_pool_mtx;
4952ffc8bcaSDan McDonald 	mlist_t		cmd_app_pool_list;
4962ffc8bcaSDan McDonald 	kmutex_t	cmd_app_pool_mtx;
4972ffc8bcaSDan McDonald 
4982ffc8bcaSDan McDonald 
499dcda19f5SSusan Scheufele 	mlist_t		cmd_pend_list;
500dcda19f5SSusan Scheufele 	kmutex_t	cmd_pend_mtx;
501dcda19f5SSusan Scheufele 
502dcda19f5SSusan Scheufele 	dma_obj_t	mfi_evt_detail_obj;
503dcda19f5SSusan Scheufele 	struct mrsas_cmd *aen_cmd;
504dcda19f5SSusan Scheufele 
505dcda19f5SSusan Scheufele 	uint32_t	aen_seq_num;
506dcda19f5SSusan Scheufele 	uint32_t	aen_class_locale_word;
507dcda19f5SSusan Scheufele 
508dcda19f5SSusan Scheufele 	scsi_hba_tran_t		*tran;
509dcda19f5SSusan Scheufele 
510dcda19f5SSusan Scheufele 	kcondvar_t	int_cmd_cv;
511dcda19f5SSusan Scheufele 	kmutex_t	int_cmd_mtx;
512dcda19f5SSusan Scheufele 
513dcda19f5SSusan Scheufele 	kcondvar_t	aen_cmd_cv;
514dcda19f5SSusan Scheufele 	kmutex_t	aen_cmd_mtx;
515dcda19f5SSusan Scheufele 
516dcda19f5SSusan Scheufele 	kcondvar_t	abort_cmd_cv;
517dcda19f5SSusan Scheufele 	kmutex_t	abort_cmd_mtx;
518dcda19f5SSusan Scheufele 
5192ffc8bcaSDan McDonald 	kmutex_t	reg_write_mtx;
5202ffc8bcaSDan McDonald 	kmutex_t	chip_mtx;
5212ffc8bcaSDan McDonald 
522dcda19f5SSusan Scheufele 	dev_info_t		*dip;
523dcda19f5SSusan Scheufele 	ddi_acc_handle_t	pci_handle;
524dcda19f5SSusan Scheufele 
525dcda19f5SSusan Scheufele 	timeout_id_t	timeout_id;
526dcda19f5SSusan Scheufele 	uint32_t	unique_id;
527dcda19f5SSusan Scheufele 	uint16_t	fw_outstanding;
528dcda19f5SSusan Scheufele 	caddr_t		regmap;
529dcda19f5SSusan Scheufele 	ddi_acc_handle_t	regmap_handle;
530dcda19f5SSusan Scheufele 	uint8_t		isr_level;
531dcda19f5SSusan Scheufele 	ddi_iblock_cookie_t	iblock_cookie;
532dcda19f5SSusan Scheufele 	ddi_iblock_cookie_t	soft_iblock_cookie;
533dcda19f5SSusan Scheufele 	ddi_softintr_t		soft_intr_id;
534dcda19f5SSusan Scheufele 	uint8_t		softint_running;
5352ffc8bcaSDan McDonald 	uint8_t		tbolt_softint_running;
536dcda19f5SSusan Scheufele 	kmutex_t	completed_pool_mtx;
537dcda19f5SSusan Scheufele 	mlist_t		completed_pool_list;
538dcda19f5SSusan Scheufele 
539dcda19f5SSusan Scheufele 	caddr_t		internal_buf;
540dcda19f5SSusan Scheufele 	uint32_t	internal_buf_dmac_add;
541dcda19f5SSusan Scheufele 	uint32_t	internal_buf_size;
542dcda19f5SSusan Scheufele 
543dcda19f5SSusan Scheufele 	uint16_t	vendor_id;
544dcda19f5SSusan Scheufele 	uint16_t	device_id;
545dcda19f5SSusan Scheufele 	uint16_t	subsysvid;
546dcda19f5SSusan Scheufele 	uint16_t	subsysid;
547dcda19f5SSusan Scheufele 	int		instance;
548dcda19f5SSusan Scheufele 	int		baseaddress;
549dcda19f5SSusan Scheufele 	char		iocnode[16];
550dcda19f5SSusan Scheufele 
551dcda19f5SSusan Scheufele 	int		fm_capabilities;
5522ffc8bcaSDan McDonald 	/*
5532ffc8bcaSDan McDonald 	 * Driver resources unroll flags.  The flag is set for resources that
5542ffc8bcaSDan McDonald 	 * are needed to be free'd at detach() time.
5552ffc8bcaSDan McDonald 	 */
5562ffc8bcaSDan McDonald 	struct _unroll {
5572ffc8bcaSDan McDonald 		uint8_t softs;		/* The software state was allocated. */
5582ffc8bcaSDan McDonald 		uint8_t regs;		/* Controller registers mapped. */
5592ffc8bcaSDan McDonald 		uint8_t intr;		/* Interrupt handler added. */
5602ffc8bcaSDan McDonald 		uint8_t reqs;		/* Request structs allocated. */
5612ffc8bcaSDan McDonald 		uint8_t mutexs;		/* Mutex's allocated. */
5622ffc8bcaSDan McDonald 		uint8_t taskq;		/* Task q's created. */
5632ffc8bcaSDan McDonald 		uint8_t tran;		/* Tran struct allocated */
5642ffc8bcaSDan McDonald 		uint8_t tranSetup;	/* Tran attached to the ddi. */
5652ffc8bcaSDan McDonald 		uint8_t devctl;		/* Device nodes for cfgadm created. */
5662ffc8bcaSDan McDonald 		uint8_t scsictl;	/* Device nodes for cfgadm created. */
5672ffc8bcaSDan McDonald 		uint8_t ioctl;		/* Device nodes for ioctl's created. */
5682ffc8bcaSDan McDonald 		uint8_t timer;		/* Timer started. */
5692ffc8bcaSDan McDonald 		uint8_t aenPend;	/* AEN cmd pending f/w. */
5702ffc8bcaSDan McDonald 		uint8_t mapUpdate_pend; /* LD MAP update cmd pending f/w. */
5712ffc8bcaSDan McDonald 		uint8_t soft_isr;	/* Soft interrupt handler allocated. */
5722ffc8bcaSDan McDonald 		uint8_t ldlist_buff;	/* Logical disk list allocated. */
5732ffc8bcaSDan McDonald 		uint8_t pdlist_buff;	/* Physical disk list allocated. */
5742ffc8bcaSDan McDonald 		uint8_t syncCmd;	/* Sync map command allocated. */
5752ffc8bcaSDan McDonald 		uint8_t verBuff;	/* 2108 MFI buffer allocated. */
5762ffc8bcaSDan McDonald 		uint8_t alloc_space_mfi;  /* Allocated space for 2108 MFI. */
5772ffc8bcaSDan McDonald 		uint8_t alloc_space_mpi2; /* Allocated space for 2208 MPI2. */
5782ffc8bcaSDan McDonald 	} unroll;
579dcda19f5SSusan Scheufele 
5802ffc8bcaSDan McDonald 
5812ffc8bcaSDan McDonald 	/* function template pointer */
5822ffc8bcaSDan McDonald 	struct mrsas_function_template *func_ptr;
5832ffc8bcaSDan McDonald 
5842ffc8bcaSDan McDonald 
585dcda19f5SSusan Scheufele 	/* MSI interrupts specific */
5862ffc8bcaSDan McDonald 	ddi_intr_handle_t *intr_htable;		/* Interrupt handle array */
5872ffc8bcaSDan McDonald 	size_t		intr_htable_size;	/* Int. handle array size */
588dcda19f5SSusan Scheufele 	int		intr_type;
589dcda19f5SSusan Scheufele 	int		intr_cnt;
590dcda19f5SSusan Scheufele 	uint_t		intr_pri;
591dcda19f5SSusan Scheufele 	int		intr_cap;
592dcda19f5SSusan Scheufele 
593dcda19f5SSusan Scheufele 	ddi_taskq_t	*taskq;
594dcda19f5SSusan Scheufele 	struct mrsas_ld	*mr_ld_list;
5952ffc8bcaSDan McDonald 	kmutex_t	config_dev_mtx;
5962ffc8bcaSDan McDonald 	/* ThunderBolt (TB) specific */
5972ffc8bcaSDan McDonald 	ddi_softintr_t	tbolt_soft_intr_id;
5982ffc8bcaSDan McDonald 
5992ffc8bcaSDan McDonald 	uint32_t	mr_tbolt_pd_max;
6002ffc8bcaSDan McDonald 	struct mrsas_tbolt_pd *mr_tbolt_pd_list;
6012ffc8bcaSDan McDonald 
6022ffc8bcaSDan McDonald 	uint8_t		fast_path_io;
6032ffc8bcaSDan McDonald 
604a1c36c8bSDan McDonald 	uint8_t		skinny;
605a1c36c8bSDan McDonald 	uint8_t		tbolt;
606df950592SHummyPkg 	uint8_t		gen3;
6072ffc8bcaSDan McDonald 	uint16_t	reply_read_index;
6082ffc8bcaSDan McDonald 	uint16_t	reply_size; 		/* Single Reply struct size */
6092ffc8bcaSDan McDonald 	uint16_t	raid_io_msg_size; 	/* Single message size */
6102ffc8bcaSDan McDonald 	uint32_t	io_request_frames_phy;
6112ffc8bcaSDan McDonald 	uint8_t 	*io_request_frames;
6122ffc8bcaSDan McDonald 	/* Virtual address of request desc frame pool */
6132ffc8bcaSDan McDonald 	MRSAS_REQUEST_DESCRIPTOR_UNION	*request_message_pool;
6142ffc8bcaSDan McDonald 	/* Physical address of request desc frame pool */
6152ffc8bcaSDan McDonald 	uint32_t	request_message_pool_phy;
6162ffc8bcaSDan McDonald 	/* Virtual address of reply Frame */
6172ffc8bcaSDan McDonald 	MPI2_REPLY_DESCRIPTORS_UNION	*reply_frame_pool;
6182ffc8bcaSDan McDonald 	/* Physical address of reply Frame */
6192ffc8bcaSDan McDonald 	uint32_t	reply_frame_pool_phy;
6202ffc8bcaSDan McDonald 	uint8_t		*reply_pool_limit;	/* Last reply frame address */
6212ffc8bcaSDan McDonald 	/* Physical address of Last reply frame */
6222ffc8bcaSDan McDonald 	uint32_t	reply_pool_limit_phy;
6232ffc8bcaSDan McDonald 	uint32_t	reply_q_depth;		/* Reply Queue Depth */
6242ffc8bcaSDan McDonald 	uint8_t		max_sge_in_main_msg;
6252ffc8bcaSDan McDonald 	uint8_t		max_sge_in_chain;
6262ffc8bcaSDan McDonald 	uint8_t    	chain_offset_io_req;
6272ffc8bcaSDan McDonald 	uint8_t		chain_offset_mpt_msg;
6282ffc8bcaSDan McDonald 	MR_FW_RAID_MAP_ALL *ld_map[2];
6292ffc8bcaSDan McDonald 	uint32_t 	ld_map_phy[2];
6302ffc8bcaSDan McDonald 	uint32_t	size_map_info;
6312ffc8bcaSDan McDonald 	uint64_t 	map_id;
6322ffc8bcaSDan McDonald 	LD_LOAD_BALANCE_INFO load_balance_info[MAX_LOGICAL_DRIVES];
6332ffc8bcaSDan McDonald 	struct mrsas_cmd *map_update_cmd;
6342ffc8bcaSDan McDonald 	uint32_t	SyncRequired;
635e73d18e5SYu Wu - Sun Microsystems - Beijing China 	kmutex_t	ocr_flags_mtx;
6362ffc8bcaSDan McDonald 	dma_obj_t	drv_ver_dma_obj;
637dcda19f5SSusan Scheufele } mrsas_t;
638dcda19f5SSusan Scheufele 
6392ffc8bcaSDan McDonald 
6402ffc8bcaSDan McDonald /*
6412ffc8bcaSDan McDonald  * Function templates for various controller specific functions
6422ffc8bcaSDan McDonald  */
6432ffc8bcaSDan McDonald struct mrsas_function_template {
6442ffc8bcaSDan McDonald 	uint32_t (*read_fw_status_reg)(struct mrsas_instance *);
645dcda19f5SSusan Scheufele 	void (*issue_cmd)(struct mrsas_cmd *, struct mrsas_instance *);
646dcda19f5SSusan Scheufele 	int (*issue_cmd_in_sync_mode)(struct mrsas_instance *,
647dcda19f5SSusan Scheufele 	    struct mrsas_cmd *);
648dcda19f5SSusan Scheufele 	int (*issue_cmd_in_poll_mode)(struct mrsas_instance *,
649dcda19f5SSusan Scheufele 	    struct mrsas_cmd *);
650dcda19f5SSusan Scheufele 	void (*enable_intr)(struct mrsas_instance *);
651dcda19f5SSusan Scheufele 	void (*disable_intr)(struct mrsas_instance *);
652dcda19f5SSusan Scheufele 	int (*intr_ack)(struct mrsas_instance *);
6532ffc8bcaSDan McDonald 	int (*init_adapter)(struct mrsas_instance *);
6542ffc8bcaSDan McDonald /*	int (*reset_adapter)(struct mrsas_instance *); */
655dcda19f5SSusan Scheufele };
656dcda19f5SSusan Scheufele 
657dcda19f5SSusan Scheufele /*
658dcda19f5SSusan Scheufele  * ### Helper routines ###
659dcda19f5SSusan Scheufele  */
660dcda19f5SSusan Scheufele 
661dcda19f5SSusan Scheufele /*
662dcda19f5SSusan Scheufele  * con_log() - console log routine
663dcda19f5SSusan Scheufele  * @param level		: indicates the severity of the message.
664dcda19f5SSusan Scheufele  * @fparam mt		: format string
665dcda19f5SSusan Scheufele  *
666dcda19f5SSusan Scheufele  * con_log displays the error messages on the console based on the current
667dcda19f5SSusan Scheufele  * debug level. Also it attaches the appropriate kernel severity level with
668dcda19f5SSusan Scheufele  * the message.
669dcda19f5SSusan Scheufele  *
670dcda19f5SSusan Scheufele  *
671dcda19f5SSusan Scheufele  * console messages debug levels
672dcda19f5SSusan Scheufele  */
673dcda19f5SSusan Scheufele #define	CL_NONE		0	/* No debug information */
6742ffc8bcaSDan McDonald #define	CL_ANN		1	/* print unconditionally, announcements */
6752ffc8bcaSDan McDonald #define	CL_ANN1		2	/* No-op  */
6762ffc8bcaSDan McDonald #define	CL_DLEVEL1	3	/* debug level 1, informative */
6772ffc8bcaSDan McDonald #define	CL_DLEVEL2	4	/* debug level 2, verbose */
6782ffc8bcaSDan McDonald #define	CL_DLEVEL3	5	/* debug level 3, very verbose */
679dcda19f5SSusan Scheufele 
680dcda19f5SSusan Scheufele #ifdef __SUNPRO_C
681dcda19f5SSusan Scheufele #define	__func__ ""
682dcda19f5SSusan Scheufele #endif
683dcda19f5SSusan Scheufele 
684dcda19f5SSusan Scheufele #define	con_log(level, fmt) { if (debug_level_g >= level) cmn_err fmt; }
685dcda19f5SSusan Scheufele 
686dcda19f5SSusan Scheufele /*
687dcda19f5SSusan Scheufele  * ### SCSA definitions ###
688dcda19f5SSusan Scheufele  */
689dcda19f5SSusan Scheufele #define	PKT2TGT(pkt)	((pkt)->pkt_address.a_target)
690dcda19f5SSusan Scheufele #define	PKT2LUN(pkt)	((pkt)->pkt_address.a_lun)
691dcda19f5SSusan Scheufele #define	PKT2TRAN(pkt)	((pkt)->pkt_adress.a_hba_tran)
692dcda19f5SSusan Scheufele #define	ADDR2TRAN(ap)	((ap)->a_hba_tran)
693dcda19f5SSusan Scheufele 
694dcda19f5SSusan Scheufele #define	TRAN2MR(tran)	(struct mrsas_instance *)(tran)->tran_hba_private)
695dcda19f5SSusan Scheufele #define	ADDR2MR(ap)	(TRAN2MR(ADDR2TRAN(ap))
696dcda19f5SSusan Scheufele 
697dcda19f5SSusan Scheufele #define	PKT2CMD(pkt)	((struct scsa_cmd *)(pkt)->pkt_ha_private)
698dcda19f5SSusan Scheufele #define	CMD2PKT(sp)	((sp)->cmd_pkt)
699dcda19f5SSusan Scheufele #define	PKT2REQ(pkt)	(&(PKT2CMD(pkt)->request))
700dcda19f5SSusan Scheufele 
701dcda19f5SSusan Scheufele #define	CMD2ADDR(cmd)	(&CMD2PKT(cmd)->pkt_address)
702dcda19f5SSusan Scheufele #define	CMD2TRAN(cmd)	(CMD2PKT(cmd)->pkt_address.a_hba_tran)
703dcda19f5SSusan Scheufele #define	CMD2MR(cmd)	(TRAN2MR(CMD2TRAN(cmd)))
704dcda19f5SSusan Scheufele 
705dcda19f5SSusan Scheufele #define	CFLAG_DMAVALID		0x0001	/* requires a dma operation */
706dcda19f5SSusan Scheufele #define	CFLAG_DMASEND		0x0002	/* Transfer from the device */
707dcda19f5SSusan Scheufele #define	CFLAG_CONSISTENT	0x0040	/* consistent data transfer */
708dcda19f5SSusan Scheufele 
709dcda19f5SSusan Scheufele /*
710dcda19f5SSusan Scheufele  * ### Data structures for ioctl inteface and internal commands ###
711dcda19f5SSusan Scheufele  */
712dcda19f5SSusan Scheufele 
713dcda19f5SSusan Scheufele /*
714dcda19f5SSusan Scheufele  * Data direction flags
715dcda19f5SSusan Scheufele  */
716dcda19f5SSusan Scheufele #define	UIOC_RD		0x00001
717dcda19f5SSusan Scheufele #define	UIOC_WR		0x00002
718dcda19f5SSusan Scheufele 
719dcda19f5SSusan Scheufele #define	SCP2HOST(scp)		(scp)->device->host	/* to host */
720dcda19f5SSusan Scheufele #define	SCP2HOSTDATA(scp)	SCP2HOST(scp)->hostdata	/* to soft state */
721dcda19f5SSusan Scheufele #define	SCP2CHANNEL(scp)	(scp)->device->channel	/* to channel */
722dcda19f5SSusan Scheufele #define	SCP2TARGET(scp)		(scp)->device->id	/* to target */
723dcda19f5SSusan Scheufele #define	SCP2LUN(scp)		(scp)->device->lun	/* to LUN */
724dcda19f5SSusan Scheufele 
725dcda19f5SSusan Scheufele #define	SCSIHOST2ADAP(host)	(((caddr_t *)(host->hostdata))[0])
726dcda19f5SSusan Scheufele #define	SCP2ADAPTER(scp)				\
727dcda19f5SSusan Scheufele 	(struct mrsas_instance *)SCSIHOST2ADAP(SCP2HOST(scp))
728dcda19f5SSusan Scheufele 
729dcda19f5SSusan Scheufele #define	MRDRV_IS_LOGICAL_SCSA(instance, acmd)		\
730dcda19f5SSusan Scheufele 	(acmd->device_id < MRDRV_MAX_LD) ? 1 : 0
731dcda19f5SSusan Scheufele #define	MRDRV_IS_LOGICAL(ap)				\
732dcda19f5SSusan Scheufele 	((ap->a_target < MRDRV_MAX_LD) && (ap->a_lun == 0)) ? 1 : 0
733dcda19f5SSusan Scheufele #define	MAP_DEVICE_ID(instance, ap)			\
734dcda19f5SSusan Scheufele 	(ap->a_target)
735dcda19f5SSusan Scheufele 
736dcda19f5SSusan Scheufele #define	HIGH_LEVEL_INTR			1
737dcda19f5SSusan Scheufele #define	NORMAL_LEVEL_INTR		0
738dcda19f5SSusan Scheufele 
7392ffc8bcaSDan McDonald #define		IO_TIMEOUT_VAL		0
740e73d18e5SYu Wu - Sun Microsystems - Beijing China #define		IO_RETRY_COUNT		3
741e73d18e5SYu Wu - Sun Microsystems - Beijing China #define		MAX_FW_RESET_COUNT	3
742dcda19f5SSusan Scheufele /*
743dcda19f5SSusan Scheufele  * scsa_cmd  - Per-command mr private data
744dcda19f5SSusan Scheufele  * @param cmd_dmahandle		:  dma handle
745dcda19f5SSusan Scheufele  * @param cmd_dmacookies	:  current dma cookies
746dcda19f5SSusan Scheufele  * @param cmd_pkt		:  scsi_pkt reference
747dcda19f5SSusan Scheufele  * @param cmd_dmacount		:  dma count
748dcda19f5SSusan Scheufele  * @param cmd_cookie		:  next cookie
749dcda19f5SSusan Scheufele  * @param cmd_ncookies		:  cookies per window
750dcda19f5SSusan Scheufele  * @param cmd_cookiecnt		:  cookies per sub-win
751dcda19f5SSusan Scheufele  * @param cmd_nwin		:  number of dma windows
752dcda19f5SSusan Scheufele  * @param cmd_curwin		:  current dma window
753dcda19f5SSusan Scheufele  * @param cmd_dma_offset	:  current window offset
754dcda19f5SSusan Scheufele  * @param cmd_dma_len		:  current window length
755dcda19f5SSusan Scheufele  * @param cmd_flags		:  private flags
756dcda19f5SSusan Scheufele  * @param cmd_cdblen		:  length of cdb
757dcda19f5SSusan Scheufele  * @param cmd_scblen		:  length of scb
758dcda19f5SSusan Scheufele  * @param cmd_buf		:  command buffer
759dcda19f5SSusan Scheufele  * @param channel		:  channel for scsi sub-system
760dcda19f5SSusan Scheufele  * @param target		:  target for scsi sub-system
761dcda19f5SSusan Scheufele  * @param lun			:  LUN for scsi sub-system
762dcda19f5SSusan Scheufele  *
763*4b9db4f6SChris Fraire  * - Allocated at same time as scsi_pkt by scsi_hba_pkt_alloc(9F)
764dcda19f5SSusan Scheufele  * - Pointed to by pkt_ha_private field in scsi_pkt
765dcda19f5SSusan Scheufele  */
766dcda19f5SSusan Scheufele struct scsa_cmd {
767dcda19f5SSusan Scheufele 	ddi_dma_handle_t	cmd_dmahandle;
768dcda19f5SSusan Scheufele 	ddi_dma_cookie_t	cmd_dmacookies[MRSAS_MAX_SGE_CNT];
769dcda19f5SSusan Scheufele 	struct scsi_pkt		*cmd_pkt;
770dcda19f5SSusan Scheufele 	ulong_t			cmd_dmacount;
771dcda19f5SSusan Scheufele 	uint_t			cmd_cookie;
772dcda19f5SSusan Scheufele 	uint_t			cmd_ncookies;
773dcda19f5SSusan Scheufele 	uint_t			cmd_cookiecnt;
774dcda19f5SSusan Scheufele 	uint_t			cmd_nwin;
775dcda19f5SSusan Scheufele 	uint_t			cmd_curwin;
776dcda19f5SSusan Scheufele 	off_t			cmd_dma_offset;
777dcda19f5SSusan Scheufele 	ulong_t			cmd_dma_len;
778dcda19f5SSusan Scheufele 	ulong_t			cmd_flags;
779dcda19f5SSusan Scheufele 	uint_t			cmd_cdblen;
780dcda19f5SSusan Scheufele 	uint_t			cmd_scblen;
781dcda19f5SSusan Scheufele 	struct buf		*cmd_buf;
782dcda19f5SSusan Scheufele 	ushort_t		device_id;
783dcda19f5SSusan Scheufele 	uchar_t			islogical;
784dcda19f5SSusan Scheufele 	uchar_t			lun;
785dcda19f5SSusan Scheufele 	struct mrsas_device	*mrsas_dev;
786dcda19f5SSusan Scheufele };
787dcda19f5SSusan Scheufele 
788dcda19f5SSusan Scheufele 
789dcda19f5SSusan Scheufele struct mrsas_cmd {
7902ffc8bcaSDan McDonald 	/*
7912ffc8bcaSDan McDonald 	 * ThunderBolt(TB) We would be needing to have a placeholder
7922ffc8bcaSDan McDonald 	 * for RAID_MSG_IO_REQUEST inside this structure. We are
7932ffc8bcaSDan McDonald 	 * supposed to embed the mr_frame inside the RAID_MSG and post
7942ffc8bcaSDan McDonald 	 * it down to the firmware.
7952ffc8bcaSDan McDonald 	 */
796dcda19f5SSusan Scheufele 	union mrsas_frame	*frame;
797dcda19f5SSusan Scheufele 	uint32_t		frame_phys_addr;
798dcda19f5SSusan Scheufele 	uint8_t			*sense;
7992ffc8bcaSDan McDonald 	uint8_t			*sense1;
800dcda19f5SSusan Scheufele 	uint32_t		sense_phys_addr;
8012ffc8bcaSDan McDonald 	uint32_t		sense_phys_addr1;
802dcda19f5SSusan Scheufele 	dma_obj_t		frame_dma_obj;
803dcda19f5SSusan Scheufele 	uint8_t			frame_dma_obj_status;
804dcda19f5SSusan Scheufele 	uint32_t		index;
805dcda19f5SSusan Scheufele 	uint8_t			sync_cmd;
806dcda19f5SSusan Scheufele 	uint8_t			cmd_status;
807dcda19f5SSusan Scheufele 	uint16_t		abort_aen;
808dcda19f5SSusan Scheufele 	mlist_t			list;
809dcda19f5SSusan Scheufele 	uint32_t		frame_count;
810dcda19f5SSusan Scheufele 	struct scsa_cmd		*cmd;
811dcda19f5SSusan Scheufele 	struct scsi_pkt		*pkt;
8122ffc8bcaSDan McDonald 	Mpi2RaidSCSIIORequest_t *scsi_io_request;
8132ffc8bcaSDan McDonald 	Mpi2SGEIOUnion_t	*sgl;
8142ffc8bcaSDan McDonald 	uint32_t		sgl_phys_addr;
8152ffc8bcaSDan McDonald 	uint32_t		scsi_io_request_phys_addr;
8162ffc8bcaSDan McDonald 	MRSAS_REQUEST_DESCRIPTOR_UNION	*request_desc;
8172ffc8bcaSDan McDonald 	uint16_t		SMID;
818e73d18e5SYu Wu - Sun Microsystems - Beijing China 	uint16_t		retry_count_for_ocr;
819e73d18e5SYu Wu - Sun Microsystems - Beijing China 	uint16_t		drv_pkt_time;
8202ffc8bcaSDan McDonald 	uint16_t		load_balance_flag;
8212ffc8bcaSDan McDonald 
822dcda19f5SSusan Scheufele };
823dcda19f5SSusan Scheufele 
824dcda19f5SSusan Scheufele #define	MAX_MGMT_ADAPTERS			1024
825dcda19f5SSusan Scheufele #define	IOC_SIGNATURE				"MR-SAS"
826dcda19f5SSusan Scheufele 
827dcda19f5SSusan Scheufele #define	IOC_CMD_FIRMWARE			0x0
828dcda19f5SSusan Scheufele #define	MRSAS_DRIVER_IOCTL_COMMON		0xF0010000
829dcda19f5SSusan Scheufele #define	MRSAS_DRIVER_IOCTL_DRIVER_VERSION	0xF0010100
830dcda19f5SSusan Scheufele #define	MRSAS_DRIVER_IOCTL_PCI_INFORMATION	0xF0010200
831dcda19f5SSusan Scheufele #define	MRSAS_DRIVER_IOCTL_MRRAID_STATISTICS	0xF0010300
832dcda19f5SSusan Scheufele 
833dcda19f5SSusan Scheufele 
834dcda19f5SSusan Scheufele #define	MRSAS_MAX_SENSE_LENGTH			32
835dcda19f5SSusan Scheufele 
836dcda19f5SSusan Scheufele struct mrsas_mgmt_info {
837dcda19f5SSusan Scheufele 
838dcda19f5SSusan Scheufele 	uint16_t			count;
839dcda19f5SSusan Scheufele 	struct mrsas_instance		*instance[MAX_MGMT_ADAPTERS];
840dcda19f5SSusan Scheufele 	uint16_t			map[MAX_MGMT_ADAPTERS];
841dcda19f5SSusan Scheufele 	int				max_index;
842dcda19f5SSusan Scheufele };
843dcda19f5SSusan Scheufele 
844dcda19f5SSusan Scheufele 
8452ffc8bcaSDan McDonald #pragma pack(1)
846dcda19f5SSusan Scheufele /*
847dcda19f5SSusan Scheufele  * SAS controller properties
848dcda19f5SSusan Scheufele  */
849dcda19f5SSusan Scheufele struct mrsas_ctrl_prop {
850dcda19f5SSusan Scheufele 	uint16_t	seq_num;
851dcda19f5SSusan Scheufele 	uint16_t	pred_fail_poll_interval;
852dcda19f5SSusan Scheufele 	uint16_t	intr_throttle_count;
853dcda19f5SSusan Scheufele 	uint16_t	intr_throttle_timeouts;
854dcda19f5SSusan Scheufele 
855dcda19f5SSusan Scheufele 	uint8_t		rebuild_rate;
856dcda19f5SSusan Scheufele 	uint8_t		patrol_read_rate;
857dcda19f5SSusan Scheufele 	uint8_t		bgi_rate;
858dcda19f5SSusan Scheufele 	uint8_t		cc_rate;
859dcda19f5SSusan Scheufele 	uint8_t		recon_rate;
860dcda19f5SSusan Scheufele 
861dcda19f5SSusan Scheufele 	uint8_t		cache_flush_interval;
862dcda19f5SSusan Scheufele 
863dcda19f5SSusan Scheufele 	uint8_t		spinup_drv_count;
864dcda19f5SSusan Scheufele 	uint8_t		spinup_delay;
865dcda19f5SSusan Scheufele 
866dcda19f5SSusan Scheufele 	uint8_t		cluster_enable;
867dcda19f5SSusan Scheufele 	uint8_t		coercion_mode;
868dcda19f5SSusan Scheufele 	uint8_t		alarm_enable;
8692ffc8bcaSDan McDonald 
870e73d18e5SYu Wu - Sun Microsystems - Beijing China 	uint8_t		reserved_1[13];
871b1385420SYu Wu - Sun Microsystems - Beijing China 	uint32_t	on_off_properties;
872e73d18e5SYu Wu - Sun Microsystems - Beijing China 	uint8_t		reserved_4[28];
873dcda19f5SSusan Scheufele };
874dcda19f5SSusan Scheufele 
875e73d18e5SYu Wu - Sun Microsystems - Beijing China 
876dcda19f5SSusan Scheufele /*
877dcda19f5SSusan Scheufele  * SAS controller information
878dcda19f5SSusan Scheufele  */
879dcda19f5SSusan Scheufele struct mrsas_ctrl_info {
880dcda19f5SSusan Scheufele 	/* PCI device information */
881dcda19f5SSusan Scheufele 	struct {
882dcda19f5SSusan Scheufele 		uint16_t	vendor_id;
883dcda19f5SSusan Scheufele 		uint16_t	device_id;
884dcda19f5SSusan Scheufele 		uint16_t	sub_vendor_id;
885dcda19f5SSusan Scheufele 		uint16_t	sub_device_id;
886dcda19f5SSusan Scheufele 		uint8_t	reserved[24];
887dcda19f5SSusan Scheufele 	} pci;
888dcda19f5SSusan Scheufele 
889dcda19f5SSusan Scheufele 	/* Host interface information */
890dcda19f5SSusan Scheufele 	struct {
891dcda19f5SSusan Scheufele 		uint8_t	PCIX		: 1;
892dcda19f5SSusan Scheufele 		uint8_t	PCIE		: 1;
893dcda19f5SSusan Scheufele 		uint8_t	iSCSI		: 1;
894dcda19f5SSusan Scheufele 		uint8_t	SAS_3G		: 1;
895dcda19f5SSusan Scheufele 		uint8_t	reserved_0	: 4;
896dcda19f5SSusan Scheufele 		uint8_t	reserved_1[6];
897dcda19f5SSusan Scheufele 		uint8_t	port_count;
898dcda19f5SSusan Scheufele 		uint64_t	port_addr[8];
899dcda19f5SSusan Scheufele 	} host_interface;
900dcda19f5SSusan Scheufele 
901dcda19f5SSusan Scheufele 	/* Device (backend) interface information */
902dcda19f5SSusan Scheufele 	struct {
903dcda19f5SSusan Scheufele 		uint8_t	SPI		: 1;
904dcda19f5SSusan Scheufele 		uint8_t	SAS_3G		: 1;
905dcda19f5SSusan Scheufele 		uint8_t	SATA_1_5G	: 1;
906dcda19f5SSusan Scheufele 		uint8_t	SATA_3G		: 1;
907dcda19f5SSusan Scheufele 		uint8_t	reserved_0	: 4;
908dcda19f5SSusan Scheufele 		uint8_t	reserved_1[6];
909dcda19f5SSusan Scheufele 		uint8_t	port_count;
910dcda19f5SSusan Scheufele 		uint64_t	port_addr[8];
911dcda19f5SSusan Scheufele 	} device_interface;
912dcda19f5SSusan Scheufele 
913dcda19f5SSusan Scheufele 	/* List of components residing in flash. All str are null terminated */
914dcda19f5SSusan Scheufele 	uint32_t	image_check_word;
915dcda19f5SSusan Scheufele 	uint32_t	image_component_count;
916dcda19f5SSusan Scheufele 
917dcda19f5SSusan Scheufele 	struct {
918dcda19f5SSusan Scheufele 		char	name[8];
919dcda19f5SSusan Scheufele 		char	version[32];
920dcda19f5SSusan Scheufele 		char	build_date[16];
921dcda19f5SSusan Scheufele 		char	built_time[16];
922dcda19f5SSusan Scheufele 	} image_component[8];
923dcda19f5SSusan Scheufele 
924dcda19f5SSusan Scheufele 	/*
925dcda19f5SSusan Scheufele 	 * List of flash components that have been flashed on the card, but
926dcda19f5SSusan Scheufele 	 * are not in use, pending reset of the adapter. This list will be
927dcda19f5SSusan Scheufele 	 * empty if a flash operation has not occurred. All stings are null
928dcda19f5SSusan Scheufele 	 * terminated
929dcda19f5SSusan Scheufele 	 */
930dcda19f5SSusan Scheufele 	uint32_t	pending_image_component_count;
931dcda19f5SSusan Scheufele 
932dcda19f5SSusan Scheufele 	struct {
933dcda19f5SSusan Scheufele 		char	name[8];
934dcda19f5SSusan Scheufele 		char	version[32];
935dcda19f5SSusan Scheufele 		char	build_date[16];
936dcda19f5SSusan Scheufele 		char	build_time[16];
937dcda19f5SSusan Scheufele 	} pending_image_component[8];
938dcda19f5SSusan Scheufele 
939dcda19f5SSusan Scheufele 	uint8_t		max_arms;
940dcda19f5SSusan Scheufele 	uint8_t		max_spans;
941dcda19f5SSusan Scheufele 	uint8_t		max_arrays;
942dcda19f5SSusan Scheufele 	uint8_t		max_lds;
943dcda19f5SSusan Scheufele 
944dcda19f5SSusan Scheufele 	char		product_name[80];
945dcda19f5SSusan Scheufele 	char		serial_no[32];
946dcda19f5SSusan Scheufele 
947dcda19f5SSusan Scheufele 	/*
948dcda19f5SSusan Scheufele 	 * Other physical/controller/operation information. Indicates the
949dcda19f5SSusan Scheufele 	 * presence of the hardware
950dcda19f5SSusan Scheufele 	 */
951dcda19f5SSusan Scheufele 	struct {
952dcda19f5SSusan Scheufele 		uint32_t	bbu		: 1;
953dcda19f5SSusan Scheufele 		uint32_t	alarm		: 1;
954dcda19f5SSusan Scheufele 		uint32_t	nvram		: 1;
955dcda19f5SSusan Scheufele 		uint32_t	uart		: 1;
956dcda19f5SSusan Scheufele 		uint32_t	reserved	: 28;
957dcda19f5SSusan Scheufele 	} hw_present;
958dcda19f5SSusan Scheufele 
959dcda19f5SSusan Scheufele 	uint32_t	current_fw_time;
960dcda19f5SSusan Scheufele 
961dcda19f5SSusan Scheufele 	/* Maximum data transfer sizes */
962dcda19f5SSusan Scheufele 	uint16_t		max_concurrent_cmds;
963dcda19f5SSusan Scheufele 	uint16_t		max_sge_count;
964dcda19f5SSusan Scheufele 	uint32_t		max_request_size;
965dcda19f5SSusan Scheufele 
966dcda19f5SSusan Scheufele 	/* Logical and physical device counts */
967dcda19f5SSusan Scheufele 	uint16_t		ld_present_count;
968dcda19f5SSusan Scheufele 	uint16_t		ld_degraded_count;
969dcda19f5SSusan Scheufele 	uint16_t		ld_offline_count;
970dcda19f5SSusan Scheufele 
971dcda19f5SSusan Scheufele 	uint16_t		pd_present_count;
972dcda19f5SSusan Scheufele 	uint16_t		pd_disk_present_count;
973dcda19f5SSusan Scheufele 	uint16_t		pd_disk_pred_failure_count;
974dcda19f5SSusan Scheufele 	uint16_t		pd_disk_failed_count;
975dcda19f5SSusan Scheufele 
976dcda19f5SSusan Scheufele 	/* Memory size information */
977dcda19f5SSusan Scheufele 	uint16_t		nvram_size;
978dcda19f5SSusan Scheufele 	uint16_t		memory_size;
979dcda19f5SSusan Scheufele 	uint16_t		flash_size;
980dcda19f5SSusan Scheufele 
981dcda19f5SSusan Scheufele 	/* Error counters */
982dcda19f5SSusan Scheufele 	uint16_t		mem_correctable_error_count;
983dcda19f5SSusan Scheufele 	uint16_t		mem_uncorrectable_error_count;
984dcda19f5SSusan Scheufele 
985dcda19f5SSusan Scheufele 	/* Cluster information */
986dcda19f5SSusan Scheufele 	uint8_t		cluster_permitted;
987dcda19f5SSusan Scheufele 	uint8_t		cluster_active;
988dcda19f5SSusan Scheufele 	uint8_t		reserved_1[2];
989dcda19f5SSusan Scheufele 
990dcda19f5SSusan Scheufele 	/* Controller capabilities structures */
991dcda19f5SSusan Scheufele 	struct {
992dcda19f5SSusan Scheufele 		uint32_t	raid_level_0	: 1;
993dcda19f5SSusan Scheufele 		uint32_t	raid_level_1	: 1;
994dcda19f5SSusan Scheufele 		uint32_t	raid_level_5	: 1;
995dcda19f5SSusan Scheufele 		uint32_t	raid_level_1E	: 1;
996dcda19f5SSusan Scheufele 		uint32_t	reserved	: 28;
997dcda19f5SSusan Scheufele 	} raid_levels;
998dcda19f5SSusan Scheufele 
999dcda19f5SSusan Scheufele 	struct {
1000dcda19f5SSusan Scheufele 		uint32_t	rbld_rate		: 1;
1001dcda19f5SSusan Scheufele 		uint32_t	cc_rate			: 1;
1002dcda19f5SSusan Scheufele 		uint32_t	bgi_rate		: 1;
1003dcda19f5SSusan Scheufele 		uint32_t	recon_rate		: 1;
1004dcda19f5SSusan Scheufele 		uint32_t	patrol_rate		: 1;
1005dcda19f5SSusan Scheufele 		uint32_t	alarm_control		: 1;
1006dcda19f5SSusan Scheufele 		uint32_t	cluster_supported	: 1;
1007dcda19f5SSusan Scheufele 		uint32_t	bbu			: 1;
1008dcda19f5SSusan Scheufele 		uint32_t	spanning_allowed	: 1;
1009dcda19f5SSusan Scheufele 		uint32_t	dedicated_hotspares	: 1;
1010dcda19f5SSusan Scheufele 		uint32_t	revertible_hotspares	: 1;
1011dcda19f5SSusan Scheufele 		uint32_t	foreign_config_import	: 1;
1012dcda19f5SSusan Scheufele 		uint32_t	self_diagnostic		: 1;
1013dcda19f5SSusan Scheufele 		uint32_t	reserved		: 19;
1014dcda19f5SSusan Scheufele 	} adapter_operations;
1015dcda19f5SSusan Scheufele 
1016dcda19f5SSusan Scheufele 	struct {
1017dcda19f5SSusan Scheufele 		uint32_t	read_policy	: 1;
1018dcda19f5SSusan Scheufele 		uint32_t	write_policy	: 1;
1019dcda19f5SSusan Scheufele 		uint32_t	io_policy	: 1;
1020dcda19f5SSusan Scheufele 		uint32_t	access_policy	: 1;
1021dcda19f5SSusan Scheufele 		uint32_t	reserved	: 28;
1022dcda19f5SSusan Scheufele 	} ld_operations;
1023dcda19f5SSusan Scheufele 
1024dcda19f5SSusan Scheufele 	struct {
1025dcda19f5SSusan Scheufele 		uint8_t	min;
1026dcda19f5SSusan Scheufele 		uint8_t	max;
1027dcda19f5SSusan Scheufele 		uint8_t	reserved[2];
1028dcda19f5SSusan Scheufele 	} stripe_size_operations;
1029dcda19f5SSusan Scheufele 
1030dcda19f5SSusan Scheufele 	struct {
1031dcda19f5SSusan Scheufele 		uint32_t	force_online	: 1;
1032dcda19f5SSusan Scheufele 		uint32_t	force_offline	: 1;
1033dcda19f5SSusan Scheufele 		uint32_t	force_rebuild	: 1;
1034dcda19f5SSusan Scheufele 		uint32_t	reserved	: 29;
1035dcda19f5SSusan Scheufele 	} pd_operations;
1036dcda19f5SSusan Scheufele 
1037dcda19f5SSusan Scheufele 	struct {
1038dcda19f5SSusan Scheufele 		uint32_t	ctrl_supports_sas	: 1;
1039dcda19f5SSusan Scheufele 		uint32_t	ctrl_supports_sata	: 1;
1040dcda19f5SSusan Scheufele 		uint32_t	allow_mix_in_encl	: 1;
1041dcda19f5SSusan Scheufele 		uint32_t	allow_mix_in_ld		: 1;
1042dcda19f5SSusan Scheufele 		uint32_t	allow_sata_in_cluster	: 1;
1043dcda19f5SSusan Scheufele 		uint32_t	reserved		: 27;
1044dcda19f5SSusan Scheufele 	} pd_mix_support;
1045dcda19f5SSusan Scheufele 
1046dcda19f5SSusan Scheufele 	/* Include the controller properties (changeable items) */
1047dcda19f5SSusan Scheufele 	uint8_t				reserved_2[12];
1048dcda19f5SSusan Scheufele 	struct mrsas_ctrl_prop		properties;
1049dcda19f5SSusan Scheufele 
1050dcda19f5SSusan Scheufele 	uint8_t				pad[0x800 - 0x640];
1051dcda19f5SSusan Scheufele };
1052dcda19f5SSusan Scheufele 
1053dcda19f5SSusan Scheufele /*
1054dcda19f5SSusan Scheufele  * ==================================
1055dcda19f5SSusan Scheufele  * MegaRAID SAS2.0 driver definitions
1056dcda19f5SSusan Scheufele  * ==================================
1057dcda19f5SSusan Scheufele  */
1058dcda19f5SSusan Scheufele #define	MRDRV_MAX_NUM_CMD			1024
1059dcda19f5SSusan Scheufele 
1060dcda19f5SSusan Scheufele #define	MRDRV_MAX_PD_CHANNELS			2
1061dcda19f5SSusan Scheufele #define	MRDRV_MAX_LD_CHANNELS			2
1062dcda19f5SSusan Scheufele #define	MRDRV_MAX_CHANNELS			(MRDRV_MAX_PD_CHANNELS + \
1063dcda19f5SSusan Scheufele 						MRDRV_MAX_LD_CHANNELS)
1064dcda19f5SSusan Scheufele #define	MRDRV_MAX_DEV_PER_CHANNEL		128
1065dcda19f5SSusan Scheufele #define	MRDRV_DEFAULT_INIT_ID			-1
1066dcda19f5SSusan Scheufele #define	MRDRV_MAX_CMD_PER_LUN			1000
1067dcda19f5SSusan Scheufele #define	MRDRV_MAX_LUN				1
1068dcda19f5SSusan Scheufele #define	MRDRV_MAX_LD				64
1069dcda19f5SSusan Scheufele 
1070dcda19f5SSusan Scheufele #define	MRDRV_RESET_WAIT_TIME			300
1071dcda19f5SSusan Scheufele #define	MRDRV_RESET_NOTICE_INTERVAL		5
1072dcda19f5SSusan Scheufele 
1073dcda19f5SSusan Scheufele #define	MRSAS_IOCTL_CMD				0
1074dcda19f5SSusan Scheufele 
10752ffc8bcaSDan McDonald #define	MRDRV_TGT_VALID				1
10762ffc8bcaSDan McDonald 
1077dcda19f5SSusan Scheufele /*
1078dcda19f5SSusan Scheufele  * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
1079dcda19f5SSusan Scheufele  * SGLs based on the size of dma_addr_t
1080dcda19f5SSusan Scheufele  */
1081dcda19f5SSusan Scheufele #define	IS_DMA64		(sizeof (dma_addr_t) == 8)
1082dcda19f5SSusan Scheufele 
10832ffc8bcaSDan McDonald #define	RESERVED0_REGISTER		0x00	/* XScale */
1084dcda19f5SSusan Scheufele #define	IB_MSG_0_OFF			0x10	/* XScale */
1085dcda19f5SSusan Scheufele #define	OB_MSG_0_OFF			0x18	/* XScale */
1086dcda19f5SSusan Scheufele #define	IB_DOORBELL_OFF			0x20	/* XScale & ROC */
1087dcda19f5SSusan Scheufele #define	OB_INTR_STATUS_OFF		0x30	/* XScale & ROC */
1088dcda19f5SSusan Scheufele #define	OB_INTR_MASK_OFF		0x34	/* XScale & ROC */
1089dcda19f5SSusan Scheufele #define	IB_QPORT_OFF			0x40	/* XScale & ROC */
1090dcda19f5SSusan Scheufele #define	OB_DOORBELL_CLEAR_OFF		0xA0	/* ROC */
1091dcda19f5SSusan Scheufele #define	OB_SCRATCH_PAD_0_OFF		0xB0	/* ROC */
1092dcda19f5SSusan Scheufele #define	OB_INTR_MASK			0xFFFFFFFF
1093dcda19f5SSusan Scheufele #define	OB_DOORBELL_CLEAR_MASK		0xFFFFFFFF
10942ffc8bcaSDan McDonald #define	SYSTOIOP_INTERRUPT_MASK		0x80000000
10952ffc8bcaSDan McDonald #define	OB_SCRATCH_PAD_2_OFF		0xB4
10962ffc8bcaSDan McDonald #define	WRITE_TBOLT_SEQ_OFF		0x00000004
10972ffc8bcaSDan McDonald #define	DIAG_TBOLT_RESET_ADAPTER	0x00000004
10982ffc8bcaSDan McDonald #define	HOST_TBOLT_DIAG_OFF		0x00000008
10992ffc8bcaSDan McDonald #define	RESET_TBOLT_STATUS_OFF		0x000003C3
1100e73d18e5SYu Wu - Sun Microsystems - Beijing China #define	WRITE_SEQ_OFF			0x000000FC
1101e73d18e5SYu Wu - Sun Microsystems - Beijing China #define	HOST_DIAG_OFF			0x000000F8
1102e73d18e5SYu Wu - Sun Microsystems - Beijing China #define	DIAG_RESET_ADAPTER		0x00000004
1103e73d18e5SYu Wu - Sun Microsystems - Beijing China #define	DIAG_WRITE_ENABLE		0x00000080
11042ffc8bcaSDan McDonald #define	SYSTOIOP_INTERRUPT_MASK		0x80000000
11052ffc8bcaSDan McDonald 
1106e73d18e5SYu Wu - Sun Microsystems - Beijing China #define	WR_IB_WRITE_SEQ(v, instance) 	ddi_put32((instance)->regmap_handle, \
1107e73d18e5SYu Wu - Sun Microsystems - Beijing China 	(uint32_t *)((uintptr_t)(instance)->regmap + WRITE_SEQ_OFF), (v))
1108e73d18e5SYu Wu - Sun Microsystems - Beijing China 
1109e73d18e5SYu Wu - Sun Microsystems - Beijing China #define	RD_OB_DRWE(instance) 		ddi_get32((instance)->regmap_handle, \
1110e73d18e5SYu Wu - Sun Microsystems - Beijing China 	(uint32_t *)((uintptr_t)(instance)->regmap + HOST_DIAG_OFF))
1111e73d18e5SYu Wu - Sun Microsystems - Beijing China 
1112e73d18e5SYu Wu - Sun Microsystems - Beijing China #define	WR_IB_DRWE(v, instance) 	ddi_put32((instance)->regmap_handle, \
1113e73d18e5SYu Wu - Sun Microsystems - Beijing China 	(uint32_t *)((uintptr_t)(instance)->regmap + HOST_DIAG_OFF), (v))
1114e73d18e5SYu Wu - Sun Microsystems - Beijing China 
11152ffc8bcaSDan McDonald #define	IB_LOW_QPORT			0xC0
11162ffc8bcaSDan McDonald #define	IB_HIGH_QPORT			0xC4
11172ffc8bcaSDan McDonald #define	OB_DOORBELL_REGISTER		0x9C	/* 1078 implementation */
11182ffc8bcaSDan McDonald 
11192ffc8bcaSDan McDonald /*
11202ffc8bcaSDan McDonald  * All MFI register set macros accept mrsas_register_set*
11212ffc8bcaSDan McDonald  */
1122dcda19f5SSusan Scheufele #define	WR_IB_MSG_0(v, instance) 	ddi_put32((instance)->regmap_handle, \
1123dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + IB_MSG_0_OFF), (v))
1124dcda19f5SSusan Scheufele 
1125dcda19f5SSusan Scheufele #define	RD_OB_MSG_0(instance) 		ddi_get32((instance)->regmap_handle, \
1126dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + OB_MSG_0_OFF))
1127dcda19f5SSusan Scheufele 
1128dcda19f5SSusan Scheufele #define	WR_IB_DOORBELL(v, instance)	ddi_put32((instance)->regmap_handle, \
1129dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + IB_DOORBELL_OFF), (v))
1130dcda19f5SSusan Scheufele 
1131dcda19f5SSusan Scheufele #define	RD_IB_DOORBELL(instance)	ddi_get32((instance)->regmap_handle, \
1132dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + IB_DOORBELL_OFF))
1133dcda19f5SSusan Scheufele 
1134dcda19f5SSusan Scheufele #define	WR_OB_INTR_STATUS(v, instance) 	ddi_put32((instance)->regmap_handle, \
1135dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + OB_INTR_STATUS_OFF), (v))
1136dcda19f5SSusan Scheufele 
1137dcda19f5SSusan Scheufele #define	RD_OB_INTR_STATUS(instance) 	ddi_get32((instance)->regmap_handle, \
1138dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + OB_INTR_STATUS_OFF))
1139dcda19f5SSusan Scheufele 
1140dcda19f5SSusan Scheufele #define	WR_OB_INTR_MASK(v, instance) 	ddi_put32((instance)->regmap_handle, \
1141dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + OB_INTR_MASK_OFF), (v))
1142dcda19f5SSusan Scheufele 
1143dcda19f5SSusan Scheufele #define	RD_OB_INTR_MASK(instance) 	ddi_get32((instance)->regmap_handle, \
1144dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + OB_INTR_MASK_OFF))
1145dcda19f5SSusan Scheufele 
1146dcda19f5SSusan Scheufele #define	WR_IB_QPORT(v, instance) 	ddi_put32((instance)->regmap_handle, \
1147dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + IB_QPORT_OFF), (v))
1148dcda19f5SSusan Scheufele 
1149dcda19f5SSusan Scheufele #define	WR_OB_DOORBELL_CLEAR(v, instance) ddi_put32((instance)->regmap_handle, \
1150dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + OB_DOORBELL_CLEAR_OFF), \
1151dcda19f5SSusan Scheufele 	(v))
1152dcda19f5SSusan Scheufele 
1153dcda19f5SSusan Scheufele #define	RD_OB_SCRATCH_PAD_0(instance) 	ddi_get32((instance)->regmap_handle, \
1154dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + OB_SCRATCH_PAD_0_OFF))
1155dcda19f5SSusan Scheufele 
11562ffc8bcaSDan McDonald /* Thunderbolt specific registers */
11572ffc8bcaSDan McDonald #define	RD_OB_SCRATCH_PAD_2(instance)	ddi_get32((instance)->regmap_handle, \
11582ffc8bcaSDan McDonald 	(uint32_t *)((uintptr_t)(instance)->regmap + OB_SCRATCH_PAD_2_OFF))
11592ffc8bcaSDan McDonald 
11602ffc8bcaSDan McDonald #define	WR_TBOLT_IB_WRITE_SEQ(v, instance) \
11612ffc8bcaSDan McDonald 	ddi_put32((instance)->regmap_handle, \
11622ffc8bcaSDan McDonald 	(uint32_t *)((uintptr_t)(instance)->regmap + WRITE_TBOLT_SEQ_OFF), (v))
11632ffc8bcaSDan McDonald 
11642ffc8bcaSDan McDonald #define	RD_TBOLT_HOST_DIAG(instance)	ddi_get32((instance)->regmap_handle, \
11652ffc8bcaSDan McDonald 	(uint32_t *)((uintptr_t)(instance)->regmap + HOST_TBOLT_DIAG_OFF))
11662ffc8bcaSDan McDonald 
11672ffc8bcaSDan McDonald #define	WR_TBOLT_HOST_DIAG(v, instance)	ddi_put32((instance)->regmap_handle, \
11682ffc8bcaSDan McDonald 	(uint32_t *)((uintptr_t)(instance)->regmap + HOST_TBOLT_DIAG_OFF), (v))
11692ffc8bcaSDan McDonald 
11702ffc8bcaSDan McDonald #define	RD_TBOLT_RESET_STAT(instance)	ddi_get32((instance)->regmap_handle, \
11712ffc8bcaSDan McDonald 	(uint32_t *)((uintptr_t)(instance)->regmap + RESET_TBOLT_STATUS_OFF))
11722ffc8bcaSDan McDonald 
11732ffc8bcaSDan McDonald 
11742ffc8bcaSDan McDonald #define	WR_MPI2_REPLY_POST_INDEX(v, instance)\
11752ffc8bcaSDan McDonald 	ddi_put32((instance)->regmap_handle,\
11762ffc8bcaSDan McDonald 	(uint32_t *)\
11772ffc8bcaSDan McDonald 	((uintptr_t)(instance)->regmap + MPI2_REPLY_POST_HOST_INDEX_OFFSET),\
11782ffc8bcaSDan McDonald 	(v))
11792ffc8bcaSDan McDonald 
11802ffc8bcaSDan McDonald 
11812ffc8bcaSDan McDonald #define	RD_MPI2_REPLY_POST_INDEX(instance)\
11822ffc8bcaSDan McDonald 	ddi_get32((instance)->regmap_handle,\
11832ffc8bcaSDan McDonald 	(uint32_t *)\
11842ffc8bcaSDan McDonald 	((uintptr_t)(instance)->regmap + MPI2_REPLY_POST_HOST_INDEX_OFFSET))
11852ffc8bcaSDan McDonald 
11862ffc8bcaSDan McDonald #define	WR_IB_LOW_QPORT(v, instance) 	ddi_put32((instance)->regmap_handle, \
11872ffc8bcaSDan McDonald 	(uint32_t *)((uintptr_t)(instance)->regmap + IB_LOW_QPORT), (v))
11882ffc8bcaSDan McDonald 
11892ffc8bcaSDan McDonald #define	WR_IB_HIGH_QPORT(v, instance) 	ddi_put32((instance)->regmap_handle, \
11902ffc8bcaSDan McDonald 	(uint32_t *)((uintptr_t)(instance)->regmap + IB_HIGH_QPORT), (v))
11912ffc8bcaSDan McDonald 
11922ffc8bcaSDan McDonald #define	WR_OB_DOORBELL_REGISTER_CLEAR(v, instance)\
11932ffc8bcaSDan McDonald 	ddi_put32((instance)->regmap_handle,\
11942ffc8bcaSDan McDonald 	(uint32_t *)((uintptr_t)(instance)->regmap + OB_DOORBELL_REGISTER), \
11952ffc8bcaSDan McDonald 	(v))
11962ffc8bcaSDan McDonald 
11972ffc8bcaSDan McDonald #define	WR_RESERVED0_REGISTER(v, instance) ddi_put32((instance)->regmap_handle,\
11982ffc8bcaSDan McDonald 	(uint32_t *)((uintptr_t)(instance)->regmap + RESERVED0_REGISTER), \
11992ffc8bcaSDan McDonald 	(v))
12002ffc8bcaSDan McDonald 
12012ffc8bcaSDan McDonald #define	RD_RESERVED0_REGISTER(instance) ddi_get32((instance)->regmap_handle, \
12022ffc8bcaSDan McDonald 	(uint32_t *)((uintptr_t)(instance)->regmap + RESERVED0_REGISTER))
12032ffc8bcaSDan McDonald 
12042ffc8bcaSDan McDonald 
12052ffc8bcaSDan McDonald 
1206dcda19f5SSusan Scheufele /*
1207dcda19f5SSusan Scheufele  * When FW is in MFI_STATE_READY or MFI_STATE_OPERATIONAL, the state data
1208dcda19f5SSusan Scheufele  * of Outbound Msg Reg 0 indicates max concurrent cmds supported, max SGEs
1209dcda19f5SSusan Scheufele  * supported per cmd and if 64-bit MFAs (M64) is enabled or disabled.
1210dcda19f5SSusan Scheufele  */
1211dcda19f5SSusan Scheufele #define	MFI_OB_INTR_STATUS_MASK		0x00000002
1212dcda19f5SSusan Scheufele 
1213dcda19f5SSusan Scheufele /*
1214dcda19f5SSusan Scheufele  * This MFI_REPLY_2108_MESSAGE_INTR flag is used also
1215dcda19f5SSusan Scheufele  * in enable_intr_ppc also. Hence bit 2, i.e. 0x4 has
1216dcda19f5SSusan Scheufele  * been set in this flag along with bit 1.
1217dcda19f5SSusan Scheufele  */
1218dcda19f5SSusan Scheufele #define	MFI_REPLY_2108_MESSAGE_INTR		0x00000001
1219dcda19f5SSusan Scheufele #define	MFI_REPLY_2108_MESSAGE_INTR_MASK	0x00000005
1220dcda19f5SSusan Scheufele 
12212ffc8bcaSDan McDonald /* Fusion interrupt mask */
12222ffc8bcaSDan McDonald #define	MFI_FUSION_ENABLE_INTERRUPT_MASK	(0x00000008)
12232ffc8bcaSDan McDonald 
1224dcda19f5SSusan Scheufele #define	MFI_POLL_TIMEOUT_SECS		60
1225dcda19f5SSusan Scheufele 
1226dcda19f5SSusan Scheufele #define	MFI_ENABLE_INTR(instance)  ddi_put32((instance)->regmap_handle, \
1227dcda19f5SSusan Scheufele 	(uint32_t *)((uintptr_t)(instance)->regmap + OB_INTR_MASK_OFF), 1)
1228dcda19f5SSusan Scheufele #define	MFI_DISABLE_INTR(instance)					\
1229dcda19f5SSusan Scheufele {									\
1230dcda19f5SSusan Scheufele 	uint32_t disable = 1;						\
1231dcda19f5SSusan Scheufele 	uint32_t mask =  ddi_get32((instance)->regmap_handle, 		\
1232dcda19f5SSusan Scheufele 	    (uint32_t *)((uintptr_t)(instance)->regmap + OB_INTR_MASK_OFF));\
1233dcda19f5SSusan Scheufele 	mask &= ~disable;						\
1234dcda19f5SSusan Scheufele 	ddi_put32((instance)->regmap_handle, (uint32_t *)		\
1235dcda19f5SSusan Scheufele 	    (uintptr_t)((instance)->regmap + OB_INTR_MASK_OFF), mask);	\
1236dcda19f5SSusan Scheufele }
1237dcda19f5SSusan Scheufele 
1238dcda19f5SSusan Scheufele /* By default, the firmware programs for 8 Kbytes of memory */
1239dcda19f5SSusan Scheufele #define	DEFAULT_MFI_MEM_SZ	8192
1240dcda19f5SSusan Scheufele #define	MINIMUM_MFI_MEM_SZ	4096
1241dcda19f5SSusan Scheufele 
1242dcda19f5SSusan Scheufele /* DCMD Message Frame MAILBOX0-11 */
1243dcda19f5SSusan Scheufele #define	DCMD_MBOX_SZ		12
1244dcda19f5SSusan Scheufele 
1245b1385420SYu Wu - Sun Microsystems - Beijing China /*
1246b1385420SYu Wu - Sun Microsystems - Beijing China  * on_off_property of mrsas_ctrl_prop
1247b1385420SYu Wu - Sun Microsystems - Beijing China  * bit0-9, 11-31 are reserved
1248b1385420SYu Wu - Sun Microsystems - Beijing China  */
1249b1385420SYu Wu - Sun Microsystems - Beijing China #define	DISABLE_OCR_PROP_FLAG   0x00000400 /* bit 10 */
1250dcda19f5SSusan Scheufele 
1251dcda19f5SSusan Scheufele struct mrsas_register_set {
12522ffc8bcaSDan McDonald 	uint32_t	reserved_0[4];			/* 0000h */
1253dcda19f5SSusan Scheufele 
12542ffc8bcaSDan McDonald 	uint32_t	inbound_msg_0;			/* 0010h */
12552ffc8bcaSDan McDonald 	uint32_t	inbound_msg_1;			/* 0014h */
12562ffc8bcaSDan McDonald 	uint32_t	outbound_msg_0;			/* 0018h */
12572ffc8bcaSDan McDonald 	uint32_t	outbound_msg_1;			/* 001Ch */
1258dcda19f5SSusan Scheufele 
12592ffc8bcaSDan McDonald 	uint32_t	inbound_doorbell;		/* 0020h */
12602ffc8bcaSDan McDonald 	uint32_t	inbound_intr_status;		/* 0024h */
12612ffc8bcaSDan McDonald 	uint32_t	inbound_intr_mask;		/* 0028h */
1262dcda19f5SSusan Scheufele 
12632ffc8bcaSDan McDonald 	uint32_t	outbound_doorbell;		/* 002Ch */
12642ffc8bcaSDan McDonald 	uint32_t	outbound_intr_status;		/* 0030h */
12652ffc8bcaSDan McDonald 	uint32_t	outbound_intr_mask;		/* 0034h */
1266dcda19f5SSusan Scheufele 
12672ffc8bcaSDan McDonald 	uint32_t	reserved_1[2];			/* 0038h */
1268dcda19f5SSusan Scheufele 
12692ffc8bcaSDan McDonald 	uint32_t	inbound_queue_port;		/* 0040h */
12702ffc8bcaSDan McDonald 	uint32_t	outbound_queue_port;		/* 0044h */
1271dcda19f5SSusan Scheufele 
12722ffc8bcaSDan McDonald 	uint32_t 	reserved_2[22];			/* 0048h */
1273dcda19f5SSusan Scheufele 
12742ffc8bcaSDan McDonald 	uint32_t 	outbound_doorbell_clear;	/* 00A0h */
1275dcda19f5SSusan Scheufele 
12762ffc8bcaSDan McDonald 	uint32_t 	reserved_3[3];			/* 00A4h */
1277dcda19f5SSusan Scheufele 
12782ffc8bcaSDan McDonald 	uint32_t 	outbound_scratch_pad;		/* 00B0h */
1279dcda19f5SSusan Scheufele 
12802ffc8bcaSDan McDonald 	uint32_t 	reserved_4[3];			/* 00B4h */
1281dcda19f5SSusan Scheufele 
12822ffc8bcaSDan McDonald 	uint32_t 	inbound_low_queue_port;		/* 00C0h */
1283dcda19f5SSusan Scheufele 
12842ffc8bcaSDan McDonald 	uint32_t 	inbound_high_queue_port;	/* 00C4h */
1285dcda19f5SSusan Scheufele 
12862ffc8bcaSDan McDonald 	uint32_t 	reserved_5;			/* 00C8h */
12872ffc8bcaSDan McDonald 	uint32_t 	index_registers[820];		/* 00CCh */
1288dcda19f5SSusan Scheufele };
1289dcda19f5SSusan Scheufele 
1290dcda19f5SSusan Scheufele struct mrsas_sge32 {
1291dcda19f5SSusan Scheufele 	uint32_t	phys_addr;
1292dcda19f5SSusan Scheufele 	uint32_t	length;
1293dcda19f5SSusan Scheufele };
1294dcda19f5SSusan Scheufele 
1295dcda19f5SSusan Scheufele struct mrsas_sge64 {
1296dcda19f5SSusan Scheufele 	uint64_t	phys_addr;
1297dcda19f5SSusan Scheufele 	uint32_t	length;
1298dcda19f5SSusan Scheufele };
1299dcda19f5SSusan Scheufele 
1300062f0014SYu Wu - Sun Microsystems - Beijing China struct mrsas_sge_ieee {
1301062f0014SYu Wu - Sun Microsystems - Beijing China 	uint64_t 	phys_addr;
1302062f0014SYu Wu - Sun Microsystems - Beijing China 	uint32_t	length;
1303062f0014SYu Wu - Sun Microsystems - Beijing China 	uint32_t	flag;
1304062f0014SYu Wu - Sun Microsystems - Beijing China };
1305062f0014SYu Wu - Sun Microsystems - Beijing China 
1306dcda19f5SSusan Scheufele union mrsas_sgl {
1307dcda19f5SSusan Scheufele 	struct mrsas_sge32	sge32[1];
1308dcda19f5SSusan Scheufele 	struct mrsas_sge64	sge64[1];
1309062f0014SYu Wu - Sun Microsystems - Beijing China 	struct mrsas_sge_ieee	sge_ieee[1];
1310dcda19f5SSusan Scheufele };
1311dcda19f5SSusan Scheufele 
1312dcda19f5SSusan Scheufele struct mrsas_header {
13132ffc8bcaSDan McDonald 	uint8_t		cmd;				/* 00h */
13142ffc8bcaSDan McDonald 	uint8_t		sense_len;			/* 01h */
13152ffc8bcaSDan McDonald 	uint8_t		cmd_status;			/* 02h */
13162ffc8bcaSDan McDonald 	uint8_t		scsi_status;			/* 03h */
1317dcda19f5SSusan Scheufele 
13182ffc8bcaSDan McDonald 	uint8_t		target_id;			/* 04h */
13192ffc8bcaSDan McDonald 	uint8_t		lun;				/* 05h */
13202ffc8bcaSDan McDonald 	uint8_t		cdb_len;			/* 06h */
13212ffc8bcaSDan McDonald 	uint8_t		sge_count;			/* 07h */
1322dcda19f5SSusan Scheufele 
13232ffc8bcaSDan McDonald 	uint32_t	context;			/* 08h */
13242ffc8bcaSDan McDonald 	uint8_t		req_id;				/* 0Ch */
13252ffc8bcaSDan McDonald 	uint8_t		msgvector;			/* 0Dh */
13262ffc8bcaSDan McDonald 	uint16_t	pad_0;				/* 0Eh */
1327dcda19f5SSusan Scheufele 
13282ffc8bcaSDan McDonald 	uint16_t	flags;				/* 10h */
13292ffc8bcaSDan McDonald 	uint16_t	timeout;			/* 12h */
13302ffc8bcaSDan McDonald 	uint32_t	data_xferlen;			/* 14h */
1331dcda19f5SSusan Scheufele };
1332dcda19f5SSusan Scheufele 
1333dcda19f5SSusan Scheufele union mrsas_sgl_frame {
1334dcda19f5SSusan Scheufele 	struct mrsas_sge32	sge32[8];
1335dcda19f5SSusan Scheufele 	struct mrsas_sge64	sge64[5];
1336dcda19f5SSusan Scheufele };
1337dcda19f5SSusan Scheufele 
1338dcda19f5SSusan Scheufele struct mrsas_init_frame {
13392ffc8bcaSDan McDonald 	uint8_t		cmd;				/* 00h */
13402ffc8bcaSDan McDonald 	uint8_t		reserved_0;			/* 01h */
13412ffc8bcaSDan McDonald 	uint8_t		cmd_status;			/* 02h */
1342dcda19f5SSusan Scheufele 
13432ffc8bcaSDan McDonald 	uint8_t		reserved_1;			/* 03h */
13442ffc8bcaSDan McDonald 	uint32_t	reserved_2;			/* 04h */
1345dcda19f5SSusan Scheufele 
13462ffc8bcaSDan McDonald 	uint32_t	context;			/* 08h */
13472ffc8bcaSDan McDonald 	uint8_t		req_id;				/* 0Ch */
13482ffc8bcaSDan McDonald 	uint8_t		msgvector;			/* 0Dh */
13492ffc8bcaSDan McDonald 	uint16_t	pad_0;				/* 0Eh */
1350dcda19f5SSusan Scheufele 
13512ffc8bcaSDan McDonald 	uint16_t	flags;				/* 10h */
13522ffc8bcaSDan McDonald 	uint16_t	reserved_3;			/* 12h */
13532ffc8bcaSDan McDonald 	uint32_t	data_xfer_len;			/* 14h */
1354dcda19f5SSusan Scheufele 
13552ffc8bcaSDan McDonald 	uint32_t	queue_info_new_phys_addr_lo;	/* 18h */
13562ffc8bcaSDan McDonald 	uint32_t	queue_info_new_phys_addr_hi;	/* 1Ch */
13572ffc8bcaSDan McDonald 	uint32_t	queue_info_old_phys_addr_lo;	/* 20h */
13582ffc8bcaSDan McDonald 	uint32_t	queue_info_old_phys_addr_hi;	/* 24h */
13592ffc8bcaSDan McDonald 	uint64_t 	driverversion;			/* 28h */
13602ffc8bcaSDan McDonald 	uint32_t	reserved_4[4];			/* 30h */
1361dcda19f5SSusan Scheufele };
1362dcda19f5SSusan Scheufele 
1363dcda19f5SSusan Scheufele struct mrsas_init_queue_info {
13642ffc8bcaSDan McDonald 	uint32_t		init_flags;			/* 00h */
13652ffc8bcaSDan McDonald 	uint32_t		reply_queue_entries;		/* 04h */
1366dcda19f5SSusan Scheufele 
13672ffc8bcaSDan McDonald 	uint32_t		reply_queue_start_phys_addr_lo;	/* 08h */
13682ffc8bcaSDan McDonald 	uint32_t		reply_queue_start_phys_addr_hi;	/* 0Ch */
13692ffc8bcaSDan McDonald 	uint32_t		producer_index_phys_addr_lo;	/* 10h */
13702ffc8bcaSDan McDonald 	uint32_t		producer_index_phys_addr_hi;	/* 14h */
13712ffc8bcaSDan McDonald 	uint32_t		consumer_index_phys_addr_lo;	/* 18h */
13722ffc8bcaSDan McDonald 	uint32_t		consumer_index_phys_addr_hi;	/* 1Ch */
1373dcda19f5SSusan Scheufele };
1374dcda19f5SSusan Scheufele 
1375dcda19f5SSusan Scheufele struct mrsas_io_frame {
13762ffc8bcaSDan McDonald 	uint8_t			cmd;			/* 00h */
13772ffc8bcaSDan McDonald 	uint8_t			sense_len;		/* 01h */
13782ffc8bcaSDan McDonald 	uint8_t			cmd_status;		/* 02h */
13792ffc8bcaSDan McDonald 	uint8_t			scsi_status;		/* 03h */
1380dcda19f5SSusan Scheufele 
13812ffc8bcaSDan McDonald 	uint8_t			target_id;		/* 04h */
13822ffc8bcaSDan McDonald 	uint8_t			access_byte;		/* 05h */
13832ffc8bcaSDan McDonald 	uint8_t			reserved_0;		/* 06h */
13842ffc8bcaSDan McDonald 	uint8_t			sge_count;		/* 07h */
1385dcda19f5SSusan Scheufele 
13862ffc8bcaSDan McDonald 	uint32_t		context;		/* 08h */
13872ffc8bcaSDan McDonald 	uint8_t			req_id;			/* 0Ch */
13882ffc8bcaSDan McDonald 	uint8_t			msgvector;		/* 0Dh */
13892ffc8bcaSDan McDonald 	uint16_t		pad_0;			/* 0Eh */
1390dcda19f5SSusan Scheufele 
13912ffc8bcaSDan McDonald 	uint16_t		flags;			/* 10h */
13922ffc8bcaSDan McDonald 	uint16_t		timeout;		/* 12h */
13932ffc8bcaSDan McDonald 	uint32_t		lba_count;		/* 14h */
1394dcda19f5SSusan Scheufele 
13952ffc8bcaSDan McDonald 	uint32_t		sense_buf_phys_addr_lo;	/* 18h */
13962ffc8bcaSDan McDonald 	uint32_t		sense_buf_phys_addr_hi;	/* 1Ch */
1397dcda19f5SSusan Scheufele 
13982ffc8bcaSDan McDonald 	uint32_t		start_lba_lo;		/* 20h */
13992ffc8bcaSDan McDonald 	uint32_t		start_lba_hi;		/* 24h */
1400dcda19f5SSusan Scheufele 
14012ffc8bcaSDan McDonald 	union mrsas_sgl		sgl;			/* 28h */
1402dcda19f5SSusan Scheufele };
1403dcda19f5SSusan Scheufele 
1404dcda19f5SSusan Scheufele struct mrsas_pthru_frame {
14052ffc8bcaSDan McDonald 	uint8_t			cmd;			/* 00h */
14062ffc8bcaSDan McDonald 	uint8_t			sense_len;		/* 01h */
14072ffc8bcaSDan McDonald 	uint8_t			cmd_status;		/* 02h */
14082ffc8bcaSDan McDonald 	uint8_t			scsi_status;		/* 03h */
1409dcda19f5SSusan Scheufele 
14102ffc8bcaSDan McDonald 	uint8_t			target_id;		/* 04h */
14112ffc8bcaSDan McDonald 	uint8_t			lun;			/* 05h */
14122ffc8bcaSDan McDonald 	uint8_t			cdb_len;		/* 06h */
14132ffc8bcaSDan McDonald 	uint8_t			sge_count;		/* 07h */
1414dcda19f5SSusan Scheufele 
14152ffc8bcaSDan McDonald 	uint32_t		context;		/* 08h */
14162ffc8bcaSDan McDonald 	uint8_t			req_id;			/* 0Ch */
14172ffc8bcaSDan McDonald 	uint8_t			msgvector;		/* 0Dh */
14182ffc8bcaSDan McDonald 	uint16_t		pad_0;			/* 0Eh */
1419dcda19f5SSusan Scheufele 
14202ffc8bcaSDan McDonald 	uint16_t		flags;			/* 10h */
14212ffc8bcaSDan McDonald 	uint16_t		timeout;		/* 12h */
14222ffc8bcaSDan McDonald 	uint32_t		data_xfer_len;		/* 14h */
1423dcda19f5SSusan Scheufele 
14242ffc8bcaSDan McDonald 	uint32_t		sense_buf_phys_addr_lo;	/* 18h */
14252ffc8bcaSDan McDonald 	uint32_t		sense_buf_phys_addr_hi;	/* 1Ch */
1426dcda19f5SSusan Scheufele 
14272ffc8bcaSDan McDonald 	uint8_t			cdb[16];		/* 20h */
14282ffc8bcaSDan McDonald 	union mrsas_sgl		sgl;			/* 30h */
1429dcda19f5SSusan Scheufele };
1430dcda19f5SSusan Scheufele 
1431dcda19f5SSusan Scheufele struct mrsas_dcmd_frame {
14322ffc8bcaSDan McDonald 	uint8_t			cmd;			/* 00h */
14332ffc8bcaSDan McDonald 	uint8_t			reserved_0;		/* 01h */
14342ffc8bcaSDan McDonald 	uint8_t			cmd_status;		/* 02h */
14352ffc8bcaSDan McDonald 	uint8_t			reserved_1[4];		/* 03h */
14362ffc8bcaSDan McDonald 	uint8_t			sge_count;		/* 07h */
1437dcda19f5SSusan Scheufele 
14382ffc8bcaSDan McDonald 	uint32_t		context;		/* 08h */
14392ffc8bcaSDan McDonald 	uint8_t			req_id;			/* 0Ch */
14402ffc8bcaSDan McDonald 	uint8_t			msgvector;		/* 0Dh */
14412ffc8bcaSDan McDonald 	uint16_t		pad_0;			/* 0Eh */
1442dcda19f5SSusan Scheufele 
14432ffc8bcaSDan McDonald 	uint16_t		flags;			/* 10h */
14442ffc8bcaSDan McDonald 	uint16_t		timeout;		/* 12h */
1445dcda19f5SSusan Scheufele 
14462ffc8bcaSDan McDonald 	uint32_t		data_xfer_len;		/* 14h */
14472ffc8bcaSDan McDonald 	uint32_t		opcode;			/* 18h */
1448dcda19f5SSusan Scheufele 
14492ffc8bcaSDan McDonald 	/* uint8_t		mbox[DCMD_MBOX_SZ]; */	/* 1Ch */
14502ffc8bcaSDan McDonald 	union {						/* 1Ch */
1451dcda19f5SSusan Scheufele 		uint8_t b[DCMD_MBOX_SZ];
1452dcda19f5SSusan Scheufele 		uint16_t s[6];
1453dcda19f5SSusan Scheufele 		uint32_t w[3];
1454dcda19f5SSusan Scheufele 	} mbox;
1455dcda19f5SSusan Scheufele 
14562ffc8bcaSDan McDonald 	union mrsas_sgl		sgl;			/* 28h */
1457dcda19f5SSusan Scheufele };
1458dcda19f5SSusan Scheufele 
1459dcda19f5SSusan Scheufele struct mrsas_abort_frame {
14602ffc8bcaSDan McDonald 	uint8_t		cmd;				/* 00h */
14612ffc8bcaSDan McDonald 	uint8_t		reserved_0;			/* 01h */
14622ffc8bcaSDan McDonald 	uint8_t		cmd_status;			/* 02h */
1463dcda19f5SSusan Scheufele 
14642ffc8bcaSDan McDonald 	uint8_t		reserved_1;			/* 03h */
14652ffc8bcaSDan McDonald 	uint32_t	reserved_2;			/* 04h */
1466dcda19f5SSusan Scheufele 
14672ffc8bcaSDan McDonald 	uint32_t	context;			/* 08h */
14682ffc8bcaSDan McDonald 	uint8_t		req_id;				/* 0Ch */
14692ffc8bcaSDan McDonald 	uint8_t		msgvector;			/* 0Dh */
14702ffc8bcaSDan McDonald 	uint16_t	pad_0;				/* 0Eh */
1471dcda19f5SSusan Scheufele 
14722ffc8bcaSDan McDonald 	uint16_t	flags;				/* 10h */
14732ffc8bcaSDan McDonald 	uint16_t	reserved_3;			/* 12h */
14742ffc8bcaSDan McDonald 	uint32_t	reserved_4;			/* 14h */
1475dcda19f5SSusan Scheufele 
14762ffc8bcaSDan McDonald 	uint32_t	abort_context;			/* 18h */
14772ffc8bcaSDan McDonald 	uint32_t	pad_1;				/* 1Ch */
1478dcda19f5SSusan Scheufele 
14792ffc8bcaSDan McDonald 	uint32_t	abort_mfi_phys_addr_lo;		/* 20h */
14802ffc8bcaSDan McDonald 	uint32_t	abort_mfi_phys_addr_hi;		/* 24h */
1481dcda19f5SSusan Scheufele 
14822ffc8bcaSDan McDonald 	uint32_t	reserved_5[6];			/* 28h */
1483dcda19f5SSusan Scheufele };
1484dcda19f5SSusan Scheufele 
1485dcda19f5SSusan Scheufele struct mrsas_smp_frame {
14862ffc8bcaSDan McDonald 	uint8_t		cmd;				/* 00h */
14872ffc8bcaSDan McDonald 	uint8_t		reserved_1;			/* 01h */
14882ffc8bcaSDan McDonald 	uint8_t		cmd_status;			/* 02h */
14892ffc8bcaSDan McDonald 	uint8_t		connection_status;		/* 03h */
1490dcda19f5SSusan Scheufele 
14912ffc8bcaSDan McDonald 	uint8_t		reserved_2[3];			/* 04h */
14922ffc8bcaSDan McDonald 	uint8_t		sge_count;			/* 07h */
1493dcda19f5SSusan Scheufele 
14942ffc8bcaSDan McDonald 	uint32_t	context;			/* 08h */
14952ffc8bcaSDan McDonald 	uint8_t		req_id;				/* 0Ch */
14962ffc8bcaSDan McDonald 	uint8_t		msgvector;			/* 0Dh */
14972ffc8bcaSDan McDonald 	uint16_t	pad_0;				/* 0Eh */
1498dcda19f5SSusan Scheufele 
14992ffc8bcaSDan McDonald 	uint16_t	flags;				/* 10h */
15002ffc8bcaSDan McDonald 	uint16_t	timeout;			/* 12h */
1501dcda19f5SSusan Scheufele 
15022ffc8bcaSDan McDonald 	uint32_t	data_xfer_len;			/* 14h */
1503dcda19f5SSusan Scheufele 
15042ffc8bcaSDan McDonald 	uint64_t	sas_addr;			/* 20h */
1505dcda19f5SSusan Scheufele 
15062ffc8bcaSDan McDonald 	union mrsas_sgl	sgl[2];				/* 28h */
1507dcda19f5SSusan Scheufele };
1508dcda19f5SSusan Scheufele 
1509dcda19f5SSusan Scheufele struct mrsas_stp_frame {
15102ffc8bcaSDan McDonald 	uint8_t		cmd;				/* 00h */
15112ffc8bcaSDan McDonald 	uint8_t		reserved_1;			/* 01h */
15122ffc8bcaSDan McDonald 	uint8_t		cmd_status;			/* 02h */
15132ffc8bcaSDan McDonald 	uint8_t		connection_status;		/* 03h */
1514dcda19f5SSusan Scheufele 
15152ffc8bcaSDan McDonald 	uint8_t		target_id;			/* 04h */
15162ffc8bcaSDan McDonald 	uint8_t		reserved_2[2];			/* 04h */
15172ffc8bcaSDan McDonald 	uint8_t		sge_count;			/* 07h */
1518dcda19f5SSusan Scheufele 
15192ffc8bcaSDan McDonald 	uint32_t	context;			/* 08h */
15202ffc8bcaSDan McDonald 	uint8_t		req_id;				/* 0Ch */
15212ffc8bcaSDan McDonald 	uint8_t		msgvector;			/* 0Dh */
15222ffc8bcaSDan McDonald 	uint16_t	pad_0;				/* 0Eh */
1523dcda19f5SSusan Scheufele 
15242ffc8bcaSDan McDonald 	uint16_t	flags;				/* 10h */
15252ffc8bcaSDan McDonald 	uint16_t	timeout;			/* 12h */
1526dcda19f5SSusan Scheufele 
15272ffc8bcaSDan McDonald 	uint32_t	data_xfer_len;			/* 14h */
1528dcda19f5SSusan Scheufele 
15292ffc8bcaSDan McDonald 	uint16_t	fis[10];			/* 28h */
15302ffc8bcaSDan McDonald 	uint32_t	stp_flags;			/* 3C */
15312ffc8bcaSDan McDonald 	union mrsas_sgl	sgl;				/* 40 */
1532dcda19f5SSusan Scheufele };
1533dcda19f5SSusan Scheufele 
1534dcda19f5SSusan Scheufele union mrsas_frame {
1535dcda19f5SSusan Scheufele 	struct mrsas_header		hdr;
1536dcda19f5SSusan Scheufele 	struct mrsas_init_frame		init;
1537dcda19f5SSusan Scheufele 	struct mrsas_io_frame		io;
1538dcda19f5SSusan Scheufele 	struct mrsas_pthru_frame	pthru;
1539dcda19f5SSusan Scheufele 	struct mrsas_dcmd_frame		dcmd;
1540dcda19f5SSusan Scheufele 	struct mrsas_abort_frame	abort;
1541dcda19f5SSusan Scheufele 	struct mrsas_smp_frame		smp;
1542dcda19f5SSusan Scheufele 	struct mrsas_stp_frame		stp;
1543dcda19f5SSusan Scheufele 
1544dcda19f5SSusan Scheufele 	uint8_t			raw_bytes[64];
1545dcda19f5SSusan Scheufele };
1546dcda19f5SSusan Scheufele 
1547dcda19f5SSusan Scheufele typedef struct mrsas_pd_address {
1548dcda19f5SSusan Scheufele 	uint16_t	device_id;
1549dcda19f5SSusan Scheufele 	uint16_t	encl_id;
1550dcda19f5SSusan Scheufele 
1551dcda19f5SSusan Scheufele 	union {
1552dcda19f5SSusan Scheufele 		struct {
1553dcda19f5SSusan Scheufele 			uint8_t encl_index;
1554dcda19f5SSusan Scheufele 			uint8_t slot_number;
1555dcda19f5SSusan Scheufele 		} pd_address;
1556dcda19f5SSusan Scheufele 		struct {
1557dcda19f5SSusan Scheufele 			uint8_t	encl_position;
1558dcda19f5SSusan Scheufele 			uint8_t	encl_connector_index;
1559dcda19f5SSusan Scheufele 		} encl_address;
1560dcda19f5SSusan Scheufele 	}address;
1561dcda19f5SSusan Scheufele 
1562dcda19f5SSusan Scheufele 	uint8_t	scsi_dev_type;
1563dcda19f5SSusan Scheufele 
1564dcda19f5SSusan Scheufele 	union {
1565dcda19f5SSusan Scheufele 		uint8_t		port_bitmap;
1566dcda19f5SSusan Scheufele 		uint8_t		port_numbers;
1567dcda19f5SSusan Scheufele 	} connected;
1568dcda19f5SSusan Scheufele 
1569dcda19f5SSusan Scheufele 	uint64_t		sas_addr[2];
1570dcda19f5SSusan Scheufele } mrsas_pd_address_t;
1571dcda19f5SSusan Scheufele 
1572dcda19f5SSusan Scheufele union mrsas_evt_class_locale {
1573dcda19f5SSusan Scheufele 	struct {
1574dcda19f5SSusan Scheufele 		uint16_t	locale;
1575dcda19f5SSusan Scheufele 		uint8_t		reserved;
1576dcda19f5SSusan Scheufele 		int8_t		class;
1577dcda19f5SSusan Scheufele 	} members;
1578dcda19f5SSusan Scheufele 
1579dcda19f5SSusan Scheufele 	uint32_t	word;
1580dcda19f5SSusan Scheufele };
1581dcda19f5SSusan Scheufele 
1582dcda19f5SSusan Scheufele struct mrsas_evt_log_info {
1583dcda19f5SSusan Scheufele 	uint32_t	newest_seq_num;
1584dcda19f5SSusan Scheufele 	uint32_t	oldest_seq_num;
1585dcda19f5SSusan Scheufele 	uint32_t	clear_seq_num;
1586dcda19f5SSusan Scheufele 	uint32_t	shutdown_seq_num;
1587dcda19f5SSusan Scheufele 	uint32_t	boot_seq_num;
1588dcda19f5SSusan Scheufele };
1589dcda19f5SSusan Scheufele 
1590dcda19f5SSusan Scheufele struct mrsas_progress {
1591dcda19f5SSusan Scheufele 	uint16_t	progress;
1592dcda19f5SSusan Scheufele 	uint16_t	elapsed_seconds;
1593dcda19f5SSusan Scheufele };
1594dcda19f5SSusan Scheufele 
1595dcda19f5SSusan Scheufele struct mrsas_evtarg_ld {
1596dcda19f5SSusan Scheufele 	uint16_t	target_id;
1597dcda19f5SSusan Scheufele 	uint8_t		ld_index;
1598dcda19f5SSusan Scheufele 	uint8_t		reserved;
1599dcda19f5SSusan Scheufele };
1600dcda19f5SSusan Scheufele 
1601dcda19f5SSusan Scheufele struct mrsas_evtarg_pd {
1602dcda19f5SSusan Scheufele 	uint16_t	device_id;
1603dcda19f5SSusan Scheufele 	uint8_t		encl_index;
1604dcda19f5SSusan Scheufele 	uint8_t		slot_number;
1605dcda19f5SSusan Scheufele };
1606dcda19f5SSusan Scheufele 
1607dcda19f5SSusan Scheufele struct mrsas_evt_detail {
1608dcda19f5SSusan Scheufele 	uint32_t	seq_num;
1609dcda19f5SSusan Scheufele 	uint32_t	time_stamp;
1610dcda19f5SSusan Scheufele 	uint32_t	code;
1611dcda19f5SSusan Scheufele 	union mrsas_evt_class_locale	cl;
1612dcda19f5SSusan Scheufele 	uint8_t		arg_type;
1613dcda19f5SSusan Scheufele 	uint8_t		reserved1[15];
1614dcda19f5SSusan Scheufele 
1615dcda19f5SSusan Scheufele 	union {
1616dcda19f5SSusan Scheufele 		struct {
1617dcda19f5SSusan Scheufele 			struct mrsas_evtarg_pd	pd;
1618dcda19f5SSusan Scheufele 			uint8_t			cdb_length;
1619dcda19f5SSusan Scheufele 			uint8_t			sense_length;
1620dcda19f5SSusan Scheufele 			uint8_t			reserved[2];
1621dcda19f5SSusan Scheufele 			uint8_t			cdb[16];
1622dcda19f5SSusan Scheufele 			uint8_t			sense[64];
1623dcda19f5SSusan Scheufele 		} cdbSense;
1624dcda19f5SSusan Scheufele 
1625dcda19f5SSusan Scheufele 		struct mrsas_evtarg_ld		ld;
1626dcda19f5SSusan Scheufele 
1627dcda19f5SSusan Scheufele 		struct {
1628dcda19f5SSusan Scheufele 			struct mrsas_evtarg_ld	ld;
1629dcda19f5SSusan Scheufele 			uint64_t		count;
1630dcda19f5SSusan Scheufele 		} ld_count;
1631dcda19f5SSusan Scheufele 
1632dcda19f5SSusan Scheufele 		struct {
1633dcda19f5SSusan Scheufele 			uint64_t		lba;
1634dcda19f5SSusan Scheufele 			struct mrsas_evtarg_ld	ld;
1635dcda19f5SSusan Scheufele 		} ld_lba;
1636dcda19f5SSusan Scheufele 
1637dcda19f5SSusan Scheufele 		struct {
1638dcda19f5SSusan Scheufele 			struct mrsas_evtarg_ld	ld;
1639dcda19f5SSusan Scheufele 			uint32_t		prevOwner;
1640dcda19f5SSusan Scheufele 			uint32_t		newOwner;
1641dcda19f5SSusan Scheufele 		} ld_owner;
1642dcda19f5SSusan Scheufele 
1643dcda19f5SSusan Scheufele 		struct {
1644dcda19f5SSusan Scheufele 			uint64_t		ld_lba;
1645dcda19f5SSusan Scheufele 			uint64_t		pd_lba;
1646dcda19f5SSusan Scheufele 			struct mrsas_evtarg_ld	ld;
1647dcda19f5SSusan Scheufele 			struct mrsas_evtarg_pd	pd;
1648dcda19f5SSusan Scheufele 		} ld_lba_pd_lba;
1649dcda19f5SSusan Scheufele 
1650dcda19f5SSusan Scheufele 		struct {
1651dcda19f5SSusan Scheufele 			struct mrsas_evtarg_ld	ld;
1652dcda19f5SSusan Scheufele 			struct mrsas_progress	prog;
1653dcda19f5SSusan Scheufele 		} ld_prog;
1654dcda19f5SSusan Scheufele 
1655dcda19f5SSusan Scheufele 		struct {
1656dcda19f5SSusan Scheufele 			struct mrsas_evtarg_ld	ld;
1657dcda19f5SSusan Scheufele 			uint32_t		prev_state;
1658dcda19f5SSusan Scheufele 			uint32_t		new_state;
1659dcda19f5SSusan Scheufele 		} ld_state;
1660dcda19f5SSusan Scheufele 
1661dcda19f5SSusan Scheufele 		struct {
1662dcda19f5SSusan Scheufele 			uint64_t		strip;
1663dcda19f5SSusan Scheufele 			struct mrsas_evtarg_ld	ld;
1664dcda19f5SSusan Scheufele 		} ld_strip;
1665dcda19f5SSusan Scheufele 
1666dcda19f5SSusan Scheufele 		struct mrsas_evtarg_pd		pd;
1667dcda19f5SSusan Scheufele 
1668dcda19f5SSusan Scheufele 		struct {
1669dcda19f5SSusan Scheufele 			struct mrsas_evtarg_pd	pd;
1670dcda19f5SSusan Scheufele 			uint32_t		err;
1671dcda19f5SSusan Scheufele 		} pd_err;
1672dcda19f5SSusan Scheufele 
1673dcda19f5SSusan Scheufele 		struct {
1674dcda19f5SSusan Scheufele 			uint64_t		lba;
1675dcda19f5SSusan Scheufele 			struct mrsas_evtarg_pd	pd;
1676dcda19f5SSusan Scheufele 		} pd_lba;
1677dcda19f5SSusan Scheufele 
1678dcda19f5SSusan Scheufele 		struct {
1679dcda19f5SSusan Scheufele 			uint64_t		lba;
1680dcda19f5SSusan Scheufele 			struct mrsas_evtarg_pd	pd;
1681dcda19f5SSusan Scheufele 			struct mrsas_evtarg_ld	ld;
1682dcda19f5SSusan Scheufele 		} pd_lba_ld;
1683dcda19f5SSusan Scheufele 
1684dcda19f5SSusan Scheufele 		struct {
1685dcda19f5SSusan Scheufele 			struct mrsas_evtarg_pd	pd;
1686dcda19f5SSusan Scheufele 			struct mrsas_progress	prog;
1687dcda19f5SSusan Scheufele 		} pd_prog;
1688dcda19f5SSusan Scheufele 
1689dcda19f5SSusan Scheufele 		struct {
1690dcda19f5SSusan Scheufele 			struct mrsas_evtarg_pd	pd;
1691dcda19f5SSusan Scheufele 			uint32_t		prevState;
1692dcda19f5SSusan Scheufele 			uint32_t		newState;
1693dcda19f5SSusan Scheufele 		} pd_state;
1694dcda19f5SSusan Scheufele 
1695dcda19f5SSusan Scheufele 		struct {
1696dcda19f5SSusan Scheufele 			uint16_t	vendorId;
1697dcda19f5SSusan Scheufele 			uint16_t	deviceId;
1698dcda19f5SSusan Scheufele 			uint16_t	subVendorId;
1699dcda19f5SSusan Scheufele 			uint16_t	subDeviceId;
1700dcda19f5SSusan Scheufele 		} pci;
1701dcda19f5SSusan Scheufele 
1702dcda19f5SSusan Scheufele 		uint32_t	rate;
1703dcda19f5SSusan Scheufele 		char		str[96];
1704dcda19f5SSusan Scheufele 
1705dcda19f5SSusan Scheufele 		struct {
1706dcda19f5SSusan Scheufele 			uint32_t	rtc;
1707dcda19f5SSusan Scheufele 			uint32_t	elapsedSeconds;
1708dcda19f5SSusan Scheufele 		} time;
1709dcda19f5SSusan Scheufele 
1710dcda19f5SSusan Scheufele 		struct {
1711dcda19f5SSusan Scheufele 			uint32_t	ecar;
1712dcda19f5SSusan Scheufele 			uint32_t	elog;
1713dcda19f5SSusan Scheufele 			char		str[64];
1714dcda19f5SSusan Scheufele 		} ecc;
1715dcda19f5SSusan Scheufele 
1716dcda19f5SSusan Scheufele 		mrsas_pd_address_t	pd_addr;
1717dcda19f5SSusan Scheufele 
1718dcda19f5SSusan Scheufele 		uint8_t		b[96];
1719dcda19f5SSusan Scheufele 		uint16_t	s[48];
1720dcda19f5SSusan Scheufele 		uint32_t	w[24];
1721dcda19f5SSusan Scheufele 		uint64_t	d[12];
1722dcda19f5SSusan Scheufele 	} args;
1723dcda19f5SSusan Scheufele 
1724dcda19f5SSusan Scheufele 	char	description[128];
1725dcda19f5SSusan Scheufele 
1726dcda19f5SSusan Scheufele };
1727dcda19f5SSusan Scheufele 
1728dcda19f5SSusan Scheufele /* only 63 are usable by the application */
1729dcda19f5SSusan Scheufele #define	MAX_LOGICAL_DRIVES			64
1730dcda19f5SSusan Scheufele /* only 255 physical devices may be used */
1731dcda19f5SSusan Scheufele #define	MAX_PHYSICAL_DEVICES			256
1732dcda19f5SSusan Scheufele #define	MAX_PD_PER_ENCLOSURE			64
1733dcda19f5SSusan Scheufele /* maximum disks per array */
1734dcda19f5SSusan Scheufele #define	MAX_ROW_SIZE				32
1735dcda19f5SSusan Scheufele /* maximum spans per logical drive */
1736dcda19f5SSusan Scheufele #define	MAX_SPAN_DEPTH				8
1737dcda19f5SSusan Scheufele /* maximum number of arrays a hot spare may be dedicated to */
1738dcda19f5SSusan Scheufele #define	MAX_ARRAYS_DEDICATED			16
1739dcda19f5SSusan Scheufele /* maximum number of arrays which may exist */
1740dcda19f5SSusan Scheufele #define	MAX_ARRAYS				128
1741dcda19f5SSusan Scheufele /* maximum number of foreign configs that may ha managed at once */
1742dcda19f5SSusan Scheufele #define	MAX_FOREIGN_CONFIGS			8
1743dcda19f5SSusan Scheufele /* maximum spares (global and dedicated combined) */
1744dcda19f5SSusan Scheufele #define	MAX_SPARES_FOR_THE_CONTROLLER		MAX_PHYSICAL_DEVICES
1745dcda19f5SSusan Scheufele /* maximum possible Target IDs (i.e. 0 to 63) */
1746dcda19f5SSusan Scheufele #define	MAX_TARGET_ID				63
1747dcda19f5SSusan Scheufele /* maximum number of supported enclosures */
1748dcda19f5SSusan Scheufele #define	MAX_ENCLOSURES				32
1749dcda19f5SSusan Scheufele /* maximum number of PHYs per controller */
1750dcda19f5SSusan Scheufele #define	MAX_PHYS_PER_CONTROLLER			16
1751dcda19f5SSusan Scheufele /* maximum number of LDs per array (due to DDF limitations) */
1752dcda19f5SSusan Scheufele #define	MAX_LDS_PER_ARRAY			16
1753dcda19f5SSusan Scheufele 
1754dcda19f5SSusan Scheufele /*
1755dcda19f5SSusan Scheufele  * -----------------------------------------------------------------------------
1756dcda19f5SSusan Scheufele  * -----------------------------------------------------------------------------
1757dcda19f5SSusan Scheufele  *
1758dcda19f5SSusan Scheufele  * Logical Drive commands
1759dcda19f5SSusan Scheufele  *
1760dcda19f5SSusan Scheufele  * -----------------------------------------------------------------------------
1761dcda19f5SSusan Scheufele  * -----------------------------------------------------------------------------
1762dcda19f5SSusan Scheufele  */
1763dcda19f5SSusan Scheufele #define	MR_DCMD_LD	0x03000000,	/* Logical Device (LD) opcodes */
1764dcda19f5SSusan Scheufele 
1765dcda19f5SSusan Scheufele /*
1766dcda19f5SSusan Scheufele  * Input:	dcmd.opcode	- MR_DCMD_LD_GET_LIST
1767dcda19f5SSusan Scheufele  *		dcmd.mbox	- reserved
1768dcda19f5SSusan Scheufele  *		dcmd.sge IN	- ptr to returned MR_LD_LIST structure
1769dcda19f5SSusan Scheufele  * Desc:	Return the logical drive list structure
1770dcda19f5SSusan Scheufele  * Status:	No error
1771dcda19f5SSusan Scheufele  */
1772dcda19f5SSusan Scheufele 
1773dcda19f5SSusan Scheufele /*
1774dcda19f5SSusan Scheufele  * defines the logical drive reference structure
1775dcda19f5SSusan Scheufele  */
1776dcda19f5SSusan Scheufele typedef	union _MR_LD_REF {	/* LD reference structure */
1777dcda19f5SSusan Scheufele 	struct {
1778dcda19f5SSusan Scheufele 		uint8_t	targetId; /* LD target id (0 to MAX_TARGET_ID) */
1779dcda19f5SSusan Scheufele 		uint8_t	reserved; /* reserved for in line with MR_PD_REF */
1780dcda19f5SSusan Scheufele 		uint16_t seqNum;  /* Sequence Number */
1781dcda19f5SSusan Scheufele 	} ld_ref;
1782dcda19f5SSusan Scheufele 	uint32_t ref;		/* shorthand reference to full 32-bits */
1783dcda19f5SSusan Scheufele } MR_LD_REF;			/* 4 bytes */
1784dcda19f5SSusan Scheufele 
1785dcda19f5SSusan Scheufele /*
1786dcda19f5SSusan Scheufele  * defines the logical drive list structure
1787dcda19f5SSusan Scheufele  */
1788dcda19f5SSusan Scheufele typedef struct _MR_LD_LIST {
1789dcda19f5SSusan Scheufele 	uint32_t	ldCount;	/* number of LDs */
1790dcda19f5SSusan Scheufele 	uint32_t	reserved;	/* pad to 8-byte boundary */
1791dcda19f5SSusan Scheufele 	struct {
1792dcda19f5SSusan Scheufele 		MR_LD_REF ref;	/* LD reference */
1793dcda19f5SSusan Scheufele 		uint8_t	state;		/* current LD state (MR_LD_STATE) */
1794dcda19f5SSusan Scheufele 		uint8_t	reserved[3];	/* pad to 8-byte boundary */
1795dcda19f5SSusan Scheufele 		uint64_t size;		/* LD size */
1796dcda19f5SSusan Scheufele 	} ldList[MAX_LOGICAL_DRIVES];
1797dcda19f5SSusan Scheufele } MR_LD_LIST;
1798dcda19f5SSusan Scheufele 
1799dcda19f5SSusan Scheufele struct mrsas_drv_ver {
1800dcda19f5SSusan Scheufele 	uint8_t	signature[12];
1801dcda19f5SSusan Scheufele 	uint8_t	os_name[16];
1802dcda19f5SSusan Scheufele 	uint8_t	os_ver[12];
1803dcda19f5SSusan Scheufele 	uint8_t	drv_name[20];
1804dcda19f5SSusan Scheufele 	uint8_t	drv_ver[32];
1805dcda19f5SSusan Scheufele 	uint8_t	drv_rel_date[20];
1806dcda19f5SSusan Scheufele };
1807dcda19f5SSusan Scheufele 
1808dcda19f5SSusan Scheufele #define	PCI_TYPE0_ADDRESSES		6
1809dcda19f5SSusan Scheufele #define	PCI_TYPE1_ADDRESSES		2
1810dcda19f5SSusan Scheufele #define	PCI_TYPE2_ADDRESSES		5
1811dcda19f5SSusan Scheufele 
1812dcda19f5SSusan Scheufele struct mrsas_pci_common_header {
1813dcda19f5SSusan Scheufele 	uint16_t	vendorID;		/* (ro) */
1814dcda19f5SSusan Scheufele 	uint16_t	deviceID;		/* (ro) */
1815dcda19f5SSusan Scheufele 	uint16_t	command;		/* Device control */
1816dcda19f5SSusan Scheufele 	uint16_t	status;
1817dcda19f5SSusan Scheufele 	uint8_t		revisionID;		/* (ro) */
1818dcda19f5SSusan Scheufele 	uint8_t		progIf;			/* (ro) */
1819dcda19f5SSusan Scheufele 	uint8_t		subClass;		/* (ro) */
1820dcda19f5SSusan Scheufele 	uint8_t		baseClass;		/* (ro) */
1821dcda19f5SSusan Scheufele 	uint8_t		cacheLineSize;		/* (ro+) */
1822dcda19f5SSusan Scheufele 	uint8_t		latencyTimer;		/* (ro+) */
1823dcda19f5SSusan Scheufele 	uint8_t		headerType;		/* (ro) */
1824dcda19f5SSusan Scheufele 	uint8_t		bist;			/* Built in self test */
1825dcda19f5SSusan Scheufele 
1826dcda19f5SSusan Scheufele 	union {
1827dcda19f5SSusan Scheufele 	    struct {
1828dcda19f5SSusan Scheufele 		uint32_t	baseAddresses[PCI_TYPE0_ADDRESSES];
1829dcda19f5SSusan Scheufele 		uint32_t	cis;
1830dcda19f5SSusan Scheufele 		uint16_t	subVendorID;
1831dcda19f5SSusan Scheufele 		uint16_t	subSystemID;
1832dcda19f5SSusan Scheufele 		uint32_t	romBaseAddress;
1833dcda19f5SSusan Scheufele 		uint8_t		capabilitiesPtr;
1834dcda19f5SSusan Scheufele 		uint8_t		reserved1[3];
1835dcda19f5SSusan Scheufele 		uint32_t	reserved2;
1836dcda19f5SSusan Scheufele 		uint8_t		interruptLine;
1837dcda19f5SSusan Scheufele 		uint8_t		interruptPin;	/* (ro) */
1838dcda19f5SSusan Scheufele 		uint8_t		minimumGrant;	/* (ro) */
1839dcda19f5SSusan Scheufele 		uint8_t		maximumLatency;	/* (ro) */
1840dcda19f5SSusan Scheufele 	    } type_0;
1841dcda19f5SSusan Scheufele 
1842dcda19f5SSusan Scheufele 	    struct {
1843dcda19f5SSusan Scheufele 		uint32_t	baseAddresses[PCI_TYPE1_ADDRESSES];
1844dcda19f5SSusan Scheufele 		uint8_t		primaryBus;
1845dcda19f5SSusan Scheufele 		uint8_t		secondaryBus;
1846dcda19f5SSusan Scheufele 		uint8_t		subordinateBus;
1847dcda19f5SSusan Scheufele 		uint8_t		secondaryLatency;
1848dcda19f5SSusan Scheufele 		uint8_t		ioBase;
1849dcda19f5SSusan Scheufele 		uint8_t		ioLimit;
1850dcda19f5SSusan Scheufele 		uint16_t	secondaryStatus;
1851dcda19f5SSusan Scheufele 		uint16_t	memoryBase;
1852dcda19f5SSusan Scheufele 		uint16_t	memoryLimit;
1853dcda19f5SSusan Scheufele 		uint16_t	prefetchBase;
1854dcda19f5SSusan Scheufele 		uint16_t	prefetchLimit;
1855dcda19f5SSusan Scheufele 		uint32_t	prefetchBaseUpper32;
1856dcda19f5SSusan Scheufele 		uint32_t	prefetchLimitUpper32;
1857dcda19f5SSusan Scheufele 		uint16_t	ioBaseUpper16;
1858dcda19f5SSusan Scheufele 		uint16_t	ioLimitUpper16;
1859dcda19f5SSusan Scheufele 		uint8_t		capabilitiesPtr;
1860dcda19f5SSusan Scheufele 		uint8_t		reserved1[3];
1861dcda19f5SSusan Scheufele 		uint32_t	romBaseAddress;
1862dcda19f5SSusan Scheufele 		uint8_t		interruptLine;
1863dcda19f5SSusan Scheufele 		uint8_t		interruptPin;
1864dcda19f5SSusan Scheufele 		uint16_t	bridgeControl;
1865dcda19f5SSusan Scheufele 	    } type_1;
1866dcda19f5SSusan Scheufele 
1867dcda19f5SSusan Scheufele 	    struct {
1868dcda19f5SSusan Scheufele 		uint32_t	socketRegistersBaseAddress;
1869dcda19f5SSusan Scheufele 		uint8_t		capabilitiesPtr;
1870dcda19f5SSusan Scheufele 		uint8_t		reserved;
1871dcda19f5SSusan Scheufele 		uint16_t	secondaryStatus;
1872dcda19f5SSusan Scheufele 		uint8_t		primaryBus;
1873dcda19f5SSusan Scheufele 		uint8_t		secondaryBus;
1874dcda19f5SSusan Scheufele 		uint8_t		subordinateBus;
1875dcda19f5SSusan Scheufele 		uint8_t		secondaryLatency;
1876dcda19f5SSusan Scheufele 		struct {
1877dcda19f5SSusan Scheufele 			uint32_t	base;
1878dcda19f5SSusan Scheufele 			uint32_t	limit;
1879dcda19f5SSusan Scheufele 		} range[PCI_TYPE2_ADDRESSES-1];
1880dcda19f5SSusan Scheufele 		uint8_t		interruptLine;
1881dcda19f5SSusan Scheufele 		uint8_t		interruptPin;
1882dcda19f5SSusan Scheufele 		uint16_t	bridgeControl;
1883dcda19f5SSusan Scheufele 	    } type_2;
1884dcda19f5SSusan Scheufele 	} header;
1885dcda19f5SSusan Scheufele };
1886dcda19f5SSusan Scheufele 
1887dcda19f5SSusan Scheufele struct mrsas_pci_link_capability {
1888dcda19f5SSusan Scheufele 	union {
1889dcda19f5SSusan Scheufele 	    struct {
1890dcda19f5SSusan Scheufele 		uint32_t linkSpeed		:4;
1891dcda19f5SSusan Scheufele 		uint32_t linkWidth		:6;
1892dcda19f5SSusan Scheufele 		uint32_t aspmSupport		:2;
1893dcda19f5SSusan Scheufele 		uint32_t losExitLatency		:3;
1894dcda19f5SSusan Scheufele 		uint32_t l1ExitLatency		:3;
1895dcda19f5SSusan Scheufele 		uint32_t rsvdp			:6;
1896dcda19f5SSusan Scheufele 		uint32_t portNumber		:8;
1897dcda19f5SSusan Scheufele 	    } bits;
1898dcda19f5SSusan Scheufele 
1899dcda19f5SSusan Scheufele 	    uint32_t asUlong;
1900dcda19f5SSusan Scheufele 	} cap;
1901dcda19f5SSusan Scheufele 
1902dcda19f5SSusan Scheufele };
1903dcda19f5SSusan Scheufele 
1904dcda19f5SSusan Scheufele struct mrsas_pci_link_status_capability {
1905dcda19f5SSusan Scheufele 	union {
1906dcda19f5SSusan Scheufele 	    struct {
1907dcda19f5SSusan Scheufele 		uint16_t linkSpeed		:4;
1908dcda19f5SSusan Scheufele 		uint16_t negotiatedLinkWidth	:6;
1909dcda19f5SSusan Scheufele 		uint16_t linkTrainingError	:1;
1910dcda19f5SSusan Scheufele 		uint16_t linkTraning		:1;
1911dcda19f5SSusan Scheufele 		uint16_t slotClockConfig	:1;
1912dcda19f5SSusan Scheufele 		uint16_t rsvdZ			:3;
1913dcda19f5SSusan Scheufele 	    } bits;
1914dcda19f5SSusan Scheufele 
1915dcda19f5SSusan Scheufele 	    uint16_t asUshort;
1916dcda19f5SSusan Scheufele 	} stat_cap;
1917dcda19f5SSusan Scheufele 
1918dcda19f5SSusan Scheufele 	uint16_t reserved;
1919dcda19f5SSusan Scheufele 
1920dcda19f5SSusan Scheufele };
1921dcda19f5SSusan Scheufele 
1922dcda19f5SSusan Scheufele struct mrsas_pci_capabilities {
1923dcda19f5SSusan Scheufele 	struct mrsas_pci_link_capability	linkCapability;
1924dcda19f5SSusan Scheufele 	struct mrsas_pci_link_status_capability linkStatusCapability;
1925dcda19f5SSusan Scheufele };
1926dcda19f5SSusan Scheufele 
1927dcda19f5SSusan Scheufele struct mrsas_pci_information
1928dcda19f5SSusan Scheufele {
1929dcda19f5SSusan Scheufele 	uint32_t		busNumber;
1930dcda19f5SSusan Scheufele 	uint8_t			deviceNumber;
1931dcda19f5SSusan Scheufele 	uint8_t			functionNumber;
1932dcda19f5SSusan Scheufele 	uint8_t			interruptVector;
1933dcda19f5SSusan Scheufele 	uint8_t			reserved;
1934dcda19f5SSusan Scheufele 	struct mrsas_pci_common_header pciHeaderInfo;
1935dcda19f5SSusan Scheufele 	struct mrsas_pci_capabilities capability;
1936dcda19f5SSusan Scheufele 	uint8_t			reserved2[32];
1937dcda19f5SSusan Scheufele };
1938dcda19f5SSusan Scheufele 
1939dcda19f5SSusan Scheufele struct mrsas_ioctl {
1940dcda19f5SSusan Scheufele 	uint16_t	version;
1941dcda19f5SSusan Scheufele 	uint16_t	controller_id;
1942dcda19f5SSusan Scheufele 	uint8_t		signature[8];
1943dcda19f5SSusan Scheufele 	uint32_t	reserved_1;
1944dcda19f5SSusan Scheufele 	uint32_t	control_code;
1945dcda19f5SSusan Scheufele 	uint32_t	reserved_2[2];
1946dcda19f5SSusan Scheufele 	uint8_t		frame[64];
1947dcda19f5SSusan Scheufele 	union mrsas_sgl_frame sgl_frame;
1948dcda19f5SSusan Scheufele 	uint8_t		sense_buff[MRSAS_MAX_SENSE_LENGTH];
1949dcda19f5SSusan Scheufele 	uint8_t		data[1];
1950dcda19f5SSusan Scheufele };
1951dcda19f5SSusan Scheufele 
1952dcda19f5SSusan Scheufele struct mrsas_aen {
1953dcda19f5SSusan Scheufele 	uint16_t	host_no;
1954dcda19f5SSusan Scheufele 	uint16_t	cmd_status;
1955dcda19f5SSusan Scheufele 	uint32_t	seq_num;
1956dcda19f5SSusan Scheufele 	uint32_t	class_locale_word;
1957dcda19f5SSusan Scheufele };
19582ffc8bcaSDan McDonald 
1959dcda19f5SSusan Scheufele #pragma pack()
1960dcda19f5SSusan Scheufele 
1961dcda19f5SSusan Scheufele #ifndef	DDI_VENDOR_LSI
1962dcda19f5SSusan Scheufele #define	DDI_VENDOR_LSI		"LSI"
1963dcda19f5SSusan Scheufele #endif /* DDI_VENDOR_LSI */
1964dcda19f5SSusan Scheufele 
19652ffc8bcaSDan McDonald int mrsas_config_scsi_device(struct mrsas_instance *,
19662ffc8bcaSDan McDonald     struct scsi_device *, dev_info_t **);
1967dcda19f5SSusan Scheufele 
19682ffc8bcaSDan McDonald int mrsas_tbolt_config_pd(struct mrsas_instance *, uint16_t,
19692ffc8bcaSDan McDonald     uint8_t, dev_info_t **);
19702ffc8bcaSDan McDonald 
19712ffc8bcaSDan McDonald dev_info_t *mrsas_find_child(struct mrsas_instance *, uint16_t, uint8_t);
19722ffc8bcaSDan McDonald int mrsas_service_evt(struct mrsas_instance *, int, int, int, uint64_t);
19732ffc8bcaSDan McDonald void return_raid_msg_pkt(struct mrsas_instance *, struct mrsas_cmd *);
19742ffc8bcaSDan McDonald struct mrsas_cmd *get_raid_msg_mfi_pkt(struct mrsas_instance *);
19752ffc8bcaSDan McDonald void return_raid_msg_mfi_pkt(struct mrsas_instance *, struct mrsas_cmd *);
19762ffc8bcaSDan McDonald 
19772ffc8bcaSDan McDonald int	alloc_space_for_mpi2(struct mrsas_instance *);
19782ffc8bcaSDan McDonald void	fill_up_drv_ver(struct mrsas_drv_ver *dv);
19792ffc8bcaSDan McDonald 
19802ffc8bcaSDan McDonald int	mrsas_issue_init_mpi2(struct mrsas_instance *);
19812ffc8bcaSDan McDonald struct scsi_pkt *mrsas_tbolt_tran_init_pkt(struct scsi_address *, register
1982dcda19f5SSusan Scheufele 		    struct scsi_pkt *, struct buf *, int, int, int, int,
1983dcda19f5SSusan Scheufele 		    int (*)(), caddr_t);
19842ffc8bcaSDan McDonald int	mrsas_tbolt_tran_start(struct scsi_address *,
1985dcda19f5SSusan Scheufele 		    register struct scsi_pkt *);
19862ffc8bcaSDan McDonald uint32_t tbolt_read_fw_status_reg(struct mrsas_instance *);
19872ffc8bcaSDan McDonald void 	tbolt_issue_cmd(struct mrsas_cmd *, struct mrsas_instance *);
19882ffc8bcaSDan McDonald int	tbolt_issue_cmd_in_poll_mode(struct mrsas_instance *,
1989dcda19f5SSusan Scheufele 		    struct mrsas_cmd *);
19902ffc8bcaSDan McDonald int	tbolt_issue_cmd_in_sync_mode(struct mrsas_instance *,
1991dcda19f5SSusan Scheufele 		    struct mrsas_cmd *);
19922ffc8bcaSDan McDonald void	tbolt_enable_intr(struct mrsas_instance *);
19932ffc8bcaSDan McDonald void	tbolt_disable_intr(struct mrsas_instance *);
19942ffc8bcaSDan McDonald int	tbolt_intr_ack(struct mrsas_instance *);
19952ffc8bcaSDan McDonald uint_t	mr_sas_tbolt_process_outstanding_cmd(struct mrsas_instance *);
19962ffc8bcaSDan McDonald     uint_t tbolt_softintr();
19972ffc8bcaSDan McDonald int 	mrsas_tbolt_dma(struct mrsas_instance *, uint32_t, int, int (*)());
19982ffc8bcaSDan McDonald int	mrsas_check_dma_handle(ddi_dma_handle_t handle);
19992ffc8bcaSDan McDonald int	mrsas_check_acc_handle(ddi_acc_handle_t handle);
20002ffc8bcaSDan McDonald int	mrsas_dma_alloc(struct mrsas_instance *, struct scsi_pkt *,
2001dcda19f5SSusan Scheufele 		    struct buf *, int, int (*)());
20022ffc8bcaSDan McDonald int	mrsas_dma_move(struct mrsas_instance *,
2003dcda19f5SSusan Scheufele 			struct scsi_pkt *, struct buf *);
20042ffc8bcaSDan McDonald int	mrsas_alloc_dma_obj(struct mrsas_instance *, dma_obj_t *,
20052ffc8bcaSDan McDonald 		    uchar_t);
20062ffc8bcaSDan McDonald void 	mr_sas_tbolt_build_mfi_cmd(struct mrsas_instance *, struct mrsas_cmd *);
20072ffc8bcaSDan McDonald int 	mrsas_dma_alloc_dmd(struct mrsas_instance *, dma_obj_t *);
20082ffc8bcaSDan McDonald void 	tbolt_complete_cmd_in_sync_mode(struct mrsas_instance *,
2009e73d18e5SYu Wu - Sun Microsystems - Beijing China 	struct mrsas_cmd *);
20102ffc8bcaSDan McDonald int 	alloc_req_rep_desc(struct mrsas_instance *);
20112ffc8bcaSDan McDonald int		mrsas_mode_sense_build(struct scsi_pkt *);
20122ffc8bcaSDan McDonald void		push_pending_mfi_pkt(struct mrsas_instance *,
2013e73d18e5SYu Wu - Sun Microsystems - Beijing China 			struct mrsas_cmd *);
20142ffc8bcaSDan McDonald int	mrsas_issue_pending_cmds(struct mrsas_instance *);
20152ffc8bcaSDan McDonald int 	mrsas_print_pending_cmds(struct mrsas_instance *);
20162ffc8bcaSDan McDonald int  	mrsas_complete_pending_cmds(struct mrsas_instance *);
2017e73d18e5SYu Wu - Sun Microsystems - Beijing China 
20182ffc8bcaSDan McDonald int	create_mfi_frame_pool(struct mrsas_instance *);
20192ffc8bcaSDan McDonald void	destroy_mfi_frame_pool(struct mrsas_instance *);
20202ffc8bcaSDan McDonald int 	create_mfi_mpi_frame_pool(struct mrsas_instance *);
20212ffc8bcaSDan McDonald void 	destroy_mfi_mpi_frame_pool(struct mrsas_instance *);
20222ffc8bcaSDan McDonald int 	create_mpi2_frame_pool(struct mrsas_instance *);
20232ffc8bcaSDan McDonald void 	destroy_mpi2_frame_pool(struct mrsas_instance *);
20242ffc8bcaSDan McDonald int	mrsas_free_dma_obj(struct mrsas_instance *, dma_obj_t);
20252ffc8bcaSDan McDonald void 	mrsas_tbolt_free_additional_dma_buffer(struct mrsas_instance *);
20262ffc8bcaSDan McDonald void 	free_req_desc_pool(struct mrsas_instance *);
20272ffc8bcaSDan McDonald void 	free_space_for_mpi2(struct mrsas_instance *);
20282ffc8bcaSDan McDonald void 	mrsas_dump_reply_desc(struct mrsas_instance *);
20292ffc8bcaSDan McDonald void 	tbolt_complete_cmd(struct mrsas_instance *, struct mrsas_cmd *);
20302ffc8bcaSDan McDonald void	display_scsi_inquiry(caddr_t);
20312ffc8bcaSDan McDonald void	service_mfi_aen(struct mrsas_instance *, struct mrsas_cmd *);
20322ffc8bcaSDan McDonald int	mrsas_mode_sense_build(struct scsi_pkt *);
20332ffc8bcaSDan McDonald int 	mrsas_tbolt_get_ld_map_info(struct mrsas_instance *);
20342ffc8bcaSDan McDonald struct mrsas_cmd *mrsas_tbolt_build_poll_cmd(struct mrsas_instance *,
20352ffc8bcaSDan McDonald 	struct scsi_address *, struct scsi_pkt *, uchar_t *);
20362ffc8bcaSDan McDonald int	mrsas_tbolt_reset_ppc(struct mrsas_instance *instance);
20372ffc8bcaSDan McDonald void	mrsas_tbolt_kill_adapter(struct mrsas_instance *instance);
20382ffc8bcaSDan McDonald int 	abort_syncmap_cmd(struct mrsas_instance *, struct mrsas_cmd *);
20392ffc8bcaSDan McDonald void	mrsas_tbolt_prepare_cdb(struct mrsas_instance *instance, U8 cdb[],
20402ffc8bcaSDan McDonald     struct IO_REQUEST_INFO *, Mpi2RaidSCSIIORequest_t *, U32);
20412ffc8bcaSDan McDonald 
20422ffc8bcaSDan McDonald 
20432ffc8bcaSDan McDonald int mrsas_init_adapter_ppc(struct mrsas_instance *instance);
20442ffc8bcaSDan McDonald int mrsas_init_adapter_tbolt(struct mrsas_instance *instance);
20452ffc8bcaSDan McDonald int mrsas_init_adapter(struct mrsas_instance *instance);
20462ffc8bcaSDan McDonald 
20472ffc8bcaSDan McDonald int mrsas_alloc_cmd_pool(struct mrsas_instance *instance);
20482ffc8bcaSDan McDonald void mrsas_free_cmd_pool(struct mrsas_instance *instance);
20492ffc8bcaSDan McDonald 
20502ffc8bcaSDan McDonald void mrsas_print_cmd_details(struct mrsas_instance *, struct mrsas_cmd *, int);
20512ffc8bcaSDan McDonald struct mrsas_cmd *get_raid_msg_pkt(struct mrsas_instance *);
20522ffc8bcaSDan McDonald 
20532ffc8bcaSDan McDonald int mfi_state_transition_to_ready(struct mrsas_instance *);
20542ffc8bcaSDan McDonald 
2055a1c36c8bSDan McDonald struct mrsas_cmd *mrsas_get_mfi_pkt(struct mrsas_instance *);
2056a1c36c8bSDan McDonald void mrsas_return_mfi_pkt(struct mrsas_instance *, struct mrsas_cmd *);
2057a1c36c8bSDan McDonald 
20582ffc8bcaSDan McDonald 
20592ffc8bcaSDan McDonald /* FMA functions. */
20602ffc8bcaSDan McDonald int mrsas_common_check(struct mrsas_instance *, struct  mrsas_cmd *);
20612ffc8bcaSDan McDonald void mrsas_fm_ereport(struct mrsas_instance *, char *);
2062dcda19f5SSusan Scheufele 
2063e73d18e5SYu Wu - Sun Microsystems - Beijing China 
2064dcda19f5SSusan Scheufele #ifdef	__cplusplus
2065dcda19f5SSusan Scheufele }
2066dcda19f5SSusan Scheufele #endif
2067dcda19f5SSusan Scheufele 
2068dcda19f5SSusan Scheufele #endif /* _MR_SAS_H_ */
2069