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