xref: /illumos-gate/usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_ioctl.h (revision 581cede61ac9c14d8d4ea452562a567189eead78)
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 
74 /*
75  *  The following are our ioctl() return status values.  If everything went
76  *  well, we return good status.  If the buffer length sent to us is too short
77  *  we return a status to tell the user.
78  */
79 #define	MPTIOCTL_STATUS_GOOD		0
80 #define	MPTIOCTL_STATUS_LEN_TOO_SHORT	1
81 
82 /*
83  *  The following is the MPTIOCTL_GET_ADAPTER_DATA data structure.  This data
84  *  structure is setup so that we hopefully are properly aligned for both
85  *  32-bit and 64-bit mode applications.
86  *
87  *  Adapter Type - Value = 4 = SCSI Protocol through SAS-2 adapter
88  *
89  *  MPI Port Number - The PCI Function number for this device
90  *
91  *  PCI Device HW Id - The PCI device number for this device
92  *
93  */
94 #define	MPTIOCTL_ADAPTER_TYPE_SAS2	4
95 typedef struct mptsas_adapter_data
96 {
97 	uint32_t	StructureLength;
98 	uint32_t	AdapterType;
99 	uint32_t	MpiPortNumber;
100 	uint32_t	PCIDeviceHwId;
101 	uint32_t	PCIDeviceHwRev;
102 	uint32_t	SubSystemId;
103 	uint32_t	SubsystemVendorId;
104 	uint32_t	Reserved1;
105 	uint32_t	MpiFirmwareVersion;
106 	uint32_t	BiosVersion;
107 	uint8_t		DriverVersion[32];
108 	uint8_t		Reserved2;
109 	uint8_t		ScsiId;
110 	uint16_t	Reserved3;
111 	uint32_t	PciInformation;
112 	uint32_t	PciSegmentId;
113 } mptsas_adapter_data_t;
114 
115 
116 typedef struct mptsas_update_flash
117 {
118 	uint64_t	PtrBuffer;
119 	uint32_t	ImageChecksum;
120 	uint32_t	ImageOffset;
121 	uint32_t	ImageSize;
122 	uint32_t	ImageType;
123 } mptsas_update_flash_t;
124 
125 
126 #define	MPTSAS_PASS_THRU_DIRECTION_NONE		0
127 #define	MPTSAS_PASS_THRU_DIRECTION_READ		1
128 #define	MPTSAS_PASS_THRU_DIRECTION_WRITE	2
129 #define	MPTSAS_PASS_THRU_DIRECTION_BOTH		3
130 
131 typedef struct mptsas_pass_thru
132 {
133 	uint64_t	PtrRequest;
134 	uint64_t	PtrReply;
135 	uint64_t	PtrData;
136 	uint32_t	RequestSize;
137 	uint32_t	ReplySize;
138 	uint32_t	DataSize;
139 	uint32_t	DataDirection;
140 	uint64_t	PtrDataOut;
141 	uint32_t	DataOutSize;
142 	uint32_t	Timeout;
143 } mptsas_pass_thru_t;
144 
145 
146 /*
147  * Event queue defines
148  */
149 #define	MPTSAS_EVENT_QUEUE_SIZE		(50) /* Max Events stored in driver */
150 #define	MPTSAS_MAX_EVENT_DATA_LENGTH	(48) /* Size of each event in Dwords */
151 
152 typedef struct mptsas_event_query
153 {
154 	uint16_t	Entries;
155 	uint16_t	Reserved;
156 	uint32_t	Types[4];
157 } mptsas_event_query_t;
158 
159 typedef struct mptsas_event_enable
160 {
161 	uint32_t	Types[4];
162 } mptsas_event_enable_t;
163 
164 /*
165  * Event record entry for ioctl.
166  */
167 typedef struct mptsas_event_entry
168 {
169 	uint32_t	Type;
170 	uint32_t	Number;
171 	uint32_t	Data[MPTSAS_MAX_EVENT_DATA_LENGTH];
172 } mptsas_event_entry_t;
173 
174 typedef struct mptsas_event_report
175 {
176 	uint32_t		Size;
177 	mptsas_event_entry_t	Events[1];
178 } mptsas_event_report_t;
179 
180 
181 typedef struct mptsas_pci_info
182 {
183 	uint32_t	BusNumber;
184 	uint8_t		DeviceNumber;
185 	uint8_t		FunctionNumber;
186 	uint16_t	InterruptVector;
187 	uint8_t		PciHeader[256];
188 } mptsas_pci_info_t;
189 
190 
191 typedef struct mptsas_diag_action
192 {
193 	uint32_t	Action;
194 	uint32_t	Length;
195 	uint64_t	PtrDiagAction;
196 	uint32_t	ReturnCode;
197 } mptsas_diag_action_t;
198 
199 #define	MPTSAS_FW_DIAGNOSTIC_BUFFER_COUNT	(3)
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		Reserved1;
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		Reserved1;
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;
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 #ifdef  __cplusplus
274 }
275 #endif
276 
277 #endif	/* _MPTSAS_IOCTL_H */
278