1*7eb99bdaSLionel Sambuc /* $NetBSD: twereg.h,v 1.15 2008/09/08 23:36:54 gmcgarry Exp $ */ 2*7eb99bdaSLionel Sambuc 3*7eb99bdaSLionel Sambuc /*- 4*7eb99bdaSLionel Sambuc * Copyright (c) 2000 The NetBSD Foundation, Inc. 5*7eb99bdaSLionel Sambuc * All rights reserved. 6*7eb99bdaSLionel Sambuc * 7*7eb99bdaSLionel Sambuc * This code is derived from software contributed to The NetBSD Foundation 8*7eb99bdaSLionel Sambuc * by Andrew Doran. 9*7eb99bdaSLionel Sambuc * 10*7eb99bdaSLionel Sambuc * Redistribution and use in source and binary forms, with or without 11*7eb99bdaSLionel Sambuc * modification, are permitted provided that the following conditions 12*7eb99bdaSLionel Sambuc * are met: 13*7eb99bdaSLionel Sambuc * 1. Redistributions of source code must retain the above copyright 14*7eb99bdaSLionel Sambuc * notice, this list of conditions and the following disclaimer. 15*7eb99bdaSLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 16*7eb99bdaSLionel Sambuc * notice, this list of conditions and the following disclaimer in the 17*7eb99bdaSLionel Sambuc * documentation and/or other materials provided with the distribution. 18*7eb99bdaSLionel Sambuc * 19*7eb99bdaSLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20*7eb99bdaSLionel Sambuc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21*7eb99bdaSLionel Sambuc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22*7eb99bdaSLionel Sambuc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23*7eb99bdaSLionel Sambuc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24*7eb99bdaSLionel Sambuc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25*7eb99bdaSLionel Sambuc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26*7eb99bdaSLionel Sambuc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27*7eb99bdaSLionel Sambuc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28*7eb99bdaSLionel Sambuc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29*7eb99bdaSLionel Sambuc * POSSIBILITY OF SUCH DAMAGE. 30*7eb99bdaSLionel Sambuc */ 31*7eb99bdaSLionel Sambuc 32*7eb99bdaSLionel Sambuc /*- 33*7eb99bdaSLionel Sambuc * Copyright (c) 2000 Michael Smith 34*7eb99bdaSLionel Sambuc * Copyright (c) 2000 BSDi 35*7eb99bdaSLionel Sambuc * All rights reserved. 36*7eb99bdaSLionel Sambuc * 37*7eb99bdaSLionel Sambuc * Redistribution and use in source and binary forms, with or without 38*7eb99bdaSLionel Sambuc * modification, are permitted provided that the following conditions 39*7eb99bdaSLionel Sambuc * are met: 40*7eb99bdaSLionel Sambuc * 1. Redistributions of source code must retain the above copyright 41*7eb99bdaSLionel Sambuc * notice, this list of conditions and the following disclaimer. 42*7eb99bdaSLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 43*7eb99bdaSLionel Sambuc * notice, this list of conditions and the following disclaimer in the 44*7eb99bdaSLionel Sambuc * documentation and/or other materials provided with the distribution. 45*7eb99bdaSLionel Sambuc * 46*7eb99bdaSLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 47*7eb99bdaSLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 48*7eb99bdaSLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 49*7eb99bdaSLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 50*7eb99bdaSLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 51*7eb99bdaSLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 52*7eb99bdaSLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 53*7eb99bdaSLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 54*7eb99bdaSLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 55*7eb99bdaSLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 56*7eb99bdaSLionel Sambuc * SUCH DAMAGE. 57*7eb99bdaSLionel Sambuc * 58*7eb99bdaSLionel Sambuc * from FreeBSD: twereg.h,v 1.1 2000/05/24 23:35:23 msmith Exp 59*7eb99bdaSLionel Sambuc */ 60*7eb99bdaSLionel Sambuc 61*7eb99bdaSLionel Sambuc #ifndef _PCI_TWEREG_H_ 62*7eb99bdaSLionel Sambuc #define _PCI_TWEREG_H_ 63*7eb99bdaSLionel Sambuc 64*7eb99bdaSLionel Sambuc /* Board registers. */ 65*7eb99bdaSLionel Sambuc #define TWE_REG_CTL 0x00 66*7eb99bdaSLionel Sambuc #define TWE_REG_STS 0x04 67*7eb99bdaSLionel Sambuc #define TWE_REG_CMD_QUEUE 0x08 68*7eb99bdaSLionel Sambuc #define TWE_REG_RESP_QUEUE 0x0c 69*7eb99bdaSLionel Sambuc 70*7eb99bdaSLionel Sambuc /* Control register bit definitions. */ 71*7eb99bdaSLionel Sambuc #define TWE_CTL_CLEAR_HOST_INTR 0x00080000 72*7eb99bdaSLionel Sambuc #define TWE_CTL_CLEAR_ATTN_INTR 0x00040000 73*7eb99bdaSLionel Sambuc #define TWE_CTL_MASK_CMD_INTR 0x00020000 74*7eb99bdaSLionel Sambuc #define TWE_CTL_MASK_RESP_INTR 0x00010000 75*7eb99bdaSLionel Sambuc #define TWE_CTL_UNMASK_CMD_INTR 0x00008000 76*7eb99bdaSLionel Sambuc #define TWE_CTL_UNMASK_RESP_INTR 0x00004000 77*7eb99bdaSLionel Sambuc #define TWE_CTL_CLEAR_ERROR_STS 0x00000200 78*7eb99bdaSLionel Sambuc #define TWE_CTL_ISSUE_SOFT_RESET 0x00000100 79*7eb99bdaSLionel Sambuc #define TWE_CTL_ENABLE_INTRS 0x00000080 80*7eb99bdaSLionel Sambuc #define TWE_CTL_DISABLE_INTRS 0x00000040 81*7eb99bdaSLionel Sambuc #define TWE_CTL_ISSUE_HOST_INTR 0x00000020 82*7eb99bdaSLionel Sambuc #define TWE_CTL_CLEAR_PARITY_ERROR 0x00800000 83*7eb99bdaSLionel Sambuc #define TWE_CTL_CLEAR_PCI_ABORT 0x00100000 84*7eb99bdaSLionel Sambuc 85*7eb99bdaSLionel Sambuc /* Status register bit definitions. */ 86*7eb99bdaSLionel Sambuc #define TWE_STS_MAJOR_VERSION_MASK 0xf0000000 87*7eb99bdaSLionel Sambuc #define TWE_STS_MINOR_VERSION_MASK 0x0f000000 88*7eb99bdaSLionel Sambuc #define TWE_STS_PCI_PARITY_ERROR 0x00800000 89*7eb99bdaSLionel Sambuc #define TWE_STS_QUEUE_ERROR 0x00400000 90*7eb99bdaSLionel Sambuc #define TWE_STS_MICROCONTROLLER_ERROR 0x00200000 91*7eb99bdaSLionel Sambuc #define TWE_STS_PCI_ABORT 0x00100000 92*7eb99bdaSLionel Sambuc #define TWE_STS_HOST_INTR 0x00080000 93*7eb99bdaSLionel Sambuc #define TWE_STS_ATTN_INTR 0x00040000 94*7eb99bdaSLionel Sambuc #define TWE_STS_CMD_INTR 0x00020000 95*7eb99bdaSLionel Sambuc #define TWE_STS_RESP_INTR 0x00010000 96*7eb99bdaSLionel Sambuc #define TWE_STS_CMD_QUEUE_FULL 0x00008000 97*7eb99bdaSLionel Sambuc #define TWE_STS_RESP_QUEUE_EMPTY 0x00004000 98*7eb99bdaSLionel Sambuc #define TWE_STS_MICROCONTROLLER_READY 0x00002000 99*7eb99bdaSLionel Sambuc #define TWE_STS_CMD_QUEUE_EMPTY 0x00001000 100*7eb99bdaSLionel Sambuc 101*7eb99bdaSLionel Sambuc #define TWE_STS_ALL_INTRS 0x000f0000 102*7eb99bdaSLionel Sambuc #define TWE_STS_CLEARABLE_BITS 0x00d00000 103*7eb99bdaSLionel Sambuc #define TWE_STS_EXPECTED_BITS 0x00002000 104*7eb99bdaSLionel Sambuc #define TWE_STS_UNEXPECTED_BITS 0x00f80000 105*7eb99bdaSLionel Sambuc 106*7eb99bdaSLionel Sambuc /* Command packet opcodes. */ 107*7eb99bdaSLionel Sambuc #define TWE_OP_NOP 0x00 108*7eb99bdaSLionel Sambuc #define TWE_OP_INIT_CONNECTION 0x01 109*7eb99bdaSLionel Sambuc #define TWE_OP_READ 0x02 110*7eb99bdaSLionel Sambuc #define TWE_OP_WRITE 0x03 111*7eb99bdaSLionel Sambuc #define TWE_OP_READVERIFY 0x04 112*7eb99bdaSLionel Sambuc #define TWE_OP_VERIFY 0x05 113*7eb99bdaSLionel Sambuc #define TWE_OP_PROBE 0x06 114*7eb99bdaSLionel Sambuc #define TWE_OP_PROBEUNIT 0x07 115*7eb99bdaSLionel Sambuc #define TWE_OP_ZEROUNIT 0x08 116*7eb99bdaSLionel Sambuc #define TWE_OP_REPLACEUNIT 0x09 117*7eb99bdaSLionel Sambuc #define TWE_OP_HOTSWAP 0x0a 118*7eb99bdaSLionel Sambuc #define TWE_OP_SETATAFEATURE 0x0c 119*7eb99bdaSLionel Sambuc #define TWE_OP_FLUSH 0x0e 120*7eb99bdaSLionel Sambuc #define TWE_OP_ABORT 0x0f 121*7eb99bdaSLionel Sambuc #define TWE_OP_CHECKSTATUS 0x10 122*7eb99bdaSLionel Sambuc #define TWE_OP_ATA_PASSTHROUGH 0x11 123*7eb99bdaSLionel Sambuc #define TWE_OP_GET_PARAM 0x12 124*7eb99bdaSLionel Sambuc #define TWE_OP_SET_PARAM 0x13 125*7eb99bdaSLionel Sambuc #define TWE_OP_CREATEUNIT 0x14 126*7eb99bdaSLionel Sambuc #define TWE_OP_DELETEUNIT 0x15 127*7eb99bdaSLionel Sambuc #define TWE_OP_REBUILDUNIT 0x17 128*7eb99bdaSLionel Sambuc #define TWE_OP_SECTOR_INFO 0x1a 129*7eb99bdaSLionel Sambuc #define TWE_OP_AEN_LISTEN 0x1c 130*7eb99bdaSLionel Sambuc #define TWE_OP_CMD_PACKET 0x1d 131*7eb99bdaSLionel Sambuc #define TWE_OP_CMD_WITH_DATA 0x1f 132*7eb99bdaSLionel Sambuc 133*7eb99bdaSLionel Sambuc /* Response queue entries. Masking and shifting yields request ID. */ 134*7eb99bdaSLionel Sambuc #define TWE_RESP_MASK 0x00000ff0 135*7eb99bdaSLionel Sambuc #define TWE_RESP_SHIFT 4 136*7eb99bdaSLionel Sambuc 137*7eb99bdaSLionel Sambuc /* Miscellenous constants. */ 138*7eb99bdaSLionel Sambuc #define TWE_ALIGNMENT 512 139*7eb99bdaSLionel Sambuc #define TWE_MAX_UNITS 16 140*7eb99bdaSLionel Sambuc #define TWE_INIT_CMD_PACKET_SIZE 0x3 141*7eb99bdaSLionel Sambuc #define TWE_SG_SIZE 62 142*7eb99bdaSLionel Sambuc #define TWE_MAX_CMDS 255 143*7eb99bdaSLionel Sambuc #define TWE_Q_START 0 144*7eb99bdaSLionel Sambuc #define TWE_UNIT_INFORMATION_TABLE_BASE 0x300 145*7eb99bdaSLionel Sambuc #define TWE_IOCTL 0x80 146*7eb99bdaSLionel Sambuc #define TWE_SECTOR_SIZE 512 147*7eb99bdaSLionel Sambuc 148*7eb99bdaSLionel Sambuc /* Scatter/gather block. */ 149*7eb99bdaSLionel Sambuc struct twe_sgb { 150*7eb99bdaSLionel Sambuc u_int32_t tsg_address; 151*7eb99bdaSLionel Sambuc u_int32_t tsg_length; 152*7eb99bdaSLionel Sambuc } __packed; 153*7eb99bdaSLionel Sambuc 154*7eb99bdaSLionel Sambuc /* 155*7eb99bdaSLionel Sambuc * Command block. This is 512 (really 508) bytes in size, and must be 156*7eb99bdaSLionel Sambuc * aligned on a 512 byte boundary. 157*7eb99bdaSLionel Sambuc */ 158*7eb99bdaSLionel Sambuc struct twe_cmd { 159*7eb99bdaSLionel Sambuc u_int8_t tc_opcode; /* high 3 bits is S/G list offset */ 160*7eb99bdaSLionel Sambuc u_int8_t tc_size; 161*7eb99bdaSLionel Sambuc u_int8_t tc_cmdid; 162*7eb99bdaSLionel Sambuc u_int8_t tc_unit; /* high nybble is host ID */ 163*7eb99bdaSLionel Sambuc u_int8_t tc_status; 164*7eb99bdaSLionel Sambuc u_int8_t tc_flags; 165*7eb99bdaSLionel Sambuc u_int16_t tc_count; /* block & param count, msg credits */ 166*7eb99bdaSLionel Sambuc union { 167*7eb99bdaSLionel Sambuc struct { 168*7eb99bdaSLionel Sambuc u_int32_t lba; 169*7eb99bdaSLionel Sambuc struct twe_sgb sgl[TWE_SG_SIZE]; 170*7eb99bdaSLionel Sambuc } io __packed; 171*7eb99bdaSLionel Sambuc struct { 172*7eb99bdaSLionel Sambuc struct twe_sgb sgl[TWE_SG_SIZE]; 173*7eb99bdaSLionel Sambuc } param; 174*7eb99bdaSLionel Sambuc struct { 175*7eb99bdaSLionel Sambuc u_int32_t response_queue_pointer; 176*7eb99bdaSLionel Sambuc } init_connection __packed; 177*7eb99bdaSLionel Sambuc } tc_args; 178*7eb99bdaSLionel Sambuc int32_t tc_pad; 179*7eb99bdaSLionel Sambuc } __packed; 180*7eb99bdaSLionel Sambuc 181*7eb99bdaSLionel Sambuc /* Get/set parameter block. */ 182*7eb99bdaSLionel Sambuc struct twe_param { 183*7eb99bdaSLionel Sambuc u_int16_t tp_table_id; 184*7eb99bdaSLionel Sambuc u_int8_t tp_param_id; 185*7eb99bdaSLionel Sambuc u_int8_t tp_param_size; 186*7eb99bdaSLionel Sambuc u_int8_t tp_data[1]; 187*7eb99bdaSLionel Sambuc } __packed; 188*7eb99bdaSLionel Sambuc 189*7eb99bdaSLionel Sambuc /* 190*7eb99bdaSLionel Sambuc * From 3ware's documentation: 191*7eb99bdaSLionel Sambuc * 192*7eb99bdaSLionel Sambuc * All parameters maintained by the controller are grouped into related 193*7eb99bdaSLionel Sambuc * tables. Tables are are accessed indirectly via get and set parameter 194*7eb99bdaSLionel Sambuc * commands. To access a specific parameter in a table, the table ID and 195*7eb99bdaSLionel Sambuc * parameter index are used to uniquely identify a parameter. Table 196*7eb99bdaSLionel Sambuc * 0xffff is the directory table and provides a list of the table IDs and 197*7eb99bdaSLionel Sambuc * sizes of all other tables. Index zero in each table specifies the 198*7eb99bdaSLionel Sambuc * entire table, and index one specifies the size of the table. An entire 199*7eb99bdaSLionel Sambuc * table can be read or set by using index zero. 200*7eb99bdaSLionel Sambuc */ 201*7eb99bdaSLionel Sambuc 202*7eb99bdaSLionel Sambuc #define TWE_PARAM_PARAM_ALL 0 203*7eb99bdaSLionel Sambuc #define TWE_PARAM_PARAM_SIZE 1 204*7eb99bdaSLionel Sambuc 205*7eb99bdaSLionel Sambuc #define TWE_PARAM_DIRECTORY 0xffff /* size is 4 * number of tables */ 206*7eb99bdaSLionel Sambuc #define TWE_PARAM_DIRECTORY_TABLES 2 /* 16 bits * number of tables */ 207*7eb99bdaSLionel Sambuc #define TWE_PARAM_DIRECTORY_SIZES 3 /* 16 bits * number of tables */ 208*7eb99bdaSLionel Sambuc 209*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVESUMMARY 0x0002 210*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVESUMMARY_Num 2 /* number of physical drives [2] */ 211*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVESUMMARY_Status 3 /* array giving drive status per aport */ 212*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVESTATUS_Missing 0x00 213*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVESTATUS_NotSupp 0xfe 214*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVESTATUS_Present 0xff 215*7eb99bdaSLionel Sambuc 216*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSUMMARY 0x0003 217*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSUMMARY_Num 2 /* number of logical units [2] */ 218*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSUMMARY_Status 3 /* array giving unit status [16] */ 219*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSTATUS_Online (1<<0) 220*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSTATUS_Complete (1<<1) 221*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSTATUS_MASK 0xfc 222*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSTATUS_Normal 0xfc 223*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSTATUS_Initialising 0xf4 /* cannot be incomplete */ 224*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSTATUS_Degraded 0xec 225*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSTATUS_Rebuilding 0xdc /* cannot be incomplete */ 226*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSTATUS_Verifying 0xcc /* cannot be incomplete */ 227*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSTATUS_Corrupt 0xbc /* cannot be complete */ 228*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITSTATUS_Missing 0x00 /* cannot be complete or online */ 229*7eb99bdaSLionel Sambuc 230*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO 0x0200 /* add drive number 0x00-0x0f XXX docco confused 0x0100 vs 0x0200 */ 231*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_Size 2 /* size in blocks [4] */ 232*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_Model 3 /* drive model string [40] */ 233*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_Serial 4 /* drive serial number [20] */ 234*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_PhysCylNum 5 /* physical geometry [2] */ 235*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_PhysHeadNum 6 /* [2] */ 236*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_PhysSectorNum 7 /* [2] */ 237*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_LogCylNum 8 /* logical geometry [2] */ 238*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_LogHeadNum 9 /* [2] */ 239*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_LogSectorNum 10 /* [2] */ 240*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_UnitNum 11 /* unit number this drive is associated with or 0xff [1] */ 241*7eb99bdaSLionel Sambuc #define TWE_PARAM_DRIVEINFO_DriveFlags 12 /* N/A [1] */ 242*7eb99bdaSLionel Sambuc 243*7eb99bdaSLionel Sambuc #define TWE_PARAM_APORTTIMEOUT 0x02c0 /* add (aport_number * 3) to parameter index */ 244*7eb99bdaSLionel Sambuc #define TWE_PARAM_APORTTIMEOUT_READ 2 /* read timeouts last 24hrs [2] */ 245*7eb99bdaSLionel Sambuc #define TWE_PARAM_APORTTIMEOUT_WRITE 3 /* write timeouts last 24hrs [2] */ 246*7eb99bdaSLionel Sambuc #define TWE_PARAM_APORTTIMEOUT_DEGRADE 4 /* degrade threshold [2] */ 247*7eb99bdaSLionel Sambuc 248*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITINFO 0x0300 /* add unit number 0x00-0x0f */ 249*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITINFO_Number 2 /* unit number [1] */ 250*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITINFO_Status 3 /* unit status [1] */ 251*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITINFO_Capacity 4 /* unit capacity in blocks [4] */ 252*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITINFO_DescriptorSize 5 /* unit descriptor size + 3 bytes [2] */ 253*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITINFO_Descriptor 6 /* unit descriptor, TWE_UnitDescriptor or TWE_Array_Descriptor */ 254*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITINFO_Flags 7 /* unit flags [1] */ 255*7eb99bdaSLionel Sambuc #define TWE_PARAM_UNITFLAGS_WCE (1<<0) 256*7eb99bdaSLionel Sambuc 257*7eb99bdaSLionel Sambuc #define TWE_PARAM_AEN 0x0401 258*7eb99bdaSLionel Sambuc #define TWE_PARAM_AEN_UnitCode 2 /* (unit number << 8) | AEN code [2] */ 259*7eb99bdaSLionel Sambuc #define TWE_AEN_QUEUE_EMPTY 0x00 260*7eb99bdaSLionel Sambuc #define TWE_AEN_SOFT_RESET 0x01 261*7eb99bdaSLionel Sambuc #define TWE_AEN_DEGRADED_MIRROR 0x02 /* reports unit */ 262*7eb99bdaSLionel Sambuc #define TWE_AEN_CONTROLLER_ERROR 0x03 263*7eb99bdaSLionel Sambuc #define TWE_AEN_REBUILD_FAIL 0x04 /* reports unit */ 264*7eb99bdaSLionel Sambuc #define TWE_AEN_REBUILD_DONE 0x05 /* reports unit */ 265*7eb99bdaSLionel Sambuc #define TWE_AEN_INCOMP_UNIT 0x06 /* reports unit */ 266*7eb99bdaSLionel Sambuc #define TWE_AEN_INIT_DONE 0x07 /* reports unit */ 267*7eb99bdaSLionel Sambuc #define TWE_AEN_UNCLEAN_SHUTDOWN 0x08 /* reports unit */ 268*7eb99bdaSLionel Sambuc #define TWE_AEN_APORT_TIMEOUT 0x09 /* reports unit, rate limited to 1 per 2^16 errors */ 269*7eb99bdaSLionel Sambuc #define TWE_AEN_DRIVE_ERROR 0x0a /* reports unit */ 270*7eb99bdaSLionel Sambuc #define TWE_AEN_REBUILD_STARTED 0x0b /* reports unit */ 271*7eb99bdaSLionel Sambuc #define TWE_AEN_QUEUE_FULL 0xff 272*7eb99bdaSLionel Sambuc #define TWE_AEN_TABLE_UNDEFINED 0x15 273*7eb99bdaSLionel Sambuc #define TWE_AEN_CODE(x) ((x) & 0xff) 274*7eb99bdaSLionel Sambuc #define TWE_AEN_UNIT(x) ((x) >> 8) 275*7eb99bdaSLionel Sambuc 276*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION 0x0402 277*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION_Mon 2 /* monitor version [16] */ 278*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION_FW 3 /* firmware version [16] */ 279*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION_BIOS 4 /* BIOSs version [16] */ 280*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION_PCB 5 /* PCB version [8] */ 281*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION_ATA 6 /* A-chip version [8] */ 282*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION_PCI 7 /* P-chip version [8] */ 283*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION_CtrlModel 8 /* N/A */ 284*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION_CtrlSerial 9 /* N/A */ 285*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION_SBufSize 10 /* N/A */ 286*7eb99bdaSLionel Sambuc #define TWE_PARAM_VERSION_CompCode 11 /* compatibility code [4] */ 287*7eb99bdaSLionel Sambuc 288*7eb99bdaSLionel Sambuc #define TWE_PARAM_CONTROLLER 0x0403 289*7eb99bdaSLionel Sambuc #define TWE_PARAM_CONTROLLER_DCBSectors 2 /* # sectors reserved for DCB per drive [2] */ 290*7eb99bdaSLionel Sambuc #define TWE_PARAM_CONTROLLER_PortCount 3 /* number of drive ports [1] */ 291*7eb99bdaSLionel Sambuc 292*7eb99bdaSLionel Sambuc #define TWE_PARAM_FEATURES 0x404 293*7eb99bdaSLionel Sambuc #define TWE_PARAM_FEATURES_DriverShutdown 2 /* set to 1 if driver supports shutdown notification [1] */ 294*7eb99bdaSLionel Sambuc 295*7eb99bdaSLionel Sambuc #define TWE_PARAM_PROC 0x406 296*7eb99bdaSLionel Sambuc #define TWE_PARAM_PROC_PERCENT 2 /* Per-sub-unit % complete of init/verify/rebuild or 0xff [16] */ 297*7eb99bdaSLionel Sambuc 298*7eb99bdaSLionel Sambuc struct twe_unit_descriptor { 299*7eb99bdaSLionel Sambuc u_int8_t num_subunits; /* must be zero */ 300*7eb99bdaSLionel Sambuc u_int8_t configuration; 301*7eb99bdaSLionel Sambuc #define TWE_UD_CONFIG_CBOD 0x0c /* JBOD with DCB, used for mirrors */ 302*7eb99bdaSLionel Sambuc #define TWE_UD_CONFIG_SPARE 0x0d /* same as CBOD, but firmware will use as spare */ 303*7eb99bdaSLionel Sambuc #define TWE_UD_CONFIG_SUBUNIT 0x0e /* drive is a subunit in an array */ 304*7eb99bdaSLionel Sambuc #define TWE_UD_CONFIG_JBOD 0x0f /* plain drive */ 305*7eb99bdaSLionel Sambuc u_int8_t phys_drv_num; /* may be 0xff if port can't be determined at runtime */ 306*7eb99bdaSLionel Sambuc u_int8_t log_drv_num; /* must be zero for configuration == 0x0f */ 307*7eb99bdaSLionel Sambuc u_int32_t start_lba; 308*7eb99bdaSLionel Sambuc u_int32_t block_count; /* actual drive size if configuration == 0x0f, otherwise less DCB size */ 309*7eb99bdaSLionel Sambuc } __packed; 310*7eb99bdaSLionel Sambuc 311*7eb99bdaSLionel Sambuc struct twe_mirror_descriptor { 312*7eb99bdaSLionel Sambuc u_int8_t flag; /* must be 0xff */ 313*7eb99bdaSLionel Sambuc u_int8_t res1; 314*7eb99bdaSLionel Sambuc u_int8_t mirunit_status[4]; /* bitmap of functional subunits in each mirror */ 315*7eb99bdaSLionel Sambuc u_int8_t res2[6]; 316*7eb99bdaSLionel Sambuc } __packed; 317*7eb99bdaSLionel Sambuc 318*7eb99bdaSLionel Sambuc struct twe_array_descriptor { 319*7eb99bdaSLionel Sambuc u_int8_t num_subunits; /* number of subunits, or number of mirror units in RAID10 */ 320*7eb99bdaSLionel Sambuc u_int8_t configuration; 321*7eb99bdaSLionel Sambuc #define TWE_AD_CONFIG_RAID0 0x00 322*7eb99bdaSLionel Sambuc #define TWE_AD_CONFIG_RAID1 0x01 323*7eb99bdaSLionel Sambuc #define TWE_AD_CONFIG_TwinStor 0x02 324*7eb99bdaSLionel Sambuc #define TWE_AD_CONFIG_RAID5 0x05 325*7eb99bdaSLionel Sambuc #define TWE_AD_CONFIG_RAID10 0x06 326*7eb99bdaSLionel Sambuc u_int8_t stripe_size; 327*7eb99bdaSLionel Sambuc #define TWE_AD_STRIPE_4k 0x03 328*7eb99bdaSLionel Sambuc #define TWE_AD_STRIPE_8k 0x04 329*7eb99bdaSLionel Sambuc #define TWE_AD_STRIPE_16k 0x05 330*7eb99bdaSLionel Sambuc #define TWE_AD_STRIPE_32k 0x06 331*7eb99bdaSLionel Sambuc #define TWE_AD_STRIPE_64k 0x07 332*7eb99bdaSLionel Sambuc #define TWE_AD_STRIPE_128k 0x08 333*7eb99bdaSLionel Sambuc #define TWE_AD_STRIPE_256k 0x09 334*7eb99bdaSLionel Sambuc #define TWE_AD_STRIPE_512k 0x0a 335*7eb99bdaSLionel Sambuc #define TWE_AD_STRIPE_1024k 0x0b 336*7eb99bdaSLionel Sambuc u_int8_t log_drv_status; /* bitmap of functional subunits, or mirror units in RAID10 */ 337*7eb99bdaSLionel Sambuc u_int32_t start_lba; 338*7eb99bdaSLionel Sambuc u_int32_t block_count; /* actual drive size if configuration == 0x0f, otherwise less DCB size */ 339*7eb99bdaSLionel Sambuc struct twe_unit_descriptor subunit[1]; 340*7eb99bdaSLionel Sambuc } __packed; 341*7eb99bdaSLionel Sambuc 342*7eb99bdaSLionel Sambuc #endif /* !_PCI_TWEREG_H_ */ 343