Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/drivers/message/fusion/mptioctl.h | |
3 | * Fusion MPT misc device (ioctl) driver. | |
4 | * For use with PCI chip/adapter(s): | |
5 | * LSIFC9xx/LSI409xx Fibre Channel | |
6 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | |
7 | * | |
b6fe4ddc | 8 | * Copyright (c) 1999-2005 LSI Logic Corporation |
1da177e4 LT |
9 | * (mailto:mpt_linux_developer@lsil.com) |
10 | * | |
1da177e4 LT |
11 | */ |
12 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | |
13 | /* | |
14 | This program is free software; you can redistribute it and/or modify | |
15 | it under the terms of the GNU General Public License as published by | |
16 | the Free Software Foundation; version 2 of the License. | |
17 | ||
18 | This program is distributed in the hope that it will be useful, | |
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | GNU General Public License for more details. | |
22 | ||
23 | NO WARRANTY | |
24 | THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR | |
25 | CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT | |
26 | LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, | |
27 | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is | |
28 | solely responsible for determining the appropriateness of using and | |
29 | distributing the Program and assumes all risks associated with its | |
30 | exercise of rights under this Agreement, including but not limited to | |
31 | the risks and costs of program errors, damage to or loss of data, | |
32 | programs or equipment, and unavailability or interruption of operations. | |
33 | ||
34 | DISCLAIMER OF LIABILITY | |
35 | NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY | |
36 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
37 | DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND | |
38 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | |
39 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | |
40 | USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED | |
41 | HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES | |
42 | ||
43 | You should have received a copy of the GNU General Public License | |
44 | along with this program; if not, write to the Free Software | |
45 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
46 | */ | |
47 | ||
48 | #ifndef MPTCTL_H_INCLUDED | |
49 | #define MPTCTL_H_INCLUDED | |
50 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | |
51 | ||
52 | #include "linux/version.h" | |
53 | ||
54 | ||
55 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | |
56 | /* | |
57 | * | |
58 | */ | |
59 | #define MPT_MISCDEV_BASENAME "mptctl" | |
60 | #define MPT_MISCDEV_PATHNAME "/dev/" MPT_MISCDEV_BASENAME | |
61 | ||
62 | #define MPT_PRODUCT_LENGTH 12 | |
63 | ||
64 | /* | |
65 | * Generic MPT Control IOCTLs and structures | |
66 | */ | |
67 | #define MPT_MAGIC_NUMBER 'm' | |
68 | ||
69 | #define MPTRWPERF _IOWR(MPT_MAGIC_NUMBER,0,struct mpt_raw_r_w) | |
70 | ||
71 | #define MPTFWDOWNLOAD _IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer) | |
72 | #define MPTCOMMAND _IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command) | |
73 | ||
74 | #if defined(__KERNEL__) && defined(CONFIG_COMPAT) | |
75 | #define MPTFWDOWNLOAD32 _IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer32) | |
76 | #define MPTCOMMAND32 _IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command32) | |
77 | #endif | |
78 | ||
79 | #define MPTIOCINFO _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo) | |
80 | #define MPTIOCINFO1 _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev0) | |
81 | #define MPTIOCINFO2 _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev1) | |
82 | #define MPTTARGETINFO _IOWR(MPT_MAGIC_NUMBER,18,struct mpt_ioctl_targetinfo) | |
83 | #define MPTTEST _IOWR(MPT_MAGIC_NUMBER,19,struct mpt_ioctl_test) | |
84 | #define MPTEVENTQUERY _IOWR(MPT_MAGIC_NUMBER,21,struct mpt_ioctl_eventquery) | |
85 | #define MPTEVENTENABLE _IOWR(MPT_MAGIC_NUMBER,22,struct mpt_ioctl_eventenable) | |
86 | #define MPTEVENTREPORT _IOWR(MPT_MAGIC_NUMBER,23,struct mpt_ioctl_eventreport) | |
87 | #define MPTHARDRESET _IOWR(MPT_MAGIC_NUMBER,24,struct mpt_ioctl_diag_reset) | |
88 | #define MPTFWREPLACE _IOWR(MPT_MAGIC_NUMBER,25,struct mpt_ioctl_replace_fw) | |
89 | ||
90 | /* | |
91 | * SPARC PLATFORM REMARKS: | |
92 | * IOCTL data structures that contain pointers | |
93 | * will have different sizes in the driver and applications | |
94 | * (as the app. will not use 8-byte pointers). | |
95 | * Apps should use MPTFWDOWNLOAD and MPTCOMMAND. | |
96 | * The driver will convert data from | |
97 | * mpt_fw_xfer32 (mpt_ioctl_command32) to mpt_fw_xfer (mpt_ioctl_command) | |
98 | * internally. | |
99 | * | |
100 | * If data structures change size, must handle as in IOCGETINFO. | |
101 | */ | |
102 | struct mpt_fw_xfer { | |
103 | unsigned int iocnum; /* IOC unit number */ | |
104 | unsigned int fwlen; | |
105 | void __user *bufp; /* Pointer to firmware buffer */ | |
106 | }; | |
107 | ||
108 | #if defined(__KERNEL__) && defined(CONFIG_COMPAT) | |
109 | struct mpt_fw_xfer32 { | |
110 | unsigned int iocnum; | |
111 | unsigned int fwlen; | |
112 | u32 bufp; | |
113 | }; | |
114 | #endif /*}*/ | |
115 | ||
116 | /* | |
117 | * IOCTL header structure. | |
118 | * iocnum - must be defined. | |
119 | * port - must be defined for all IOCTL commands other than MPTIOCINFO | |
120 | * maxDataSize - ignored on MPTCOMMAND commands | |
121 | * - ignored on MPTFWREPLACE commands | |
122 | * - on query commands, reports the maximum number of bytes to be returned | |
123 | * to the host driver (count includes the header). | |
124 | * That is, set to sizeof(struct mpt_ioctl_iocinfo) for fixed sized commands. | |
125 | * Set to sizeof(struct mpt_ioctl_targetinfo) + datasize for variable | |
126 | * sized commands. (MPTTARGETINFO, MPTEVENTREPORT) | |
127 | */ | |
128 | typedef struct _mpt_ioctl_header { | |
129 | unsigned int iocnum; /* IOC unit number */ | |
130 | unsigned int port; /* IOC port number */ | |
131 | int maxDataSize; /* Maximum Num. bytes to transfer on read */ | |
132 | } mpt_ioctl_header; | |
133 | ||
134 | /* | |
135 | * Issue a diagnostic reset | |
136 | */ | |
137 | struct mpt_ioctl_diag_reset { | |
138 | mpt_ioctl_header hdr; | |
139 | }; | |
140 | ||
141 | ||
142 | /* | |
143 | * PCI bus/device/function information structure. | |
144 | */ | |
145 | struct mpt_ioctl_pci_info { | |
146 | union { | |
147 | struct { | |
148 | unsigned int deviceNumber : 5; | |
149 | unsigned int functionNumber : 3; | |
150 | unsigned int busNumber : 24; | |
151 | } bits; | |
152 | unsigned int asUlong; | |
153 | } u; | |
154 | }; | |
155 | ||
156 | struct mpt_ioctl_pci_info2 { | |
157 | union { | |
158 | struct { | |
159 | unsigned int deviceNumber : 5; | |
160 | unsigned int functionNumber : 3; | |
161 | unsigned int busNumber : 24; | |
162 | } bits; | |
163 | unsigned int asUlong; | |
164 | } u; | |
165 | int segmentID; | |
166 | }; | |
167 | ||
168 | /* | |
169 | * Adapter Information Page | |
170 | * Read only. | |
171 | * Data starts at offset 0xC | |
172 | */ | |
173 | #define MPT_IOCTL_INTERFACE_FC (0x01) | |
174 | #define MPT_IOCTL_INTERFACE_SCSI (0x00) | |
175 | #define MPT_IOCTL_VERSION_LENGTH (32) | |
176 | ||
177 | struct mpt_ioctl_iocinfo { | |
178 | mpt_ioctl_header hdr; | |
179 | int adapterType; /* SCSI or FCP */ | |
180 | int port; /* port number */ | |
181 | int pciId; /* PCI Id. */ | |
182 | int hwRev; /* hardware revision */ | |
183 | int subSystemDevice; /* PCI subsystem Device ID */ | |
184 | int subSystemVendor; /* PCI subsystem Vendor ID */ | |
185 | int numDevices; /* number of devices */ | |
186 | int FWVersion; /* FW Version (integer) */ | |
187 | int BIOSVersion; /* BIOS Version (integer) */ | |
188 | char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */ | |
189 | char busChangeEvent; | |
190 | char hostId; | |
191 | char rsvd[2]; | |
192 | struct mpt_ioctl_pci_info2 pciInfo; /* Added Rev 2 */ | |
193 | }; | |
194 | ||
195 | struct mpt_ioctl_iocinfo_rev1 { | |
196 | mpt_ioctl_header hdr; | |
197 | int adapterType; /* SCSI or FCP */ | |
198 | int port; /* port number */ | |
199 | int pciId; /* PCI Id. */ | |
200 | int hwRev; /* hardware revision */ | |
201 | int subSystemDevice; /* PCI subsystem Device ID */ | |
202 | int subSystemVendor; /* PCI subsystem Vendor ID */ | |
203 | int numDevices; /* number of devices */ | |
204 | int FWVersion; /* FW Version (integer) */ | |
205 | int BIOSVersion; /* BIOS Version (integer) */ | |
206 | char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */ | |
207 | char busChangeEvent; | |
208 | char hostId; | |
209 | char rsvd[2]; | |
210 | struct mpt_ioctl_pci_info pciInfo; /* Added Rev 1 */ | |
211 | }; | |
212 | ||
213 | /* Original structure, must always accept these | |
214 | * IOCTLs. 4 byte pads can occur based on arch with | |
215 | * above structure. Wish to re-align, but cannot. | |
216 | */ | |
217 | struct mpt_ioctl_iocinfo_rev0 { | |
218 | mpt_ioctl_header hdr; | |
219 | int adapterType; /* SCSI or FCP */ | |
220 | int port; /* port number */ | |
221 | int pciId; /* PCI Id. */ | |
222 | int hwRev; /* hardware revision */ | |
223 | int subSystemDevice; /* PCI subsystem Device ID */ | |
224 | int subSystemVendor; /* PCI subsystem Vendor ID */ | |
225 | int numDevices; /* number of devices */ | |
226 | int FWVersion; /* FW Version (integer) */ | |
227 | int BIOSVersion; /* BIOS Version (integer) */ | |
228 | char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */ | |
229 | char busChangeEvent; | |
230 | char hostId; | |
231 | char rsvd[2]; | |
232 | }; | |
233 | ||
234 | /* | |
235 | * Device Information Page | |
236 | * Report the number of, and ids of, all targets | |
237 | * on this IOC. The ids array is a packed structure | |
238 | * of the known targetInfo. | |
239 | * bits 31-24: reserved | |
240 | * 23-16: LUN | |
241 | * 15- 8: Bus Number | |
242 | * 7- 0: Target ID | |
243 | */ | |
244 | struct mpt_ioctl_targetinfo { | |
245 | mpt_ioctl_header hdr; | |
246 | int numDevices; /* Num targets on this ioc */ | |
247 | int targetInfo[1]; | |
248 | }; | |
249 | ||
250 | ||
251 | /* | |
252 | * Event reporting IOCTL's. These IOCTL's will | |
253 | * use the following defines: | |
254 | */ | |
255 | struct mpt_ioctl_eventquery { | |
256 | mpt_ioctl_header hdr; | |
257 | unsigned short eventEntries; | |
258 | unsigned short reserved; | |
259 | unsigned int eventTypes; | |
260 | }; | |
261 | ||
262 | struct mpt_ioctl_eventenable { | |
263 | mpt_ioctl_header hdr; | |
264 | unsigned int eventTypes; | |
265 | }; | |
266 | ||
267 | #ifndef __KERNEL__ | |
268 | typedef struct { | |
269 | uint event; | |
270 | uint eventContext; | |
271 | uint data[2]; | |
272 | } MPT_IOCTL_EVENTS; | |
273 | #endif | |
274 | ||
275 | struct mpt_ioctl_eventreport { | |
276 | mpt_ioctl_header hdr; | |
277 | MPT_IOCTL_EVENTS eventData[1]; | |
278 | }; | |
279 | ||
280 | #define MPT_MAX_NAME 32 | |
281 | struct mpt_ioctl_test { | |
282 | mpt_ioctl_header hdr; | |
283 | u8 name[MPT_MAX_NAME]; | |
284 | int chip_type; | |
285 | u8 product [MPT_PRODUCT_LENGTH]; | |
286 | }; | |
287 | ||
288 | /* Replace the FW image cached in host driver memory | |
289 | * newImageSize - image size in bytes | |
290 | * newImage - first byte of the new image | |
291 | */ | |
292 | typedef struct mpt_ioctl_replace_fw { | |
293 | mpt_ioctl_header hdr; | |
294 | int newImageSize; | |
295 | u8 newImage[1]; | |
296 | } mpt_ioctl_replace_fw_t; | |
297 | ||
298 | /* General MPT Pass through data strucutre | |
299 | * | |
300 | * iocnum | |
301 | * timeout - in seconds, command timeout. If 0, set by driver to | |
302 | * default value. | |
303 | * replyFrameBufPtr - reply location | |
304 | * dataInBufPtr - destination for read | |
305 | * dataOutBufPtr - data source for write | |
306 | * senseDataPtr - sense data location | |
307 | * maxReplyBytes - maximum number of reply bytes to be sent to app. | |
308 | * dataInSize - num bytes for data transfer in (read) | |
309 | * dataOutSize - num bytes for data transfer out (write) | |
310 | * dataSgeOffset - offset in words from the start of the request message | |
311 | * to the first SGL | |
312 | * MF[1]; | |
313 | * | |
314 | * Remark: Some config pages have bi-directional transfer, | |
315 | * both a read and a write. The basic structure allows for | |
316 | * a bidirectional set up. Normal messages will have one or | |
317 | * both of these buffers NULL. | |
318 | */ | |
319 | struct mpt_ioctl_command { | |
320 | mpt_ioctl_header hdr; | |
321 | int timeout; /* optional (seconds) */ | |
322 | char __user *replyFrameBufPtr; | |
323 | char __user *dataInBufPtr; | |
324 | char __user *dataOutBufPtr; | |
325 | char __user *senseDataPtr; | |
326 | int maxReplyBytes; | |
327 | int dataInSize; | |
328 | int dataOutSize; | |
329 | int maxSenseBytes; | |
330 | int dataSgeOffset; | |
331 | char MF[1]; | |
332 | }; | |
333 | ||
334 | /* | |
335 | * SPARC PLATFORM: See earlier remark. | |
336 | */ | |
337 | #if defined(__KERNEL__) && defined(CONFIG_COMPAT) | |
338 | struct mpt_ioctl_command32 { | |
339 | mpt_ioctl_header hdr; | |
340 | int timeout; | |
341 | u32 replyFrameBufPtr; | |
342 | u32 dataInBufPtr; | |
343 | u32 dataOutBufPtr; | |
344 | u32 senseDataPtr; | |
345 | int maxReplyBytes; | |
346 | int dataInSize; | |
347 | int dataOutSize; | |
348 | int maxSenseBytes; | |
349 | int dataSgeOffset; | |
350 | char MF[1]; | |
351 | }; | |
352 | #endif /*}*/ | |
353 | ||
354 | ||
355 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | |
356 | /* | |
357 | * HP Specific IOCTL Defines and Structures | |
358 | */ | |
359 | ||
360 | #define CPQFCTS_IOC_MAGIC 'Z' | |
361 | #define HP_IOC_MAGIC 'Z' | |
362 | #define HP_GETHOSTINFO _IOR(HP_IOC_MAGIC, 20, hp_host_info_t) | |
363 | #define HP_GETHOSTINFO1 _IOR(HP_IOC_MAGIC, 20, hp_host_info_rev0_t) | |
364 | #define HP_GETTARGETINFO _IOR(HP_IOC_MAGIC, 21, hp_target_info_t) | |
365 | ||
366 | /* All HP IOCTLs must include this header | |
367 | */ | |
368 | typedef struct _hp_header { | |
369 | unsigned int iocnum; | |
370 | unsigned int host; | |
371 | unsigned int channel; | |
372 | unsigned int id; | |
373 | unsigned int lun; | |
374 | } hp_header_t; | |
375 | ||
376 | /* | |
377 | * Header: | |
378 | * iocnum required (input) | |
379 | * host ignored | |
380 | * channe ignored | |
381 | * id ignored | |
382 | * lun ignored | |
383 | */ | |
384 | typedef struct _hp_host_info { | |
385 | hp_header_t hdr; | |
386 | u16 vendor; | |
387 | u16 device; | |
388 | u16 subsystem_vendor; | |
389 | u16 subsystem_id; | |
390 | u8 devfn; | |
391 | u8 bus; | |
392 | ushort host_no; /* SCSI Host number, if scsi driver not loaded*/ | |
393 | u8 fw_version[16]; /* string */ | |
394 | u8 serial_number[24]; /* string */ | |
395 | u32 ioc_status; | |
396 | u32 bus_phys_width; | |
397 | u32 base_io_addr; | |
398 | u32 rsvd; | |
399 | unsigned int hard_resets; /* driver initiated resets */ | |
400 | unsigned int soft_resets; /* ioc, external resets */ | |
401 | unsigned int timeouts; /* num timeouts */ | |
402 | } hp_host_info_t; | |
403 | ||
404 | /* replace ulongs with uints, need to preserve backwards | |
405 | * compatibility. | |
406 | */ | |
407 | typedef struct _hp_host_info_rev0 { | |
408 | hp_header_t hdr; | |
409 | u16 vendor; | |
410 | u16 device; | |
411 | u16 subsystem_vendor; | |
412 | u16 subsystem_id; | |
413 | u8 devfn; | |
414 | u8 bus; | |
415 | ushort host_no; /* SCSI Host number, if scsi driver not loaded*/ | |
416 | u8 fw_version[16]; /* string */ | |
417 | u8 serial_number[24]; /* string */ | |
418 | u32 ioc_status; | |
419 | u32 bus_phys_width; | |
420 | u32 base_io_addr; | |
421 | u32 rsvd; | |
422 | unsigned long hard_resets; /* driver initiated resets */ | |
423 | unsigned long soft_resets; /* ioc, external resets */ | |
424 | unsigned long timeouts; /* num timeouts */ | |
425 | } hp_host_info_rev0_t; | |
426 | ||
427 | /* | |
428 | * Header: | |
429 | * iocnum required (input) | |
430 | * host required | |
431 | * channel required (bus number) | |
432 | * id required | |
433 | * lun ignored | |
434 | * | |
435 | * All error values between 0 and 0xFFFF in size. | |
436 | */ | |
437 | typedef struct _hp_target_info { | |
438 | hp_header_t hdr; | |
439 | u32 parity_errors; | |
440 | u32 phase_errors; | |
441 | u32 select_timeouts; | |
442 | u32 message_rejects; | |
443 | u32 negotiated_speed; | |
444 | u8 negotiated_width; | |
445 | u8 rsvd[7]; /* 8 byte alignment */ | |
446 | } hp_target_info_t; | |
447 | ||
448 | #define HP_STATUS_OTHER 1 | |
449 | #define HP_STATUS_OK 2 | |
450 | #define HP_STATUS_FAILED 3 | |
451 | ||
452 | #define HP_BUS_WIDTH_UNK 1 | |
453 | #define HP_BUS_WIDTH_8 2 | |
454 | #define HP_BUS_WIDTH_16 3 | |
455 | #define HP_BUS_WIDTH_32 4 | |
456 | ||
457 | #define HP_DEV_SPEED_ASYNC 2 | |
458 | #define HP_DEV_SPEED_FAST 3 | |
459 | #define HP_DEV_SPEED_ULTRA 4 | |
460 | #define HP_DEV_SPEED_ULTRA2 5 | |
461 | #define HP_DEV_SPEED_ULTRA160 6 | |
462 | #define HP_DEV_SPEED_SCSI1 7 | |
463 | #define HP_DEV_SPEED_ULTRA320 8 | |
464 | ||
465 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | |
466 | ||
467 | ||
468 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | |
469 | ||
470 | #endif | |
471 |