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 #ifndef _SCSI_SES_H_
30 #define _SCSI_SES_H_
31
32
33 struct ses_scsi_diag {
34 u_int8_t opcode;
35 u_int8_t flags;
36 #define SES_DIAG_PCV (1<<0)
37 #define SES_DIAG_PF (1<<4)
38 u_int8_t pgcode;
39 #define SES_PAGE_CONFIG 0x01
40 #define SES_PAGE_STATUS 0x02
41 #define SES_PAGE_EDESC 0x07
42 u_int16_t length;
43 u_int8_t control;
44 } __packed;
45
46
47
48 #define SES_T_UNSPEC 0x00
49 #define SES_T_DEVICE 0x01
50 #define SES_T_POWERSUPPLY 0x02
51 #define SES_T_COOLING 0x03
52 #define SES_T_TEMP 0x04
53 #define SES_T_DOORLOCK 0x05
54 #define SES_T_ALARM 0x06
55 #define SES_T_ENC_SRV_CTRL 0x07
56 #define SES_T_SCC_CTRL 0x08
57 #define SES_T_NONVOL_CACHE 0x09
58 #define SES_T_INV_OP_REASON 0x0a
59 #define SES_T_UPS 0x0b
60 #define SES_T_DISPLAY 0x0c
61 #define SES_T_KEYPAD 0x0d
62 #define SES_T_ENCLOSURE 0x0e
63 #define SES_T_SCSI_PORT_TRANS 0x0f
64 #define SES_T_LANGUAGE 0x10
65 #define SES_T_COMM_PORT 0x11
66 #define SES_T_VOLTAGE 0x12
67 #define SES_T_CURRENT 0x13
68 #define SES_T_SCSI_TARGET_PORT 0x14
69 #define SES_T_SCSI_INIT_PORT 0x15
70 #define SES_T_SIMP_SUBENC 0x16
71 #define SES_T_ARRAY_DEVICE 0x17
72
73 #define SES_NUM_TYPES 256
74
75
76 struct ses_config_hdr {
77 u_int8_t pgcode;
78 u_int8_t n_subenc;
79 u_int16_t length;
80 u_int32_t gencode;
81 } __packed;
82 #define SES_CFG_HDRLEN sizeof(struct ses_config_hdr)
83
84
85 struct ses_enc_hdr {
86 u_int8_t enc_id;
87 u_int8_t subenc_id;
88 u_int8_t n_types;
89 u_int8_t vendor_len;
90 } __packed;
91 #define SES_ENC_HDRLEN sizeof(struct ses_enc_hdr)
92
93
94 struct ses_enc_desc {
95 u_int8_t logical_id[8];
96 u_int8_t vendor_id[8];
97 u_int8_t prod_id[16];
98 u_int8_t prod_rev[4];
99 u_int8_t vendor[0];
100 } __packed;
101
102
103 struct ses_type_desc {
104 u_int8_t type;
105 u_int8_t n_elem;
106 u_int8_t subenc_id;
107 u_int8_t desc_len;
108 } __packed;
109 #define SES_TYPE_DESCLEN sizeof(struct ses_type_desc)
110
111
112 struct ses_status_hdr {
113 u_int8_t pgcode;
114 u_int8_t flags;
115 #define SES_STAT_UNRECOV (1<<0)
116 #define SES_STAT_CRIT (1<<1)
117 #define SES_STAT_NONCRIT (1<<2)
118 #define SES_STAT_INFO (1<<3)
119 #define SES_STAT_INVOP (1<<4)
120 u_int16_t length;
121 u_int32_t gencode;
122 } __packed;
123 #define SES_STAT_HDRLEN sizeof(struct ses_status_hdr)
124
125 struct ses_status {
126 u_int8_t com;
127 #define SES_STAT_CODE_MASK 0x0f
128 #define SES_STAT_CODE(x) ((x) & SES_STAT_CODE_MASK)
129 #define SES_STAT_CODE_UNSUP 0x00
130 #define SES_STAT_CODE_OK 0x01
131 #define SES_STAT_CODE_CRIT 0x02
132 #define SES_STAT_CODE_NONCRIT 0x03
133 #define SES_STAT_CODE_UNREC 0x04
134 #define SES_STAT_CODE_NOTINST 0x05
135 #define SES_STAT_CODE_UNKNOWN 0x06
136 #define SES_STAT_CODE_NOTAVAIL 0x07
137 #define SES_STAT_SWAP (1<<4)
138 #define SES_STAT_DISABLED (1<<5)
139 #define SES_STAT_PRDFAIL (1<<6)
140 #define SES_STAT_SELECT (1<<7)
141
142 u_int8_t f1;
143 u_int8_t f2;
144 u_int8_t f3;
145 } __packed;
146 #define SES_STAT_ELEMLEN sizeof(struct ses_status)
147
148
149
150
151 #define SES_S_DEV_REPORT (1<<0)
152 #define SES_S_DEV_IDENT (1<<1)
153 #define SES_S_DEV_REMOVE (1<<2)
154 #define SES_S_DEV_INSERT (1<<3)
155 #define SES_S_DEV_ENCBYPB (1<<4)
156 #define SES_S_DEV_ENCBYPA (1<<5)
157 #define SES_S_DEV_DONOTREM (1<<6)
158 #define SES_S_DEV_APPCLBYPA (1<<7)
159
160 #define SES_S_DEV_DEVBYPB (1<<0)
161 #define SES_S_DEV_DEVBYPA (1<<1)
162 #define SES_S_DEV_BYPB (1<<2)
163 #define SES_S_DEV_BYPA (1<<3)
164 #define SES_S_DEV_OFF (1<<4)
165 #define SES_S_DEV_FAULTRQST (1<<5)
166 #define SES_S_DEV_FAULTSENSE (1<<6)
167 #define SES_S_DEV_APPCLBYPB (1<<7)
168
169
170
171
172 #define SES_C_DEV_IDENT (1<<1)
173 #define SES_C_DEV_REMOVE (1<<2)
174 #define SES_C_DEV_INSERT (1<<3)
175 #define SES_C_DEV_DONOTREM (1<<6)
176 #define SES_C_DEV_ACTIVE (1<<7)
177 #define SES_C_DEV_F2MASK (SES_C_DEV_IDENT | SES_C_DEV_REMOVE | \
178 SES_C_DEV_INSERT | SES_C_DEV_DONOTREM | SES_C_DEV_ACTIVE )
179
180 #define SES_C_DEV_BYPB (1<<2)
181 #define SES_C_DEV_BYPA (1<<3)
182 #define SES_C_DEV_OFF (1<<4)
183 #define SES_C_DEV_FAULT (1<<5)
184 #define SES_C_DEV_F3MASK (SES_C_DEV_BYPB | SES_C_DEV_BYPA | \
185 SES_C_DEV_OFF | SES_C_DEV_FAULT)
186
187
188 #define SES_S_PSU_IDENT(d) ((d)->f1 & (1<<6))
189 #define SES_S_PSU_DCOC(d) ((d)->f2 & (1<<1))
190 #define SES_S_PSU_DCUV(d) ((d)->f2 & (1<<2))
191 #define SES_S_PSU_DCOV(d) ((d)->f2 & (1<<3))
192 #define SES_S_PSU_DCFAIL(d) ((d)->f3 & (1<<0))
193 #define SES_S_PSU_ACFAIL(d) ((d)->f3 & (1<<1))
194 #define SES_S_PSU_TEMPWARN(d) ((d)->f3 & (1<<2))
195 #define SES_S_PSU_OVERTEMP(d) ((d)->f3 & (1<<3))
196 #define SES_S_PSU_OFF(d) ((d)->f3 & (1<<4))
197 #define SES_S_PSU_RQSTON(d) ((d)->f3 & (1<<5))
198 #define SES_S_PSU_FAIL(d) ((d)->f3 & (1<<6))
199
200
201 #define SES_S_COOL_IDENT(d) ((d)->f1 & (1<<6))
202 #define SES_S_COOL_SPEED_MASK 0x03
203 #define SES_S_COOL_SPEED(d) ((d)->f2 + \
204 ((u_int16_t)((d)->f2 & SES_S_COOL_SPEED_MASK) << 8))
205 #define SES_S_COOL_FACTOR 10
206 #define SES_S_COOL_CODE(d) ((d)->f3 & 0x7)
207 #define SES_S_COOL_C_STOPPED 0x0
208 #define SES_S_COOL_C_LOW1 0x1
209 #define SES_S_COOL_C_LOW2 0x2
210 #define SES_S_COOL_C_LOW3 0x3
211 #define SES_S_COOL_C_INTER 0x4
212 #define SES_S_COOL_C_HI3 0x5
213 #define SES_S_COOL_C_HI2 0x6
214 #define SES_S_COOL_C_HI1 0x7
215 #define SES_S_COOL_OFF ((d)->f3 & (1<<4))
216 #define SES_S_COOL_RQSTON ((d)->f3 & (1<<5))
217 #define SES_S_COOL_FAIL ((d)->f3 & (1<<6))
218
219
220 #define SES_S_TEMP_IDENT(d) ((d)->f1 & (1<<7))
221 #define SES_S_TEMP(d) ((d)->f2)
222 #define SES_S_TEMP_OFFSET (-20)
223 #define SES_S_TEMP_UTWARN ((d)->f3 & (1<<0))
224 #define SES_S_TEMP_UTFAIL ((d)->f3 & (1<<1))
225 #define SES_S_TEMP_OTWARN ((d)->f3 & (1<<2))
226 #define SES_S_TEMP_OTFAIL ((d)->f3 & (1<<3))
227
228
229
230
231
232 #define SES_STAT_LEN(t, e) \
233 (SES_STAT_HDRLEN + SES_STAT_ELEMLEN * ((t)+(e)))
234
235 #endif