/*1* linux/drivers/message/fusion/mptioctl.h2* Fusion MPT misc device (ioctl) driver.3* For use with PCI chip/adapter(s):4* LSIFC9xx/LSI409xx Fibre Channel5* running LSI Fusion MPT (Message Passing Technology) firmware.6*7* Copyright (c) 1999-2008 LSI Corporation8* (mailto:[email protected])9*10*/11/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/12/*13This program is free software; you can redistribute it and/or modify14it under the terms of the GNU General Public License as published by15the Free Software Foundation; version 2 of the License.1617This program is distributed in the hope that it will be useful,18but WITHOUT ANY WARRANTY; without even the implied warranty of19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20GNU General Public License for more details.2122NO WARRANTY23THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR24CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT25LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,26MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is27solely responsible for determining the appropriateness of using and28distributing the Program and assumes all risks associated with its29exercise of rights under this Agreement, including but not limited to30the risks and costs of program errors, damage to or loss of data,31programs or equipment, and unavailability or interruption of operations.3233DISCLAIMER OF LIABILITY34NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY35DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL36DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND37ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR38TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE39USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED40HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES4142You should have received a copy of the GNU General Public License43along with this program; if not, write to the Free Software44Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA45*/4647#ifndef MPTCTL_H_INCLUDED48#define MPTCTL_H_INCLUDED49/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/50515253/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/54/*55*56*/57#define MPT_MISCDEV_BASENAME "mptctl"58#define MPT_MISCDEV_PATHNAME "/dev/" MPT_MISCDEV_BASENAME5960#define MPT_PRODUCT_LENGTH 126162/*63* Generic MPT Control IOCTLs and structures64*/65#define MPT_MAGIC_NUMBER 'm'6667#define MPTRWPERF _IOWR(MPT_MAGIC_NUMBER,0,struct mpt_raw_r_w)6869#define MPTFWDOWNLOAD _IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer)70#define MPTCOMMAND _IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command)7172#if defined(__KERNEL__) && defined(CONFIG_COMPAT)73#define MPTFWDOWNLOAD32 _IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer32)74#define MPTCOMMAND32 _IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command32)75#endif7677#define MPTIOCINFO _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo)78#define MPTIOCINFO1 _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev0)79#define MPTIOCINFO2 _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev1)80#define MPTTARGETINFO _IOWR(MPT_MAGIC_NUMBER,18,struct mpt_ioctl_targetinfo)81#define MPTTEST _IOWR(MPT_MAGIC_NUMBER,19,struct mpt_ioctl_test)82#define MPTEVENTQUERY _IOWR(MPT_MAGIC_NUMBER,21,struct mpt_ioctl_eventquery)83#define MPTEVENTENABLE _IOWR(MPT_MAGIC_NUMBER,22,struct mpt_ioctl_eventenable)84#define MPTEVENTREPORT _IOWR(MPT_MAGIC_NUMBER,23,struct mpt_ioctl_eventreport)85#define MPTHARDRESET _IOWR(MPT_MAGIC_NUMBER,24,struct mpt_ioctl_diag_reset)86#define MPTFWREPLACE _IOWR(MPT_MAGIC_NUMBER,25,struct mpt_ioctl_replace_fw)8788/*89* SPARC PLATFORM REMARKS:90* IOCTL data structures that contain pointers91* will have different sizes in the driver and applications92* (as the app. will not use 8-byte pointers).93* Apps should use MPTFWDOWNLOAD and MPTCOMMAND.94* The driver will convert data from95* mpt_fw_xfer32 (mpt_ioctl_command32) to mpt_fw_xfer (mpt_ioctl_command)96* internally.97*98* If data structures change size, must handle as in IOCGETINFO.99*/100struct mpt_fw_xfer {101unsigned int iocnum; /* IOC unit number */102unsigned int fwlen;103void __user *bufp; /* Pointer to firmware buffer */104};105106#if defined(__KERNEL__) && defined(CONFIG_COMPAT)107struct mpt_fw_xfer32 {108unsigned int iocnum;109unsigned int fwlen;110u32 bufp;111};112#endif /*}*/113114/*115* IOCTL header structure.116* iocnum - must be defined.117* port - must be defined for all IOCTL commands other than MPTIOCINFO118* maxDataSize - ignored on MPTCOMMAND commands119* - ignored on MPTFWREPLACE commands120* - on query commands, reports the maximum number of bytes to be returned121* to the host driver (count includes the header).122* That is, set to sizeof(struct mpt_ioctl_iocinfo) for fixed sized commands.123* Set to sizeof(struct mpt_ioctl_targetinfo) + datasize for variable124* sized commands. (MPTTARGETINFO, MPTEVENTREPORT)125*/126typedef struct _mpt_ioctl_header {127unsigned int iocnum; /* IOC unit number */128unsigned int port; /* IOC port number */129int maxDataSize; /* Maximum Num. bytes to transfer on read */130} mpt_ioctl_header;131132/*133* Issue a diagnostic reset134*/135struct mpt_ioctl_diag_reset {136mpt_ioctl_header hdr;137};138139140/*141* PCI bus/device/function information structure.142*/143struct mpt_ioctl_pci_info {144union {145struct {146unsigned int deviceNumber : 5;147unsigned int functionNumber : 3;148unsigned int busNumber : 24;149} bits;150unsigned int asUlong;151} u;152};153154struct mpt_ioctl_pci_info2 {155union {156struct {157unsigned int deviceNumber : 5;158unsigned int functionNumber : 3;159unsigned int busNumber : 24;160} bits;161unsigned int asUlong;162} u;163int segmentID;164};165166/*167* Adapter Information Page168* Read only.169* Data starts at offset 0xC170*/171#define MPT_IOCTL_INTERFACE_SCSI (0x00)172#define MPT_IOCTL_INTERFACE_FC (0x01)173#define MPT_IOCTL_INTERFACE_FC_IP (0x02)174#define MPT_IOCTL_INTERFACE_SAS (0x03)175#define MPT_IOCTL_VERSION_LENGTH (32)176177struct mpt_ioctl_iocinfo {178mpt_ioctl_header hdr;179int adapterType; /* SCSI or FCP */180int port; /* port number */181int pciId; /* PCI Id. */182int hwRev; /* hardware revision */183int subSystemDevice; /* PCI subsystem Device ID */184int subSystemVendor; /* PCI subsystem Vendor ID */185int numDevices; /* number of devices */186int FWVersion; /* FW Version (integer) */187int BIOSVersion; /* BIOS Version (integer) */188char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */189char busChangeEvent;190char hostId;191char rsvd[2];192struct mpt_ioctl_pci_info2 pciInfo; /* Added Rev 2 */193};194195struct mpt_ioctl_iocinfo_rev1 {196mpt_ioctl_header hdr;197int adapterType; /* SCSI or FCP */198int port; /* port number */199int pciId; /* PCI Id. */200int hwRev; /* hardware revision */201int subSystemDevice; /* PCI subsystem Device ID */202int subSystemVendor; /* PCI subsystem Vendor ID */203int numDevices; /* number of devices */204int FWVersion; /* FW Version (integer) */205int BIOSVersion; /* BIOS Version (integer) */206char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */207char busChangeEvent;208char hostId;209char rsvd[2];210struct mpt_ioctl_pci_info pciInfo; /* Added Rev 1 */211};212213/* Original structure, must always accept these214* IOCTLs. 4 byte pads can occur based on arch with215* above structure. Wish to re-align, but cannot.216*/217struct mpt_ioctl_iocinfo_rev0 {218mpt_ioctl_header hdr;219int adapterType; /* SCSI or FCP */220int port; /* port number */221int pciId; /* PCI Id. */222int hwRev; /* hardware revision */223int subSystemDevice; /* PCI subsystem Device ID */224int subSystemVendor; /* PCI subsystem Vendor ID */225int numDevices; /* number of devices */226int FWVersion; /* FW Version (integer) */227int BIOSVersion; /* BIOS Version (integer) */228char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */229char busChangeEvent;230char hostId;231char rsvd[2];232};233234/*235* Device Information Page236* Report the number of, and ids of, all targets237* on this IOC. The ids array is a packed structure238* of the known targetInfo.239* bits 31-24: reserved240* 23-16: LUN241* 15- 8: Bus Number242* 7- 0: Target ID243*/244struct mpt_ioctl_targetinfo {245mpt_ioctl_header hdr;246int numDevices; /* Num targets on this ioc */247int targetInfo[1];248};249250251/*252* Event reporting IOCTL's. These IOCTL's will253* use the following defines:254*/255struct mpt_ioctl_eventquery {256mpt_ioctl_header hdr;257unsigned short eventEntries;258unsigned short reserved;259unsigned int eventTypes;260};261262struct mpt_ioctl_eventenable {263mpt_ioctl_header hdr;264unsigned int eventTypes;265};266267#ifndef __KERNEL__268typedef struct {269uint event;270uint eventContext;271uint data[2];272} MPT_IOCTL_EVENTS;273#endif274275struct mpt_ioctl_eventreport {276mpt_ioctl_header hdr;277MPT_IOCTL_EVENTS eventData[1];278};279280#define MPT_MAX_NAME 32281struct mpt_ioctl_test {282mpt_ioctl_header hdr;283u8 name[MPT_MAX_NAME];284int chip_type;285u8 product [MPT_PRODUCT_LENGTH];286};287288/* Replace the FW image cached in host driver memory289* newImageSize - image size in bytes290* newImage - first byte of the new image291*/292typedef struct mpt_ioctl_replace_fw {293mpt_ioctl_header hdr;294int newImageSize;295u8 newImage[1];296} mpt_ioctl_replace_fw_t;297298/* General MPT Pass through data strucutre299*300* iocnum301* timeout - in seconds, command timeout. If 0, set by driver to302* default value.303* replyFrameBufPtr - reply location304* dataInBufPtr - destination for read305* dataOutBufPtr - data source for write306* senseDataPtr - sense data location307* 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 message311* to the first SGL312* MF[1];313*314* Remark: Some config pages have bi-directional transfer,315* both a read and a write. The basic structure allows for316* a bidirectional set up. Normal messages will have one or317* both of these buffers NULL.318*/319struct mpt_ioctl_command {320mpt_ioctl_header hdr;321int timeout; /* optional (seconds) */322char __user *replyFrameBufPtr;323char __user *dataInBufPtr;324char __user *dataOutBufPtr;325char __user *senseDataPtr;326int maxReplyBytes;327int dataInSize;328int dataOutSize;329int maxSenseBytes;330int dataSgeOffset;331char MF[1];332};333334/*335* SPARC PLATFORM: See earlier remark.336*/337#if defined(__KERNEL__) && defined(CONFIG_COMPAT)338struct mpt_ioctl_command32 {339mpt_ioctl_header hdr;340int timeout;341u32 replyFrameBufPtr;342u32 dataInBufPtr;343u32 dataOutBufPtr;344u32 senseDataPtr;345int maxReplyBytes;346int dataInSize;347int dataOutSize;348int maxSenseBytes;349int dataSgeOffset;350char MF[1];351};352#endif /*}*/353354355/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/356357#define CPQFCTS_IOC_MAGIC 'Z'358#define HP_IOC_MAGIC 'Z'359#define HP_GETHOSTINFO _IOR(HP_IOC_MAGIC, 20, hp_host_info_t)360#define HP_GETHOSTINFO1 _IOR(HP_IOC_MAGIC, 20, hp_host_info_rev0_t)361#define HP_GETTARGETINFO _IOR(HP_IOC_MAGIC, 21, hp_target_info_t)362363typedef struct _hp_header {364unsigned int iocnum;365unsigned int host;366unsigned int channel;367unsigned int id;368unsigned int lun;369} hp_header_t;370371/*372* Header:373* iocnum required (input)374* host ignored375* channe ignored376* id ignored377* lun ignored378*/379typedef struct _hp_host_info {380hp_header_t hdr;381u16 vendor;382u16 device;383u16 subsystem_vendor;384u16 subsystem_id;385u8 devfn;386u8 bus;387ushort host_no; /* SCSI Host number, if scsi driver not loaded*/388u8 fw_version[16]; /* string */389u8 serial_number[24]; /* string */390u32 ioc_status;391u32 bus_phys_width;392u32 base_io_addr;393u32 rsvd;394unsigned int hard_resets; /* driver initiated resets */395unsigned int soft_resets; /* ioc, external resets */396unsigned int timeouts; /* num timeouts */397} hp_host_info_t;398399/* replace ulongs with uints, need to preserve backwards400* compatibility.401*/402typedef struct _hp_host_info_rev0 {403hp_header_t hdr;404u16 vendor;405u16 device;406u16 subsystem_vendor;407u16 subsystem_id;408u8 devfn;409u8 bus;410ushort host_no; /* SCSI Host number, if scsi driver not loaded*/411u8 fw_version[16]; /* string */412u8 serial_number[24]; /* string */413u32 ioc_status;414u32 bus_phys_width;415u32 base_io_addr;416u32 rsvd;417unsigned long hard_resets; /* driver initiated resets */418unsigned long soft_resets; /* ioc, external resets */419unsigned long timeouts; /* num timeouts */420} hp_host_info_rev0_t;421422/*423* Header:424* iocnum required (input)425* host required426* channel required (bus number)427* id required428* lun ignored429*430* All error values between 0 and 0xFFFF in size.431*/432typedef struct _hp_target_info {433hp_header_t hdr;434u32 parity_errors;435u32 phase_errors;436u32 select_timeouts;437u32 message_rejects;438u32 negotiated_speed;439u8 negotiated_width;440u8 rsvd[7]; /* 8 byte alignment */441} hp_target_info_t;442443#define HP_STATUS_OTHER 1444#define HP_STATUS_OK 2445#define HP_STATUS_FAILED 3446447#define HP_BUS_WIDTH_UNK 1448#define HP_BUS_WIDTH_8 2449#define HP_BUS_WIDTH_16 3450#define HP_BUS_WIDTH_32 4451452#define HP_DEV_SPEED_ASYNC 2453#define HP_DEV_SPEED_FAST 3454#define HP_DEV_SPEED_ULTRA 4455#define HP_DEV_SPEED_ULTRA2 5456#define HP_DEV_SPEED_ULTRA160 6457#define HP_DEV_SPEED_SCSI1 7458#define HP_DEV_SPEED_ULTRA320 8459460/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/461462463/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/464465#endif466467468469