Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  linux/drivers/message/fusion/mptioctl.h
0003  *      Fusion MPT misc device (ioctl) driver.
0004  *      For use with PCI chip/adapter(s):
0005  *          LSIFC9xx/LSI409xx Fibre Channel
0006  *      running LSI Fusion MPT (Message Passing Technology) firmware.
0007  *
0008  *  Copyright (c) 1999-2008 LSI Corporation
0009  *  (mailto:DL-MPTFusionLinux@lsi.com)
0010  *
0011  */
0012 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
0013 /*
0014     This program is free software; you can redistribute it and/or modify
0015     it under the terms of the GNU General Public License as published by
0016     the Free Software Foundation; version 2 of the License.
0017 
0018     This program is distributed in the hope that it will be useful,
0019     but WITHOUT ANY WARRANTY; without even the implied warranty of
0020     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0021     GNU General Public License for more details.
0022 
0023     NO WARRANTY
0024     THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
0025     CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
0026     LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
0027     MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
0028     solely responsible for determining the appropriateness of using and
0029     distributing the Program and assumes all risks associated with its
0030     exercise of rights under this Agreement, including but not limited to
0031     the risks and costs of program errors, damage to or loss of data,
0032     programs or equipment, and unavailability or interruption of operations.
0033 
0034     DISCLAIMER OF LIABILITY
0035     NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
0036     DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0037     DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
0038     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
0039     TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
0040     USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
0041     HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
0042 
0043     You should have received a copy of the GNU General Public License
0044     along with this program; if not, write to the Free Software
0045     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0046 */
0047 
0048 #ifndef MPTCTL_H_INCLUDED
0049 #define MPTCTL_H_INCLUDED
0050 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
0051 
0052 
0053 
0054 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
0055 /*
0056  *
0057  */
0058 #define MPT_MISCDEV_BASENAME            "mptctl"
0059 #define MPT_MISCDEV_PATHNAME            "/dev/" MPT_MISCDEV_BASENAME
0060 
0061 #define MPT_PRODUCT_LENGTH              12
0062 
0063 /*
0064  *  Generic MPT Control IOCTLs and structures
0065  */
0066 #define MPT_MAGIC_NUMBER    'm'
0067 
0068 #define MPTRWPERF       _IOWR(MPT_MAGIC_NUMBER,0,struct mpt_raw_r_w)
0069 
0070 #define MPTFWDOWNLOAD       _IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer)
0071 #define MPTCOMMAND      _IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command)
0072 
0073 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
0074 #define MPTFWDOWNLOAD32     _IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer32)
0075 #define MPTCOMMAND32        _IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command32)
0076 #endif
0077 
0078 #define MPTIOCINFO      _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo)
0079 #define MPTIOCINFO1     _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev0)
0080 #define MPTIOCINFO2     _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev1)
0081 #define MPTTARGETINFO       _IOWR(MPT_MAGIC_NUMBER,18,struct mpt_ioctl_targetinfo)
0082 #define MPTTEST         _IOWR(MPT_MAGIC_NUMBER,19,struct mpt_ioctl_test)
0083 #define MPTEVENTQUERY       _IOWR(MPT_MAGIC_NUMBER,21,struct mpt_ioctl_eventquery)
0084 #define MPTEVENTENABLE      _IOWR(MPT_MAGIC_NUMBER,22,struct mpt_ioctl_eventenable)
0085 #define MPTEVENTREPORT      _IOWR(MPT_MAGIC_NUMBER,23,struct mpt_ioctl_eventreport)
0086 #define MPTHARDRESET        _IOWR(MPT_MAGIC_NUMBER,24,struct mpt_ioctl_diag_reset)
0087 #define MPTFWREPLACE        _IOWR(MPT_MAGIC_NUMBER,25,struct mpt_ioctl_replace_fw)
0088 
0089 /*
0090  * SPARC PLATFORM REMARKS:
0091  * IOCTL data structures that contain pointers
0092  * will have different sizes in the driver and applications
0093  * (as the app. will not use 8-byte pointers).
0094  * Apps should use MPTFWDOWNLOAD and MPTCOMMAND.
0095  * The driver will convert data from
0096  * mpt_fw_xfer32 (mpt_ioctl_command32) to mpt_fw_xfer (mpt_ioctl_command)
0097  * internally.
0098  *
0099  * If data structures change size, must handle as in IOCGETINFO.
0100  */
0101 struct mpt_fw_xfer {
0102     unsigned int     iocnum;    /* IOC unit number */
0103     unsigned int     fwlen;
0104     void        __user *bufp;   /* Pointer to firmware buffer */
0105 };
0106 
0107 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
0108 struct mpt_fw_xfer32 {
0109     unsigned int iocnum;
0110     unsigned int fwlen;
0111     u32 bufp;
0112 };
0113 #endif  /*}*/
0114 
0115 /*
0116  *  IOCTL header structure.
0117  *  iocnum - must be defined.
0118  *  port - must be defined for all IOCTL commands other than MPTIOCINFO
0119  *  maxDataSize - ignored on MPTCOMMAND commands
0120  *      - ignored on MPTFWREPLACE commands
0121  *      - on query commands, reports the maximum number of bytes to be returned
0122  *        to the host driver (count includes the header).
0123  *        That is, set to sizeof(struct mpt_ioctl_iocinfo) for fixed sized commands.
0124  *        Set to sizeof(struct mpt_ioctl_targetinfo) + datasize for variable
0125  *          sized commands. (MPTTARGETINFO, MPTEVENTREPORT)
0126  */
0127 typedef struct _mpt_ioctl_header {
0128     unsigned int     iocnum;    /* IOC unit number */
0129     unsigned int     port;      /* IOC port number */
0130     int      maxDataSize;   /* Maximum Num. bytes to transfer on read */
0131 } mpt_ioctl_header;
0132 
0133 /*
0134  * Issue a diagnostic reset
0135  */
0136 struct mpt_ioctl_diag_reset {
0137     mpt_ioctl_header hdr;
0138 };
0139 
0140 
0141 /*
0142  *  PCI bus/device/function information structure.
0143  */
0144 struct mpt_ioctl_pci_info {
0145     union {
0146         struct {
0147             unsigned int  deviceNumber   :  5;
0148             unsigned int  functionNumber :  3;
0149             unsigned int  busNumber      : 24;
0150         } bits;
0151         unsigned int  asUlong;
0152     } u;
0153 };
0154 
0155 struct mpt_ioctl_pci_info2 {
0156     union {
0157         struct {
0158             unsigned int  deviceNumber   :  5;
0159             unsigned int  functionNumber :  3;
0160             unsigned int  busNumber      : 24;
0161         } bits;
0162         unsigned int  asUlong;
0163     } u;
0164   int segmentID;
0165 };
0166 
0167 /*
0168  *  Adapter Information Page
0169  *  Read only.
0170  *  Data starts at offset 0xC
0171  */
0172 #define MPT_IOCTL_INTERFACE_SCSI    (0x00)
0173 #define MPT_IOCTL_INTERFACE_FC      (0x01)
0174 #define MPT_IOCTL_INTERFACE_FC_IP   (0x02)
0175 #define MPT_IOCTL_INTERFACE_SAS     (0x03)
0176 #define MPT_IOCTL_VERSION_LENGTH    (32)
0177 
0178 struct mpt_ioctl_iocinfo {
0179     mpt_ioctl_header hdr;
0180     int      adapterType;   /* SCSI or FCP */
0181     int      port;      /* port number */
0182     int      pciId;     /* PCI Id. */
0183     int      hwRev;     /* hardware revision */
0184     int      subSystemDevice;   /* PCI subsystem Device ID */
0185     int      subSystemVendor;   /* PCI subsystem Vendor ID */
0186     int      numDevices;        /* number of devices */
0187     int      FWVersion;     /* FW Version (integer) */
0188     int      BIOSVersion;       /* BIOS Version (integer) */
0189     char         driverVersion[MPT_IOCTL_VERSION_LENGTH];   /* Driver Version (string) */
0190     char         busChangeEvent;
0191     char         hostId;
0192     char         rsvd[2];
0193     struct mpt_ioctl_pci_info2  pciInfo; /* Added Rev 2 */
0194 };
0195 
0196 struct mpt_ioctl_iocinfo_rev1 {
0197     mpt_ioctl_header hdr;
0198     int      adapterType;   /* SCSI or FCP */
0199     int      port;      /* port number */
0200     int      pciId;     /* PCI Id. */
0201     int      hwRev;     /* hardware revision */
0202     int      subSystemDevice;   /* PCI subsystem Device ID */
0203     int      subSystemVendor;   /* PCI subsystem Vendor ID */
0204     int      numDevices;        /* number of devices */
0205     int      FWVersion;     /* FW Version (integer) */
0206     int      BIOSVersion;       /* BIOS Version (integer) */
0207     char         driverVersion[MPT_IOCTL_VERSION_LENGTH];   /* Driver Version (string) */
0208     char         busChangeEvent;
0209     char         hostId;
0210     char         rsvd[2];
0211     struct mpt_ioctl_pci_info  pciInfo; /* Added Rev 1 */
0212 };
0213 
0214 /* Original structure, must always accept these
0215  * IOCTLs. 4 byte pads can occur based on arch with
0216  * above structure. Wish to re-align, but cannot.
0217  */
0218 struct mpt_ioctl_iocinfo_rev0 {
0219     mpt_ioctl_header hdr;
0220     int      adapterType;   /* SCSI or FCP */
0221     int      port;      /* port number */
0222     int      pciId;     /* PCI Id. */
0223     int      hwRev;     /* hardware revision */
0224     int      subSystemDevice;   /* PCI subsystem Device ID */
0225     int      subSystemVendor;   /* PCI subsystem Vendor ID */
0226     int      numDevices;        /* number of devices */
0227     int      FWVersion;     /* FW Version (integer) */
0228     int      BIOSVersion;       /* BIOS Version (integer) */
0229     char         driverVersion[MPT_IOCTL_VERSION_LENGTH];   /* Driver Version (string) */
0230     char         busChangeEvent;
0231     char         hostId;
0232     char         rsvd[2];
0233 };
0234 
0235 /*
0236  * Device Information Page
0237  * Report the number of, and ids of, all targets
0238  * on this IOC.  The ids array is a packed structure
0239  * of the known targetInfo.
0240  * bits 31-24: reserved
0241  *      23-16: LUN
0242  *      15- 8: Bus Number
0243  *       7- 0: Target ID
0244  */
0245 struct mpt_ioctl_targetinfo {
0246     mpt_ioctl_header hdr;
0247     int      numDevices;    /* Num targets on this ioc */
0248     int      targetInfo[1];
0249 };
0250 
0251 
0252 /*
0253  * Event reporting IOCTL's.  These IOCTL's will
0254  * use the following defines:
0255  */
0256 struct mpt_ioctl_eventquery {
0257     mpt_ioctl_header hdr;
0258     unsigned short   eventEntries;
0259     unsigned short   reserved;
0260     unsigned int     eventTypes;
0261 };
0262 
0263 struct mpt_ioctl_eventenable {
0264     mpt_ioctl_header hdr;
0265     unsigned int     eventTypes;
0266 };
0267 
0268 #ifndef __KERNEL__
0269 typedef struct {
0270     uint    event;
0271     uint    eventContext;
0272     uint    data[2];
0273 } MPT_IOCTL_EVENTS;
0274 #endif
0275 
0276 struct mpt_ioctl_eventreport {
0277     mpt_ioctl_header    hdr;
0278     MPT_IOCTL_EVENTS    eventData[1];
0279 };
0280 
0281 #define MPT_MAX_NAME    32
0282 struct mpt_ioctl_test {
0283     mpt_ioctl_header hdr;
0284     u8       name[MPT_MAX_NAME];
0285     int      chip_type;
0286     u8       product [MPT_PRODUCT_LENGTH];
0287 };
0288 
0289 /* Replace the FW image cached in host driver memory
0290  * newImageSize - image size in bytes
0291  * newImage - first byte of the new image
0292  */
0293 typedef struct mpt_ioctl_replace_fw {
0294     mpt_ioctl_header hdr;
0295     int      newImageSize;
0296     u8       newImage[1];
0297 } mpt_ioctl_replace_fw_t;
0298 
0299 /* General MPT Pass through data strucutre
0300  *
0301  * iocnum
0302  * timeout - in seconds, command timeout. If 0, set by driver to
0303  *      default value.
0304  * replyFrameBufPtr - reply location
0305  * dataInBufPtr - destination for read
0306  * dataOutBufPtr - data source for write
0307  * senseDataPtr - sense data location
0308  * maxReplyBytes - maximum number of reply bytes to be sent to app.
0309  * dataInSize - num bytes for data transfer in (read)
0310  * dataOutSize - num bytes for data transfer out (write)
0311  * dataSgeOffset - offset in words from the start of the request message
0312  *      to the first SGL
0313  * MF[1];
0314  *
0315  * Remark:  Some config pages have bi-directional transfer,
0316  * both a read and a write. The basic structure allows for
0317  * a bidirectional set up. Normal messages will have one or
0318  * both of these buffers NULL.
0319  */
0320 struct mpt_ioctl_command {
0321     mpt_ioctl_header hdr;
0322     int     timeout;    /* optional (seconds) */
0323     char        __user *replyFrameBufPtr;
0324     char        __user *dataInBufPtr;
0325     char        __user *dataOutBufPtr;
0326     char        __user *senseDataPtr;
0327     int     maxReplyBytes;
0328     int     dataInSize;
0329     int     dataOutSize;
0330     int     maxSenseBytes;
0331     int     dataSgeOffset;
0332     char        MF[1];
0333 };
0334 
0335 /*
0336  * SPARC PLATFORM: See earlier remark.
0337  */
0338 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
0339 struct mpt_ioctl_command32 {
0340     mpt_ioctl_header hdr;
0341     int timeout;
0342     u32 replyFrameBufPtr;
0343     u32 dataInBufPtr;
0344     u32 dataOutBufPtr;
0345     u32 senseDataPtr;
0346     int maxReplyBytes;
0347     int dataInSize;
0348     int dataOutSize;
0349     int maxSenseBytes;
0350     int dataSgeOffset;
0351     char    MF[1];
0352 };
0353 #endif  /*}*/
0354 
0355 
0356 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
0357 
0358 #define CPQFCTS_IOC_MAGIC 'Z'
0359 #define HP_IOC_MAGIC 'Z'
0360 #define HP_GETHOSTINFO      _IOR(HP_IOC_MAGIC, 20, hp_host_info_t)
0361 #define HP_GETHOSTINFO1     _IOR(HP_IOC_MAGIC, 20, hp_host_info_rev0_t)
0362 #define HP_GETTARGETINFO    _IOR(HP_IOC_MAGIC, 21, hp_target_info_t)
0363 
0364 typedef struct _hp_header {
0365     unsigned int iocnum;
0366     unsigned int host;
0367     unsigned int channel;
0368     unsigned int id;
0369     unsigned int lun;
0370 } hp_header_t;
0371 
0372 /*
0373  *  Header:
0374  *  iocnum  required (input)
0375  *  host    ignored
0376  *  channe  ignored
0377  *  id      ignored
0378  *  lun     ignored
0379  */
0380 typedef struct _hp_host_info {
0381     hp_header_t  hdr;
0382     u16      vendor;
0383     u16      device;
0384     u16      subsystem_vendor;
0385     u16      subsystem_id;
0386     u8       devfn;
0387     u8       bus;
0388     ushort       host_no;       /* SCSI Host number, if scsi driver not loaded*/
0389     u8       fw_version[16];    /* string */
0390     u8       serial_number[24]; /* string */
0391     u32      ioc_status;
0392     u32      bus_phys_width;
0393     u32      base_io_addr;
0394     u32      rsvd;
0395     unsigned int     hard_resets;       /* driver initiated resets */
0396     unsigned int     soft_resets;       /* ioc, external resets */
0397     unsigned int     timeouts;      /* num timeouts */
0398 } hp_host_info_t;
0399 
0400 /* replace ulongs with uints, need to preserve backwards
0401  * compatibility.
0402  */
0403 typedef struct _hp_host_info_rev0 {
0404     hp_header_t  hdr;
0405     u16      vendor;
0406     u16      device;
0407     u16      subsystem_vendor;
0408     u16      subsystem_id;
0409     u8       devfn;
0410     u8       bus;
0411     ushort       host_no;       /* SCSI Host number, if scsi driver not loaded*/
0412     u8       fw_version[16];    /* string */
0413     u8       serial_number[24]; /* string */
0414     u32      ioc_status;
0415     u32      bus_phys_width;
0416     u32      base_io_addr;
0417     u32      rsvd;
0418     unsigned long    hard_resets;       /* driver initiated resets */
0419     unsigned long    soft_resets;       /* ioc, external resets */
0420     unsigned long    timeouts;      /* num timeouts */
0421 } hp_host_info_rev0_t;
0422 
0423 /*
0424  *  Header:
0425  *  iocnum  required (input)
0426  *  host    required
0427  *  channel required    (bus number)
0428  *  id      required
0429  *  lun     ignored
0430  *
0431  *  All error values between 0 and 0xFFFF in size.
0432  */
0433 typedef struct _hp_target_info {
0434     hp_header_t  hdr;
0435     u32 parity_errors;
0436     u32 phase_errors;
0437     u32 select_timeouts;
0438     u32 message_rejects;
0439     u32 negotiated_speed;
0440     u8  negotiated_width;
0441     u8  rsvd[7];                /* 8 byte alignment */
0442 } hp_target_info_t;
0443 
0444 #define HP_STATUS_OTHER     1
0445 #define HP_STATUS_OK        2
0446 #define HP_STATUS_FAILED    3
0447 
0448 #define HP_BUS_WIDTH_UNK    1
0449 #define HP_BUS_WIDTH_8      2
0450 #define HP_BUS_WIDTH_16     3
0451 #define HP_BUS_WIDTH_32     4
0452 
0453 #define HP_DEV_SPEED_ASYNC  2
0454 #define HP_DEV_SPEED_FAST   3
0455 #define HP_DEV_SPEED_ULTRA  4
0456 #define HP_DEV_SPEED_ULTRA2 5
0457 #define HP_DEV_SPEED_ULTRA160   6
0458 #define HP_DEV_SPEED_SCSI1  7
0459 #define HP_DEV_SPEED_ULTRA320   8
0460 
0461 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
0462 
0463 
0464 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
0465 
0466 #endif
0467