1 /* $NetBSD: icpreg.h,v 1.7 2008/09/08 23:36:54 gmcgarry Exp $ */ 2 3 /*- 4 * Copyright (c) 2002 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Andrew Doran. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * Copyright (c) 1999, 2000 Niklas Hallqvist. All rights reserved. 34 * 35 * Redistribution and use in source and binary forms, with or without 36 * modification, are permitted provided that the following conditions 37 * are met: 38 * 1. Redistributions of source code must retain the above copyright 39 * notice, this list of conditions and the following disclaimer. 40 * 2. Redistributions in binary form must reproduce the above copyright 41 * notice, this list of conditions and the following disclaimer in the 42 * documentation and/or other materials provided with the distribution. 43 * 3. All advertising materials mentioning features or use of this software 44 * must display the following acknowledgement: 45 * This product includes software developed by Niklas Hallqvist. 46 * 4. The name of the author may not be used to endorse or promote products 47 * derived from this software without specific prior written permission. 48 * 49 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 50 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 51 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 52 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 53 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 54 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 55 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 56 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 57 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 58 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 * 60 * from OpenBSD: gdtreg.h,v 1.1 2000/02/07 00:33:03 niklas Exp 61 */ 62 63 #ifndef _IC_ICPREG_H_ 64 #define _IC_ICPREG_H_ 65 66 #define ICP_MAXBUS 6 /* XXX Why not 5? */ 67 #define ICP_MAX_LDRIVES 255 /* max logical drive count */ 68 #define ICP_MAX_HDRIVES 100 /* max host drive count */ 69 #define ICP_MAXID_FC 127 /* Fibre-channel maximum ID */ 70 #define ICP_MAXOFFSETS 128 71 #define ICP_MAXSG 17 /* Max. s/g elements; actually 128 */ 72 #define ICP_PROTOCOL_VERSION 1 73 #define ICP_LINUX_OS 8 /* Used for cache optimization */ 74 #define ICP_SCATTER_GATHER 1 /* s/g feature */ 75 #define ICP_SECS32 0x1f /* round capacity */ 76 #define ICP_LOCALBOARD 0 /* Board node always 0 */ 77 #define ICP_MAX_CMDS 124 78 #define ICP_SECTOR_SIZE 0x200 /* Always 512 bytes for cache devs */ 79 #define ICP_MAX_EVENTS 0x100 /* event buffer */ 80 81 /* DPMEM constants */ 82 #define ICP_MPR_MAGIC 0xc0ffee11 83 #define ICP_IC_HEADER_BYTES 48 84 #define ICP_IC_QUEUE_BYTES 4 85 86 /* Cache/raw service commands */ 87 #define ICP_INIT 0 /* service initialization */ 88 #define ICP_READ 1 /* read command */ 89 #define ICP_WRITE 2 /* write command */ 90 #define ICP_INFO 3 /* information about devices */ 91 #define ICP_FLUSH 4 /* flush dirty cache buffers */ 92 #define ICP_IOCTL 5 /* ioctl command */ 93 #define ICP_DEVTYPE 9 /* additional information */ 94 #define ICP_MOUNT 10 /* mount cache device */ 95 #define ICP_UNMOUNT 11 /* unmount cache device */ 96 #define ICP_SET_FEAT 12 /* set features (scatter/gather) */ 97 #define ICP_GET_FEAT 13 /* get features */ 98 #define ICP_WRITE_THR 16 /* write through */ 99 #define ICP_READ_THR 17 /* read through */ 100 #define ICP_EXT_INFO 18 /* extended info */ 101 #define ICP_RESET 19 /* controller reset */ 102 #define ICP_FREEZE_IO 25 /* freeze all IOs */ 103 #define ICP_UNFREEZE_IO 26 /* unfreeze all IOs */ 104 105 /* Additional raw service commands */ 106 #define ICP_RESERVE 14 /* reserve device to raw service */ 107 #define ICP_RELEASE 15 /* release device */ 108 #define ICP_RESERVE_ALL 16 /* reserve all devices */ 109 #define ICP_RELEASE_ALL 17 /* release all devices */ 110 #define ICP_RESET_BUS 18 /* reset bus */ 111 #define ICP_SCAN_START 19 /* start device scan */ 112 #define ICP_SCAN_END 20 /* stop device scan */ 113 114 /* IOCTL command defines */ 115 #define ICP_SCSI_DR_INFO 0x00 /* SCSI drive info */ 116 #define ICP_SCSI_CHAN_CNT 0x05 /* SCSI channel count */ 117 #define ICP_SCSI_DR_LIST 0x06 /* SCSI drive list */ 118 #define ICP_SCSI_DEF_CNT 0x15 /* grown/primary defects */ 119 #define ICP_DSK_STATISTICS 0x4b /* SCSI disk statistics */ 120 #define ICP_IOCHAN_DESC 0x5d /* description of IO channel */ 121 #define ICP_IOCHAN_RAW_DESC 0x5e /* description of raw IO channel */ 122 123 #define ICP_L_CTRL_PATTERN 0x20000000 /* SCSI IOCTL mask */ 124 #define ICP_ARRAY_INFO 0x12 /* array drive info */ 125 #define ICP_ARRAY_DRV_LIST 0x0f /* array drive list */ 126 #define ICP_LA_CTRL_PATTERN 0x10000000 /* array IOCTL mask */ 127 #define ICP_CACHE_DRV_CNT 0x01 /* cache drive count */ 128 #define ICP_CACHE_DRV_LIST 0x02 /* cache drive list */ 129 #define ICP_CACHE_INFO 0x04 /* cache info */ 130 #define ICP_CACHE_CONFIG 0x05 /* cache configuration */ 131 #define ICP_CACHE_DRV_INFO 0x07 /* cache drive info */ 132 #define ICP_BOARD_FEATURES 0x15 /* controller features */ 133 #define ICP_BOARD_INFO 0x28 /* controller info */ 134 #define ICP_HOST_GET 0x10001 /* get host drive list */ 135 #define ICP_IO_CHANNEL 0x20000 /* default IO channel */ 136 #define ICP_INVALID_CHANNEL 0xffff /* invalid channel */ 137 138 /* Service errors */ 139 #define ICP_S_MSG_REQUEST 0 /* screen service: async evt message */ 140 #define ICP_S_OK 1 /* no error */ 141 #define ICP_S_BSY 7 /* controller busy */ 142 #define ICP_S_RAW_SCSI 12 /* raw service: target error */ 143 #define ICP_S_RAW_ILL 0xff /* raw service: illegal */ 144 #define ICP_S_NO_STATUS 0x1000 /* got no status (driver-generated) */ 145 146 /* Controller services */ 147 #define ICP_SCSIRAWSERVICE 3 148 #define ICP_CACHESERVICE 9 149 #define ICP_SCREENSERVICE 11 150 151 /* Data direction raw service. */ 152 #define ICP_DATA_IN 0x01000000 153 #define ICP_DATA_OUT 0x00000000 154 155 /* Command queue entries */ 156 #define ICP_OFFSET 0x00 /* u_int16_t, command offset in the DP RAM */ 157 #define ICP_SERV_ID 0x02 /* u_int16_t, service */ 158 #define ICP_COMM_Q_SZ 0x04 159 160 /* Interface area */ 161 #define ICP_S_CMD_INDX 0x00 /* u_int8_t, special command */ 162 #define ICP_S_STATUS 0x01 /* volatile u_int8_t, status special command */ 163 #define ICP_S_INFO 0x04 /* u_int32_t [4], add. info special command */ 164 #define ICP_SEMA0 0x14 /* volatile u_int8_t, command semaphore */ 165 #define ICP_CMD_INDEX 0x18 /* u_int8_t, command number */ 166 #define ICP_STATUS 0x1c /* volatile u_int16_t, command status */ 167 #define ICP_SERVICE 0x1e /* u_int16_t, service (for asynch. events) */ 168 #define ICP_DPR_INFO 0x20 /* u_int32_t [2], additional info */ 169 #define ICP_COMM_QUEUE 0x28 /* command queue */ 170 #define ICP_DPR_CMD (0x30 + ICP_MAXOFFSETS * ICP_COMM_Q_SZ) 171 /* u_int8_t [], commands */ 172 #define ICP_DPR_IF_SZ ICP_DPR_CMD 173 174 /* Get cache info */ 175 #define ICP_CINFO_CPAR 0x00 176 #define ICP_CINFO_CSTAT 0x0c 177 178 /* Other defines */ 179 #define ICP_ASYNCINDEX 0 /* command index asynchronous event */ 180 #define ICP_SPEZINDEX 1 /* command index unknown service */ 181 182 /* I/O channel header */ 183 struct icp_ioc_version { 184 u_int32_t iv_version; /* version (~0: newest) */ 185 u_int8_t iv_listents; /* list entry count */ 186 u_int8_t iv_firstchan; /* first channel number */ 187 u_int8_t iv_lastchan; /* last channel number */ 188 u_int8_t iv_chancount; /* channel count */ 189 u_int32_t iv_listoffset; /* offset of list[0] */ 190 } __packed; 191 192 #define ICP_IOC_NEWEST 0xffffffff 193 194 /* Get I/O channel description */ 195 struct icp_ioc { 196 u_int32_t io_addr; /* channel address */ 197 u_int8_t io_type; /* type (SCSI/FCAL) */ 198 u_int8_t io_localno; /* local number */ 199 u_int16_t io_features; /* channel features */ 200 } __packed; 201 202 /* Get raw I/O channel description */ 203 struct icp_rawioc { 204 u_int8_t ri_procid; /* processor ID */ 205 u_int8_t ri_defect; /* defect? */ 206 u_int16_t ri_padding; 207 } __packed; 208 209 /* Get SCSI channel count */ 210 struct icp_getch { 211 u_int32_t gc_channo; /* channel number */ 212 u_int32_t gc_drivecnt; /* drive count */ 213 u_int8_t gc_scsiid; /* SCSI initiator ID */ 214 u_int8_t gc_scsistate; /* SCSI processor state */ 215 } __packed; 216 217 /* Cache info/config IOCTL structures */ 218 struct icp_cpar { 219 u_int32_t cp_version; /* firmware version */ 220 u_int16_t cp_state; /* cache state (on/off) */ 221 u_int16_t cp_strategy; /* cache strategy */ 222 u_int16_t cp_write_back; /* write back (on/off) */ 223 u_int16_t cp_block_size; /* cache block size */ 224 } __packed; 225 226 struct icp_cstat { 227 u_int32_t cs_size; /* cache size */ 228 u_int32_t cs_readcnt; /* read counter */ 229 u_int32_t cs_writecnt; /* write counter */ 230 u_int32_t cs_trhits; /* track hits */ 231 u_int32_t cs_sechits; /* sector hits */ 232 u_int32_t cs_secmiss; /* sector misses */ 233 } __packed; 234 235 /* Board information. */ 236 struct icp_binfo { 237 u_int32_t bi_ser_no; /* serial number */ 238 u_int8_t bi_oem_id[2]; /* OEM ID */ 239 u_int16_t bi_ep_flags; /* eprom flags */ 240 u_int32_t bi_proc_id; /* processor ID */ 241 u_int32_t bi_memsize; /* memory size (bytes) */ 242 u_int8_t bi_mem_banks; /* memory banks */ 243 u_int8_t bi_chan_type; /* channel type */ 244 u_int8_t bi_chan_count; /* channel count */ 245 u_int8_t bi_rdongle_pres; /* dongle present */ 246 u_int32_t bi_epr_fw_ver; /* (eprom) firmware ver */ 247 u_int32_t bi_upd_fw_ver; /* (update) firmware ver */ 248 u_int32_t bi_upd_revision; /* update revision */ 249 char bi_type_string[16]; /* char controller name */ 250 char bi_raid_string[16]; /* char RAID firmware name */ 251 u_int8_t bi_update_pres; /* update present? */ 252 u_int8_t bi_xor_pres; /* XOR engine present */ 253 u_int8_t bi_prom_type; /* ROM type (eprom/flash) */ 254 u_int8_t bi_prom_count; /* number of ROM devices */ 255 u_int32_t bi_dup_pres; /* duplexing module pres? */ 256 u_int32_t bi_chan_pres; /* # of exp. channels */ 257 u_int32_t bi_mem_pres; /* memory expansion inst? */ 258 u_int8_t bi_ft_bus_system; /* fault bus supported? */ 259 u_int8_t bi_subtype_valid; /* board_subtype valid */ 260 u_int8_t bi_board_subtype; /* subtype/hardware level */ 261 u_int8_t bi_rampar_pres; /* RAM parity check hw? */ 262 } __packed; 263 264 /* Board features. */ 265 struct icp_bfeat { 266 u_int8_t bf_chaining; /* chaining supported */ 267 u_int8_t bf_striping; /* striping (RAID-0) supported */ 268 u_int8_t bf_mirroring; /* mirroring (RAID-1) supported */ 269 u_int8_t bf_raid; /* RAID-4/5/10 supported */ 270 } __packed; 271 272 /* Cache drive information. */ 273 struct icp_cdevinfo { 274 char cd_name[8]; 275 u_int32_t cd_devtype; 276 u_int32_t cd_ldcnt; 277 u_int32_t cd_last_error; 278 u_int8_t cd_initialized; 279 u_int8_t cd_removable; 280 u_int8_t cd_write_protected; 281 u_int8_t cd_flags; 282 u_int32_t ld_blkcnt; 283 u_int32_t ld_blksize; 284 u_int32_t ld_dcnt; 285 u_int32_t ld_slave; 286 u_int32_t ld_dtype; 287 u_int32_t ld_last_error; 288 char ld_name[8]; 289 u_int8_t ld_error; 290 } __packed; 291 292 struct icp_sg { 293 u_int32_t sg_addr; 294 u_int32_t sg_len; 295 } __packed; 296 297 struct icp_cachecmd { 298 u_int16_t cc_deviceno; 299 u_int32_t cc_blockno; 300 u_int32_t cc_blockcnt; 301 u_int32_t cc_addr; /* ~0 == s/g */ 302 u_int32_t cc_nsgent; 303 struct icp_sg cc_sg[ICP_MAXSG]; 304 } __packed; 305 306 struct icp_ioctlcmd { 307 u_int16_t ic_bufsize; 308 u_int32_t ic_subfunc; 309 u_int32_t ic_channel; 310 u_int32_t ic_addr; 311 } __packed; 312 313 struct icp_screencmd { 314 u_int32_t sc_msghandle; 315 u_int32_t sc_msgaddr; 316 } __packed; 317 318 struct icp_rawcmd { 319 u_int16_t rc_padding0; /* unused */ 320 u_int32_t rc_direction; /* data direction */ 321 u_int32_t rc_mdisc_time; /* disc. time (0: none) */ 322 u_int32_t rc_mcon_time; /* conn. time (0: none) */ 323 u_int32_t rc_sdata; /* dest address */ 324 u_int32_t rc_sdlen; /* data length */ 325 u_int32_t rc_clen; /* CDB length */ 326 u_int8_t rc_cdb[12]; /* SCSI CDB */ 327 u_int8_t rc_target; /* target ID */ 328 u_int8_t rc_lun; /* LUN */ 329 u_int8_t rc_bus; /* channel */ 330 u_int8_t rc_priority; /* priority; 0 only */ 331 u_int32_t rc_sense_len; /* sense length */ 332 u_int32_t rc_sense_addr; /* sense address */ 333 u_int32_t rc_padding1; /* unused */ 334 u_int32_t rc_nsgent; /* s/g element count */ 335 struct icp_sg rc_sg[ICP_MAXSG]; /* s/g list */ 336 } __packed; 337 338 struct icp_cmdhdr { 339 u_int32_t cmd_boardnode; /* always 0 */ 340 u_int32_t cmd_cmdindex; /* command identifier */ 341 u_int16_t cmd_opcode; 342 } __packed; 343 344 struct icp_cmd { 345 u_int32_t cmd_boardnode; /* always 0 */ 346 u_int32_t cmd_cmdindex; /* command identifier */ 347 u_int16_t cmd_opcode; 348 349 union { 350 struct icp_rawcmd rc; 351 struct icp_screencmd sc; 352 struct icp_ioctlcmd ic; 353 struct icp_cachecmd cc; 354 } cmd_packet; 355 } __packed; 356 357 #endif /* !_IC_ICPREG_H_ */ 358