1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Copyright (c) 2000 to 2009, LSI Corporation.
29  * All rights reserved.
30  *
31  * Redistribution and use in source and binary forms of all code within
32  * this file that is exclusively owned by LSI, with or without
33  * modification, is permitted provided that, in addition to the CDDL 1.0
34  * License requirements, the following conditions are met:
35  *
36  *    Neither the name of the author nor the names of its contributors may be
37  *    used to endorse or promote products derived from this software without
38  *    specific prior written permission.
39  *
40  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
43  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
44  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
45  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
46  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
47  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
48  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
51  * DAMAGE.
52  */
53 
54 #ifndef _MPTSAS_IOCTL_H
55 #define	_MPTSAS_IOCTL_H
56 
57 #ifdef  __cplusplus
58 extern "C" {
59 #endif
60 
61 #include <sys/types.h>
62 
63 #define	MPTIOCTL			('I' << 8)
64 #define	MPTIOCTL_GET_ADAPTER_DATA	(MPTIOCTL | 1)
65 #define	MPTIOCTL_UPDATE_FLASH		(MPTIOCTL | 2)
66 #define	MPTIOCTL_RESET_ADAPTER		(MPTIOCTL | 3)
67 #define	MPTIOCTL_PASS_THRU		(MPTIOCTL | 4)
68 #define	MPTIOCTL_EVENT_QUERY		(MPTIOCTL | 5)
69 #define	MPTIOCTL_EVENT_ENABLE		(MPTIOCTL | 6)
70 #define	MPTIOCTL_EVENT_REPORT		(MPTIOCTL | 7)
71 #define	MPTIOCTL_GET_PCI_INFO		(MPTIOCTL | 8)
72 #define	MPTIOCTL_DIAG_ACTION		(MPTIOCTL | 9)
73 #define	MPTIOCTL_REG_ACCESS		(MPTIOCTL | 10)
74 
75 /*
76  *  The following are our ioctl() return status values.  If everything went
77  *  well, we return good status.  If the buffer length sent to us is too short
78  *  we return a status to tell the user.
79  */
80 #define	MPTIOCTL_STATUS_GOOD		0
81 #define	MPTIOCTL_STATUS_LEN_TOO_SHORT	1
82 
83 /*
84  *  The following is the MPTIOCTL_GET_ADAPTER_DATA data structure.  This data
85  *  structure is setup so that we hopefully are properly aligned for both
86  *  32-bit and 64-bit mode applications.
87  *
88  *  Adapter Type - Value = 4 = SCSI Protocol through SAS-2 adapter
89  *
90  *  MPI Port Number - The PCI Function number for this device
91  *
92  *  PCI Device HW Id - The PCI device number for this device
93  *
94  */
95 #define	MPTIOCTL_ADAPTER_TYPE_SAS2	4
96 typedef struct mptsas_adapter_data
97 {
98 	uint32_t	StructureLength;
99 	uint32_t	AdapterType;
100 	uint32_t	MpiPortNumber;
101 	uint32_t	PCIDeviceHwId;
102 	uint32_t	PCIDeviceHwRev;
103 	uint32_t	SubSystemId;
104 	uint32_t	SubsystemVendorId;
105 	uint32_t	Reserved1;
106 	uint32_t	MpiFirmwareVersion;
107 	uint32_t	BiosVersion;
108 	uint8_t		DriverVersion[32];
109 	uint8_t		Reserved2;
110 	uint8_t		ScsiId;
111 	uint16_t	Reserved3;
112 	uint32_t	PciInformation;
113 	uint32_t	PciSegmentId;
114 } mptsas_adapter_data_t;
115 
116 
117 typedef struct mptsas_update_flash
118 {
119 	uint64_t	PtrBuffer;
120 	uint32_t	ImageChecksum;
121 	uint32_t	ImageOffset;
122 	uint32_t	ImageSize;
123 	uint32_t	ImageType;
124 } mptsas_update_flash_t;
125 
126 
127 #define	MPTSAS_PASS_THRU_DIRECTION_NONE		0
128 #define	MPTSAS_PASS_THRU_DIRECTION_READ		1
129 #define	MPTSAS_PASS_THRU_DIRECTION_WRITE	2
130 #define	MPTSAS_PASS_THRU_DIRECTION_BOTH		3
131 
132 typedef struct mptsas_pass_thru
133 {
134 	uint64_t	PtrRequest;
135 	uint64_t	PtrReply;
136 	uint64_t	PtrData;
137 	uint32_t	RequestSize;
138 	uint32_t	ReplySize;
139 	uint32_t	DataSize;
140 	uint32_t	DataDirection;
141 	uint64_t	PtrDataOut;
142 	uint32_t	DataOutSize;
143 	uint32_t	Timeout;
144 } mptsas_pass_thru_t;
145 
146 
147 /*
148  * Event queue defines
149  */
150 #define	MPTSAS_EVENT_QUEUE_SIZE		(50) /* Max Events stored in driver */
151 #define	MPTSAS_MAX_EVENT_DATA_LENGTH	(48) /* Size of each event in Dwords */
152 
153 typedef struct mptsas_event_query
154 {
155 	uint16_t	Entries;
156 	uint16_t	Reserved;
157 	uint32_t	Types[4];
158 } mptsas_event_query_t;
159 
160 typedef struct mptsas_event_enable
161 {
162 	uint32_t	Types[4];
163 } mptsas_event_enable_t;
164 
165 /*
166  * Event record entry for ioctl.
167  */
168 typedef struct mptsas_event_entry
169 {
170 	uint32_t	Type;
171 	uint32_t	Number;
172 	uint32_t	Data[MPTSAS_MAX_EVENT_DATA_LENGTH];
173 } mptsas_event_entry_t;
174 
175 typedef struct mptsas_event_report
176 {
177 	uint32_t		Size;
178 	mptsas_event_entry_t	Events[1];
179 } mptsas_event_report_t;
180 
181 
182 typedef struct mptsas_pci_info
183 {
184 	uint32_t	BusNumber;
185 	uint8_t		DeviceNumber;
186 	uint8_t		FunctionNumber;
187 	uint16_t	InterruptVector;
188 	uint8_t		PciHeader[256];
189 } mptsas_pci_info_t;
190 
191 
192 typedef struct mptsas_diag_action
193 {
194 	uint32_t	Action;
195 	uint32_t	Length;
196 	uint64_t	PtrDiagAction;
197 	uint32_t	ReturnCode;
198 } mptsas_diag_action_t;
199 
200 #define	MPTSAS_FW_DIAGNOSTIC_UID_NOT_FOUND	(0xFF)
201 
202 #define	MPTSAS_FW_DIAG_NEW			(0x806E6577)
203 
204 #define	MPTSAS_FW_DIAG_TYPE_REGISTER		(0x00000001)
205 #define	MPTSAS_FW_DIAG_TYPE_UNREGISTER		(0x00000002)
206 #define	MPTSAS_FW_DIAG_TYPE_QUERY		(0x00000003)
207 #define	MPTSAS_FW_DIAG_TYPE_READ_BUFFER		(0x00000004)
208 #define	MPTSAS_FW_DIAG_TYPE_RELEASE		(0x00000005)
209 
210 #define	MPTSAS_FW_DIAG_INVALID_UID		(0x00000000)
211 
212 #define	MPTSAS_FW_DIAG_ERROR_SUCCESS		(0x00000000)
213 #define	MPTSAS_FW_DIAG_ERROR_FAILURE		(0x00000001)
214 #define	MPTSAS_FW_DIAG_ERROR_INVALID_PARAMETER	(0x00000002)
215 #define	MPTSAS_FW_DIAG_ERROR_POST_FAILED	(0x00000010)
216 #define	MPTSAS_FW_DIAG_ERROR_INVALID_UID	(0x00000011)
217 #define	MPTSAS_FW_DIAG_ERROR_RELEASE_FAILED	(0x00000012)
218 #define	MPTSAS_FW_DIAG_ERROR_NO_BUFFER		(0x00000013)
219 #define	MPTSAS_FW_DIAG_ERROR_ALREADY_RELEASED	(0x00000014)
220 
221 
222 typedef struct mptsas_fw_diag_register
223 {
224 	uint8_t		ExtendedType;
225 	uint8_t		BufferType;
226 	uint16_t	ApplicationFlags;
227 	uint32_t	DiagnosticFlags;
228 	uint32_t	ProductSpecific[23];
229 	uint32_t	RequestedBufferSize;
230 	uint32_t	UniqueId;
231 } mptsas_fw_diag_register_t;
232 
233 typedef struct mptsas_fw_diag_unregister
234 {
235 	uint32_t	UniqueId;
236 } mptsas_fw_diag_unregister_t;
237 
238 #define	MPTSAS_FW_DIAG_FLAG_APP_OWNED		(0x0001)
239 #define	MPTSAS_FW_DIAG_FLAG_BUFFER_VALID	(0x0002)
240 #define	MPTSAS_FW_DIAG_FLAG_FW_BUFFER_ACCESS	(0x0004)
241 
242 typedef struct mptsas_fw_diag_query
243 {
244 	uint8_t		ExtendedType;
245 	uint8_t		BufferType;
246 	uint16_t	ApplicationFlags;
247 	uint32_t	DiagnosticFlags;
248 	uint32_t	ProductSpecific[23];
249 	uint32_t	TotalBufferSize;
250 	uint32_t	DriverAddedBufferSize;
251 	uint32_t	UniqueId;
252 } mptsas_fw_diag_query_t;
253 
254 typedef struct mptsas_fw_diag_release
255 {
256 	uint32_t	UniqueId;
257 } mptsas_fw_diag_release_t;
258 
259 #define	MPTSAS_FW_DIAG_FLAG_REREGISTER		(0x0001)
260 #define	MPTSAS_FW_DIAG_FLAG_FORCE_RELEASE	(0x0002)
261 
262 typedef struct mptsas_diag_read_buffer
263 {
264 	uint8_t		Status;
265 	uint8_t		Reserved;
266 	uint16_t	Flags;
267 	uint32_t	StartingOffset;
268 	uint32_t	BytesToRead;
269 	uint32_t	UniqueId;
270 	uint32_t	DataBuffer[1];
271 } mptsas_diag_read_buffer_t;
272 
273 /*
274  * Register Access
275  */
276 #define	REG_IO_READ	1
277 #define	REG_IO_WRITE	2
278 #define	REG_MEM_READ	3
279 #define	REG_MEM_WRITE	4
280 
281 typedef struct mptsas_reg_access
282 {
283 	uint32_t	Command;
284 	uint32_t	RegOffset;
285 	uint32_t	RegData;
286 } mptsas_reg_access_t;
287 
288 #ifdef  __cplusplus
289 }
290 #endif
291 
292 #endif	/* _MPTSAS_IOCTL_H */
293