twe_tables.h revision 118508
1109864Sjeff/*-
2113357Sjeff * Copyright (c) 2000 Michael Smith
3109864Sjeff * Copyright (c) 2000 BSDi
4109864Sjeff * All rights reserved.
5109864Sjeff *
6109864Sjeff * Redistribution and use in source and binary forms, with or without
7109864Sjeff * modification, are permitted provided that the following conditions
8109864Sjeff * are met:
9109864Sjeff * 1. Redistributions of source code must retain the above copyright
10109864Sjeff *    notice, this list of conditions and the following disclaimer.
11109864Sjeff * 2. Redistributions in binary form must reproduce the above copyright
12109864Sjeff *    notice, this list of conditions and the following disclaimer in the
13109864Sjeff *    documentation and/or other materials provided with the distribution.
14109864Sjeff *
15109864Sjeff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16109864Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17109864Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18109864Sjeff * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19109864Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20109864Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21109864Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22109864Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23109864Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24109864Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25109864Sjeff * SUCH DAMAGE.
26109864Sjeff *
27116182Sobrien *	$FreeBSD: head/sys/dev/twe/twe_tables.h 118508 2003-08-05 19:55:21Z ps $
28116182Sobrien */
29116182Sobrien
30109864Sjeff/*
31109864Sjeff * Lookup table for code-to-text translations.
32109864Sjeff */
33109864Sjeffstruct twe_code_lookup {
34109864Sjeff    char	*string;
35109864Sjeff    u_int32_t	code;
36109864Sjeff};
37112966Sjeff
38122038Sjeffextern char	*twe_describe_code(struct twe_code_lookup *table, u_int32_t code);
39109864Sjeff
40109864Sjeff#ifndef TWE_DEFINE_TABLES
41109864Sjeffextern struct twe_code_lookup twe_table_status[];
42109864Sjeffextern struct twe_code_lookup twe_table_unitstate[];
43109864Sjeffextern struct twe_code_lookup twe_table_unittype[];
44109864Sjeffextern struct twe_code_lookup twe_table_aen[];
45109864Sjeffextern struct twe_code_lookup twe_table_opcode[];
46109864Sjeff#else /* TWE_DEFINE_TABLES */
47109864Sjeff
48109864Sjeff/********************************************************************************
49109864Sjeff * Look up a text description of a numeric code and return a pointer to same.
50109864Sjeff */
51109864Sjeffchar *
52109864Sjefftwe_describe_code(struct twe_code_lookup *table, u_int32_t code)
53109864Sjeff{
54121790Sjeff    int		i;
55109864Sjeff
56113357Sjeff    for (i = 0; table[i].string != NULL; i++)
57113357Sjeff	if (table[i].code == code)
58109864Sjeff	    return(table[i].string);
59109864Sjeff    return(table[i+1].string);
60109864Sjeff}
61109864Sjeff
62109864Sjeff
63109864Sjeffstruct twe_code_lookup twe_table_status[] = {
64109864Sjeff    /* success */
65109864Sjeff    {"successful completion",					0x00},
66113357Sjeff    /* info */
67113357Sjeff    {"command in progress",					0x42},
68113357Sjeff    {"retrying interface CRC error from UDMA command",		0x6c},
69113357Sjeff    /* warning */
70113357Sjeff    {"redundant/inconsequential request ignored",		0x81},
71113357Sjeff    {"failed to write zeroes to LBA 0",				0x8e},
72113357Sjeff    {"failed to profile TwinStor zones",			0x8f},
73113357Sjeff    /* fatal */
74116365Sjeff    {"aborted due to system command or reconfiguration",	0xc1},
75113357Sjeff    {"aborted",							0xc4},
76113357Sjeff    {"access error",						0xc5},
77111857Sjeff    {"access violation",					0xc6},
78113357Sjeff    {"device failure",						0xc7},	/* high byte may be port number */
79111857Sjeff    {"controller error",					0xc8},
80116069Sjeff    {"timed out",						0xc9},
81116069Sjeff    {"invalid unit number",					0xcb},
82116069Sjeff    {"unit not available",					0xcf},
83116069Sjeff    {"undefined opcode",					0xd2},
84116069Sjeff    {"request incompatible with unit",				0xdb},
85109864Sjeff    {"invalid request",						0xdc},
86109864Sjeff    {"firmware error, reset requested",				0xff},
87109864Sjeff    {NULL,	0},
88109864Sjeff    {"unknown status",	0}
89109864Sjeff};
90109864Sjeff
91109864Sjeffstruct twe_code_lookup twe_table_unitstate[] = {
92109864Sjeff    {"Normal",		TWE_PARAM_UNITSTATUS_Normal},
93109864Sjeff    {"Initialising",	TWE_PARAM_UNITSTATUS_Initialising},
94109864Sjeff    {"Degraded",	TWE_PARAM_UNITSTATUS_Degraded},
95109864Sjeff    {"Rebuilding",	TWE_PARAM_UNITSTATUS_Rebuilding},
96109864Sjeff    {"Verifying",	TWE_PARAM_UNITSTATUS_Verifying},
97113357Sjeff    {"Corrupt",		TWE_PARAM_UNITSTATUS_Corrupt},
98110260Sjeff    {"Missing",		TWE_PARAM_UNITSTATUS_Missing},
99109864Sjeff    {NULL, 0},
100109864Sjeff    {"unknown state",	0}
101109864Sjeff};
102109864Sjeff
103109864Sjeffstruct twe_code_lookup twe_table_unittype[] = {
104109864Sjeff    {"RAID0",		TWE_UD_CONFIG_RAID0},
105110260Sjeff    {"RAID1",		TWE_UD_CONFIG_RAID1},
106121790Sjeff    {"TwinStor",	TWE_UD_CONFIG_TwinStor},
107109864Sjeff    {"RAID5",		TWE_UD_CONFIG_RAID5},
108121790Sjeff    {"RAID10",		TWE_UD_CONFIG_RAID10},
109122038Sjeff    {"CBOD",		TWE_UD_CONFIG_CBOD},
110122038Sjeff    {"SPARE",		TWE_UD_CONFIG_SPARE},
111121790Sjeff    {"SUBUNIT",		TWE_UD_CONFIG_SUBUNIT},
112109864Sjeff    {"JBOD",		TWE_UD_CONFIG_JBOD},
113110645Sjeff    {NULL, 0},
114110645Sjeff    {"unknown type",	0}
115109864Sjeff};
116109864Sjeff
117110645Sjeffstruct twe_code_lookup twe_table_aen[] = {
118109864Sjeff    {"q queue empty",			0x00},
119109864Sjeff    {"q soft reset",			0x01},
120109864Sjeff    {"c degraded mirror",		0x02},
121109864Sjeff    {"a controller error",		0x03},
122109864Sjeff    {"c rebuild fail",			0x04},
123109864Sjeff    {"c rebuild done",			0x05},
124110267Sjeff    {"c incomplete unit",		0x06},
125109864Sjeff    {"c initialisation done",		0x07},
126109864Sjeff    {"c unclean shutdown detected",	0x08},
127109864Sjeff    {"c drive timeout",			0x09},
128109864Sjeff    {"c drive error",			0x0a},
129109864Sjeff    {"c rebuild started",		0x0b},
130109864Sjeff    {"c init started",			0x0c},
131109864Sjeff    {"c logical unit deleted",		0x0d},
132109864Sjeff    {"p SMART threshold exceeded",	0x0f},
133109864Sjeff    {"p ATA UDMA downgrade",		0x21},
134116642Sjeff    {"p ATA UDMA upgrade",		0x22},
135116642Sjeff    {"p sector repair occurred",	0x23},
136116642Sjeff    {"a SBUF integrity check failure",	0x24},
137116642Sjeff    {"p lost cached write",		0x25},
138111857Sjeff    {"p drive ECC error detected",	0x26},
139111857Sjeff    {"p DCB checksum error",		0x27},
140116642Sjeff    {"p DCB unsupported version",	0x28},
141111857Sjeff    {"c verify started",		0x29},
142109864Sjeff    {"c verify failed",			0x2a},
143111857Sjeff    {"c verify complete",		0x2b},
144121869Sjeff    {"p overwrote bad sector during rebuild",	0x2c},
145121869Sjeff    {"p encountered bad sector during rebuild",	0x2d},
146116642Sjeff    {"a replacement drive too small", 0x2e},
147113357Sjeff    {"c array not previously initialized", 0x2f},
148116642Sjeff    {"p drive not supported", 0x30},
149109864Sjeff    {"a aen queue full",		0xff},
150109864Sjeff    {NULL, 0},
151111857Sjeff    {"x unknown AEN",		0}
152109864Sjeff};
153110645Sjeff
154110645Sjeffstruct twe_code_lookup twe_table_opcode[] = {
155121868Sjeff    {"NOP",			0x00},
156116365Sjeff    {"INIT_CONNECTION",		0x01},
157111857Sjeff    {"READ",			0x02},
158109864Sjeff    {"WRITE",			0x03},
159121126Sjeff    {"READVERIFY",		0x04},
160121868Sjeff    {"VERIFY",			0x05},
161116365Sjeff    {"ZEROUNIT",		0x08},
162116365Sjeff    {"REPLACEUNIT",		0x09},
163121126Sjeff    {"HOTSWAP",			0x0a},
164111857Sjeff    {"SETATAFEATURE",		0x0c},
165109864Sjeff    {"FLUSH",			0x0e},
166109864Sjeff    {"ABORT",			0x0f},
167109864Sjeff    {"CHECKSTATUS",		0x10},
168109864Sjeff    {"GET_PARAM",		0x12},
169109864Sjeff    {"SET_PARAM",		0x13},
170109864Sjeff    {"CREATEUNIT",		0x14},
171109864Sjeff    {"DELETEUNIT",		0x15},
172112966Sjeff    {"REBUILDUNIT",		0x17},
173112966Sjeff    {"SECTOR_INFO",		0x1a},
174121871Sjeff    {"AEN_LISTEN",		0x1c},
175109864Sjeff    {"CMD_PACKET",		0x1d},
176113357Sjeff    {NULL, 0},
177113357Sjeff    {"unknown opcode",		0}
178121871Sjeff};
179111857Sjeff
180109864Sjeff#endif
181112966Sjeff