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-2002 LSI Logic Corporation 19 * Originally By: Steven J. Ralston 20 * (mailto:sjralston1@netscape.net) 21 * (mailto:Pam.Delaney@lsil.com) 22 * 23 * $Id: mptctl.h,v 1.1.1.1 2008/10/15 03:26:34 james26_jang 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(__sparc__) && defined(__sparc_v9__) /*{*/ 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 MPTTARGETINFO _IOWR(MPT_MAGIC_NUMBER,18,struct mpt_ioctl_targetinfo) 94#define MPTTEST _IOWR(MPT_MAGIC_NUMBER,19,struct mpt_ioctl_test) 95#define MPTEVENTQUERY _IOWR(MPT_MAGIC_NUMBER,21,struct mpt_ioctl_eventquery) 96#define MPTEVENTENABLE _IOWR(MPT_MAGIC_NUMBER,22,struct mpt_ioctl_eventenable) 97#define MPTEVENTREPORT _IOWR(MPT_MAGIC_NUMBER,23,struct mpt_ioctl_eventreport) 98#define MPTHARDRESET _IOWR(MPT_MAGIC_NUMBER,24,struct mpt_ioctl_diag_reset) 99#define MPTFWREPLACE _IOWR(MPT_MAGIC_NUMBER,25,struct mpt_ioctl_replace_fw) 100 101/* 102 * SPARC PLATFORM REMARK: 103 * IOCTL data structures that contain pointers 104 * will have different sizes in the driver and applications 105 * (as the app. will not use 8-byte pointers). 106 * Apps should use MPTFWDOWNLOAD and MPTCOMMAND. 107 * The driver will convert data from 108 * mpt_fw_xfer32 (mpt_ioctl_command32) to mpt_fw_xfer (mpt_ioctl_command) 109 * internally. 110 */ 111struct mpt_fw_xfer { 112 unsigned int iocnum; /* IOC unit number */ 113 unsigned int fwlen; 114 void *bufp; /* Pointer to firmware buffer */ 115}; 116 117#if defined(__KERNEL__) && defined(__sparc__) && defined(__sparc_v9__) /*{*/ 118struct mpt_fw_xfer32 { 119 unsigned int iocnum; 120 unsigned int fwlen; 121 u32 bufp; 122}; 123#endif /*}*/ 124 125/* 126 * IOCTL header structure. 127 * iocnum - must be defined. 128 * port - must be defined for all IOCTL commands other than MPTIOCINFO 129 * maxDataSize - ignored on MPTCOMMAND commands 130 * - ignored on MPTFWREPLACE commands 131 * - on query commands, reports the maximum number of bytes to be returned 132 * to the host driver (count includes the header). 133 * That is, set to sizeof(struct mpt_ioctl_iocinfo) for fixed sized commands. 134 * Set to sizeof(struct mpt_ioctl_targetinfo) + datasize for variable 135 * sized commands. (MPTTARGETINFO, MPTEVENTREPORT) 136 */ 137typedef struct _mpt_ioctl_header { 138 unsigned int iocnum; /* IOC unit number */ 139 unsigned int port; /* IOC port number */ 140 int maxDataSize; /* Maximum Num. bytes to transfer on read */ 141} mpt_ioctl_header; 142 143/* 144 * Issue a diagnostic reset 145 */ 146struct mpt_ioctl_diag_reset { 147 mpt_ioctl_header hdr; 148}; 149 150 151/* 152 * PCI bus/device/function information structure. 153 */ 154struct mpt_ioctl_pci_info { 155 union { 156 struct { 157 unsigned long deviceNumber : 5; 158 unsigned long functionNumber : 3; 159 unsigned long busNumber : 24; 160 } bits; 161 unsigned long asUlong; 162 } u; 163}; 164 165/* 166 * Adapter Information Page 167 * Read only. 168 * Data starts at offset 0xC 169 */ 170#define MPT_IOCTL_INTERFACE_FC (0x01) 171#define MPT_IOCTL_INTERFACE_SCSI (0x00) 172#define MPT_IOCTL_VERSION_LENGTH (32) 173 174struct mpt_ioctl_iocinfo { 175 mpt_ioctl_header hdr; 176 int adapterType; /* SCSI or FCP */ 177 int port; /* port number */ 178 int pciId; /* PCI Id. */ 179 int hwRev; /* hardware revision */ 180 int subSystemDevice; /* PCI subsystem Device ID */ 181 int subSystemVendor; /* PCI subsystem Vendor ID */ 182 int numDevices; /* number of devices */ 183 int FWVersion; /* FW Version (integer) */ 184 int BIOSVersion; /* BIOS Version (integer) */ 185 char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */ 186 char busChangeEvent; 187 char hostId; 188 char rsvd[2]; 189 struct mpt_ioctl_pci_info pciInfo; /* Added Rev 1 */ 190}; 191 192/* 193 * Device Information Page 194 * Report the number of, and ids of, all targets 195 * on this IOC. The ids array is a packed structure 196 * of the known targetInfo. 197 * bits 31-24: reserved 198 * 23-16: LUN 199 * 15- 8: Bus Number 200 * 7- 0: Target ID 201 */ 202struct mpt_ioctl_targetinfo { 203 mpt_ioctl_header hdr; 204 int numDevices; /* Num targets on this ioc */ 205 int targetInfo[1]; 206}; 207 208 209/* 210 * Event reporting IOCTL's. These IOCTL's will 211 * use the following defines: 212 */ 213struct mpt_ioctl_eventquery { 214 mpt_ioctl_header hdr; 215 unsigned short eventEntries; 216 unsigned short reserved; 217 unsigned int eventTypes; 218}; 219 220struct mpt_ioctl_eventenable { 221 mpt_ioctl_header hdr; 222 unsigned int eventTypes; 223}; 224 225#ifndef __KERNEL__ 226typedef struct { 227 uint event; 228 uint eventContext; 229 uint data[2]; 230} MPT_IOCTL_EVENTS; 231#endif 232 233struct mpt_ioctl_eventreport { 234 mpt_ioctl_header hdr; 235 MPT_IOCTL_EVENTS eventData[1]; 236}; 237 238#define MPT_MAX_NAME 32 239struct mpt_ioctl_test { 240 mpt_ioctl_header hdr; 241 u8 name[MPT_MAX_NAME]; 242 int chip_type; 243 u8 product [MPT_PRODUCT_LENGTH]; 244}; 245 246/* Replace the FW image cached in host driver memory 247 * newImageSize - image size in bytes 248 * newImage - first byte of the new image 249 */ 250typedef struct mpt_ioctl_replace_fw { 251 mpt_ioctl_header hdr; 252 int newImageSize; 253 u8 newImage[1]; 254} mpt_ioctl_replace_fw_t; 255 256/* General MPT Pass through data strucutre 257 * 258 * iocnum 259 * timeout - in seconds, command timeout. If 0, set by driver to 260 * default value. 261 * replyFrameBufPtr - reply location 262 * dataInBufPtr - destination for read 263 * dataOutBufPtr - data source for write 264 * senseDataPtr - sense data location 265 * maxReplyBytes - maximum number of reply bytes to be sent to app. 266 * dataInSize - num bytes for data transfer in (read) 267 * dataOutSize - num bytes for data transfer out (write) 268 * dataSgeOffset - offset in words from the start of the request message 269 * to the first SGL 270 * MF[1]; 271 * 272 * Remark: Some config pages have bi-directional transfer, 273 * both a read and a write. The basic structure allows for 274 * a bidirectional set up. Normal messages will have one or 275 * both of these buffers NULL. 276 */ 277struct mpt_ioctl_command { 278 mpt_ioctl_header hdr; 279 int timeout; /* optional (seconds) */ 280 char *replyFrameBufPtr; 281 char *dataInBufPtr; 282 char *dataOutBufPtr; 283 char *senseDataPtr; 284 int maxReplyBytes; 285 int dataInSize; 286 int dataOutSize; 287 int maxSenseBytes; 288 int dataSgeOffset; 289 char MF[1]; 290}; 291 292/* 293 * SPARC PLATFORM: See earlier remark. 294 */ 295#if defined(__KERNEL__) && defined(__sparc__) && defined(__sparc_v9__) /*{*/ 296struct mpt_ioctl_command32 { 297 mpt_ioctl_header hdr; 298 int timeout; 299 u32 replyFrameBufPtr; 300 u32 dataInBufPtr; 301 u32 dataOutBufPtr; 302 u32 senseDataPtr; 303 int maxReplyBytes; 304 int dataInSize; 305 int dataOutSize; 306 int maxSenseBytes; 307 int dataSgeOffset; 308 char MF[1]; 309}; 310#endif /*}*/ 311 312 313 314/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 315 /* 316 * COMPAQ Specific IOCTL Defines and Structures 317 */ 318 319#define CPQFCTS_IOC_MAGIC 'Z' 320 321#define CPQFCTS_GETPCIINFO _IOR(CPQFCTS_IOC_MAGIC, 1, cpqfc_pci_info_struct) 322#define CPQFCTS_GETDRIVER _IOR(CPQFCTS_IOC_MAGIC, 2, int) 323#define CPQFCTS_CTLR_STATUS _IOR(CPQFCTS_IOC_MAGIC, 3, struct _cpqfc_ctlr_status) 324#define CPQFCTS_SCSI_IOCTL_FC_TARGET_ADDRESS _IOR(CPQFCTS_IOC_MAGIC, 4, struct scsi_fctargaddress) 325#define CPQFCTS_SCSI_PASSTHRU _IOWR(CPQFCTS_IOC_MAGIC, 5, VENDOR_IOCTL_REQ) 326#if defined(__sparc__) && defined(__sparc_v9__) 327#define CPQFCTS_SCSI_PASSTHRU32 _IOWR(CPQFCTS_IOC_MAGIC, 5, VENDOR_IOCTL_REQ32) 328#endif 329 330typedef struct { 331 unsigned short bus; 332 unsigned short bus_type; 333 unsigned short device_fn; 334 u32 board_id; 335 u32 slot_number; 336 unsigned short vendor_id; 337 unsigned short device_id; 338 unsigned short class_code; 339 unsigned short sub_vendor_id; 340 unsigned short sub_device_id; 341 u8 serial_number[81]; 342} cpqfc_pci_info_struct; 343 344 345typedef struct scsi_fctargaddress { 346 unsigned int host_port_id; 347 u8 host_wwn[8]; /* WW Network Name */ 348} Scsi_FCTargAddress; 349 350typedef struct _cpqfc_ctlr_status { 351 u32 status; 352 u32 offline_reason; 353} cpqfc_ctlr_status; 354 355 356/* Compaq SCSI I/O Passthru structures. 357 */ 358#define MPT_COMPAQ_READ 0x26 359#define MPT_COMPAQ_WRITE 0x27 360 361typedef struct { 362 int lc; /* controller number */ 363 int node; /* node number */ 364 int ld; /* target logical id */ 365 u32 nexus; 366 void *argp; 367} VENDOR_IOCTL_REQ; 368 369#if defined(__KERNEL__) && defined(__sparc__) && defined(__sparc_v9__) /*{*/ 370typedef struct { 371 int lc; /* controller number */ 372 int node; /* node number */ 373 int ld; /* target logical id */ 374 u32 nexus; 375 u32 argp; 376} VENDOR_IOCTL_REQ32; 377#endif 378 379typedef struct { 380 char cdb[16]; /* cdb */ 381 unsigned short bus; /* bus number */ 382 unsigned short pdrive; /* physical drive */ 383 int len; /* data area size */ 384 int sense_len; /* sense size */ 385 char sense_data[40]; /* sense buffer */ 386 void *bufp; /* data buffer pointer */ 387 char rw_flag; 388} cpqfc_passthru_t; 389 390#if defined(__KERNEL__) && defined(__sparc__) && defined(__sparc_v9__) /*{*/ 391typedef struct { 392 char cdb[16]; /* cdb */ 393 unsigned short bus; /* bus number */ 394 unsigned short pdrive; /* physical drive */ 395 int len; /* data area size */ 396 int sense_len; /* sense size */ 397 char sense_data[40]; /* sense buffer */ 398 u32 bufp; /* data buffer pointer */ 399 char rw_flag; 400} cpqfc_passthru32_t; 401#endif 402 403/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 404 405 406/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 407 408#endif 409 410