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.
9 * This driver would not exist if not for Alan Cox's development
10 * of the linux i2o driver.
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!
16 * (see also mptbase.c)
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)
23 * $Id: mptctl.h,v 1.13 2002/12/03 21:26:33 pdelaney Exp $
25 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
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.
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.
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.
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
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
61 #ifndef MPTCTL_H_INCLUDED
62 #define MPTCTL_H_INCLUDED
63 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
65 #include "linux/version.h"
68 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
72 #define MPT_MISCDEV_BASENAME "mptctl"
73 #define MPT_MISCDEV_PATHNAME "/dev/" MPT_MISCDEV_BASENAME
75 #define MPT_PRODUCT_LENGTH 12
78 * Generic MPT Control IOCTLs and structures
80 #define MPT_MAGIC_NUMBER 'm'
82 #define MPTRWPERF _IOWR(MPT_MAGIC_NUMBER,0,struct mpt_raw_r_w)
84 #define MPTFWDOWNLOAD _IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer)
85 #define MPTCOMMAND _IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command)
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)
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 MPTTARGETINFO _IOWR(MPT_MAGIC_NUMBER,18,struct mpt_ioctl_targetinfo)
95 #define MPTTEST _IOWR(MPT_MAGIC_NUMBER,19,struct mpt_ioctl_test)
96 #define MPTEVENTQUERY _IOWR(MPT_MAGIC_NUMBER,21,struct mpt_ioctl_eventquery)
97 #define MPTEVENTENABLE _IOWR(MPT_MAGIC_NUMBER,22,struct mpt_ioctl_eventenable)
98 #define MPTEVENTREPORT _IOWR(MPT_MAGIC_NUMBER,23,struct mpt_ioctl_eventreport)
99 #define MPTHARDRESET _IOWR(MPT_MAGIC_NUMBER,24,struct mpt_ioctl_diag_reset)
100 #define MPTFWREPLACE _IOWR(MPT_MAGIC_NUMBER,25,struct mpt_ioctl_replace_fw)
103 * SPARC PLATFORM REMARKS:
104 * IOCTL data structures that contain pointers
105 * will have different sizes in the driver and applications
106 * (as the app. will not use 8-byte pointers).
107 * Apps should use MPTFWDOWNLOAD and MPTCOMMAND.
108 * The driver will convert data from
109 * mpt_fw_xfer32 (mpt_ioctl_command32) to mpt_fw_xfer (mpt_ioctl_command)
112 * If data structures change size, must handle as in IOCGETINFO.
115 unsigned int iocnum; /* IOC unit number */
117 void *bufp; /* Pointer to firmware buffer */
120 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
121 struct mpt_fw_xfer32 {
129 * IOCTL header structure.
130 * iocnum - must be defined.
131 * port - must be defined for all IOCTL commands other than MPTIOCINFO
132 * maxDataSize - ignored on MPTCOMMAND commands
133 * - ignored on MPTFWREPLACE commands
134 * - on query commands, reports the maximum number of bytes to be returned
135 * to the host driver (count includes the header).
136 * That is, set to sizeof(struct mpt_ioctl_iocinfo) for fixed sized commands.
137 * Set to sizeof(struct mpt_ioctl_targetinfo) + datasize for variable
138 * sized commands. (MPTTARGETINFO, MPTEVENTREPORT)
140 typedef struct _mpt_ioctl_header {
141 unsigned int iocnum; /* IOC unit number */
142 unsigned int port; /* IOC port number */
143 int maxDataSize; /* Maximum Num. bytes to transfer on read */
147 * Issue a diagnostic reset
149 struct mpt_ioctl_diag_reset {
150 mpt_ioctl_header hdr;
155 * PCI bus/device/function information structure.
157 struct mpt_ioctl_pci_info {
160 unsigned int deviceNumber : 5;
161 unsigned int functionNumber : 3;
162 unsigned int busNumber : 24;
164 unsigned int asUlong;
169 * Adapter Information Page
171 * Data starts at offset 0xC
173 #define MPT_IOCTL_INTERFACE_FC (0x01)
174 #define MPT_IOCTL_INTERFACE_SCSI (0x00)
175 #define MPT_IOCTL_VERSION_LENGTH (32)
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) */
192 struct mpt_ioctl_pci_info pciInfo; /* Added Rev 1 */
195 /* Original structure, must always accept these
196 * IOCTLs. 4 byte pads can occur based on arch with
197 * above structure. Wish to re-align, but cannot.
199 struct mpt_ioctl_iocinfo_rev0 {
200 mpt_ioctl_header hdr;
201 int adapterType; /* SCSI or FCP */
202 int port; /* port number */
203 int pciId; /* PCI Id. */
204 int hwRev; /* hardware revision */
205 int subSystemDevice; /* PCI subsystem Device ID */
206 int subSystemVendor; /* PCI subsystem Vendor ID */
207 int numDevices; /* number of devices */
208 int FWVersion; /* FW Version (integer) */
209 int BIOSVersion; /* BIOS Version (integer) */
210 char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */
217 * Device Information Page
218 * Report the number of, and ids of, all targets
219 * on this IOC. The ids array is a packed structure
220 * of the known targetInfo.
221 * bits 31-24: reserved
226 struct mpt_ioctl_targetinfo {
227 mpt_ioctl_header hdr;
228 int numDevices; /* Num targets on this ioc */
234 * Event reporting IOCTL's. These IOCTL's will
235 * use the following defines:
237 struct mpt_ioctl_eventquery {
238 mpt_ioctl_header hdr;
239 unsigned short eventEntries;
240 unsigned short reserved;
241 unsigned int eventTypes;
244 struct mpt_ioctl_eventenable {
245 mpt_ioctl_header hdr;
246 unsigned int eventTypes;
257 struct mpt_ioctl_eventreport {
258 mpt_ioctl_header hdr;
259 MPT_IOCTL_EVENTS eventData[1];
262 #define MPT_MAX_NAME 32
263 struct mpt_ioctl_test {
264 mpt_ioctl_header hdr;
265 u8 name[MPT_MAX_NAME];
267 u8 product [MPT_PRODUCT_LENGTH];
270 /* Replace the FW image cached in host driver memory
271 * newImageSize - image size in bytes
272 * newImage - first byte of the new image
274 typedef struct mpt_ioctl_replace_fw {
275 mpt_ioctl_header hdr;
278 } mpt_ioctl_replace_fw_t;
280 /* General MPT Pass through data strucutre
283 * timeout - in seconds, command timeout. If 0, set by driver to
285 * replyFrameBufPtr - reply location
286 * dataInBufPtr - destination for read
287 * dataOutBufPtr - data source for write
288 * senseDataPtr - sense data location
289 * maxReplyBytes - maximum number of reply bytes to be sent to app.
290 * dataInSize - num bytes for data transfer in (read)
291 * dataOutSize - num bytes for data transfer out (write)
292 * dataSgeOffset - offset in words from the start of the request message
296 * Remark: Some config pages have bi-directional transfer,
297 * both a read and a write. The basic structure allows for
298 * a bidirectional set up. Normal messages will have one or
299 * both of these buffers NULL.
301 struct mpt_ioctl_command {
302 mpt_ioctl_header hdr;
303 int timeout; /* optional (seconds) */
304 char *replyFrameBufPtr;
317 * SPARC PLATFORM: See earlier remark.
319 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
320 struct mpt_ioctl_command32 {
321 mpt_ioctl_header hdr;
323 u32 replyFrameBufPtr;
337 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
339 * HP Specific IOCTL Defines and Structures
342 #define CPQFCTS_IOC_MAGIC 'Z'
343 #define HP_IOC_MAGIC 'Z'
344 #define HP_GETHOSTINFO _IOR(HP_IOC_MAGIC, 20, hp_host_info_t)
345 #define HP_GETHOSTINFO1 _IOR(HP_IOC_MAGIC, 20, hp_host_info_rev0_t)
346 #define HP_GETTARGETINFO _IOR(HP_IOC_MAGIC, 21, hp_target_info_t)
348 /* All HP IOCTLs must include this header
350 typedef struct _hp_header {
353 unsigned int channel;
360 * iocnum required (input)
366 typedef struct _hp_host_info {
370 u16 subsystem_vendor;
374 ushort host_no; /* SCSI Host number, if scsi driver not loaded*/
375 u8 fw_version[16]; /* string */
376 u8 serial_number[24]; /* string */
381 unsigned int hard_resets; /* driver initiated resets */
382 unsigned int soft_resets; /* ioc, external resets */
383 unsigned int timeouts; /* num timeouts */
386 /* replace ulongs with uints, need to preserve backwards
389 typedef struct _hp_host_info_rev0 {
393 u16 subsystem_vendor;
397 ushort host_no; /* SCSI Host number, if scsi driver not loaded*/
398 u8 fw_version[16]; /* string */
399 u8 serial_number[24]; /* string */
404 unsigned long hard_resets; /* driver initiated resets */
405 unsigned long soft_resets; /* ioc, external resets */
406 unsigned long timeouts; /* num timeouts */
407 } hp_host_info_rev0_t;
411 * iocnum required (input)
413 * channel required (bus number)
417 * All error values between 0 and 0xFFFF in size.
419 typedef struct _hp_target_info {
425 u32 negotiated_speed;
427 u8 rsvd[7]; /* 8 byte alignment */
430 #define HP_STATUS_OTHER 1
431 #define HP_STATUS_OK 2
432 #define HP_STATUS_FAILED 3
434 #define HP_BUS_WIDTH_UNK 1
435 #define HP_BUS_WIDTH_8 2
436 #define HP_BUS_WIDTH_16 3
437 #define HP_BUS_WIDTH_32 4
439 #define HP_DEV_SPEED_ASYNC 2
440 #define HP_DEV_SPEED_FAST 3
441 #define HP_DEV_SPEED_ULTRA 4
442 #define HP_DEV_SPEED_ULTRA2 5
443 #define HP_DEV_SPEED_ULTRA160 6
444 #define HP_DEV_SPEED_SCSI1 7
445 #define HP_DEV_SPEED_ULTRA320 8
447 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
450 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/