1 /* $FreeBSD: src/sys/dev/iir/iir.h,v 1.16 2007/06/17 05:55:50 scottl Exp $ */ 2 /*- 3 * Copyright (c) 2000-04 ICP vortex GmbH 4 * Copyright (c) 2002-04 Intel Corporation 5 * Copyright (c) 2003-04 Adaptec Inc. 6 * All Rights Reserved 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions, and the following disclaimer, 13 * without modification, immediately at the beginning of the file. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 */ 33 34 /* 35 * 36 * iir.h: Definitions/Constants used by the Intel Integrated RAID driver 37 * 38 * Written by: Achim Leubner <achim_leubner@adaptec.com> 39 * Fixes/Additions: Boji Tony Kannanthanam <boji.t.kannanthanam@intel.com> 40 * 41 * credits: Niklas Hallqvist; OpenBSD driver for the ICP Controllers. 42 * FreeBSD.ORG; Great O/S to work on and for. 43 * 44 * $Id: iir.h 1.6 2004/03/30 10:19:44 achim Exp $" 45 */ 46 47 #ifndef _IIR_H 48 #define _IIR_H 49 50 #include <sys/ioccom.h> 51 52 #define IIR_DRIVER_VERSION 1 53 #define IIR_DRIVER_SUBVERSION 5 54 55 /* OEM IDs */ 56 #define OEM_ID_ICP 0x941c 57 #define OEM_ID_INTEL 0x8000 58 59 #define GDT_VENDOR_ID 0x1119 60 #define GDT_DEVICE_ID_MIN 0x100 61 #define GDT_DEVICE_ID_MAX 0x2ff 62 #define GDT_DEVICE_ID_NEWRX 0x300 63 64 #define INTEL_VENDOR_ID 0x8086 65 #define INTEL_DEVICE_ID_IIR 0x600 66 67 #define GDT_MAXBUS 6 /* XXX Why not 5? */ 68 #define GDT_MAX_HDRIVES 100 /* max 100 host drives */ 69 #define GDT_MAXID_FC 127 /* Fibre-channel IDs */ 70 #define GDT_MAXID 16 /* SCSI IDs */ 71 #define GDT_MAXOFFSETS 128 72 #define GDT_MAXSG 32 /* Max. s/g elements */ 73 #define GDT_PROTOCOL_VERSION 1 74 #define GDT_LINUX_OS 8 /* Used for cache optimization */ 75 #define GDT_SCATTER_GATHER 1 /* s/g feature */ 76 #define GDT_SECS32 0x1f /* round capacity */ 77 #define GDT_LOCALBOARD 0 /* Board node always 0 */ 78 #define GDT_MAXCMDS 124 79 #define GDT_SECTOR_SIZE 0x200 /* Always 512 bytes for cache devs */ 80 #define GDT_MAX_EVENTS 0x100 /* event buffer */ 81 82 /* DPMEM constants */ 83 #define GDT_MPR_MAGIC 0xc0ffee11 84 #define GDT_IC_HEADER_BYTES 48 85 #define GDT_IC_QUEUE_BYTES 4 86 #define GDT_DPMEM_COMMAND_OFFSET \ 87 (GDT_IC_HEADER_BYTES + GDT_IC_QUEUE_BYTES * GDT_MAXOFFSETS) 88 89 /* geometry constants */ 90 #define GDT_MAXCYLS 1024 91 #define GDT_HEADS 64 92 #define GDT_SECS 32 /* mapping 64*32 */ 93 #define GDT_MEDHEADS 127 94 #define GDT_MEDSECS 63 /* mapping 127*63 */ 95 #define GDT_BIGHEADS 255 96 #define GDT_BIGSECS 63 /* mapping 255*63 */ 97 98 /* data direction raw service */ 99 #define GDT_DATA_IN 0x01000000L 100 #define GDT_DATA_OUT 0x00000000L 101 102 /* Cache/raw service commands */ 103 #define GDT_INIT 0 /* service initialization */ 104 #define GDT_READ 1 /* read command */ 105 #define GDT_WRITE 2 /* write command */ 106 #define GDT_INFO 3 /* information about devices */ 107 #define GDT_FLUSH 4 /* flush dirty cache buffers */ 108 #define GDT_IOCTL 5 /* ioctl command */ 109 #define GDT_DEVTYPE 9 /* additional information */ 110 #define GDT_MOUNT 10 /* mount cache device */ 111 #define GDT_UNMOUNT 11 /* unmount cache device */ 112 #define GDT_SET_FEAT 12 /* set features (scatter/gather) */ 113 #define GDT_GET_FEAT 13 /* get features */ 114 #define GDT_WRITE_THR 16 /* write through */ 115 #define GDT_READ_THR 17 /* read through */ 116 #define GDT_EXT_INFO 18 /* extended info */ 117 #define GDT_RESET 19 /* controller reset */ 118 #define GDT_FREEZE_IO 25 /* freeze all IOs */ 119 #define GDT_UNFREEZE_IO 26 /* unfreeze all IOs */ 120 121 /* Additional raw service commands */ 122 #define GDT_RESERVE 14 /* reserve device to raw service */ 123 #define GDT_RELEASE 15 /* release device */ 124 #define GDT_RESERVE_ALL 16 /* reserve all devices */ 125 #define GDT_RELEASE_ALL 17 /* release all devices */ 126 #define GDT_RESET_BUS 18 /* reset bus */ 127 #define GDT_SCAN_START 19 /* start device scan */ 128 #define GDT_SCAN_END 20 /* stop device scan */ 129 130 /* IOCTL command defines */ 131 #define GDT_SCSI_DR_INFO 0x00 /* SCSI drive info */ 132 #define GDT_SCSI_CHAN_CNT 0x05 /* SCSI channel count */ 133 #define GDT_SCSI_DR_LIST 0x06 /* SCSI drive list */ 134 #define GDT_SCSI_DEF_CNT 0x15 /* grown/primary defects */ 135 #define GDT_DSK_STATISTICS 0x4b /* SCSI disk statistics */ 136 #define GDT_IOCHAN_DESC 0x5d /* description of IO channel */ 137 #define GDT_IOCHAN_RAW_DESC 0x5e /* description of raw IO channel */ 138 139 #define GDT_L_CTRL_PATTERN 0x20000000 /* SCSI IOCTL mask */ 140 #define GDT_ARRAY_INFO 0x12 /* array drive info */ 141 #define GDT_ARRAY_DRV_LIST 0x0f /* array drive list */ 142 #define GDT_LA_CTRL_PATTERN 0x10000000 /* array IOCTL mask */ 143 #define GDT_CACHE_DRV_CNT 0x01 /* cache drive count */ 144 #define GDT_CACHE_DRV_LIST 0x02 /* cache drive list */ 145 #define GDT_CACHE_INFO 0x04 /* cache info */ 146 #define GDT_CACHE_CONFIG 0x05 /* cache configuration */ 147 #define GDT_CACHE_DRV_INFO 0x07 /* cache drive info */ 148 #define GDT_BOARD_FEATURES 0x15 /* controller features */ 149 #define GDT_BOARD_INFO 0x28 /* controller info */ 150 #define GDT_OEM_STR_RECORD 0x84 /* OEM info */ 151 #define GDT_HOST_GET 0x10001 /* get host drive list */ 152 #define GDT_IO_CHANNEL 0x20000 /* default IO channel */ 153 #define GDT_INVALID_CHANNEL 0xffff /* invalid channel */ 154 155 /* IOCTLs */ 156 #define GDT_IOCTL_GENERAL _IOWR('J', 0, gdt_ucmd_t) /* general IOCTL */ 157 #define GDT_IOCTL_DRVERS _IOR('J', 1, int) /* get driver version */ 158 #define GDT_IOCTL_CTRTYPE _IOWR('J', 2, gdt_ctrt_t) /* get ctr. type */ 159 #define GDT_IOCTL_DRVERS_OLD _IOWR('J', 1, int) /* get driver version */ 160 #define GDT_IOCTL_CTRTYPE_OLD _IOR('J', 2, gdt_ctrt_t) /* get ctr. type */ 161 #define GDT_IOCTL_OSVERS _IOR('J', 3, gdt_osv_t) /* get OS version */ 162 #define GDT_IOCTL_CTRCNT _IOR('J', 5, int) /* get ctr. count */ 163 #define GDT_IOCTL_EVENT _IOWR('J', 8, gdt_event_t) /* get event */ 164 #define GDT_IOCTL_STATIST _IOR('J', 9, gdt_statist_t) /* get statistics */ 165 166 /* Service errors */ 167 #define GDT_S_OK 1 /* no error */ 168 #define GDT_S_BSY 7 /* controller busy */ 169 #define GDT_S_RAW_SCSI 12 /* raw service: target error */ 170 #define GDT_S_RAW_ILL 0xff /* raw service: illegal */ 171 #define GDT_S_NO_STATUS 0x1000 /* got no status (driver-generated) */ 172 173 /* Controller services */ 174 #define GDT_SCSIRAWSERVICE 3 175 #define GDT_CACHESERVICE 9 176 #define GDT_SCREENSERVICE 11 177 178 /* Scatter/gather element */ 179 #define GDT_SG_PTR 0x00 /* u_int32_t, address */ 180 #define GDT_SG_LEN 0x04 /* u_int32_t, length */ 181 #define GDT_SG_SZ 0x08 182 183 /* Cache service command */ 184 #define GDT_CACHE_DEVICENO 0x00 /* u_int16_t, number of cache drive */ 185 #define GDT_CACHE_BLOCKNO 0x02 /* u_int32_t, block number */ 186 #define GDT_CACHE_BLOCKCNT 0x06 /* u_int32_t, block count */ 187 #define GDT_CACHE_DESTADDR 0x0a /* u_int32_t, dest. addr. (-1: s/g) */ 188 #define GDT_CACHE_SG_CANZ 0x0e /* u_int32_t, s/g element count */ 189 #define GDT_CACHE_SG_LST 0x12 /* [GDT_MAXSG], s/g list */ 190 #define GDT_CACHE_SZ (0x12 + GDT_MAXSG * GDT_SG_SZ) 191 192 /* Ioctl command */ 193 #define GDT_IOCTL_PARAM_SIZE 0x00 /* u_int16_t, size of buffer */ 194 #define GDT_IOCTL_SUBFUNC 0x02 /* u_int32_t, ioctl function */ 195 #define GDT_IOCTL_CHANNEL 0x06 /* u_int32_t, device */ 196 #define GDT_IOCTL_P_PARAM 0x0a /* u_int32_t, buffer */ 197 #define GDT_IOCTL_SZ 0x0e 198 199 /* Screen service defines */ 200 #define GDT_MSG_INV_HANDLE -1 /* special message handle */ 201 #define GDT_MSGLEN 16 /* size of message text */ 202 #define GDT_MSG_SIZE 34 /* size of message structure */ 203 #define GDT_MSG_REQUEST 0 /* async. event. message */ 204 205 /* Screen service command */ 206 #define GDT_SCREEN_MSG_HANDLE 0x02 /* u_int32_t, message handle */ 207 #define GDT_SCREEN_MSG_ADDR 0x06 /* u_int32_t, message buffer address */ 208 #define GDT_SCREEN_SZ 0x0a 209 210 /* Screen service message */ 211 #define GDT_SCR_MSG_HANDLE 0x00 /* u_int32_t, message handle */ 212 #define GDT_SCR_MSG_LEN 0x04 /* u_int32_t, size of message */ 213 #define GDT_SCR_MSG_ALEN 0x08 /* u_int32_t, answer length */ 214 #define GDT_SCR_MSG_ANSWER 0x0c /* u_int8_t, answer flag */ 215 #define GDT_SCR_MSG_EXT 0x0d /* u_int8_t, more messages? */ 216 #define GDT_SCR_MSG_RES 0x0e /* u_int16_t, reserved */ 217 #define GDT_SCR_MSG_TEXT 0x10 /* GDT_MSGLEN+2, message text */ 218 #define GDT_SCR_MSG_SZ (0x12 + GDT_MSGLEN) 219 220 /* Raw service command */ 221 #define GDT_RAW_DIRECTION 0x02 /* u_int32_t, data direction */ 222 #define GDT_RAW_MDISC_TIME 0x06 /* u_int32_t, disc. time (0: none) */ 223 #define GDT_RAW_MCON_TIME 0x0a /* u_int32_t, conn. time (0: none) */ 224 #define GDT_RAW_SDATA 0x0e /* u_int32_t, dest. addr. (-1: s/g) */ 225 #define GDT_RAW_SDLEN 0x12 /* u_int32_t, data length */ 226 #define GDT_RAW_CLEN 0x16 /* u_int32_t, SCSI cmd len (6/10/12) */ 227 #define GDT_RAW_CMD 0x1a /* u_int8_t [12], SCSI command */ 228 #define GDT_RAW_TARGET 0x26 /* u_int8_t, target ID */ 229 #define GDT_RAW_LUN 0x27 /* u_int8_t, LUN */ 230 #define GDT_RAW_BUS 0x28 /* u_int8_t, SCSI bus number */ 231 #define GDT_RAW_PRIORITY 0x29 /* u_int8_t, only 0 used */ 232 #define GDT_RAW_SENSE_LEN 0x2a /* u_int32_t, sense data length */ 233 #define GDT_RAW_SENSE_DATA 0x2e /* u_int32_t, sense data address */ 234 #define GDT_RAW_SG_RANZ 0x36 /* u_int32_t, s/g element count */ 235 #define GDT_RAW_SG_LST 0x3a /* [GDT_MAXSG], s/g list */ 236 #define GDT_RAW_SZ (0x3a + GDT_MAXSG * GDT_SG_SZ) 237 238 /* Command structure */ 239 #define GDT_CMD_BOARDNODE 0x00 /* u_int32_t, board node (always 0) */ 240 #define GDT_CMD_COMMANDINDEX 0x04 /* u_int32_t, command number */ 241 #define GDT_CMD_OPCODE 0x08 /* u_int16_t, opcode (READ, ...) */ 242 #define GDT_CMD_UNION 0x0a /* cache/screen/raw service command */ 243 #define GDT_CMD_UNION_SZ GDT_RAW_SZ 244 #define GDT_CMD_SZ (0x0a + GDT_CMD_UNION_SZ) 245 246 /* Command queue entries */ 247 #define GDT_OFFSET 0x00 /* u_int16_t, command offset in the DP RAM */ 248 #define GDT_SERV_ID 0x02 /* u_int16_t, service */ 249 #define GDT_COMM_Q_SZ 0x04 250 251 /* Interface area */ 252 #define GDT_S_CMD_INDX 0x00 /* u_int8_t, special command */ 253 #define GDT_S_STATUS 0x01 /* volatile u_int8_t, status special command */ 254 #define GDT_S_INFO 0x04 /* u_int32_t [4], add. info special command */ 255 #define GDT_SEMA0 0x14 /* volatile u_int8_t, command semaphore */ 256 #define GDT_CMD_INDEX 0x18 /* u_int8_t, command number */ 257 #define GDT_STATUS 0x1c /* volatile u_int16_t, command status */ 258 #define GDT_SERVICE 0x1e /* u_int16_t, service (for asynch. events) */ 259 #define GDT_DPR_INFO 0x20 /* u_int32_t [2], additional info */ 260 #define GDT_COMM_QUEUE 0x28 /* command queue */ 261 #define GDT_DPR_CMD (0x30 + GDT_MAXOFFSETS * GDT_COMM_Q_SZ) 262 /* u_int8_t [], commands */ 263 264 /* I/O channel header */ 265 #define GDT_IOC_VERSION 0x00 /* u_int32_t, version (~0: newest) */ 266 #define GDT_IOC_LIST_ENTRIES 0x04 /* u_int8_t, list entry count */ 267 #define GDT_IOC_FIRST_CHAN 0x05 /* u_int8_t, first channel number */ 268 #define GDT_IOC_LAST_CHAN 0x06 /* u_int8_t, last channel number */ 269 #define GDT_IOC_CHAN_COUNT 0x07 /* u_int8_t, (R) channel count */ 270 #define GDT_IOC_LIST_OFFSET 0x08 /* u_int32_t, offset of list[0] */ 271 #define GDT_IOC_HDR_SZ 0x0c 272 273 #define GDT_IOC_NEWEST 0xffffffff /* goes into GDT_IOC_VERSION */ 274 275 /* Get I/O channel description */ 276 #define GDT_IOC_ADDRESS 0x00 /* u_int32_t, channel address */ 277 #define GDT_IOC_TYPE 0x04 /* u_int8_t, type (SCSI/FCSL) */ 278 #define GDT_IOC_LOCAL_NO 0x05 /* u_int8_t, local number */ 279 #define GDT_IOC_FEATURES 0x06 /* u_int16_t, channel features */ 280 #define GDT_IOC_SZ 0x08 281 282 /* Get raw I/O channel description */ 283 #define GDT_RAWIOC_PROC_ID 0x00 /* u_int8_t, processor id */ 284 #define GDT_RAWIOC_PROC_DEFECT 0x01 /* u_int8_t, defect? */ 285 #define GDT_RAWIOC_SZ 0x04 286 287 /* Get SCSI channel count */ 288 #define GDT_GETCH_CHANNEL_NO 0x00 /* u_int32_t, channel number */ 289 #define GDT_GETCH_DRIVE_CNT 0x04 /* u_int32_t, drive count */ 290 #define GDT_GETCH_SIOP_ID 0x08 /* u_int8_t, SCSI processor ID */ 291 #define GDT_GETCH_SIOP_STATE 0x09 /* u_int8_t, SCSI processor state */ 292 #define GDT_GETCH_SZ 0x0a 293 294 /* Cache info/config IOCTL structures */ 295 #define GDT_CPAR_VERSION 0x00 /* u_int32_t, firmware version */ 296 #define GDT_CPAR_STATE 0x04 /* u_int16_t, cache state (on/off) */ 297 #define GDT_CPAR_STRATEGY 0x06 /* u_int16_t, cache strategy */ 298 #define GDT_CPAR_WRITE_BACK 0x08 /* u_int16_t, write back (on/off) */ 299 #define GDT_CPAR_BLOCK_SIZE 0x0a /* u_int16_t, cache block size */ 300 #define GDT_CPAR_SZ 0x0c 301 302 #define GDT_CSTAT_CSIZE 0x00 /* u_int32_t, cache size */ 303 #define GDT_CSTAT_READ_CNT 0x04 /* u_int32_t, read counter */ 304 #define GDT_CSTAT_WRITE_CNT 0x08 /* u_int32_t, write counter */ 305 #define GDT_CSTAT_TR_HITS 0x0c /* u_int32_t, track hits */ 306 #define GDT_CSTAT_SEC_HITS 0x10 /* u_int32_t, sector hits */ 307 #define GDT_CSTAT_SEC_MISS 0x14 /* u_int32_t, sector misses */ 308 #define GDT_CSTAT_SZ 0x18 309 310 /* Get cache info */ 311 #define GDT_CINFO_CPAR 0x00 312 #define GDT_CINFO_CSTAT GDT_CPAR_SZ 313 #define GDT_CINFO_SZ (GDT_CPAR_SZ + GDT_CSTAT_SZ) 314 315 /* Get board info */ 316 #define GDT_BINFO_SER_NO 0x00 /* u_int32_t, serial number */ 317 #define GDT_BINFO_OEM_ID 0x04 /* u_int8_t [2], OEM ID */ 318 #define GDT_BINFO_EP_FLAGS 0x06 /* u_int16_t, eprom flags */ 319 #define GDT_BINFO_PROC_ID 0x08 /* u_int32_t, processor ID */ 320 #define GDT_BINFO_MEMSIZE 0x0c /* u_int32_t, memory size (bytes) */ 321 #define GDT_BINFO_MEM_BANKS 0x10 /* u_int8_t, memory banks */ 322 #define GDT_BINFO_CHAN_TYPE 0x11 /* u_int8_t, channel type */ 323 #define GDT_BINFO_CHAN_COUNT 0x12 /* u_int8_t, channel count */ 324 #define GDT_BINFO_RDONGLE_PRES 0x13 /* u_int8_t, dongle present */ 325 #define GDT_BINFO_EPR_FW_VER 0x14 /* u_int32_t, (eprom) firmware ver */ 326 #define GDT_BINFO_UPD_FW_VER 0x18 /* u_int32_t, (update) firmware ver */ 327 #define GDT_BINFO_UPD_REVISION 0x1c /* u_int32_t, update revision */ 328 #define GDT_BINFO_TYPE_STRING 0x20 /* char [16], controller name */ 329 #define GDT_BINFO_RAID_STRING 0x30 /* char [16], RAID firmware name */ 330 #define GDT_BINFO_UPDATE_PRES 0x40 /* u_int8_t, update present? */ 331 #define GDT_BINFO_XOR_PRES 0x41 /* u_int8_t, XOR engine present */ 332 #define GDT_BINFO_PROM_TYPE 0x42 /* u_int8_t, ROM type (eprom/flash) */ 333 #define GDT_BINFO_PROM_COUNT 0x43 /* u_int8_t, number of ROM devices */ 334 #define GDT_BINFO_DUP_PRES 0x44 /* u_int32_t, duplexing module pres? */ 335 #define GDT_BINFO_CHAN_PRES 0x48 /* u_int32_t, # of exp. channels */ 336 #define GDT_BINFO_MEM_PRES 0x4c /* u_int32_t, memory expansion inst? */ 337 #define GDT_BINFO_FT_BUS_SYSTEM 0x50 /* u_int8_t, fault bus supported? */ 338 #define GDT_BINFO_SUBTYPE_VALID 0x51 /* u_int8_t, board_subtype valid */ 339 #define GDT_BINFO_BOARD_SUBTYPE 0x52 /* u_int8_t, subtype/hardware level */ 340 #define GDT_BINFO_RAMPAR_PRES 0x53 /* u_int8_t, RAM parity check hw? */ 341 #define GDT_BINFO_SZ 0x54 342 343 /* Get board features */ 344 #define GDT_BFEAT_CHAINING 0x00 /* u_int8_t, chaining supported */ 345 #define GDT_BFEAT_STRIPING 0x01 /* u_int8_t, striping (RAID-0) supp. */ 346 #define GDT_BFEAT_MIRRORING 0x02 /* u_int8_t, mirroring (RAID-1) supp */ 347 #define GDT_BFEAT_RAID 0x03 /* u_int8_t, RAID-4/5/10 supported */ 348 #define GDT_BFEAT_SZ 0x04 349 350 /* Other defines */ 351 #define GDT_ASYNCINDEX 0 /* command index asynchronous event */ 352 #define GDT_SPEZINDEX 1 /* command index unknown service */ 353 354 /* Debugging */ 355 #ifdef GDT_DEBUG 356 #define GDT_D_INTR 0x01 357 #define GDT_D_MISC 0x02 358 #define GDT_D_CMD 0x04 359 #define GDT_D_QUEUE 0x08 360 #define GDT_D_TIMEOUT 0x10 361 #define GDT_D_INIT 0x20 362 #define GDT_D_INVALID 0x40 363 #define GDT_D_DEBUG 0x80 364 extern int gdt_debug; 365 #ifdef __SERIAL__ 366 extern int ser_printf(const char *fmt, ...); 367 #define GDT_DPRINTF(mask, args) if (gdt_debug & (mask)) ser_kprintf args 368 #else 369 #define GDT_DPRINTF(mask, args) if (gdt_debug & (mask)) kprintf args 370 #endif 371 #else 372 #define GDT_DPRINTF(mask, args) 373 #endif 374 375 /* Miscellaneous constants */ 376 #define GDT_RETRIES 100000000 /* 100000 * 1us = 100s */ 377 #define GDT_TIMEOUT 100000000 /* 100000 * 1us = 100s */ 378 #define GDT_POLL_TIMEOUT 10000000 /* 10000 * 1us = 10s */ 379 #define GDT_WATCH_TIMEOUT 10000000 /* 10000 * 1us = 10s */ 380 #define GDT_SCRATCH_SZ 3072 /* 3KB scratch buffer */ 381 382 /* Map minor numbers to device identity */ 383 #define LUN_MASK 0x0007 384 #define TARGET_MASK 0x03f8 385 #define BUS_MASK 0x1c00 386 #define HBA_MASK 0xe000 387 388 #define minor2lun(minor) ( minor & LUN_MASK ) 389 #define minor2target(minor) ( (minor & TARGET_MASK) >> 3 ) 390 #define minor2bus(minor) ( (minor & BUS_MASK) >> 10 ) 391 #define minor2hba(minor) ( (minor & HBA_MASK) >> 13 ) 392 #define hba2minor(hba) ( (hba << 13) & HBA_MASK ) 393 394 395 /* struct for GDT_IOCTL_GENERAL */ 396 #pragma pack(1) 397 typedef struct gdt_ucmd { 398 u_int16_t io_node; 399 u_int16_t service; 400 u_int32_t timeout; 401 u_int16_t status; 402 u_int32_t info; 403 404 u_int32_t BoardNode; /* board node (always 0) */ 405 u_int32_t CommandIndex; /* command number */ 406 u_int16_t OpCode; /* the command (READ,..) */ 407 union { 408 struct { 409 u_int16_t DeviceNo; /* number of cache drive */ 410 u_int32_t BlockNo; /* block number */ 411 u_int32_t BlockCnt; /* block count */ 412 void *DestAddr; /* data */ 413 } cache; /* cache service cmd. str. */ 414 struct { 415 u_int16_t param_size; /* size of p_param buffer */ 416 u_int32_t subfunc; /* IOCTL function */ 417 u_int32_t channel; /* device */ 418 void *p_param; /* data */ 419 } ioctl; /* IOCTL command structure */ 420 struct { 421 u_int16_t reserved; 422 u_int32_t direction; /* data direction */ 423 u_int32_t mdisc_time; /* disc. time (0: no timeout)*/ 424 u_int32_t mcon_time; /* connect time(0: no to.) */ 425 void *sdata; /* dest. addr. (if s/g: -1) */ 426 u_int32_t sdlen; /* data length (bytes) */ 427 u_int32_t clen; /* SCSI cmd. length(6,10,12) */ 428 u_int8_t cmd[12]; /* SCSI command */ 429 u_int8_t target; /* target ID */ 430 u_int8_t lun; /* LUN */ 431 u_int8_t bus; /* SCSI bus number */ 432 u_int8_t priority; /* only 0 used */ 433 u_int32_t sense_len; /* sense data length */ 434 void *sense_data; /* sense data addr. */ 435 u_int32_t link_p; /* linked cmds (not supp.) */ 436 } raw; /* raw service cmd. struct. */ 437 } u; 438 u_int8_t data[GDT_SCRATCH_SZ]; 439 int complete_flag; 440 TAILQ_ENTRY(gdt_ucmd) links; 441 } gdt_ucmd_t; 442 443 /* struct for GDT_IOCTL_CTRTYPE */ 444 typedef struct gdt_ctrt { 445 u_int16_t io_node; 446 u_int16_t oem_id; 447 u_int16_t type; 448 u_int32_t info; 449 u_int8_t access; 450 u_int8_t remote; 451 u_int16_t ext_type; 452 u_int16_t device_id; 453 u_int16_t sub_device_id; 454 } gdt_ctrt_t; 455 456 /* struct for GDT_IOCTL_OSVERS */ 457 typedef struct gdt_osv { 458 u_int8_t oscode; 459 u_int8_t version; 460 u_int8_t subversion; 461 u_int16_t revision; 462 char name[64]; 463 } gdt_osv_t; 464 465 /* OEM */ 466 #define GDT_OEM_VERSION 0x00 467 #define GDT_OEM_BUFSIZE 0x0c 468 typedef struct { 469 u_int32_t ctl_version; 470 u_int32_t file_major_version; 471 u_int32_t file_minor_version; 472 u_int32_t buffer_size; 473 u_int32_t cpy_count; 474 u_int32_t ext_error; 475 u_int32_t oem_id; 476 u_int32_t board_id; 477 } gdt_oem_param_t; 478 479 typedef struct { 480 char product_0_1_name[16]; 481 char product_4_5_name[16]; 482 char product_cluster_name[16]; 483 char product_reserved[16]; 484 char scsi_cluster_target_vendor_id[16]; 485 char cluster_raid_fw_name[16]; 486 char oem_brand_name[16]; 487 char oem_raid_type[16]; 488 char bios_type[13]; 489 char bios_title[50]; 490 char oem_company_name[37]; 491 u_int32_t pci_id_1; 492 u_int32_t pci_id_2; 493 char validation_status[80]; 494 char reserved_1[4]; 495 char scsi_host_drive_inquiry_vendor_id[16]; 496 char library_file_template[32]; 497 char tool_name_1[32]; 498 char tool_name_2[32]; 499 char tool_name_3[32]; 500 char oem_contact_1[84]; 501 char oem_contact_2[84]; 502 char oem_contact_3[84]; 503 } gdt_oem_record_t; 504 505 typedef struct { 506 gdt_oem_param_t parameters; 507 gdt_oem_record_t text; 508 } gdt_oem_str_record_t; 509 510 511 /* controller event structure */ 512 #define GDT_ES_ASYNC 1 513 #define GDT_ES_DRIVER 2 514 #define GDT_ES_TEST 3 515 #define GDT_ES_SYNC 4 516 typedef struct { 517 u_int16_t size; /* size of structure */ 518 union { 519 char stream[16]; 520 struct { 521 u_int16_t ionode; 522 u_int16_t service; 523 u_int32_t index; 524 } driver; 525 struct { 526 u_int16_t ionode; 527 u_int16_t service; 528 u_int16_t status; 529 u_int32_t info; 530 u_int8_t scsi_coord[3]; 531 } async; 532 struct { 533 u_int16_t ionode; 534 u_int16_t service; 535 u_int16_t status; 536 u_int32_t info; 537 u_int16_t hostdrive; 538 u_int8_t scsi_coord[3]; 539 u_int8_t sense_key; 540 } sync; 541 struct { 542 u_int32_t l1, l2, l3, l4; 543 } test; 544 } eu; 545 u_int32_t severity; 546 u_int8_t event_string[256]; 547 } gdt_evt_data; 548 549 /* dvrevt structure */ 550 typedef struct { 551 u_int32_t first_stamp; 552 u_int32_t last_stamp; 553 u_int16_t same_count; 554 u_int16_t event_source; 555 u_int16_t event_idx; 556 u_int8_t application; 557 u_int8_t reserved; 558 gdt_evt_data event_data; 559 } gdt_evt_str; 560 561 /* struct for GDT_IOCTL_EVENT */ 562 typedef struct gdt_event { 563 int erase; 564 int handle; 565 gdt_evt_str dvr; 566 } gdt_event_t; 567 568 /* struct for GDT_IOCTL_STATIST */ 569 typedef struct gdt_statist { 570 u_int16_t io_count_act; 571 u_int16_t io_count_max; 572 u_int16_t req_queue_act; 573 u_int16_t req_queue_max; 574 u_int16_t cmd_index_act; 575 u_int16_t cmd_index_max; 576 u_int16_t sg_count_act; 577 u_int16_t sg_count_max; 578 } gdt_statist_t; 579 580 #pragma pack() 581 582 /* Context structure for interrupt services */ 583 struct gdt_intr_ctx { 584 u_int32_t info, info2; 585 u_int16_t cmd_status, service; 586 u_int8_t istatus; 587 }; 588 589 /* softc structure */ 590 struct gdt_softc { 591 int sc_hanum; 592 int sc_class; /* Controller class */ 593 #define GDT_MPR 0x05 594 #define GDT_CLASS_MASK 0x07 595 #define GDT_FC 0x10 596 #define GDT_CLASS(gdt) ((gdt)->sc_class & GDT_CLASS_MASK) 597 int sc_bus, sc_slot; 598 u_int16_t sc_vendor; 599 u_int16_t sc_device, sc_subdevice; 600 u_int16_t sc_fw_vers; 601 int sc_init_level; 602 int sc_state; 603 #define GDT_NORMAL 0x00 604 #define GDT_POLLING 0x01 605 #define GDT_SHUTDOWN 0x02 606 #define GDT_POLL_WAIT 0x80 607 cdev_t sc_dev; 608 bus_space_tag_t sc_dpmemt; 609 bus_space_handle_t sc_dpmemh; 610 bus_addr_t sc_dpmembase; 611 bus_dma_tag_t sc_parent_dmat; 612 bus_dma_tag_t sc_buffer_dmat; 613 bus_dma_tag_t sc_gcscratch_dmat; 614 bus_dmamap_t sc_gcscratch_dmamap; 615 bus_addr_t sc_gcscratch_busbase; 616 617 struct gdt_ccb *sc_gccbs; 618 u_int8_t *sc_gcscratch; 619 SLIST_HEAD(, gdt_ccb) sc_free_gccb, sc_pending_gccb; 620 TAILQ_HEAD(, ccb_hdr) sc_ccb_queue; 621 TAILQ_HEAD(, gdt_ucmd) sc_ucmd_queue; 622 623 u_int16_t sc_ic_all_size; 624 u_int16_t sc_cmd_off; 625 u_int16_t sc_cmd_cnt; 626 627 u_int32_t sc_info; 628 u_int32_t sc_info2; 629 u_int16_t sc_status; 630 u_int16_t sc_service; 631 632 u_int8_t sc_bus_cnt; 633 u_int8_t sc_virt_bus; 634 u_int8_t sc_bus_id[GDT_MAXBUS]; 635 u_int8_t sc_more_proc; 636 637 struct { 638 u_int8_t hd_present; 639 u_int8_t hd_is_logdrv; 640 u_int8_t hd_is_arraydrv; 641 u_int8_t hd_is_master; 642 u_int8_t hd_is_parity; 643 u_int8_t hd_is_hotfix; 644 u_int8_t hd_master_no; 645 u_int8_t hd_lock; 646 u_int8_t hd_heads; 647 u_int8_t hd_secs; 648 u_int16_t hd_devtype; 649 u_int32_t hd_size; 650 u_int8_t hd_ldr_no; 651 u_int8_t hd_rw_attribs; 652 u_int32_t hd_start_sec; 653 } sc_hdr[GDT_MAX_HDRIVES]; 654 655 u_int16_t sc_raw_feat; 656 u_int16_t sc_cache_feat; 657 658 gdt_evt_data sc_dvr; 659 char oem_name[8]; 660 661 struct cam_sim *sims[GDT_MAXBUS]; 662 struct cam_path *paths[GDT_MAXBUS]; 663 664 void (*sc_copy_cmd)(struct gdt_softc *, struct gdt_ccb *); 665 u_int8_t (*sc_get_status)(struct gdt_softc *); 666 void (*sc_intr)(struct gdt_softc *, struct gdt_intr_ctx *); 667 void (*sc_release_event)(struct gdt_softc *); 668 void (*sc_set_sema0)(struct gdt_softc *); 669 int (*sc_test_busy)(struct gdt_softc *); 670 671 TAILQ_ENTRY(gdt_softc) links; 672 }; 673 674 /* 675 * A command control block, one for each corresponding command index of the 676 * controller. 677 */ 678 struct gdt_ccb { 679 u_int8_t *gc_scratch; 680 bus_addr_t gc_scratch_busbase; 681 union ccb *gc_ccb; 682 gdt_ucmd_t *gc_ucmd; 683 bus_dmamap_t gc_dmamap; 684 int gc_map_flag; 685 int gc_timeout; 686 u_int8_t gc_service; 687 u_int8_t gc_cmd_index; 688 u_int8_t gc_flags; 689 #define GDT_GCF_UNUSED 0 690 #define GDT_GCF_INTERNAL 1 691 #define GDT_GCF_SCREEN 2 692 #define GDT_GCF_SCSI 3 693 #define GDT_GCF_IOCTL 4 694 u_int16_t gc_cmd_len; 695 u_int8_t gc_cmd[GDT_CMD_SZ]; 696 SLIST_ENTRY(gdt_ccb) sle; 697 }; 698 699 700 int iir_init(struct gdt_softc *); 701 void iir_free(struct gdt_softc *); 702 void iir_attach(struct gdt_softc *); 703 void iir_intr(void *arg); 704 705 #ifdef __GNUC__ 706 /* These all require correctly aligned buffers */ 707 static __inline__ void gdt_enc16(u_int8_t *, u_int16_t); 708 static __inline__ void gdt_enc32(u_int8_t *, u_int32_t); 709 static __inline__ u_int16_t gdt_dec16(u_int8_t *); 710 static __inline__ u_int32_t gdt_dec32(u_int8_t *); 711 712 static __inline__ void 713 gdt_enc16(u_int8_t *addr, u_int16_t value) 714 { 715 *(u_int16_t *)addr = htole16(value); 716 } 717 718 static __inline__ void 719 gdt_enc32(u_int8_t *addr, u_int32_t value) 720 { 721 *(u_int32_t *)addr = htole32(value); 722 } 723 724 static __inline__ u_int16_t 725 gdt_dec16(u_int8_t *addr) 726 { 727 return le16toh(*(u_int16_t *)addr); 728 } 729 730 static __inline__ u_int32_t 731 gdt_dec32(u_int8_t *addr) 732 { 733 return le32toh(*(u_int32_t *)addr); 734 } 735 #endif 736 737 extern TAILQ_HEAD(gdt_softc_list, gdt_softc) gdt_softcs; 738 extern u_int8_t gdt_polling; 739 740 cdev_t gdt_make_dev(int unit); 741 void gdt_destroy_dev(cdev_t dev); 742 void gdt_next(struct gdt_softc *gdt); 743 void gdt_free_ccb(struct gdt_softc *gdt, struct gdt_ccb *gccb); 744 745 gdt_evt_str *gdt_store_event(u_int16_t source, u_int16_t idx, 746 gdt_evt_data *evt); 747 int gdt_read_event(int handle, gdt_evt_str *estr); 748 void gdt_readapp_event(u_int8_t app, gdt_evt_str *estr); 749 void gdt_clear_events(void); 750 751 #endif 752