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