1 /*- 2 * Copyright (c) 2001 Michael Smith 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: src/sys/dev/ciss/cissio.h,v 1.1.2.1 2001/12/12 06:38:16 ps Exp $ 27 * $DragonFly: src/sys/dev/raid/ciss/cissio.h,v 1.2 2003/06/17 04:28:23 dillon Exp $ 28 */ 29 30 /* 31 * Driver ioctl interface. 32 * 33 * Note that this interface is API-compatible with the Linux implementation 34 * except as noted, and thus this header bears a striking resemblance to 35 * the Linux driver's cciss_ioctl.h. 36 * 37 */ 38 39 #include <sys/ioccom.h> 40 41 #pragma pack(1) 42 43 typedef struct 44 { 45 u_int8_t bus; 46 u_int8_t dev_fn; 47 u_int32_t board_id; 48 } cciss_pci_info_struct; 49 50 typedef struct 51 { 52 u_int32_t delay; 53 u_int32_t count; 54 } cciss_coalint_struct; 55 56 typedef char NodeName_type[16]; 57 typedef u_int32_t Heartbeat_type; 58 59 #define CISS_PARSCSIU2 0x0001 60 #define CISS_PARCSCIU3 0x0002 61 #define CISS_FIBRE1G 0x0100 62 #define CISS_FIBRE2G 0x0200 63 typedef u_int32_t BusTypes_type; 64 65 typedef char FirmwareVer_type[4]; 66 typedef u_int32_t DriverVer_type; 67 68 /* passthrough command definitions */ 69 #define SENSEINFOBYTES 32 70 #define CISS_MAX_LUN 16 71 #define LEVEL2LUN 1 72 #define LEVEL3LUN 0 73 74 /* command status value */ 75 #define CMD_SUCCESS 0x0000 76 #define CMD_TARGET_STATUS 0x0001 77 #define CMD_DATA_UNDERRUN 0x0002 78 #define CMD_DATA_OVERRUN 0x0003 79 #define CMD_INVALID 0x0004 80 #define CMD_PROTOCOL_ERR 0x0005 81 #define CMD_HARDWARE_ERR 0x0006 82 #define CMD_CONNECTION_LOST 0x0007 83 #define CMD_ABORTED 0x0008 84 #define CMD_ABORT_FAILED 0x0009 85 #define CMD_UNSOLICITED_ABORT 0x000A 86 #define CMD_TIMEOUT 0x000B 87 #define CMD_UNABORTABLE 0x000C 88 89 /* transfer direction */ 90 #define XFER_NONE 0x00 91 #define XFER_WRITE 0x01 92 #define XFER_READ 0x02 93 #define XFER_RSVD 0x03 94 95 /* task attribute */ 96 #define ATTR_UNTAGGED 0x00 97 #define ATTR_SIMPLE 0x04 98 #define ATTR_HEADOFQUEUE 0x05 99 #define ATTR_ORDERED 0x06 100 #define ATTR_ACA 0x07 101 102 /* CDB type */ 103 #define TYPE_CMD 0x00 104 #define TYPE_MSG 0x01 105 106 /* command list structure */ 107 typedef union { 108 struct { 109 u_int8_t Dev; 110 u_int8_t Bus:6; 111 u_int8_t Mode:2; 112 } PeripDev __attribute__ ((__packed__)); 113 struct { 114 u_int8_t DevLSB; 115 u_int8_t DevMSB:6; 116 u_int8_t Mode:2; 117 } LogDev __attribute__ ((__packed__)); 118 struct { 119 u_int8_t Dev:5; 120 u_int8_t Bus:3; 121 u_int8_t Targ:6; 122 u_int8_t Mode:2; 123 } LogUnit __attribute__ ((__packed__)); 124 } SCSI3Addr_struct; 125 126 typedef struct { 127 u_int32_t TargetId:24; 128 u_int32_t Bus:6; 129 u_int32_t Mode:2; 130 SCSI3Addr_struct Target[2]; 131 } PhysDevAddr_struct __attribute__ ((__packed__)); 132 133 typedef struct { 134 u_int32_t VolId:30; 135 u_int32_t Mode:2; 136 u_int8_t reserved[4]; 137 } LogDevAddr_struct __attribute__ ((__packed__)); 138 139 typedef union { 140 u_int8_t LunAddrBytes[8]; 141 SCSI3Addr_struct SCSI3Lun[4]; 142 PhysDevAddr_struct PhysDev; 143 LogDevAddr_struct LogDev; 144 } LUNAddr_struct __attribute__ ((__packed__)); 145 146 typedef struct { 147 u_int8_t CDBLen; 148 struct { 149 u_int8_t Type:3; 150 u_int8_t Attribute:3; 151 u_int8_t Direction:2; 152 } Type __attribute__ ((__packed__)); 153 u_int16_t Timeout; 154 u_int8_t CDB[16]; 155 } RequestBlock_struct __attribute__ ((__packed__)); 156 157 typedef union { 158 struct { 159 u_int8_t Reserved[3]; 160 u_int8_t Type; 161 u_int32_t ErrorInfo; 162 } Common_Info __attribute__ ((__packed__)); 163 struct { 164 u_int8_t Reserved[2]; 165 u_int8_t offense_size; 166 u_int8_t offense_num; 167 u_int32_t offense_value; 168 } Invalid_Cmd __attribute__ ((__packed__)); 169 } MoreErrInfo_struct __attribute__ ((__packed__)); 170 171 typedef struct { 172 u_int8_t ScsiStatus; 173 u_int8_t SenseLen; 174 u_int16_t CommandStatus; 175 u_int32_t ResidualCnt; 176 MoreErrInfo_struct MoreErrInfo; 177 u_int8_t SenseInfo[SENSEINFOBYTES]; 178 } ErrorInfo_struct __attribute__ ((__packed__)); 179 180 typedef struct { 181 LUNAddr_struct LUN_info; /* 8 */ 182 RequestBlock_struct Request; /* 20 */ 183 ErrorInfo_struct error_info; /* 48 */ 184 u_int16_t buf_size; /* 2 */ 185 u_int8_t *buf; /* 4 */ 186 } IOCTL_Command_struct __attribute__ ((__packed__)); 187 188 /* 189 * Note that we'd normally pass the struct in directly, but 190 * this code is trying to be compatible with other drivers. 191 */ 192 #define CCISS_GETPCIINFO _IOR ('C', 200, cciss_pci_info_struct) 193 #define CCISS_GETINTINFO _IOR ('C', 201, cciss_coalint_struct) 194 #define CCISS_SETINTINFO _IOW ('C', 202, cciss_coalint_struct) 195 #define CCISS_GETNODENAME _IOR ('C', 203, NodeName_type) 196 #define CCISS_SETNODENAME _IOW ('C', 204, NodeName_type) 197 #define CCISS_GETHEARTBEAT _IOR ('C', 205, Heartbeat_type) 198 #define CCISS_GETBUSTYPES _IOR ('C', 206, BusTypes_type) 199 #define CCISS_GETFIRMVER _IOR ('C', 207, FirmwareVer_type) 200 #define CCISS_GETDRIVERVER _IOR ('C', 208, DriverVer_type) 201 #define CCISS_REVALIDVOLS _IO ('C', 209) 202 #define CCISS_PASSTHRU _IOWR ('C', 210, IOCTL_Command_struct) 203 204 #pragma pack() 205