/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*-
* Copyright (c) 2000 Michael Smith
* Copyright (c) 2000 BSDi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from FreeBSD: twereg.h,v 1.1 2000/05/24 23:35:23 msmith Exp
*/
/*
* From 3ware's documentation:
*
* All parameters maintained by the controller are grouped into related
* tables. Tables are accessed indirectly via get and set parameter
* commands. To access a specific parameter in a table, the table ID and
* parameter index are used to uniquely identify a parameter. Table
* 0xffff is the directory table and provides a list of the table IDs and
* sizes of all other tables. Index zero in each table specifies the
* entire table, and index one specifies the size of the table. An entire
* table can be read or set by using index zero.
*/
#define TWE_PARAM_DIRECTORY 0xffff /* size is 4 * number of tables */
#define TWE_PARAM_DIRECTORY_TABLES 2 /* 16 bits * number of tables */
#define TWE_PARAM_DIRECTORY_SIZES 3 /* 16 bits * number of tables */
#define TWE_PARAM_DRIVESUMMARY 0x0002
#define TWE_PARAM_DRIVESUMMARY_Num 2 /* number of physical drives [2] */
#define TWE_PARAM_DRIVESUMMARY_Status 3 /* array giving drive status per aport */
#define TWE_PARAM_DRIVESTATUS_Missing 0x00
#define TWE_PARAM_DRIVESTATUS_NotSupp 0xfe
#define TWE_PARAM_DRIVESTATUS_Present 0xff
#define TWE_PARAM_UNITSUMMARY 0x0003
#define TWE_PARAM_UNITSUMMARY_Num 2 /* number of logical units [2] */
#define TWE_PARAM_UNITSUMMARY_Status 3 /* array giving unit status [16] */
#define TWE_PARAM_UNITSTATUS_Online (1<<0)
#define TWE_PARAM_UNITSTATUS_Complete (1<<1)
#define TWE_PARAM_UNITSTATUS_MASK 0xfc
#define TWE_PARAM_UNITSTATUS_Normal 0xfc
#define TWE_PARAM_UNITSTATUS_Initialising 0xf4 /* cannot be incomplete */
#define TWE_PARAM_UNITSTATUS_Degraded 0xec
#define TWE_PARAM_UNITSTATUS_Rebuilding 0xdc /* cannot be incomplete */
#define TWE_PARAM_UNITSTATUS_Verifying 0xcc /* cannot be incomplete */
#define TWE_PARAM_UNITSTATUS_Corrupt 0xbc /* cannot be complete */
#define TWE_PARAM_UNITSTATUS_Missing 0x00 /* cannot be complete or online */
#define TWE_PARAM_DRIVEINFO 0x0200 /* add drive number 0x00-0x0f XXX docco confused 0x0100 vs 0x0200 */
#define TWE_PARAM_DRIVEINFO_Size 2 /* size in blocks [4] */
#define TWE_PARAM_DRIVEINFO_Model 3 /* drive model string [40] */
#define TWE_PARAM_DRIVEINFO_Serial 4 /* drive serial number [20] */
#define TWE_PARAM_DRIVEINFO_PhysCylNum 5 /* physical geometry [2] */
#define TWE_PARAM_DRIVEINFO_PhysHeadNum 6 /* [2] */
#define TWE_PARAM_DRIVEINFO_PhysSectorNum 7 /* [2] */
#define TWE_PARAM_DRIVEINFO_LogCylNum 8 /* logical geometry [2] */
#define TWE_PARAM_DRIVEINFO_LogHeadNum 9 /* [2] */
#define TWE_PARAM_DRIVEINFO_LogSectorNum 10 /* [2] */
#define TWE_PARAM_DRIVEINFO_UnitNum 11 /* unit number this drive is associated with or 0xff [1] */
#define TWE_PARAM_DRIVEINFO_DriveFlags 12 /* N/A [1] */
#define TWE_PARAM_APORTTIMEOUT 0x02c0 /* add (aport_number * 3) to parameter index */
#define TWE_PARAM_APORTTIMEOUT_READ 2 /* read timeouts last 24hrs [2] */
#define TWE_PARAM_APORTTIMEOUT_WRITE 3 /* write timeouts last 24hrs [2] */
#define TWE_PARAM_APORTTIMEOUT_DEGRADE 4 /* degrade threshold [2] */
#define TWE_PARAM_UNITINFO 0x0300 /* add unit number 0x00-0x0f */
#define TWE_PARAM_UNITINFO_Number 2 /* unit number [1] */
#define TWE_PARAM_UNITINFO_Status 3 /* unit status [1] */
#define TWE_PARAM_UNITINFO_Capacity 4 /* unit capacity in blocks [4] */
#define TWE_PARAM_UNITINFO_DescriptorSize 5 /* unit descriptor size + 3 bytes [2] */
#define TWE_PARAM_UNITINFO_Descriptor 6 /* unit descriptor, TWE_UnitDescriptor or TWE_Array_Descriptor */
#define TWE_PARAM_UNITINFO_Flags 7 /* unit flags [1] */
#define TWE_PARAM_UNITFLAGS_WCE (1<<0)
#define TWE_PARAM_AEN 0x0401
#define TWE_PARAM_AEN_UnitCode 2 /* (unit number << 8) | AEN code [2] */
#define TWE_AEN_QUEUE_EMPTY 0x00
#define TWE_AEN_SOFT_RESET 0x01
#define TWE_AEN_DEGRADED_MIRROR 0x02 /* reports unit */
#define TWE_AEN_CONTROLLER_ERROR 0x03
#define TWE_AEN_REBUILD_FAIL 0x04 /* reports unit */
#define TWE_AEN_REBUILD_DONE 0x05 /* reports unit */
#define TWE_AEN_INCOMP_UNIT 0x06 /* reports unit */
#define TWE_AEN_INIT_DONE 0x07 /* reports unit */
#define TWE_AEN_UNCLEAN_SHUTDOWN 0x08 /* reports unit */
#define TWE_AEN_APORT_TIMEOUT 0x09 /* reports unit, rate limited to 1 per 2^16 errors */
#define TWE_AEN_DRIVE_ERROR 0x0a /* reports unit */
#define TWE_AEN_REBUILD_STARTED 0x0b /* reports unit */
#define TWE_AEN_QUEUE_FULL 0xff
#define TWE_AEN_TABLE_UNDEFINED 0x15
#define TWE_AEN_CODE(x) ((x) & 0xff)
#define TWE_AEN_UNIT(x) ((x) >> 8)
#define TWE_PARAM_CONTROLLER 0x0403
#define TWE_PARAM_CONTROLLER_DCBSectors 2 /* # sectors reserved for DCB per drive [2] */
#define TWE_PARAM_CONTROLLER_PortCount 3 /* number of drive ports [1] */
#define TWE_PARAM_FEATURES 0x404
#define TWE_PARAM_FEATURES_DriverShutdown 2 /* set to 1 if driver supports shutdown notification [1] */
#define TWE_PARAM_PROC 0x406
#define TWE_PARAM_PROC_PERCENT 2 /* Per-sub-unit % complete of init/verify/rebuild or 0xff [16] */
struct twe_unit_descriptor {
u_int8_t num_subunits; /* must be zero */
u_int8_t configuration;
#define TWE_UD_CONFIG_CBOD 0x0c /* JBOD with DCB, used for mirrors */
#define TWE_UD_CONFIG_SPARE 0x0d /* same as CBOD, but firmware will use as spare */
#define TWE_UD_CONFIG_SUBUNIT 0x0e /* drive is a subunit in an array */
#define TWE_UD_CONFIG_JBOD 0x0f /* plain drive */
u_int8_t phys_drv_num; /* may be 0xff if port can't be determined at runtime */
u_int8_t log_drv_num; /* must be zero for configuration == 0x0f */
u_int32_t start_lba;
u_int32_t block_count; /* actual drive size if configuration == 0x0f, otherwise less DCB size */
} __packed;
struct twe_mirror_descriptor {
u_int8_t flag; /* must be 0xff */
u_int8_t res1;
u_int8_t mirunit_status[4]; /* bitmap of functional subunits in each mirror */
u_int8_t res2[6];
} __packed;
struct twe_array_descriptor {
u_int8_t num_subunits; /* number of subunits, or number of mirror units in RAID10 */
u_int8_t configuration;
#define TWE_AD_CONFIG_RAID0 0x00
#define TWE_AD_CONFIG_RAID1 0x01
#define TWE_AD_CONFIG_TwinStor 0x02
#define TWE_AD_CONFIG_RAID5 0x05
#define TWE_AD_CONFIG_RAID10 0x06
u_int8_t stripe_size;
#define TWE_AD_STRIPE_4k 0x03
#define TWE_AD_STRIPE_8k 0x04
#define TWE_AD_STRIPE_16k 0x05
#define TWE_AD_STRIPE_32k 0x06
#define TWE_AD_STRIPE_64k 0x07
#define TWE_AD_STRIPE_128k 0x08
#define TWE_AD_STRIPE_256k 0x09
#define TWE_AD_STRIPE_512k 0x0a
#define TWE_AD_STRIPE_1024k 0x0b
u_int8_t log_drv_status; /* bitmap of functional subunits, or mirror units in RAID10 */
u_int32_t start_lba;
u_int32_t block_count; /* actual drive size if configuration == 0x0f, otherwise less DCB size */
struct twe_unit_descriptor subunit[1];
} __packed;