xref: /dragonfly/sys/dev/raid/twe/twe_tables.h (revision 2cd2d2b5)
1 /*-
2  * Copyright (c) 2000 Michael Smith
3  * Copyright (c) 2000 BSDi
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  *	$FreeBSD: src/sys/dev/twe/twe_tables.h,v 1.1.2.2 2002/03/07 09:57:02 msmith Exp $
28  *	$DragonFly: src/sys/dev/raid/twe/twe_tables.h,v 1.3 2004/01/05 17:40:00 drhodus Exp $
29  */
30 
31 /*
32  * Lookup table for code-to-text translations.
33  */
34 struct twe_code_lookup {
35     char	*string;
36     u_int32_t	code;
37 };
38 
39 extern char	*twe_describe_code(struct twe_code_lookup *table, u_int32_t code);
40 
41 #ifndef TWE_DEFINE_TABLES
42 extern struct twe_code_lookup twe_table_status[];
43 extern struct twe_code_lookup twe_table_unitstate[];
44 extern struct twe_code_lookup twe_table_unittype[];
45 extern struct twe_code_lookup twe_table_aen[];
46 extern struct twe_code_lookup twe_table_opcode[];
47 #else /* TWE_DEFINE_TABLES */
48 
49 /********************************************************************************
50  * Look up a text description of a numeric code and return a pointer to same.
51  */
52 char *
53 twe_describe_code(struct twe_code_lookup *table, u_int32_t code)
54 {
55     int		i;
56 
57     for (i = 0; table[i].string != NULL; i++)
58 	if (table[i].code == code)
59 	    return(table[i].string);
60     return(table[i+1].string);
61 }
62 
63 
64 struct twe_code_lookup twe_table_status[] = {
65     /* success */
66     {"successful completion",					0x00},
67     /* info */
68     {"command in progress",					0x42},
69     {"retrying interface CRC error from UDMA command",		0x6c},
70     /* warning */
71     {"redundant/inconsequential request ignored",		0x81},
72     {"failed to write zeroes to LBA 0",				0x8e},
73     {"failed to profile TwinStor zones",			0x8f},
74     /* fatal */
75     {"aborted due to system command or reconfiguration",	0xc1},
76     {"aborted",							0xc4},
77     {"access error",						0xc5},
78     {"access violation",					0xc6},
79     {"device failure",						0xc7},	/* high byte may be port number */
80     {"controller error",					0xc8},
81     {"timed out",						0xc9},
82     {"invalid unit number",					0xcb},
83     {"unit not available",					0xcf},
84     {"undefined opcode",					0xd2},
85     {"request incompatible with unit",				0xdb},
86     {"invalid request",						0xdc},
87     {"firmware error, reset requested",				0xff},
88     {NULL,	0},
89     {"unknown status",	0}
90 };
91 
92 struct twe_code_lookup twe_table_unitstate[] = {
93     {"Normal",		TWE_PARAM_UNITSTATUS_Normal},
94     {"Initialising",	TWE_PARAM_UNITSTATUS_Initialising},
95     {"Degraded",	TWE_PARAM_UNITSTATUS_Degraded},
96     {"Rebuilding",	TWE_PARAM_UNITSTATUS_Rebuilding},
97     {"Verifying",	TWE_PARAM_UNITSTATUS_Verifying},
98     {"Corrupt",		TWE_PARAM_UNITSTATUS_Corrupt},
99     {"Missing",		TWE_PARAM_UNITSTATUS_Missing},
100     {NULL, 0},
101     {"unknown state",	0}
102 };
103 
104 struct twe_code_lookup twe_table_unittype[] = {
105     {"RAID0",		TWE_UD_CONFIG_RAID0},
106     {"RAID1",		TWE_UD_CONFIG_RAID1},
107     {"TwinStor",	TWE_UD_CONFIG_TwinStor},
108     {"RAID5",		TWE_UD_CONFIG_RAID5},
109     {"RAID10",		TWE_UD_CONFIG_RAID10},
110     {"CBOD",		TWE_UD_CONFIG_CBOD},
111     {"SPARE",		TWE_UD_CONFIG_SPARE},
112     {"SUBUNIT",		TWE_UD_CONFIG_SUBUNIT},
113     {"JBOD",		TWE_UD_CONFIG_JBOD},
114     {NULL, 0},
115     {"unknown type",	0}
116 };
117 
118 struct twe_code_lookup twe_table_aen[] = {
119     {"q queue empty",			0x00},
120     {"q soft reset",			0x01},
121     {"c degraded mirror",		0x02},
122     {"a controller error",		0x03},
123     {"c rebuild fail",			0x04},
124     {"c rebuild done",			0x05},
125     {"c incomplete unit",		0x06},
126     {"c initialisation done",		0x07},
127     {"c unclean shutdown detected",	0x08},
128     {"c drive timeout",			0x09},
129     {"c drive error",			0x0a},
130     {"c rebuild started",		0x0b},
131     {"c init started",			0x0c},
132     {"c logical unit deleted",		0x0d},
133     {"p SMART threshold exceeded",	0x0f},
134     {"p ATA UDMA downgrade",		0x21},
135     {"p ATA UDMA upgrade",		0x22},
136     {"p sector repair occurred",	0x23},
137     {"a SBUF integrity check failure",	0x24},
138     {"p lost cached write",		0x25},
139     {"p drive ECC error detected",	0x26},
140     {"p DCB checksum error",		0x27},
141     {"p DCB unsupported version",	0x28},
142     {"c verify started",		0x29},
143     {"c verify failed",			0x2a},
144     {"c verify complete",		0x2b},
145     {"p overwrote bad sector during rebuild",	0x2c},
146     {"p encountered bad sector during rebuild",	0x2d},
147     {"a replacement drive too small", 0x2e},
148     {"c array not previously initialized", 0x2f},
149     {"p drive not supported", 0x30},
150     {"a aen queue full",		0xff},
151     {NULL, 0},
152     {"x unknown AEN",		0}
153 };
154 
155 struct twe_code_lookup twe_table_opcode[] = {
156     {"NOP",			0x00},
157     {"INIT_CONNECTION",		0x01},
158     {"READ",			0x02},
159     {"WRITE",			0x03},
160     {"READVERIFY",		0x04},
161     {"VERIFY",			0x05},
162     {"ZEROUNIT",		0x08},
163     {"REPLACEUNIT",		0x09},
164     {"HOTSWAP",			0x0a},
165     {"SETATAFEATURE",		0x0c},
166     {"FLUSH",			0x0e},
167     {"ABORT",			0x0f},
168     {"CHECKSTATUS",		0x10},
169     {"GET_PARAM",		0x12},
170     {"SET_PARAM",		0x13},
171     {"CREATEUNIT",		0x14},
172     {"DELETEUNIT",		0x15},
173     {"REBUILDUNIT",		0x17},
174     {"SECTOR_INFO",		0x1a},
175     {"AEN_LISTEN",		0x1c},
176     {"CMD_PACKET",		0x1d},
177     {NULL, 0},
178     {"unknown opcode",		0}
179 };
180 
181 #endif
182