summaryrefslogtreecommitdiffstats
path: root/sys/dev/twe/twe_tables.h
blob: aa1ab020772f55d7ef33690d1c81b716a9e047e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*-
 * 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.
 *
 *	$FreeBSD$
 */

/*
 * Lookup table for code-to-text translations.
 */
struct twe_code_lookup {
    char	*string;
    u_int32_t	code;
};

extern char	*twe_describe_code(struct twe_code_lookup *table, u_int32_t code);

#ifndef TWE_DEFINE_TABLES
extern struct twe_code_lookup twe_table_status[];
extern struct twe_code_lookup twe_table_unitstate[];
extern struct twe_code_lookup twe_table_unittype[];
extern struct twe_code_lookup twe_table_aen[];
extern struct twe_code_lookup twe_table_opcode[];
#else /* TWE_DEFINE_TABLES */

/********************************************************************************
 * Look up a text description of a numeric code and return a pointer to same.
 */
char *
twe_describe_code(struct twe_code_lookup *table, u_int32_t code)
{
    int		i;

    for (i = 0; table[i].string != NULL; i++)
	if (table[i].code == code)
	    return(table[i].string);
    return(table[i+1].string);
}


struct twe_code_lookup twe_table_status[] = {
    /* success */
    {"successful completion",					0x00},
    /* info */
    {"command in progress",					0x42},
    {"retrying interface CRC error from UDMA command",		0x6c},
    /* warning */
    {"redundant/inconsequential request ignored",		0x81},
    {"failed to write zeroes to LBA 0",				0x8e},
    {"failed to profile TwinStor zones",			0x8f},
    /* fatal */
    {"aborted due to system command or reconfiguration",	0xc1},
    {"aborted",							0xc4},
    {"access error",						0xc5},
    {"access violation",					0xc6},
    {"device failure",						0xc7},	/* high byte may be port number */
    {"controller error",					0xc8},
    {"timed out",						0xc9},
    {"invalid unit number",					0xcb},
    {"unit not available",					0xcf},
    {"undefined opcode",					0xd2},
    {"request incompatible with unit",				0xdb},
    {"invalid request",						0xdc},
    {"firmware error, reset requested",				0xff},
    {NULL,	0},
    {"unknown status",	0}
};

struct twe_code_lookup twe_table_unitstate[] = {
    {"Normal",		TWE_PARAM_UNITSTATUS_Normal},
    {"Initialising",	TWE_PARAM_UNITSTATUS_Initialising},
    {"Degraded",	TWE_PARAM_UNITSTATUS_Degraded},
    {"Rebuilding",	TWE_PARAM_UNITSTATUS_Rebuilding},
    {"Verifying",	TWE_PARAM_UNITSTATUS_Verifying},
    {"Corrupt",		TWE_PARAM_UNITSTATUS_Corrupt},
    {"Missing",		TWE_PARAM_UNITSTATUS_Missing},
    {NULL, 0},
    {"unknown state",	0}
};

struct twe_code_lookup twe_table_unittype[] = {
    {"RAID0",		TWE_UD_CONFIG_RAID0},
    {"RAID1",		TWE_UD_CONFIG_RAID1},
    {"TwinStor",	TWE_UD_CONFIG_TwinStor},
    {"RAID5",		TWE_UD_CONFIG_RAID5},
    {"RAID10",		TWE_UD_CONFIG_RAID10},
    {"CBOD",		TWE_UD_CONFIG_CBOD},
    {"SPARE",		TWE_UD_CONFIG_SPARE},
    {"SUBUNIT",		TWE_UD_CONFIG_SUBUNIT},
    {"JBOD",		TWE_UD_CONFIG_JBOD},
    {NULL, 0},
    {"unknown type",	0}
};

struct twe_code_lookup twe_table_aen[] = {
    {"q queue empty",			0x00},
    {"q soft reset",			0x01},
    {"c degraded mirror",		0x02},
    {"p controller error",		0x03},
    {"c rebuild fail",			0x04},
    {"c rebuild done",			0x05},
    {"c incomplete unit",		0x06},
    {"c initialisation done",		0x07},
    {"c unclean shutdown detected",	0x08},
    {"c drive timeout",			0x09},
    {"c drive error",			0x0a},
    {"c rebuild started",		0x0b},
    {"p aen queue full",		0xff},
    {NULL, 0},
    {"x unknown AEN",		0}
};

struct twe_code_lookup twe_table_opcode[] = {
    {"NOP",			0x00},
    {"INIT_CONNECTION",		0x01},
    {"READ",			0x02},
    {"WRITE",			0x03},
    {"READVERIFY",		0x04},
    {"VERIFY",			0x05},
    {"ZEROUNIT",		0x08},
    {"REPLACEUNIT",		0x09},
    {"HOTSWAP",			0x0a},
    {"SETATAFEATURE",		0x0c},
    {"FLUSH",			0x0e},
    {"ABORT",			0x0f},
    {"CHECKSTATUS",		0x10},
    {"GET_PARAM",		0x12},
    {"SET_PARAM",		0x13},
    {"CREATEUNIT",		0x14},
    {"DELETEUNIT",		0x15},
    {"REBUILDUNIT",		0x17},
    {"SECTOR_INFO",		0x1a},
    {"AEN_LISTEN",		0x1c},
    {"CMD_PACKET",		0x1d},
    {NULL, 0},
    {"unknown opcode",		0}
};    
    
#endif
OpenPOWER on IntegriCloud