Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / dev / raid / amr / amr_tables.h
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  * Copyright (c) 2002 Eric Moore
28  * Copyright (c) 2002 LSI Logic Corporation
29  * All rights reserved.
30  *
31  * Redistribution and use in source and binary forms, with or without
32  * modification, are permitted provided that the following conditions
33  * are met:
34  * 1. Redistributions of source code must retain the above copyright
35  *    notice, this list of conditions and the following disclaimer.
36  * 2. Redistributions in binary form must reproduce the above copyright
37  *    notice, this list of conditions and the following disclaimer in the
38  *    documentation and/or other materials provided with the distribution.
39  * 3. The party using or redistributing the source code and binary forms
40  *    agrees to the disclaimer below and the terms and conditions set forth
41  *    herein.
42  *
43  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
44  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
47  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53  * SUCH DAMAGE.
54  *
55  *      $FreeBSD: src/sys/dev/amr/amr_tables.h,v 1.1.2.3 2002/11/11 13:19:10 emoore Exp $
56  */
57
58 /*
59  * Lookup table for code-to-text translations.
60  */
61 struct amr_code_lookup {
62     char        *string;
63     u_int32_t   code;
64 };
65
66 extern char     *amr_describe_code(struct amr_code_lookup *table, u_int32_t code);
67
68 #ifndef AMR_DEFINE_TABLES
69 extern struct amr_code_lookup amr_table_qinit[];
70 extern struct amr_code_lookup amr_table_sinit[];
71 extern struct amr_code_lookup amr_table_drvstate[];
72
73 #else /* AMR_DEFINE_TABLES */
74
75 /********************************************************************************
76  * Look up a text description of a numeric code and return a pointer to same.
77  */
78 char *
79 amr_describe_code(struct amr_code_lookup *table, u_int32_t code)
80 {
81     int         i;
82
83     for (i = 0; table[i].string != NULL; i++)
84         if (table[i].code == code)
85             return(table[i].string);
86     return(table[i+1].string);
87 }
88
89 struct amr_code_lookup amr_table_qinit[] = {
90     {"init scanning drives",            AMR_QINIT_SCAN},
91     {"init scanning initialising",      AMR_QINIT_SCANINIT},
92     {"init firmware initing",           AMR_QINIT_FIRMWARE},
93     {"init in progress",                AMR_QINIT_INPROG},
94     {"init spinning drives",            AMR_QINIT_SPINUP},
95     {"insufficient memory",             AMR_QINIT_NOMEM},
96     {"init flushing cache",             AMR_QINIT_CACHEFLUSH},
97     {"init successfully done",          AMR_QINIT_DONE},
98     {NULL, 0},
99     {"unknown init code", 0}
100 };
101
102 struct amr_code_lookup amr_table_sinit[] = {
103     {"init abnormal terminated",        AMR_SINIT_ABEND},
104     {"insufficient memory",             AMR_SINIT_NOMEM},
105     {"firmware flushing cache",         AMR_SINIT_CACHEFLUSH},
106     {"init in progress",                AMR_SINIT_INPROG},
107     {"firmware spinning drives",        AMR_SINIT_SPINUP},
108     {"init successfully done",          AMR_SINIT_DONE},
109     {NULL, 0},
110     {"unknown init code", 0}
111 };
112
113 struct amr_code_lookup amr_table_drvstate[] = {
114     {"offline",                 AMR_DRV_OFFLINE},
115     {"degraded",                AMR_DRV_DEGRADED},
116     {"optimal",                 AMR_DRV_OPTIMAL},
117     {"online",                  AMR_DRV_ONLINE},
118     {"failed",                  AMR_DRV_FAILED},
119     {"rebuild",                 AMR_DRV_REBUILD},
120     {"hot spare",               AMR_DRV_HOTSPARE},
121     {NULL, 0},
122     {"unknown", 0}
123 };
124
125 struct amr_code_lookup amr_table_adaptertype[] = {
126     {"Series 431",                      AMR_SIG_431},
127     {"Series 438",                      AMR_SIG_438},
128     {"Series 762",                      AMR_SIG_762},
129     {"Integrated HP NetRAID (T5)",      AMR_SIG_T5},
130     {"Series 466",                      AMR_SIG_466},
131     {"Series 467",                      AMR_SIG_467},
132     {"Integrated HP NetRAID (T7)",      AMR_SIG_T7},
133     {"Series 490",                      AMR_SIG_490},
134     {NULL, 0},
135     {"unknown adapter", 0}
136 };
137
138 #endif