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