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