xref: /freebsd/sys/cam/scsi/scsi_ses.h (revision ca987d4641cdcd7f27e153db17c5bf064934faf5)
1 /* $FreeBSD$ */
2 /*-
3  * Copyright (c) 2000 by Matthew Jacob
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  *    without modification, immediately at the beginning of the file.
12  * 2. The name of the author may not be used to endorse or promote products
13  *    derived from this software without specific prior written permission.
14  *
15  * Alternatively, this software may be distributed under the terms of the
16  * the GNU Public License ("GPL").
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
22  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  */
31 
32 #ifndef	_SCSI_SES_H_
33 #define	_SCSI_SES_H_
34 
35 #include <cam/scsi/scsi_all.h>
36 
37 /*========================== Field Extraction Macros =========================*/
38 #define MK_ENUM(S, F, SUFFIX) S ## _ ## F ## SUFFIX
39 
40 #define GEN_GETTER(LS, US, LF, UF)					    \
41 static inline int							    \
42 LS ## _get_ ## LF(struct LS *elem) {					    \
43 	return ((elem->bytes[MK_ENUM(US,UF,_BYTE)] & MK_ENUM(US,UF,_MASK))  \
44 	     >> MK_ENUM(US,UF,_SHIFT));					    \
45 }
46 
47 #define GEN_SETTER(LS, US, LF, UF)					    \
48 static inline void							    \
49 LS ## _set_ ## LF(struct LS *elem, int val) {				    \
50 	elem->bytes[MK_ENUM(US,UF,_BYTE)] &= ~MK_ENUM(US,UF,_MASK);	    \
51 	elem->bytes[MK_ENUM(US,UF,_BYTE)] |=				    \
52 	    (val << MK_ENUM(US,UF,_SHIFT)) & MK_ENUM(US,UF,_MASK);	    \
53 }
54 
55 #define GEN_HDR_GETTER(LS, US, LF, UF)					    \
56 static inline int							    \
57 LS ## _get_ ## LF(struct LS *page) {					    \
58 	return ((page->hdr.page_specific_flags & MK_ENUM(US,UF,_MASK))	    \
59 	     >> MK_ENUM(US,UF,_SHIFT));					    \
60 }
61 
62 #define GEN_HDR_SETTER(LS, US, LF, UF)					    \
63 static inline void							    \
64 LS ## _set_ ## LF(struct LS *page, int val) {				    \
65 	page->hdr.page_specific_flags &= ~MK_ENUM(US,UF,_MASK);		    \
66 	page->hdr.page_specific_flags |=				    \
67 	    (val << MK_ENUM(US,UF,_SHIFT)) & MK_ENUM(US,UF,_MASK);	    \
68 }
69 
70 #define GEN_ACCESSORS(LS, US, LF, UF)					    \
71 GEN_GETTER(LS, US, LF, UF)						    \
72 GEN_SETTER(LS, US, LF, UF)
73 
74 #define GEN_HDR_ACCESSORS(LS, US, LF, UF)				    \
75 GEN_HDR_GETTER(LS, US, LF, UF)						    \
76 GEN_HDR_SETTER(LS, US, LF, UF)
77 
78 /*===============  Common SCSI ENC Diagnostic Page Structures ===============*/
79 struct ses_page_hdr {
80 	uint8_t page_code;
81 	uint8_t page_specific_flags;
82 	uint8_t length[2];
83 	uint8_t gen_code[4];
84 };
85 
86 static inline size_t
87 ses_page_length(const struct ses_page_hdr *hdr)
88 {
89 	/*
90 	 * The page length as received only accounts for bytes that
91 	 * follow the length field, namely starting with the generation
92 	 * code field.
93 	 */
94 	return (scsi_2btoul(hdr->length)
95 	      + offsetof(struct ses_page_hdr, gen_code));
96 }
97 
98 /*============= SCSI ENC Configuration Diagnostic Page Structures ============*/
99 struct ses_enc_desc {
100 	uint8_t byte0;
101 	/*
102 	 * reserved0	: 1,
103 	 * rel_id	: 3,	relative enclosure process id
104 	 * reserved1	: 1,
105 	 * num_procs	: 3;	number of enclosure procesenc
106 	 */
107 	uint8_t	subenc_id;	/* Sub-enclosure Identifier */
108 	uint8_t	num_types;	/* # of supported types */
109 	uint8_t	length;		/* Enclosure Descriptor Length */
110 	uint8_t	logical_id[8];	/* formerly wwn */
111 	uint8_t	vendor_id[8];
112 	uint8_t	product_id[16];
113 	uint8_t	product_rev[4];
114 	uint8_t vendor_bytes[];
115 };
116 
117 static inline uint8_t *
118 ses_enc_desc_last_byte(struct ses_enc_desc *encdesc)
119 {
120 	return (&encdesc->length + encdesc->length);
121 }
122 
123 static inline struct ses_enc_desc *
124 ses_enc_desc_next(struct ses_enc_desc *encdesc)
125 {
126 	return ((struct ses_enc_desc *)(ses_enc_desc_last_byte(encdesc) + 1));
127 }
128 
129 static inline int
130 ses_enc_desc_is_complete(struct ses_enc_desc *encdesc, uint8_t *last_buf_byte)
131 {
132 	return (&encdesc->length <= last_buf_byte
133 	     && ses_enc_desc_last_byte(encdesc) <= last_buf_byte);
134 }
135 
136 struct ses_elm_type_desc {
137 	uint8_t	etype_elm_type;	/* type of element */
138 	uint8_t	etype_maxelt;	/* maximum supported */
139 	uint8_t	etype_subenc;	/* in sub-enclosure #n */
140 	uint8_t	etype_txt_len;	/* Type Descriptor Text Length */
141 };
142 
143 struct ses_cfg_page {
144 	struct ses_page_hdr hdr;
145 	struct ses_enc_desc subencs[];
146 	/* type descriptors */
147 	/* type text */
148 };
149 
150 static inline int
151 ses_cfg_page_get_num_subenc(struct ses_cfg_page *page)
152 {
153 	return (page->hdr.page_specific_flags + 1);
154 }
155 
156 
157 /*================ SCSI SES Control Diagnostic Page Structures ==============*/
158 struct ses_ctrl_common {
159 	uint8_t bytes[1];
160 };
161 
162 enum ses_ctrl_common_field_data {
163 	SES_CTRL_COMMON_SELECT_BYTE		= 0,
164 	SES_CTRL_COMMON_SELECT_MASK		= 0x80,
165 	SES_CTRL_COMMON_SELECT_SHIFT		= 7,
166 
167 	SES_CTRL_COMMON_PRDFAIL_BYTE		= 0,
168 	SES_CTRL_COMMON_PRDFAIL_MASK		= 0x40,
169 	SES_CTRL_COMMON_PRDFAIL_SHIFT		= 6,
170 
171 	SES_CTRL_COMMON_DISABLE_BYTE		= 0,
172 	SES_CTRL_COMMON_DISABLE_MASK		= 0x20,
173 	SES_CTRL_COMMON_DISABLE_SHIFT		= 5,
174 
175 	SES_CTRL_COMMON_RST_SWAP_BYTE		= 0,
176 	SES_CTRL_COMMON_RST_SWAP_MASK		= 0x10,
177 	SES_CTRL_COMMON_RST_SWAP_SHIFT		= 4
178 };
179 
180 #define GEN_SES_CTRL_COMMON_ACCESSORS(LCASE, UCASE) \
181     GEN_ACCESSORS(ses_ctrl_common, SES_CTRL_COMMON, LCASE, UCASE)
182 GEN_SES_CTRL_COMMON_ACCESSORS(select,   SELECT)
183 GEN_SES_CTRL_COMMON_ACCESSORS(prdfail,  PRDFAIL)
184 GEN_SES_CTRL_COMMON_ACCESSORS(disable,  DISABLE)
185 GEN_SES_CTRL_COMMON_ACCESSORS(rst_swap, RST_SWAP)
186 #undef GEN_SES_CTRL_COMMON_ACCESSORS
187 
188 /*------------------------ Device Slot Control Element ----------------------*/
189 struct ses_ctrl_dev_slot {
190 	struct ses_ctrl_common common;
191 	uint8_t bytes[3];
192 };
193 
194 enum ses_ctrl_dev_slot_field_data {
195 	SES_CTRL_DEV_SLOT_RQST_ACTIVE_BYTE	= 1,
196 	SES_CTRL_DEV_SLOT_RQST_ACTIVE_MASK	= 0x80,
197 	SES_CTRL_DEV_SLOT_RQST_ACTIVE_SHIFT	= 7,
198 
199 	SES_CTRL_DEV_SLOT_DO_NOT_REMOVE_BYTE	= 1,
200 	SES_CTRL_DEV_SLOT_DO_NOT_REMOVE_MASK	= 0x40,
201 	SES_CTRL_DEV_SLOT_DO_NOT_REMOVE_SHIFT	= 6,
202 
203 	SES_CTRL_DEV_SLOT_RQST_MISSING_BYTE	= 1,
204 	SES_CTRL_DEV_SLOT_RQST_MISSING_MASK	= 0x10,
205 	SES_CTRL_DEV_SLOT_RQST_MISSING_SHIFT	= 4,
206 
207 	SES_CTRL_DEV_SLOT_RQST_INSERT_BYTE	= 1,
208 	SES_CTRL_DEV_SLOT_RQST_INSERT_MASK	= 0x08,
209 	SES_CTRL_DEV_SLOT_RQST_INSERT_SHIFT	= 3,
210 
211 	SES_CTRL_DEV_SLOT_RQST_REMOVE_BYTE	= 1,
212 	SES_CTRL_DEV_SLOT_RQST_REMOVE_MASK	= 0x04,
213 	SES_CTRL_DEV_SLOT_RQST_REMOVE_SHIFT	= 2,
214 
215 	SES_CTRL_DEV_SLOT_RQST_IDENT_BYTE	= 1,
216 	SES_CTRL_DEV_SLOT_RQST_IDENT_MASK	= 0x02,
217 	SES_CTRL_DEV_SLOT_RQST_IDENT_SHIFT	= 1,
218 
219 	SES_CTRL_DEV_SLOT_RQST_FAULT_BYTE	= 2,
220 	SES_CTRL_DEV_SLOT_RQST_FAULT_MASK	= 0x20,
221 	SES_CTRL_DEV_SLOT_RQST_FAULT_SHIFT	= 5,
222 
223 	SES_CTRL_DEV_SLOT_DEVICE_OFF_BYTE	= 2,
224 	SES_CTRL_DEV_SLOT_DEVICE_OFF_MASK	= 0x10,
225 	SES_CTRL_DEV_SLOT_DEVICE_OFF_SHIFT	= 4,
226 
227 	SES_CTRL_DEV_SLOT_ENABLE_BYP_A_BYTE	= 2,
228 	SES_CTRL_DEV_SLOT_ENABLE_BYP_A_MASK	= 0x08,
229 	SES_CTRL_DEV_SLOT_ENABLE_BYP_A_SHIFT	= 3,
230 
231 	SES_CTRL_DEV_SLOT_ENABLE_BYP_B_BYTE	= 2,
232 	SES_CTRL_DEV_SLOT_ENABLE_BYP_B_MASK	= 0x04,
233 	SES_CTRL_DEV_SLOT_ENABLE_BYP_B_SHIFT	= 2
234 };
235 #define GEN_SES_CTRL_DEV_SLOT_ACCESSORS(LCASE, UCASE) \
236     GEN_ACCESSORS(ses_ctrl_dev_slot, SES_CTRL_DEV_SLOT, LCASE, UCASE)
237 
238 GEN_SES_CTRL_DEV_SLOT_ACCESSORS(rqst_active,   RQST_ACTIVE)
239 GEN_SES_CTRL_DEV_SLOT_ACCESSORS(do_not_remove, DO_NOT_REMOVE)
240 GEN_SES_CTRL_DEV_SLOT_ACCESSORS(rqst_missing,  RQST_MISSING)
241 GEN_SES_CTRL_DEV_SLOT_ACCESSORS(rqst_insert,   RQST_INSERT)
242 GEN_SES_CTRL_DEV_SLOT_ACCESSORS(rqst_remove,   RQST_REMOVE)
243 GEN_SES_CTRL_DEV_SLOT_ACCESSORS(rqst_ident,    RQST_IDENT)
244 GEN_SES_CTRL_DEV_SLOT_ACCESSORS(rqst_fault,    RQST_FAULT)
245 GEN_SES_CTRL_DEV_SLOT_ACCESSORS(device_off,    DEVICE_OFF)
246 GEN_SES_CTRL_DEV_SLOT_ACCESSORS(enable_byp_a,  ENABLE_BYP_A)
247 GEN_SES_CTRL_DEV_SLOT_ACCESSORS(enable_byp_b,  ENABLE_BYP_B)
248 #undef GEN_SES_CTRL_DEV_SLOT_ACCESSORS
249 
250 /*--------------------- Array Device Slot Control Element --------------------*/
251 struct ses_ctrl_array_dev_slot {
252 	struct ses_ctrl_common common;
253 	uint8_t bytes[3];
254 };
255 
256 enum ses_ctrl_array_dev_slot_field_data {
257 	SES_CTRL_ARRAY_DEV_SLOT_RQST_OK_BYTE			= 0,
258 	SES_CTRL_ARRAY_DEV_SLOT_RQST_OK_MASK			= 0x80,
259 	SES_CTRL_ARRAY_DEV_SLOT_RQST_OK_SHIFT			= 7,
260 
261 	SES_CTRL_ARRAY_DEV_SLOT_RQST_RSVD_DEVICE_BYTE		= 0,
262 	SES_CTRL_ARRAY_DEV_SLOT_RQST_RSVD_DEVICE_MASK		= 0x40,
263 	SES_CTRL_ARRAY_DEV_SLOT_RQST_RSVD_DEVICE_SHIFT		= 6,
264 
265 	SES_CTRL_ARRAY_DEV_SLOT_RQST_HOT_SPARE_BYTE		= 0,
266 	SES_CTRL_ARRAY_DEV_SLOT_RQST_HOT_SPARE_MASK		= 0x20,
267 	SES_CTRL_ARRAY_DEV_SLOT_RQST_HOT_SPARE_SHIFT		= 5,
268 
269 	SES_CTRL_ARRAY_DEV_SLOT_RQST_CONS_CHECK_BYTE		= 0,
270 	SES_CTRL_ARRAY_DEV_SLOT_RQST_CONS_CHECK_MASK		= 0x10,
271 	SES_CTRL_ARRAY_DEV_SLOT_RQST_CONS_CHECK_SHIFT		= 4,
272 
273 	SES_CTRL_ARRAY_DEV_SLOT_RQST_IN_CRIT_ARRAY_BYTE		= 0,
274 	SES_CTRL_ARRAY_DEV_SLOT_RQST_IN_CRIT_ARRAY_MASK		= 0x08,
275 	SES_CTRL_ARRAY_DEV_SLOT_RQST_IN_CRIT_ARRAY_SHIFT	= 3,
276 
277 	SES_CTRL_ARRAY_DEV_SLOT_RQST_IN_FAILED_ARRAY_BYTE	= 0,
278 	SES_CTRL_ARRAY_DEV_SLOT_RQST_IN_FAILED_ARRAY_MASK	= 0x04,
279 	SES_CTRL_ARRAY_DEV_SLOT_RQST_IN_FAILED_ARRAY_SHIFT	= 2,
280 
281 	SES_CTRL_ARRAY_DEV_SLOT_RQST_REBUILD_REMAP_BYTE		= 0,
282 	SES_CTRL_ARRAY_DEV_SLOT_RQST_REBUILD_REMAP_MASK		= 0x02,
283 	SES_CTRL_ARRAY_DEV_SLOT_RQST_REBUILD_REMAP_SHIFT	= 1,
284 
285 	SES_CTRL_ARRAY_DEV_SLOT_RQST_REBUILD_REMAP_ABORT_BYTE	= 0,
286 	SES_CTRL_ARRAY_DEV_SLOT_RQST_REBUILD_REMAP_ABORT_MASK	= 0x01,
287 	SES_CTRL_ARRAY_DEV_SLOT_RQST_REBUILD_REMAP_ABORT_SHIFT	= 0
288 
289 	/*
290 	 * The remaining fields are identical to the device
291 	 * slot element type.  Access them through the device slot
292 	 * element type and its accessors.
293 	 */
294 };
295 #define GEN_SES_CTRL_ARRAY_DEV_SLOT_ACCESSORS(LCASE, UCASE)		\
296     GEN_ACCESSORS(ses_ctrl_array_dev_slot, SES_CTRL_ARRAY_DEV_SLOT,	\
297 		  LCASE, UCASE)
298 GEN_SES_CTRL_ARRAY_DEV_SLOT_ACCESSORS(rqst_ok,             RQST_OK)
299 GEN_SES_CTRL_ARRAY_DEV_SLOT_ACCESSORS(rqst_rsvd_device,    RQST_RSVD_DEVICE)
300 GEN_SES_CTRL_ARRAY_DEV_SLOT_ACCESSORS(rqst_hot_spare,      RQST_HOT_SPARE)
301 GEN_SES_CTRL_ARRAY_DEV_SLOT_ACCESSORS(rqst_cons_check,     RQST_CONS_CHECK)
302 GEN_SES_CTRL_ARRAY_DEV_SLOT_ACCESSORS(rqst_in_crit_array,  RQST_IN_CRIT_ARRAY)
303 GEN_SES_CTRL_ARRAY_DEV_SLOT_ACCESSORS(rqst_in_failed_array,
304 				      RQST_IN_FAILED_ARRAY)
305 GEN_SES_CTRL_ARRAY_DEV_SLOT_ACCESSORS(rqst_rebuild_remap,  RQST_REBUILD_REMAP)
306 GEN_SES_CTRL_ARRAY_DEV_SLOT_ACCESSORS(rqst_rebuild_remap_abort,
307 				      RQST_REBUILD_REMAP_ABORT)
308 #undef GEN_SES_CTRL_ARRAY_DEV_SLOT_ACCESSORS
309 
310 /*----------------------- Power Supply Control Element -----------------------*/
311 struct ses_ctrl_power_supply {
312 	struct ses_ctrl_common common;
313 	uint8_t bytes[3];
314 };
315 
316 enum ses_ctrl_power_supply_field_data {
317 	SES_CTRL_POWER_SUPPLY_RQST_IDENT_BYTE	= 0,
318 	SES_CTRL_POWER_SUPPLY_RQST_IDENT_MASK	= 0x80,
319 	SES_CTRL_POWER_SUPPLY_RQST_IDENT_SHIFT	= 7,
320 
321 	SES_CTRL_POWER_SUPPLY_RQST_FAIL_BYTE	= 2,
322 	SES_CTRL_POWER_SUPPLY_RQST_FAIL_MASK	= 0x40,
323 	SES_CTRL_POWER_SUPPLY_RQST_FAIL_SHIFT	= 6,
324 
325 	SES_CTRL_POWER_SUPPLY_RQST_ON_BYTE	= 2,
326 	SES_CTRL_POWER_SUPPLY_RQST_ON_MASK	= 0x20,
327 	SES_CTRL_POWER_SUPPLY_RQST_ON_SHIFT	= 5
328 };
329 
330 #define GEN_SES_CTRL_POWER_SUPPLY_ACCESSORS(LCASE, UCASE)	\
331     GEN_ACCESSORS(ses_ctrl_power_supply, SES_CTRL_POWER_SUPPLY, LCASE, UCASE)
332 GEN_SES_CTRL_POWER_SUPPLY_ACCESSORS(rqst_ident, RQST_IDENT)
333 GEN_SES_CTRL_POWER_SUPPLY_ACCESSORS(rqst_fail,  RQST_FAIL)
334 GEN_SES_CTRL_POWER_SUPPLY_ACCESSORS(rqst_on,    RQST_ON)
335 #undef GEN_SES_CTRL_POWER_SUPPLY_ACCESSORS
336 
337 /*-------------------------- Cooling Control Element -------------------------*/
338 struct ses_ctrl_cooling {
339 	struct ses_ctrl_common common;
340 	uint8_t bytes[3];
341 };
342 
343 enum ses_ctrl_cooling_field_data {
344 	SES_CTRL_COOLING_RQST_IDENT_BYTE		= 0,
345 	SES_CTRL_COOLING_RQST_IDENT_MASK		= 0x80,
346 	SES_CTRL_COOLING_RQST_IDENT_SHIFT		= 7,
347 
348 	SES_CTRL_COOLING_RQST_FAIL_BYTE			= 2,
349 	SES_CTRL_COOLING_RQST_FAIL_MASK			= 0x40,
350 	SES_CTRL_COOLING_RQST_FAIL_SHIFT		= 6,
351 
352 	SES_CTRL_COOLING_RQST_ON_BYTE			= 2,
353 	SES_CTRL_COOLING_RQST_ON_MASK			= 0x20,
354 	SES_CTRL_COOLING_RQST_ON_SHIFT			= 5,
355 
356 	SES_CTRL_COOLING_RQSTED_SPEED_CODE_BYTE		= 2,
357 	SES_CTRL_COOLING_RQSTED_SPEED_CODE_MASK		= 0x07,
358 	SES_CTRL_COOLING_RQSTED_SPEED_CODE_SHIFT	= 2,
359 	SES_CTRL_COOLING_RQSTED_SPEED_CODE_UNCHANGED	= 0x00,
360 	SES_CTRL_COOLING_RQSTED_SPEED_CODE_LOWEST	= 0x01,
361 	SES_CTRL_COOLING_RQSTED_SPEED_CODE_HIGHEST	= 0x07
362 };
363 
364 #define GEN_SES_CTRL_COOLING_ACCESSORS(LCASE, UCASE)	\
365     GEN_ACCESSORS(ses_ctrl_cooling, SES_CTRL_COOLING, LCASE, UCASE)
366 GEN_SES_CTRL_COOLING_ACCESSORS(rqst_ident,        RQST_IDENT)
367 GEN_SES_CTRL_COOLING_ACCESSORS(rqst_fail,         RQST_FAIL)
368 GEN_SES_CTRL_COOLING_ACCESSORS(rqst_on,           RQST_ON)
369 GEN_SES_CTRL_COOLING_ACCESSORS(rqsted_speed_code, RQSTED_SPEED_CODE)
370 #undef GEN_SES_CTRL_COOLING_ACCESSORS
371 
372 /*-------------------- Temperature Sensor Control Element --------------------*/
373 struct ses_ctrl_temp_sensor {
374 	struct ses_ctrl_common common;
375 	uint8_t bytes[3];
376 };
377 
378 enum ses_ctrl_temp_sensor_field_data {
379 	SES_CTRL_TEMP_SENSOR_RQST_IDENT_BYTE	= 0,
380 	SES_CTRL_TEMP_SENSOR_RQST_IDENT_MASK	= 0x80,
381 	SES_CTRL_TEMP_SENSOR_RQST_IDENT_SHIFT	= 7,
382 
383 	SES_CTRL_TEMP_SENSOR_RQST_FAIL_BYTE	= 0,
384 	SES_CTRL_TEMP_SENSOR_RQST_FAIL_MASK	= 0x40,
385 	SES_CTRL_TEMP_SENSOR_RQST_FAIL_SHIFT	= 6
386 };
387 
388 #define GEN_SES_CTRL_TEMP_SENSOR_ACCESSORS(LCASE, UCASE)	\
389     GEN_ACCESSORS(ses_ctrl_temp_sensor, SES_CTRL_TEMP_SENSOR, LCASE, UCASE)
390 GEN_SES_CTRL_TEMP_SENSOR_ACCESSORS(rqst_ident, RQST_IDENT)
391 GEN_SES_CTRL_TEMP_SENSOR_ACCESSORS(rqst_fail,  RQST_FAIL)
392 #undef GEN_SES_CTRL_TEMP_SENSOR_ACCESSORS
393 
394 /*------------------------- Door Lock Control Element ------------------------*/
395 struct ses_ctrl_door_lock {
396 	struct ses_ctrl_common common;
397 	uint8_t bytes[3];
398 };
399 
400 enum ses_ctrl_door_lock_field_data {
401 	SES_CTRL_DOOR_LOCK_RQST_IDENT_BYTE	= 0,
402 	SES_CTRL_DOOR_LOCK_RQST_IDENT_MASK	= 0x80,
403 	SES_CTRL_DOOR_LOCK_RQST_IDENT_SHIFT	= 7,
404 
405 	SES_CTRL_DOOR_LOCK_RQST_FAIL_BYTE	= 0,
406 	SES_CTRL_DOOR_LOCK_RQST_FAIL_MASK	= 0x40,
407 	SES_CTRL_DOOR_LOCK_RQST_FAIL_SHIFT	= 6,
408 
409 	SES_CTRL_DOOR_LOCK_UNLOCK_BYTE		= 2,
410 	SES_CTRL_DOOR_LOCK_UNLOCK_MASK		= 0x01,
411 	SES_CTRL_DOOR_LOCK_UNLOCK_SHIFT		= 0
412 };
413 
414 #define GEN_SES_CTRL_DOOR_LOCK_ACCESSORS(LCASE, UCASE)	\
415     GEN_ACCESSORS(ses_ctrl_door_lock, SES_CTRL_DOOR_LOCK, LCASE, UCASE)
416 GEN_SES_CTRL_DOOR_LOCK_ACCESSORS(rqst_ident, RQST_IDENT)
417 GEN_SES_CTRL_DOOR_LOCK_ACCESSORS(rqst_fail,  RQST_FAIL)
418 GEN_SES_CTRL_DOOR_LOCK_ACCESSORS(unlock,     UNLOCK)
419 #undef GEN_SES_CTRL_DOOR_LOCK_ACCESSORS
420 
421 /*----------------------- Audible Alarm Control Element ----------------------*/
422 struct ses_ctrl_audible_alarm {
423 	struct ses_ctrl_common common;
424 	uint8_t bytes[3];
425 };
426 
427 enum ses_ctrl_audible_alarm_field_data {
428 	SES_CTRL_AUDIBLE_ALARM_RQST_IDENT_BYTE		= 0,
429 	SES_CTRL_AUDIBLE_ALARM_RQST_IDENT_MASK		= 0x80,
430 	SES_CTRL_AUDIBLE_ALARM_RQST_IDENT_SHIFT		= 7,
431 
432 	SES_CTRL_AUDIBLE_ALARM_RQST_FAIL_BYTE		= 0,
433 	SES_CTRL_AUDIBLE_ALARM_RQST_FAIL_MASK		= 0x40,
434 	SES_CTRL_AUDIBLE_ALARM_RQST_FAIL_SHIFT		= 6,
435 
436 	SES_CTRL_AUDIBLE_ALARM_SET_MUTE_BYTE		= 2,
437 	SES_CTRL_AUDIBLE_ALARM_SET_MUTE_MASK		= 0x40,
438 	SES_CTRL_AUDIBLE_ALARM_SET_MUTE_SHIFT		= 6,
439 
440 	SES_CTRL_AUDIBLE_ALARM_SET_REMIND_BYTE		= 2,
441 	SES_CTRL_AUDIBLE_ALARM_SET_REMIND_MASK		= 0x10,
442 	SES_CTRL_AUDIBLE_ALARM_SET_REMIND_SHIFT		= 4,
443 
444 	SES_CTRL_AUDIBLE_ALARM_TONE_CONTROL_BYTE	= 2,
445 	SES_CTRL_AUDIBLE_ALARM_TONE_CONTROL_MASK	= 0x0F,
446 	SES_CTRL_AUDIBLE_ALARM_TONE_CONTROL_SHIFT	= 0,
447 	SES_CTRL_AUDIBLE_ALARM_TONE_CONTROL_INFO	= 0x08,
448 	SES_CTRL_AUDIBLE_ALARM_TONE_CONTROL_NON_CRIT	= 0x04,
449 	SES_CTRL_AUDIBLE_ALARM_TONE_CONTROL_CRIT	= 0x02,
450 	SES_CTRL_AUDIBLE_ALARM_TONE_CONTROL_UNRECOV	= 0x01
451 };
452 
453 #define GEN_SES_CTRL_AUDIBLE_ALARM_ACCESSORS(LCASE, UCASE)	\
454     GEN_ACCESSORS(ses_ctrl_audible_alarm, SES_CTRL_AUDIBLE_ALARM, LCASE, UCASE)
455 GEN_SES_CTRL_AUDIBLE_ALARM_ACCESSORS(rqst_ident,   RQST_IDENT)
456 GEN_SES_CTRL_AUDIBLE_ALARM_ACCESSORS(rqst_fail,    RQST_FAIL)
457 GEN_SES_CTRL_AUDIBLE_ALARM_ACCESSORS(set_mute,     SET_MUTE)
458 GEN_SES_CTRL_AUDIBLE_ALARM_ACCESSORS(set_remind,   SET_REMIND)
459 GEN_SES_CTRL_AUDIBLE_ALARM_ACCESSORS(tone_control, TONE_CONTROL)
460 #undef GEN_SES_CTRL_AUDIBLE_ALARM_ACCESSORS
461 
462 /*--------- Enclosure Services Controller Electronics Control Element --------*/
463 struct ses_ctrl_ecc_electronics {
464 	struct ses_ctrl_common common;
465 	uint8_t bytes[3];
466 };
467 
468 enum ses_ctrl_ecc_electronics_field_data {
469 	SES_CTRL_ECC_ELECTRONICS_RQST_IDENT_BYTE	= 0,
470 	SES_CTRL_ECC_ELECTRONICS_RQST_IDENT_MASK	= 0x80,
471 	SES_CTRL_ECC_ELECTRONICS_RQST_IDENT_SHIFT	= 7,
472 
473 	SES_CTRL_ECC_ELECTRONICS_RQST_FAIL_BYTE		= 0,
474 	SES_CTRL_ECC_ELECTRONICS_RQST_FAIL_MASK		= 0x40,
475 	SES_CTRL_ECC_ELECTRONICS_RQST_FAIL_SHIFT	= 6,
476 
477 	SES_CTRL_ECC_ELECTRONICS_SELECT_ELEMENT_BYTE	= 1,
478 	SES_CTRL_ECC_ELECTRONICS_SELECT_ELEMENT_MASK	= 0x01,
479 	SES_CTRL_ECC_ELECTRONICS_SELECT_ELEMENT_SHIFT	= 0
480 };
481 
482 #define GEN_SES_CTRL_ECC_ELECTRONICS_ACCESSORS(LCASE, UCASE)		\
483     GEN_ACCESSORS(ses_ctrl_ecc_electronics, SES_CTRL_ECC_ELECTRONICS,	\
484 		  LCASE, UCASE)
485 GEN_SES_CTRL_ECC_ELECTRONICS_ACCESSORS(rqst_ident,     RQST_IDENT)
486 GEN_SES_CTRL_ECC_ELECTRONICS_ACCESSORS(rqst_fail,      RQST_FAIL)
487 GEN_SES_CTRL_ECC_ELECTRONICS_ACCESSORS(select_element, SELECT_ELEMENT)
488 #undef GEN_SES_CTRL_ECC_ELECTRONICS_ACCESSORS
489 
490 /*----------- SCSI Services Controller Electronics Control Element -----------*/
491 struct ses_ctrl_scc_electronics {
492 	struct ses_ctrl_common common;
493 	uint8_t bytes[3];
494 };
495 
496 enum ses_ctrl_scc_electronics_field_data {
497 	SES_CTRL_SCC_ELECTRONICS_RQST_IDENT_BYTE	= 0,
498 	SES_CTRL_SCC_ELECTRONICS_RQST_IDENT_MASK	= 0x80,
499 	SES_CTRL_SCC_ELECTRONICS_RQST_IDENT_SHIFT	= 7,
500 
501 	SES_CTRL_SCC_ELECTRONICS_RQST_FAIL_BYTE		= 0,
502 	SES_CTRL_SCC_ELECTRONICS_RQST_FAIL_MASK		= 0x40,
503 	SES_CTRL_SCC_ELECTRONICS_RQST_FAIL_SHIFT	= 6
504 };
505 
506 #define GEN_SES_CTRL_SCC_ELECTRONICS_ACCESSORS(LCASE, UCASE)		\
507     GEN_ACCESSORS(ses_ctrl_scc_electronics, SES_CTRL_SCC_ELECTRONICS,	\
508 		  LCASE, UCASE)
509 GEN_SES_CTRL_SCC_ELECTRONICS_ACCESSORS(rqst_ident, RQST_IDENT)
510 GEN_SES_CTRL_SCC_ELECTRONICS_ACCESSORS(rqst_fail,  RQST_FAIL)
511 #undef GEN_SES_CTRL_SCC_ELECTRONICS_ACCESSORS
512 
513 /*--------------------- Nonvolatile Cache Control Element --------------------*/
514 struct ses_ctrl_nv_cache {
515 	struct ses_ctrl_common common;
516 	uint8_t bytes[3];
517 };
518 
519 enum ses_ctrl_nv_cache_field_data {
520 	SES_CTRL_NV_CACHE_RQST_IDENT_BYTE	= 0,
521 	SES_CTRL_NV_CACHE_RQST_IDENT_MASK	= 0x80,
522 	SES_CTRL_NV_CACHE_RQST_IDENT_SHIFT	= 7,
523 
524 	SES_CTRL_NV_CACHE_RQST_FAIL_BYTE	= 0,
525 	SES_CTRL_NV_CACHE_RQST_FAIL_MASK	= 0x40,
526 	SES_CTRL_NV_CACHE_RQST_FAIL_SHIFT	= 6
527 };
528 
529 #define GEN_SES_CTRL_NV_CACHE_ACCESSORS(LCASE, UCASE)		\
530     GEN_ACCESSORS(ses_ctrl_nv_cache, SES_CTRL_NV_CACHE,	LCASE, UCASE)
531 GEN_SES_CTRL_NV_CACHE_ACCESSORS(rqst_ident, RQST_IDENT)
532 GEN_SES_CTRL_NV_CACHE_ACCESSORS(rqst_fail,  RQST_FAIL)
533 #undef GEN_SES_CTRL_NV_CACHE_ACCESSORS
534 
535 /*----------------- Invalid Operation Reason Control Element -----------------*/
536 struct ses_ctrl_invalid_op_reason {
537 	struct ses_ctrl_common common;
538 	uint8_t bytes[3];
539 };
540 
541 /* There are no element specific fields currently defined in the spec. */
542 
543 /*--------------- Uninterruptible Power Supply Control Element ---------------*/
544 struct ses_ctrl_ups {
545 	struct ses_ctrl_common common;
546 	uint8_t bytes[3];
547 };
548 
549 enum ses_ctrl_ups_field_data {
550 	SES_CTRL_UPS_RQST_IDENT_BYTE	= 2,
551 	SES_CTRL_UPS_RQST_IDENT_MASK	= 0x80,
552 	SES_CTRL_UPS_RQST_IDENT_SHIFT	= 7,
553 
554 	SES_CTRL_UPS_RQST_FAIL_BYTE	= 2,
555 	SES_CTRL_UPS_RQST_FAIL_MASK	= 0x40,
556 	SES_CTRL_UPS_RQST_FAIL_SHIFT	= 6
557 };
558 
559 #define GEN_SES_CTRL_UPS_ACCESSORS(LCASE, UCASE)	\
560     GEN_ACCESSORS(ses_ctrl_ups, SES_CTRL_UPS, LCASE, UCASE)
561 GEN_SES_CTRL_UPS_ACCESSORS(rqst_ident, RQST_IDENT)
562 GEN_SES_CTRL_UPS_ACCESSORS(rqst_fail,  RQST_FAIL)
563 #undef GEN_SES_CTRL_UPS_ACCESSORS
564 
565 /*-------------------------- Display Control Element -------------------------*/
566 struct ses_ctrl_display {
567 	struct ses_ctrl_common common;
568 	uint8_t bytes[1];
569 	uint8_t display_character[2];
570 };
571 
572 enum ses_ctrl_display_field_data {
573 	SES_CTRL_DISPLAY_RQST_IDENT_BYTE	= 0,
574 	SES_CTRL_DISPLAY_RQST_IDENT_MASK	= 0x80,
575 	SES_CTRL_DISPLAY_RQST_IDENT_SHIFT	= 7,
576 
577 	SES_CTRL_DISPLAY_RQST_FAIL_BYTE		= 0,
578 	SES_CTRL_DISPLAY_RQST_FAIL_MASK		= 0x40,
579 	SES_CTRL_DISPLAY_RQST_FAIL_SHIFT	= 6,
580 
581 	SES_CTRL_DISPLAY_DISPLAY_MODE_BYTE	= 0,
582 	SES_CTRL_DISPLAY_DISPLAY_MODE_MASK	= 0x03,
583 	SES_CTRL_DISPLAY_DISPLAY_MODE_SHIFT	= 6,
584 	SES_CTRL_DISPLAY_DISPLAY_MODE_UNCHANGED = 0x0,
585 	SES_CTRL_DISPLAY_DISPLAY_MODE_ESP	= 0x1,
586 	SES_CTRL_DISPLAY_DISPLAY_MODE_DC_FIELD	= 0x2
587 };
588 
589 #define GEN_SES_CTRL_DISPLAY_ACCESSORS(LCASE, UCASE)	\
590     GEN_ACCESSORS(ses_ctrl_display, SES_CTRL_DISPLAY, LCASE, UCASE)
591 GEN_SES_CTRL_DISPLAY_ACCESSORS(rqst_ident,   RQST_IDENT)
592 GEN_SES_CTRL_DISPLAY_ACCESSORS(rqst_fail,    RQST_FAIL)
593 GEN_SES_CTRL_DISPLAY_ACCESSORS(display_mode, DISPLAY_MODE)
594 #undef GEN_SES_CTRL_DISPLAY_ACCESSORS
595 
596 /*----------------------- Key Pad Entry Control Element ----------------------*/
597 struct ses_ctrl_key_pad_entry {
598 	struct ses_ctrl_common common;
599 	uint8_t bytes[3];
600 };
601 
602 enum ses_ctrl_key_pad_entry_field_data {
603 	SES_CTRL_KEY_PAD_ENTRY_RQST_IDENT_BYTE	= 0,
604 	SES_CTRL_KEY_PAD_ENTRY_RQST_IDENT_MASK	= 0x80,
605 	SES_CTRL_KEY_PAD_ENTRY_RQST_IDENT_SHIFT	= 7,
606 
607 	SES_CTRL_KEY_PAD_ENTRY_RQST_FAIL_BYTE	= 0,
608 	SES_CTRL_KEY_PAD_ENTRY_RQST_FAIL_MASK	= 0x40,
609 	SES_CTRL_KEY_PAD_ENTRY_RQST_FAIL_SHIFT	= 6
610 };
611 
612 #define GEN_SES_CTRL_KEY_PAD_ENTRY_ACCESSORS(LCASE, UCASE)	\
613     GEN_ACCESSORS(ses_ctrl_key_pad_entry, SES_CTRL_KEY_PAD_ENTRY, LCASE, UCASE)
614 GEN_SES_CTRL_KEY_PAD_ENTRY_ACCESSORS(rqst_ident,   RQST_IDENT)
615 GEN_SES_CTRL_KEY_PAD_ENTRY_ACCESSORS(rqst_fail,    RQST_FAIL)
616 #undef GEN_SES_CTRL_KEY_PAD_ENTRY_ACCESSORS
617 
618 /*------------------------- Enclosure Control Element ------------------------*/
619 struct ses_ctrl_enclosure {
620 	struct ses_ctrl_common common;
621 	uint8_t bytes[3];
622 };
623 
624 enum ses_ctrl_enclosure_field_data {
625 	SES_CTRL_ENCLOSURE_RQST_IDENT_BYTE		= 0,
626 	SES_CTRL_ENCLOSURE_RQST_IDENT_MASK		= 0x80,
627 	SES_CTRL_ENCLOSURE_RQST_IDENT_SHIFT		= 7,
628 
629 	SES_CTRL_ENCLOSURE_POWER_CYCLE_RQST_BYTE	= 1,
630 	SES_CTRL_ENCLOSURE_POWER_CYCLE_RQST_MASK	= 0xC0,
631 	SES_CTRL_ENCLOSURE_POWER_CYCLE_RQST_SHIFT	= 6,
632 	SES_CTRL_ENCLOSURE_POWER_CYCLE_RQST_NONE	= 0x0,
633 	SES_CTRL_ENCLOSURE_POWER_CYCLE_RQST_AFTER_DELAY	= 0x1,
634 	SES_CTRL_ENCLOSURE_POWER_CYCLE_RQST_CANCEL	= 0x2,
635 
636 	SES_CTRL_ENCLOSURE_POWER_CYCLE_DELAY_BYTE	= 1,
637 	SES_CTRL_ENCLOSURE_POWER_CYCLE_DELAY_MASK	= 0x3F,
638 	SES_CTRL_ENCLOSURE_POWER_CYCLE_DELAY_SHIFT	= 0,
639 	SES_CTRL_ENCLOSURE_POWER_CYCLE_DELAY_MAX	= 60,/*minutes*/
640 
641 	SES_CTRL_ENCLOSURE_POWER_OFF_DURATION_BYTE	= 2,
642 	SES_CTRL_ENCLOSURE_POWER_OFF_DURATION_MASK	= 0xFC,
643 	SES_CTRL_ENCLOSURE_POWER_OFF_DURATION_SHIFT	= 2,
644 	SES_CTRL_ENCLOSURE_POWER_OFF_DURATION_MAX_AUTO	= 60,
645 	SES_CTRL_ENCLOSURE_POWER_OFF_DURATION_MANUAL	= 63,
646 
647 	SES_CTRL_ENCLOSURE_RQST_FAIL_BYTE		= 2,
648 	SES_CTRL_ENCLOSURE_RQST_FAIL_MASK		= 0x02,
649 	SES_CTRL_ENCLOSURE_RQST_FAIL_SHIFT		= 1,
650 
651 	SES_CTRL_ENCLOSURE_RQST_WARN_BYTE		= 2,
652 	SES_CTRL_ENCLOSURE_RQST_WARN_MASK		= 0x01,
653 	SES_CTRL_ENCLOSURE_RQST_WARN_SHIFT		= 0
654 };
655 
656 #define GEN_SES_CTRL_ENCLOSURE_ACCESSORS(LCASE, UCASE)		\
657     GEN_ACCESSORS(ses_ctrl_enclosure, SES_CTRL_ENCLOSURE, LCASE, UCASE)
658 GEN_SES_CTRL_ENCLOSURE_ACCESSORS(rqst_ident,         RQST_IDENT)
659 GEN_SES_CTRL_ENCLOSURE_ACCESSORS(power_cycle_rqst,   POWER_CYCLE_RQST)
660 GEN_SES_CTRL_ENCLOSURE_ACCESSORS(power_cycle_delay,  POWER_CYCLE_DELAY)
661 GEN_SES_CTRL_ENCLOSURE_ACCESSORS(power_off_duration, POWER_OFF_DURATION)
662 GEN_SES_CTRL_ENCLOSURE_ACCESSORS(rqst_fail,          RQST_FAIL)
663 GEN_SES_CTRL_ENCLOSURE_ACCESSORS(rqst_warn,          RQST_WARN)
664 #undef GEN_SES_CTRL_ENCLOSURE_ACCESSORS
665 
666 /*------------------- SCSI Port/Transceiver Control Element ------------------*/
667 struct ses_ctrl_scsi_port_or_xcvr {
668 	struct ses_ctrl_common common;
669 	uint8_t bytes[3];
670 };
671 
672 enum ses_ctrl_scsi_port_or_xcvr_field_data {
673 	SES_CTRL_SCSI_PORT_OR_XCVR_RQST_IDENT_BYTE	= 0,
674 	SES_CTRL_SCSI_PORT_OR_XCVR_RQST_IDENT_MASK	= 0x80,
675 	SES_CTRL_SCSI_PORT_OR_XCVR_RQST_IDENT_SHIFT	= 7,
676 
677 	SES_CTRL_SCSI_PORT_OR_XCVR_RQST_FAIL_BYTE	= 0,
678 	SES_CTRL_SCSI_PORT_OR_XCVR_RQST_FAIL_MASK	= 0x40,
679 	SES_CTRL_SCSI_PORT_OR_XCVR_RQST_FAIL_SHIFT	= 6,
680 
681 	SES_CTRL_SCSI_PORT_OR_XCVR_DISABLE_BYTE		= 2,
682 	SES_CTRL_SCSI_PORT_OR_XCVR_DISABLE_MASK		= 0x10,
683 	SES_CTRL_SCSI_PORT_OR_XCVR_DISABLE_SHIFT	= 4
684 };
685 
686 #define GEN_SES_CTRL_SCSI_PORT_OR_XCVR_ACCESSORS(LCASE, UCASE)		 \
687     GEN_ACCESSORS(ses_ctrl_scsi_port_or_xcvr, SES_CTRL_SCSI_PORT_OR_XCVR,\
688 		  LCASE, UCASE)
689 GEN_SES_CTRL_SCSI_PORT_OR_XCVR_ACCESSORS(rqst_ident, RQST_IDENT)
690 GEN_SES_CTRL_SCSI_PORT_OR_XCVR_ACCESSORS(disable,    DISABLE)
691 GEN_SES_CTRL_SCSI_PORT_OR_XCVR_ACCESSORS(rqst_fail,  RQST_FAIL)
692 #undef GEN_SES_CTRL_SCSI_PORT_OR_XCVR_ACCESSORS
693 
694 /*------------------------- Language Control Element -------------------------*/
695 struct ses_ctrl_language {
696 	struct ses_ctrl_common common;
697 	uint8_t bytes[1];
698 	uint8_t language_code[2];
699 };
700 
701 enum ses_ctrl_language_field_data {
702 	SES_CTRL_LANGUAGE_RQST_IDENT_BYTE	= 0,
703 	SES_CTRL_LANGUAGE_RQST_IDENT_MASK	= 0x80,
704 	SES_CTRL_LANGUAGE_RQST_IDENT_SHIFT	= 7
705 };
706 
707 #define GEN_SES_CTRL_LANGUAGE_ACCESSORS(LCASE, UCASE)		 \
708     GEN_ACCESSORS(ses_ctrl_language, SES_CTRL_LANGUAGE, LCASE, UCASE)
709 GEN_SES_CTRL_LANGUAGE_ACCESSORS(rqst_ident, RQST_IDENT)
710 #undef GEN_SES_CTRL_LANGUAGE_ACCESSORS
711 
712 /*-------------------- Communication Port Control Element --------------------*/
713 struct ses_ctrl_comm_port {
714 	struct ses_ctrl_common common;
715 	uint8_t bytes[3];
716 };
717 
718 enum ses_ctrl_comm_port_field_data {
719 	SES_CTRL_COMM_PORT_RQST_IDENT_BYTE	= 0,
720 	SES_CTRL_COMM_PORT_RQST_IDENT_MASK	= 0x80,
721 	SES_CTRL_COMM_PORT_RQST_IDENT_SHIFT	= 7,
722 
723 	SES_CTRL_COMM_PORT_RQST_FAIL_BYTE	= 0,
724 	SES_CTRL_COMM_PORT_RQST_FAIL_MASK	= 0x40,
725 	SES_CTRL_COMM_PORT_RQST_FAIL_SHIFT	= 6,
726 
727 	SES_CTRL_COMM_PORT_DISABLE_BYTE		= 2,
728 	SES_CTRL_COMM_PORT_DISABLE_MASK		= 0x01,
729 	SES_CTRL_COMM_PORT_DISABLE_SHIFT	= 0
730 };
731 
732 #define GEN_SES_CTRL_COMM_PORT_ACCESSORS(LCASE, UCASE)		 \
733     GEN_ACCESSORS(ses_ctrl_comm_port, SES_CTRL_COMM_PORT, LCASE, UCASE)
734 GEN_SES_CTRL_COMM_PORT_ACCESSORS(rqst_ident, RQST_IDENT)
735 GEN_SES_CTRL_COMM_PORT_ACCESSORS(rqst_fail,  RQST_FAIL)
736 GEN_SES_CTRL_COMM_PORT_ACCESSORS(disable,    DISABLE)
737 #undef GEN_SES_CTRL_COMM_PORT_ACCESSORS
738 
739 /*---------------------- Voltage Sensor Control Element ----------------------*/
740 struct ses_ctrl_voltage_sensor {
741 	struct ses_ctrl_common common;
742 	uint8_t bytes[3];
743 };
744 
745 enum ses_ctrl_voltage_sensor_field_data {
746 	SES_CTRL_VOLTAGE_SENSOR_RQST_IDENT_BYTE		= 0,
747 	SES_CTRL_VOLTAGE_SENSOR_RQST_IDENT_MASK		= 0x80,
748 	SES_CTRL_VOLTAGE_SENSOR_RQST_IDENT_SHIFT	= 7,
749 
750 	SES_CTRL_VOLTAGE_SENSOR_RQST_FAIL_BYTE		= 0,
751 	SES_CTRL_VOLTAGE_SENSOR_RQST_FAIL_MASK		= 0x40,
752 	SES_CTRL_VOLTAGE_SENSOR_RQST_FAIL_SHIFT		= 6
753 };
754 
755 #define GEN_SES_CTRL_VOLTAGE_SENSOR_ACCESSORS(LCASE, UCASE)		\
756     GEN_ACCESSORS(ses_ctrl_voltage_sensor, SES_CTRL_VOLTAGE_SENSOR,	\
757 		  LCASE, UCASE)
758 GEN_SES_CTRL_VOLTAGE_SENSOR_ACCESSORS(rqst_ident, RQST_IDENT)
759 GEN_SES_CTRL_VOLTAGE_SENSOR_ACCESSORS(rqst_fail,  RQST_FAIL)
760 #undef GEN_SES_CTRL_VOLTAGE_SENSOR_ACCESSORS
761 
762 /*---------------------- Current Sensor Control Element ----------------------*/
763 struct ses_ctrl_current_sensor {
764 	struct ses_ctrl_common common;
765 	uint8_t bytes[3];
766 };
767 
768 enum ses_ctrl_current_sensor_field_data {
769 	SES_CTRL_CURRENT_SENSOR_RQST_IDENT_BYTE		= 0,
770 	SES_CTRL_CURRENT_SENSOR_RQST_IDENT_MASK		= 0x80,
771 	SES_CTRL_CURRENT_SENSOR_RQST_IDENT_SHIFT	= 7,
772 
773 	SES_CTRL_CURRENT_SENSOR_RQST_FAIL_BYTE		= 0,
774 	SES_CTRL_CURRENT_SENSOR_RQST_FAIL_MASK		= 0x40,
775 	SES_CTRL_CURRENT_SENSOR_RQST_FAIL_SHIFT		= 6
776 };
777 
778 #define GEN_SES_CTRL_CURRENT_SENSOR_ACCESSORS(LCASE, UCASE)		\
779     GEN_ACCESSORS(ses_ctrl_current_sensor, SES_CTRL_CURRENT_SENSOR,	\
780 		  LCASE, UCASE)
781 GEN_SES_CTRL_CURRENT_SENSOR_ACCESSORS(rqst_ident, RQST_IDENT)
782 GEN_SES_CTRL_CURRENT_SENSOR_ACCESSORS(rqst_fail,  RQST_FAIL)
783 #undef GEN_SES_CTRL_CURRENT_SENSOR_ACCESSORS
784 
785 /*--------------------- SCSI Target Port Control Element ---------------------*/
786 struct ses_ctrl_target_port {
787 	struct ses_ctrl_common common;
788 	uint8_t bytes[3];
789 };
790 
791 enum ses_ctrl_scsi_target_port_field_data {
792 	SES_CTRL_TARGET_PORT_RQST_IDENT_BYTE	= 0,
793 	SES_CTRL_TARGET_PORT_RQST_IDENT_MASK	= 0x80,
794 	SES_CTRL_TARGET_PORT_RQST_IDENT_SHIFT	= 7,
795 
796 	SES_CTRL_TARGET_PORT_RQST_FAIL_BYTE	= 0,
797 	SES_CTRL_TARGET_PORT_RQST_FAIL_MASK	= 0x40,
798 	SES_CTRL_TARGET_PORT_RQST_FAIL_SHIFT	= 6,
799 
800 	SES_CTRL_TARGET_PORT_ENABLE_BYTE	= 2,
801 	SES_CTRL_TARGET_PORT_ENABLE_MASK	= 0x01,
802 	SES_CTRL_TARGET_PORT_ENABLE_SHIFT	= 0
803 };
804 
805 #define GEN_SES_CTRL_TARGET_PORT_ACCESSORS(LCASE, UCASE)	\
806     GEN_ACCESSORS(ses_ctrl_target_port, SES_CTRL_TARGET_PORT, LCASE, UCASE)
807 GEN_SES_CTRL_TARGET_PORT_ACCESSORS(rqst_ident, RQST_IDENT)
808 GEN_SES_CTRL_TARGET_PORT_ACCESSORS(rqst_fail,  RQST_FAIL)
809 GEN_SES_CTRL_TARGET_PORT_ACCESSORS(enable,     ENABLE)
810 #undef GEN_SES_CTRL_TARGET_PORT_ACCESSORS
811 
812 /*-------------------- SCSI Initiator Port Control Element -------------------*/
813 struct ses_ctrl_initiator_port {
814 	struct ses_ctrl_common common;
815 	uint8_t bytes[3];
816 };
817 
818 enum ses_ctrl_initiator_port_field_data {
819 	SES_CTRL_INITIATOR_PORT_RQST_IDENT_BYTE		= 0,
820 	SES_CTRL_INITIATOR_PORT_RQST_IDENT_MASK		= 0x80,
821 	SES_CTRL_INITIATOR_PORT_RQST_IDENT_SHIFT	= 7,
822 
823 	SES_CTRL_INITIATOR_PORT_RQST_FAIL_BYTE		= 0,
824 	SES_CTRL_INITIATOR_PORT_RQST_FAIL_MASK		= 0x40,
825 	SES_CTRL_INITIATOR_PORT_RQST_FAIL_SHIFT		= 6,
826 
827 	SES_CTRL_INITIATOR_PORT_ENABLE_BYTE		= 2,
828 	SES_CTRL_INITIATOR_PORT_ENABLE_MASK		= 0x01,
829 	SES_CTRL_INITIATOR_PORT_ENABLE_SHIFT		= 0
830 };
831 
832 #define GEN_SES_CTRL_INITIATOR_PORT_ACCESSORS(LCASE, UCASE)		\
833     GEN_ACCESSORS(ses_ctrl_initiator_port, SES_CTRL_INITIATOR_PORT,	\
834 		  LCASE, UCASE)
835 GEN_SES_CTRL_INITIATOR_PORT_ACCESSORS(rqst_ident, RQST_IDENT)
836 GEN_SES_CTRL_INITIATOR_PORT_ACCESSORS(rqst_fail,  RQST_FAIL)
837 GEN_SES_CTRL_INITIATOR_PORT_ACCESSORS(enable,     ENABLE)
838 #undef GEN_SES_CTRL_INITIATOR_PORT_ACCESSORS
839 
840 /*-------------------- Simple Subenclosure Control Element -------------------*/
841 struct ses_ctrl_simple_subenc {
842 	struct ses_ctrl_common common;
843 	uint8_t bytes[3];
844 };
845 
846 enum ses_ctrl_simple_subenc_field_data {
847 	SES_CTRL_SIMPlE_SUBSES_RQST_IDENT_BYTE	= 0,
848 	SES_CTRL_SIMPlE_SUBSES_RQST_IDENT_MASK	= 0x80,
849 	SES_CTRL_SIMPlE_SUBSES_RQST_IDENT_SHIFT	= 7,
850 
851 	SES_CTRL_SIMPlE_SUBSES_RQST_FAIL_BYTE	= 0,
852 	SES_CTRL_SIMPlE_SUBSES_RQST_FAIL_MASK	= 0x40,
853 	SES_CTRL_SIMPlE_SUBSES_RQST_FAIL_SHIFT	= 6
854 };
855 
856 #define GEN_SES_CTRL_SIMPlE_SUBSES_ACCESSORS(LCASE, UCASE)		\
857     GEN_ACCESSORS(ses_ctrl_simple_subenc, SES_CTRL_SIMPlE_SUBSES,	\
858 		  LCASE, UCASE)
859 GEN_SES_CTRL_SIMPlE_SUBSES_ACCESSORS(rqst_ident, RQST_IDENT)
860 GEN_SES_CTRL_SIMPlE_SUBSES_ACCESSORS(rqst_fail,  RQST_FAIL)
861 #undef GEN_SES_CTRL_SIMPlE_SUBSES_ACCESSORS
862 
863 /*----------------------- SAS Expander Control Element -----------------------*/
864 struct ses_ctrl_sas_expander {
865 	struct ses_ctrl_common common;
866 	uint8_t bytes[3];
867 };
868 
869 enum ses_ctrl_sas_expander_field_data {
870 	SES_CTRL_SAS_EXPANDER_RQST_IDENT_BYTE	= 0,
871 	SES_CTRL_SAS_EXPANDER_RQST_IDENT_MASK	= 0x80,
872 	SES_CTRL_SAS_EXPANDER_RQST_IDENT_SHIFT	= 7,
873 
874 	SES_CTRL_SAS_EXPANDER_RQST_FAIL_BYTE	= 0,
875 	SES_CTRL_SAS_EXPANDER_RQST_FAIL_MASK	= 0x40,
876 	SES_CTRL_SAS_EXPANDER_RQST_FAIL_SHIFT	= 6
877 };
878 
879 #define GEN_SES_CTRL_SAS_EXPANDER_ACCESSORS(LCASE, UCASE)	\
880     GEN_ACCESSORS(ses_ctrl_sas_expander, SES_CTRL_SAS_EXPANDER,	LCASE, UCASE)
881 GEN_SES_CTRL_SAS_EXPANDER_ACCESSORS(rqst_ident, RQST_IDENT)
882 GEN_SES_CTRL_SAS_EXPANDER_ACCESSORS(rqst_fail,  RQST_FAIL)
883 #undef GEN_SES_CTRL_SAS_EXPANDER_ACCESSORS
884 
885 /*----------------------- SAS Connector Control Element ----------------------*/
886 struct ses_ctrl_sas_connector {
887 	struct ses_ctrl_common common;
888 	uint8_t bytes[3];
889 };
890 
891 enum ses_ctrl_sas_connector_field_data {
892 	SES_CTRL_SAS_CONNECTOR_RQST_IDENT_BYTE		= 0,
893 	SES_CTRL_SAS_CONNECTOR_RQST_IDENT_MASK		= 0x80,
894 	SES_CTRL_SAS_CONNECTOR_RQST_IDENT_SHIFT		= 7,
895 
896 	SES_CTRL_SAS_CONNECTOR_RQST_FAIL_BYTE		= 2,
897 	SES_CTRL_SAS_CONNECTOR_RQST_FAIL_MASK		= 0x40,
898 	SES_CTRL_SAS_CONNECTOR_RQST_FAIL_SHIFT		= 6
899 };
900 
901 #define GEN_SES_CTRL_SAS_CONNECTOR_ACCESSORS(LCASE, UCASE)		\
902     GEN_ACCESSORS(ses_ctrl_sas_connector, SES_CTRL_SAS_CONNECTOR,	\
903 		  LCASE, UCASE)
904 GEN_SES_CTRL_SAS_CONNECTOR_ACCESSORS(rqst_ident, RQST_IDENT)
905 GEN_SES_CTRL_SAS_CONNECTOR_ACCESSORS(rqst_fail,  RQST_FAIL)
906 #undef GEN_SES_CTRL_SAS_CONNECTOR_ACCESSORS
907 
908 /*------------------------- Universal Control Element ------------------------*/
909 union ses_ctrl_element {
910 	struct ses_ctrl_common            common;
911 	struct ses_ctrl_dev_slot          dev_slot;
912 	struct ses_ctrl_array_dev_slot    array_dev_slot;
913 	struct ses_ctrl_power_supply      power_supply;
914 	struct ses_ctrl_cooling           cooling;
915 	struct ses_ctrl_temp_sensor       temp_sensor;
916 	struct ses_ctrl_door_lock         door_lock;
917 	struct ses_ctrl_audible_alarm     audible_alarm;
918 	struct ses_ctrl_ecc_electronics   ecc_electronics;
919 	struct ses_ctrl_scc_electronics   scc_electronics;
920 	struct ses_ctrl_nv_cache          nv_cache;
921 	struct ses_ctrl_invalid_op_reason invalid_op_reason;
922 	struct ses_ctrl_ups               ups;
923 	struct ses_ctrl_display           display;
924 	struct ses_ctrl_key_pad_entry     key_pad_entry;
925 	struct ses_ctrl_scsi_port_or_xcvr scsi_port_or_xcvr;
926 	struct ses_ctrl_language          language;
927 	struct ses_ctrl_comm_port         comm_port;
928 	struct ses_ctrl_voltage_sensor    voltage_sensor;
929 	struct ses_ctrl_current_sensor    current_sensor;
930 	struct ses_ctrl_target_port	  target_port;
931 	struct ses_ctrl_initiator_port    initiator_port;
932 	struct ses_ctrl_simple_subenc	  simple_subenc;
933 	struct ses_ctrl_sas_expander      sas_expander;
934 	struct ses_ctrl_sas_connector     sas_connector;
935 };
936 
937 /*--------------------- SCSI SES Control Diagnostic Page ---------------------*/
938 struct ses_ctrl_page {
939 	struct ses_page_hdr hdr;
940 	union ses_ctrl_element   elements[];
941 };
942 
943 enum ses_ctrl_page_field_data {
944 	SES_CTRL_PAGE_INFO_MASK		= 0x08,
945 	SES_CTRL_PAGE_INFO_SHIFT	= 3,
946 
947 	SES_CTRL_PAGE_NON_CRIT_MASK	= 0x04,
948 	SES_CTRL_PAGE_NON_CRIT_SHIFT	= 2,
949 
950 	SES_CTRL_PAGE_CRIT_MASK		= 0x02,
951 	SES_CTRL_PAGE_CRIT_SHIFT	= 1,
952 
953 	SES_CTRL_PAGE_UNRECOV_MASK	= 0x01,
954 	SES_CTRL_PAGE_UNRECOV_SHIFT	= 0
955 };
956 
957 #define GEN_SES_CTRL_PAGE_ACCESSORS(LCASE, UCASE) \
958     GEN_HDR_ACCESSORS(ses_ctrl_page, SES_CTRL_PAGE, LCASE, UCASE)
959 
960 GEN_SES_CTRL_PAGE_ACCESSORS(info,     INFO)
961 GEN_SES_CTRL_PAGE_ACCESSORS(non_crit, NON_CRIT)
962 GEN_SES_CTRL_PAGE_ACCESSORS(crit,     CRIT)
963 GEN_SES_CTRL_PAGE_ACCESSORS(unrecov,  UNRECOV)
964 #undef GEN_SES_CTRL_PAGE_ACCESSORS
965 
966 /*================= SCSI SES Status Diagnostic Page Structures ===============*/
967 struct ses_status_common {
968 	uint8_t bytes[1];
969 };
970 
971 enum ses_status_common_field_data {
972 	SES_STATUS_COMMON_PRDFAIL_BYTE			= 0,
973 	SES_STATUS_COMMON_PRDFAIL_MASK			= 0x40,
974 	SES_STATUS_COMMON_PRDFAIL_SHIFT			= 6,
975 
976 	SES_STATUS_COMMON_DISABLED_BYTE			= 0,
977 	SES_STATUS_COMMON_DISABLED_MASK			= 0x20,
978 	SES_STATUS_COMMON_DISABLED_SHIFT		= 5,
979 
980 	SES_STATUS_COMMON_SWAP_BYTE			= 0,
981 	SES_STATUS_COMMON_SWAP_MASK			= 0x10,
982 	SES_STATUS_COMMON_SWAP_SHIFT			= 4,
983 
984 	SES_STATUS_COMMON_ELEMENT_STATUS_CODE_BYTE	= 0,
985 	SES_STATUS_COMMON_ELEMENT_STATUS_CODE_MASK	= 0x0F,
986 	SES_STATUS_COMMON_ELEMENT_STATUS_CODE_SHIFT	= 0
987 };
988 
989 #define GEN_SES_STATUS_COMMON_ACCESSORS(LCASE, UCASE) \
990     GEN_GETTER(ses_status_common, SES_STATUS_COMMON, LCASE, UCASE)
991 
992 GEN_SES_STATUS_COMMON_ACCESSORS(prdfail,             PRDFAIL)
993 GEN_SES_STATUS_COMMON_ACCESSORS(disabled,            DISABLED)
994 GEN_SES_STATUS_COMMON_ACCESSORS(swap,                SWAP)
995 GEN_SES_STATUS_COMMON_ACCESSORS(element_status_code, ELEMENT_STATUS_CODE)
996 #undef GEN_SES_STATUS_COMMON_ACCESSORS
997 
998 /*------------------------- Device Slot Status Element -----------------------*/
999 struct ses_status_dev_slot {
1000 	struct ses_status_common common;
1001 	uint8_t slot_address;
1002 	uint8_t bytes[2];
1003 };
1004 
1005 enum ses_status_dev_slot_field_data {
1006 	SES_STATUS_DEV_SLOT_APP_CLIENT_BYPED_A_BYTE	= 0,
1007 	SES_STATUS_DEV_SLOT_APP_CLIENT_BYPED_A_MASK	= 0x80,
1008 	SES_STATUS_DEV_SLOT_APP_CLIENT_BYPED_A_SHIFT	= 7,
1009 
1010 	SES_STATUS_DEV_SLOT_DO_NOT_REMOVE_BYTE		= 0,
1011 	SES_STATUS_DEV_SLOT_DO_NOT_REMOVE_MASK		= 0x40,
1012 	SES_STATUS_DEV_SLOT_DO_NOT_REMOVE_SHIFT		= 6,
1013 
1014 	SES_STATUS_DEV_SLOT_ENCLOSURE_BYPED_A_BYTE	= 0,
1015 	SES_STATUS_DEV_SLOT_ENCLOSURE_BYPED_A_MASK	= 0x20,
1016 	SES_STATUS_DEV_SLOT_ENCLOSURE_BYPED_A_SHIFT	= 5,
1017 
1018 	SES_STATUS_DEV_SLOT_ENCLOSURE_BYPED_B_BYTE	= 0,
1019 	SES_STATUS_DEV_SLOT_ENCLOSURE_BYPED_B_MASK	= 0x10,
1020 	SES_STATUS_DEV_SLOT_ENCLOSURE_BYPED_B_SHIFT	= 4,
1021 
1022 	SES_STATUS_DEV_SLOT_INSERT_READY_BYTE		= 0,
1023 	SES_STATUS_DEV_SLOT_INSERT_READY_MASK		= 0x08,
1024 	SES_STATUS_DEV_SLOT_INSERT_READY_SHIFT		= 3,
1025 
1026 	SES_STATUS_DEV_SLOT_REMOVE_BYTE			= 0,
1027 	SES_STATUS_DEV_SLOT_REMOVE_MASK			= 0x04,
1028 	SES_STATUS_DEV_SLOT_REMOVE_SHIFT		= 2,
1029 
1030 	SES_STATUS_DEV_SLOT_IDENT_BYTE			= 0,
1031 	SES_STATUS_DEV_SLOT_IDENT_MASK			= 0x02,
1032 	SES_STATUS_DEV_SLOT_IDENT_SHIFT			= 1,
1033 
1034 	SES_STATUS_DEV_SLOT_REPORT_BYTE			= 0,
1035 	SES_STATUS_DEV_SLOT_REPORT_MASK			= 0x01,
1036 	SES_STATUS_DEV_SLOT_REPORT_SHIFT		= 0,
1037 
1038 	SES_STATUS_DEV_SLOT_APP_CLIENT_BYPED_B_BYTE	= 1,
1039 	SES_STATUS_DEV_SLOT_APP_CLIENT_BYPED_B_MASK	= 0x80,
1040 	SES_STATUS_DEV_SLOT_APP_CLIENT_BYPED_B_SHIFT	= 7,
1041 
1042 	SES_STATUS_DEV_SLOT_FAULT_SENSED_BYTE		= 1,
1043 	SES_STATUS_DEV_SLOT_FAULT_SENSED_MASK		= 0x40,
1044 	SES_STATUS_DEV_SLOT_FAULT_SENSED_SHIFT		= 6,
1045 
1046 	SES_STATUS_DEV_SLOT_FAULT_REQUESTED_BYTE	= 1,
1047 	SES_STATUS_DEV_SLOT_FAULT_REQUESTED_MASK	= 0x20,
1048 	SES_STATUS_DEV_SLOT_FAULT_REQUESTED_SHIFT	= 5,
1049 
1050 	SES_STATUS_DEV_SLOT_DEVICE_OFF_BYTE		= 1,
1051 	SES_STATUS_DEV_SLOT_DEVICE_OFF_MASK		= 0x10,
1052 	SES_STATUS_DEV_SLOT_DEVICE_OFF_SHIFT		= 4,
1053 
1054 	SES_STATUS_DEV_SLOT_BYPED_A_BYTE		= 1,
1055 	SES_STATUS_DEV_SLOT_BYPED_A_MASK		= 0x08,
1056 	SES_STATUS_DEV_SLOT_BYPED_A_SHIFT		= 3,
1057 
1058 	SES_STATUS_DEV_SLOT_BYPED_B_BYTE		= 1,
1059 	SES_STATUS_DEV_SLOT_BYPED_B_MASK		= 0x04,
1060 	SES_STATUS_DEV_SLOT_BYPED_B_SHIFT		= 2,
1061 
1062 	SES_STATUS_DEV_SLOT_DEVICE_BYPED_A_BYTE		= 1,
1063 	SES_STATUS_DEV_SLOT_DEVICE_BYPED_A_MASK		= 0x02,
1064 	SES_STATUS_DEV_SLOT_DEVICE_BYPED_A_SHIFT	= 1,
1065 
1066 	SES_STATUS_DEV_SLOT_DEVICE_BYPED_B_BYTE		= 1,
1067 	SES_STATUS_DEV_SLOT_DEVICE_BYPED_B_MASK		= 0x01,
1068 	SES_STATUS_DEV_SLOT_DEVICE_BYPED_B_SHIFT	= 0
1069 };
1070 #define GEN_SES_STATUS_DEV_SLOT_ACCESSORS(LCASE, UCASE) \
1071     GEN_GETTER(ses_status_dev_slot, SES_STATUS_DEV_SLOT, LCASE, UCASE)
1072 
1073 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(app_client_byped_a, APP_CLIENT_BYPED_A)
1074 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(do_not_remove,      DO_NOT_REMOVE)
1075 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(enclosure_byped_a,  ENCLOSURE_BYPED_A)
1076 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(enclosure_byped_b,  ENCLOSURE_BYPED_B)
1077 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(insert_ready,       INSERT_READY)
1078 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(remove,             REMOVE)
1079 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(ident,              IDENT)
1080 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(report,             REPORT)
1081 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(app_client_byped_b, APP_CLIENT_BYPED_B)
1082 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(fault_sensed,       FAULT_SENSED)
1083 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(fault_requested,    FAULT_REQUESTED)
1084 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(device_off,         DEVICE_OFF)
1085 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(byped_a,            BYPED_A)
1086 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(byped_b,            BYPED_B)
1087 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(device_byped_a,     DEVICE_BYPED_A)
1088 GEN_SES_STATUS_DEV_SLOT_ACCESSORS(device_byped_b,     DEVICE_BYPED_B)
1089 #undef GEN_SES_STATUS_DEV_SLOT_ACCESSORS
1090 
1091 /*---------------------- Array Device Slot Status Element --------------------*/
1092 struct ses_status_array_dev_slot {
1093 	struct ses_status_common common;
1094 	uint8_t bytes[3];
1095 };
1096 
1097 enum ses_status_array_dev_slot_field_data {
1098 	SES_STATUS_ARRAY_DEV_SLOT_OK_BYTE			= 0,
1099 	SES_STATUS_ARRAY_DEV_SLOT_OK_MASK			= 0x80,
1100 	SES_STATUS_ARRAY_DEV_SLOT_OK_SHIFT			= 7,
1101 
1102 	SES_STATUS_ARRAY_DEV_SLOT_RSVD_DEVICE_BYTE		= 0,
1103 	SES_STATUS_ARRAY_DEV_SLOT_RSVD_DEVICE_MASK		= 0x40,
1104 	SES_STATUS_ARRAY_DEV_SLOT_RSVD_DEVICE_SHIFT		= 6,
1105 
1106 	SES_STATUS_ARRAY_DEV_SLOT_HOT_SPARE_BYTE		= 0,
1107 	SES_STATUS_ARRAY_DEV_SLOT_HOT_SPARE_MASK		= 0x20,
1108 	SES_STATUS_ARRAY_DEV_SLOT_HOT_SPARE_SHIFT		= 5,
1109 
1110 	SES_STATUS_ARRAY_DEV_SLOT_CONS_CHECK_BYTE		= 0,
1111 	SES_STATUS_ARRAY_DEV_SLOT_CONS_CHECK_MASK		= 0x10,
1112 	SES_STATUS_ARRAY_DEV_SLOT_CONS_CHECK_SHIFT		= 4,
1113 
1114 	SES_STATUS_ARRAY_DEV_SLOT_IN_CRIT_ARRAY_BYTE		= 0,
1115 	SES_STATUS_ARRAY_DEV_SLOT_IN_CRIT_ARRAY_MASK		= 0x08,
1116 	SES_STATUS_ARRAY_DEV_SLOT_IN_CRIT_ARRAY_SHIFT		= 3,
1117 
1118 	SES_STATUS_ARRAY_DEV_SLOT_IN_FAILED_ARRAY_BYTE		= 0,
1119 	SES_STATUS_ARRAY_DEV_SLOT_IN_FAILED_ARRAY_MASK		= 0x04,
1120 	SES_STATUS_ARRAY_DEV_SLOT_IN_FAILED_ARRAY_SHIFT		= 2,
1121 
1122 	SES_STATUS_ARRAY_DEV_SLOT_REBUILD_REMAP_BYTE		= 0,
1123 	SES_STATUS_ARRAY_DEV_SLOT_REBUILD_REMAP_MASK		= 0x02,
1124 	SES_STATUS_ARRAY_DEV_SLOT_REBUILD_REMAP_SHIFT		= 1,
1125 
1126 	SES_STATUS_ARRAY_DEV_SLOT_REBUILD_REMAP_ABORT_BYTE	= 0,
1127 	SES_STATUS_ARRAY_DEV_SLOT_REBUILD_REMAP_ABORT_MASK	= 0x01,
1128 	SES_STATUS_ARRAY_DEV_SLOT_REBUILD_REMAP_ABORT_SHIFT	= 0
1129 
1130 	/*
1131 	 * The remaining fields are identical to the device
1132 	 * slot element type.  Access them through the device slot
1133 	 * element type and its accessors.
1134 	 */
1135 };
1136 #define GEN_SES_STATUS_ARRAY_DEV_SLOT_ACCESSORS(LCASE, UCASE)		\
1137     GEN_GETTER(ses_status_array_dev_slot, SES_STATUS_ARRAY_DEV_SLOT,	\
1138 	       LCASE, UCASE)
1139 GEN_SES_STATUS_ARRAY_DEV_SLOT_ACCESSORS(ok,              OK)
1140 GEN_SES_STATUS_ARRAY_DEV_SLOT_ACCESSORS(rsvd_device,     RSVD_DEVICE)
1141 GEN_SES_STATUS_ARRAY_DEV_SLOT_ACCESSORS(hot_spare,       HOT_SPARE)
1142 GEN_SES_STATUS_ARRAY_DEV_SLOT_ACCESSORS(cons_check,      CONS_CHECK)
1143 GEN_SES_STATUS_ARRAY_DEV_SLOT_ACCESSORS(in_crit_array,   IN_CRIT_ARRAY)
1144 GEN_SES_STATUS_ARRAY_DEV_SLOT_ACCESSORS(in_failed_array, IN_FAILED_ARRAY)
1145 GEN_SES_STATUS_ARRAY_DEV_SLOT_ACCESSORS(rebuild_remap,   REBUILD_REMAP)
1146 GEN_SES_STATUS_ARRAY_DEV_SLOT_ACCESSORS(rebuild_remap_abort,
1147 					REBUILD_REMAP_ABORT)
1148 #undef GEN_SES_STATUS_ARRAY_DEV_SLOT_ACCESSORS
1149 
1150 /*----------------------- Power Supply Status Element ------------------------*/
1151 struct ses_status_power_supply {
1152 	struct ses_status_common common;
1153 	uint8_t bytes[3];
1154 };
1155 
1156 enum ses_status_power_supply_field_data {
1157 	SES_STATUS_POWER_SUPPLY_IDENT_BYTE		= 0,
1158 	SES_STATUS_POWER_SUPPLY_IDENT_MASK		= 0x80,
1159 	SES_STATUS_POWER_SUPPLY_IDENT_SHIFT		= 7,
1160 
1161 	SES_STATUS_POWER_SUPPLY_DC_OVER_VOLTAGE_BYTE	= 1,
1162 	SES_STATUS_POWER_SUPPLY_DC_OVER_VOLTAGE_MASK	= 0x08,
1163 	SES_STATUS_POWER_SUPPLY_DC_OVER_VOLTAGE_SHIFT	= 3,
1164 
1165 	SES_STATUS_POWER_SUPPLY_DC_UNDER_VOLTAGE_BYTE	= 1,
1166 	SES_STATUS_POWER_SUPPLY_DC_UNDER_VOLTAGE_MASK	= 0x04,
1167 	SES_STATUS_POWER_SUPPLY_DC_UNDER_VOLTAGE_SHIFT	= 2,
1168 
1169 	SES_STATUS_POWER_SUPPLY_DC_OVER_CURRENT_BYTE	= 1,
1170 	SES_STATUS_POWER_SUPPLY_DC_OVER_CURRENT_MASK	= 0x02,
1171 	SES_STATUS_POWER_SUPPLY_DC_OVER_CURRENT_SHIFT	= 1,
1172 
1173 	SES_STATUS_POWER_SUPPLY_HOT_SWAP_BYTE		= 2,
1174 	SES_STATUS_POWER_SUPPLY_HOT_SWAP_MASK		= 0x80,
1175 	SES_STATUS_POWER_SUPPLY_HOT_SWAP_SHIFT		= 7,
1176 
1177 	SES_STATUS_POWER_SUPPLY_FAIL_BYTE		= 2,
1178 	SES_STATUS_POWER_SUPPLY_FAIL_MASK		= 0x40,
1179 	SES_STATUS_POWER_SUPPLY_FAIL_SHIFT		= 6,
1180 
1181 	SES_STATUS_POWER_SUPPLY_REQUESTED_ON_BYTE	= 2,
1182 	SES_STATUS_POWER_SUPPLY_REQUESTED_ON_MASK	= 0x20,
1183 	SES_STATUS_POWER_SUPPLY_REQUESTED_ON_SHIFT	= 5,
1184 
1185 	SES_STATUS_POWER_SUPPLY_OFF_BYTE		= 2,
1186 	SES_STATUS_POWER_SUPPLY_OFF_MASK		= 0x10,
1187 	SES_STATUS_POWER_SUPPLY_OFF_SHIFT		= 4,
1188 
1189 	SES_STATUS_POWER_SUPPLY_OVERTMP_FAIL_BYTE	= 2,
1190 	SES_STATUS_POWER_SUPPLY_OVERTMP_FAIL_MASK	= 0x08,
1191 	SES_STATUS_POWER_SUPPLY_OVERTMP_FAIL_SHIFT	= 3,
1192 
1193 	SES_STATUS_POWER_SUPPLY_TEMP_WARN_BYTE		= 2,
1194 	SES_STATUS_POWER_SUPPLY_TEMP_WARN_MASK		= 0x04,
1195 	SES_STATUS_POWER_SUPPLY_TEMP_WARN_SHIFT		= 2,
1196 
1197 	SES_STATUS_POWER_SUPPLY_AC_FAIL_BYTE		= 2,
1198 	SES_STATUS_POWER_SUPPLY_AC_FAIL_MASK		= 0x02,
1199 	SES_STATUS_POWER_SUPPLY_AC_FAIL_SHIFT		= 1,
1200 
1201 	SES_STATUS_POWER_SUPPLY_DC_FAIL_BYTE		= 2,
1202 	SES_STATUS_POWER_SUPPLY_DC_FAIL_MASK		= 0x01,
1203 	SES_STATUS_POWER_SUPPLY_DC_FAIL_SHIFT		= 0
1204 };
1205 
1206 #define GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(LCASE, UCASE)	\
1207     GEN_GETTER(ses_status_power_supply, SES_STATUS_POWER_SUPPLY, LCASE, UCASE)
1208 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(ident,            IDENT)
1209 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(dc_over_voltage,  DC_OVER_VOLTAGE)
1210 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(dc_under_voltage, DC_UNDER_VOLTAGE)
1211 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(dc_over_current,  DC_OVER_CURRENT)
1212 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(hot_swap,         HOT_SWAP)
1213 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(fail,             FAIL)
1214 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(requested_on,     REQUESTED_ON)
1215 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(off,              OFF)
1216 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(overtmp_fail,     OVERTMP_FAIL)
1217 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(temp_warn,        TEMP_WARN)
1218 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(ac_fail,          AC_FAIL)
1219 GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS(dc_fail,          DC_FAIL)
1220 #undef GEN_SES_STATUS_POWER_SUPPLY_ACCESSORS
1221 
1222 /*-------------------------- Cooling Status Element --------------------------*/
1223 struct ses_status_cooling {
1224 	struct ses_status_common common;
1225 	uint8_t bytes[3];
1226 };
1227 
1228 enum ses_status_cooling_field_data {
1229 	SES_STATUS_COOLING_IDENT_BYTE			= 0,
1230 	SES_STATUS_COOLING_IDENT_MASK			= 0x80,
1231 	SES_STATUS_COOLING_IDENT_SHIFT			= 7,
1232 
1233 	SES_STATUS_COOLING_ACTUAL_FAN_SPEED_MSB_BYTE	= 0,
1234 	SES_STATUS_COOLING_ACTUAL_FAN_SPEED_MSB_MASK	= 0x07,
1235 	SES_STATUS_COOLING_ACTUAL_FAN_SPEED_MSB_SHIFT	= 0,
1236 
1237 	SES_STATUS_COOLING_ACTUAL_FAN_SPEED_LSB_BYTE	= 1,
1238 	SES_STATUS_COOLING_ACTUAL_FAN_SPEED_LSB_MASK	= 0xFF,
1239 	SES_STATUS_COOLING_ACTUAL_FAN_SPEED_LSB_SHIFT	= 0,
1240 
1241 	SES_STATUS_COOLING_HOT_SWAP_BYTE		= 2,
1242 	SES_STATUS_COOLING_HOT_SWAP_MASK		= 0x40,
1243 	SES_STATUS_COOLING_HOT_SWAP_SHIFT		= 6,
1244 
1245 	SES_STATUS_COOLING_FAIL_BYTE			= 2,
1246 	SES_STATUS_COOLING_FAIL_MASK			= 0x40,
1247 	SES_STATUS_COOLING_FAIL_SHIFT			= 6,
1248 
1249 	SES_STATUS_COOLING_REQUESTED_ON_BYTE		= 2,
1250 	SES_STATUS_COOLING_REQUESTED_ON_MASK		= 0x20,
1251 	SES_STATUS_COOLING_REQUESTED_ON_SHIFT		= 5,
1252 
1253 	SES_STATUS_COOLING_OFF_BYTE			= 2,
1254 	SES_STATUS_COOLING_OFF_MASK			= 0x20,
1255 	SES_STATUS_COOLING_OFF_SHIFT			= 5,
1256 
1257 	SES_STATUS_COOLING_ACTUAL_SPEED_CODE_BYTE	= 2,
1258 	SES_STATUS_COOLING_ACTUAL_SPEED_CODE_MASK	= 0x07,
1259 	SES_STATUS_COOLING_ACTUAL_SPEED_CODE_SHIFT	= 2,
1260 	SES_STATUS_COOLING_ACTUAL_SPEED_CODE_STOPPED	= 0x00,
1261 	SES_STATUS_COOLING_ACTUAL_SPEED_CODE_LOWEST	= 0x01,
1262 	SES_STATUS_COOLING_ACTUAL_SPEED_CODE_HIGHEST	= 0x07
1263 };
1264 
1265 #define GEN_SES_STATUS_COOLING_ACCESSORS(LCASE, UCASE)	\
1266     GEN_GETTER(ses_status_cooling, SES_STATUS_COOLING, LCASE, UCASE)
1267 GEN_SES_STATUS_COOLING_ACCESSORS(ident,                IDENT)
1268 GEN_SES_STATUS_COOLING_ACCESSORS(actual_fan_speed_msb, ACTUAL_FAN_SPEED_MSB)
1269 GEN_SES_STATUS_COOLING_ACCESSORS(actual_fan_speed_lsb, ACTUAL_FAN_SPEED_LSB)
1270 GEN_SES_STATUS_COOLING_ACCESSORS(hot_swap,             HOT_SWAP)
1271 GEN_SES_STATUS_COOLING_ACCESSORS(fail,                 FAIL)
1272 GEN_SES_STATUS_COOLING_ACCESSORS(requested_on,         REQUESTED_ON)
1273 GEN_SES_STATUS_COOLING_ACCESSORS(off,                  OFF)
1274 GEN_SES_STATUS_COOLING_ACCESSORS(actual_speed_code,    ACTUAL_SPEED_CODE)
1275 #undef GEN_SES_STATUS_COOLING_ACCESSORS
1276 
1277 static inline int
1278 ses_status_cooling_get_actual_fan_speed(struct ses_status_cooling *elem)
1279 {
1280 	return (ses_status_cooling_get_actual_fan_speed_msb(elem) << 8
1281 	      | ses_status_cooling_get_actual_fan_speed_lsb(elem));
1282 }
1283 
1284 /*-------------------- Temperature Sensor Status Element ---------------------*/
1285 struct ses_status_temp_sensor {
1286 	struct ses_status_common common;
1287 	uint8_t bytes[3];
1288 };
1289 
1290 enum ses_status_temp_sensor_field_data {
1291 	SES_STATUS_TEMP_SENSOR_IDENT_BYTE		= 0,
1292 	SES_STATUS_TEMP_SENSOR_IDENT_MASK		= 0x80,
1293 	SES_STATUS_TEMP_SENSOR_IDENT_SHIFT		= 7,
1294 
1295 	SES_STATUS_TEMP_SENSOR_FAIL_BYTE		= 0,
1296 	SES_STATUS_TEMP_SENSOR_FAIL_MASK		= 0x40,
1297 	SES_STATUS_TEMP_SENSOR_FAIL_SHIFT		= 6,
1298 
1299 	SES_STATUS_TEMP_SENSOR_TEMPERATURE_BYTE		= 1,
1300 	SES_STATUS_TEMP_SENSOR_TEMPERATURE_MASK		= 0xFF,
1301 	SES_STATUS_TEMP_SENSOR_TEMPERATURE_SHIFT	= 0,
1302 
1303 	SES_STATUS_TEMP_SENSOR_OT_FAILURE_BYTE		= 2,
1304 	SES_STATUS_TEMP_SENSOR_OT_FAILURE_MASK		= 0x08,
1305 	SES_STATUS_TEMP_SENSOR_OT_FAILURE_SHIFT		= 3,
1306 
1307 	SES_STATUS_TEMP_SENSOR_OT_WARNING_BYTE		= 2,
1308 	SES_STATUS_TEMP_SENSOR_OT_WARNING_MASK		= 0x04,
1309 	SES_STATUS_TEMP_SENSOR_OT_WARNING_SHIFT		= 2,
1310 
1311 	SES_STATUS_TEMP_SENSOR_UT_FAILURE_BYTE		= 2,
1312 	SES_STATUS_TEMP_SENSOR_UT_FAILURE_MASK		= 0x02,
1313 	SES_STATUS_TEMP_SENSOR_UT_FAILURE_SHIFT		= 1,
1314 
1315 	SES_STATUS_TEMP_SENSOR_UT_WARNING_BYTE		= 2,
1316 	SES_STATUS_TEMP_SENSOR_UT_WARNING_MASK		= 0x01,
1317 	SES_STATUS_TEMP_SENSOR_UT_WARNING_SHIFT		= 0
1318 };
1319 
1320 #define GEN_SES_STATUS_TEMP_SENSOR_ACCESSORS(LCASE, UCASE)	\
1321     GEN_GETTER(ses_status_temp_sensor, SES_STATUS_TEMP_SENSOR, LCASE, UCASE)
1322 GEN_SES_STATUS_TEMP_SENSOR_ACCESSORS(ident,       IDENT)
1323 GEN_SES_STATUS_TEMP_SENSOR_ACCESSORS(fail,        FAIL)
1324 GEN_SES_STATUS_TEMP_SENSOR_ACCESSORS(temperature, TEMPERATURE)
1325 GEN_SES_STATUS_TEMP_SENSOR_ACCESSORS(ot_failure,  OT_FAILURE)
1326 GEN_SES_STATUS_TEMP_SENSOR_ACCESSORS(ot_warning,  OT_WARNING)
1327 GEN_SES_STATUS_TEMP_SENSOR_ACCESSORS(ut_failure,  UT_FAILURE)
1328 GEN_SES_STATUS_TEMP_SENSOR_ACCESSORS(ut_warning,  UT_WARNING)
1329 #undef GEN_SES_STATUS_TEMP_SENSOR_ACCESSORS
1330 
1331 /*------------------------- Door Lock Status Element -------------------------*/
1332 struct ses_status_door_lock {
1333 	struct ses_status_common common;
1334 	uint8_t bytes[3];
1335 };
1336 
1337 enum ses_status_door_lock_field_data {
1338 	SES_STATUS_DOOR_LOCK_IDENT_BYTE		= 0,
1339 	SES_STATUS_DOOR_LOCK_IDENT_MASK		= 0x80,
1340 	SES_STATUS_DOOR_LOCK_IDENT_SHIFT	= 7,
1341 
1342 	SES_STATUS_DOOR_LOCK_FAIL_BYTE		= 0,
1343 	SES_STATUS_DOOR_LOCK_FAIL_MASK		= 0x40,
1344 	SES_STATUS_DOOR_LOCK_FAIL_SHIFT		= 6,
1345 
1346 	SES_STATUS_DOOR_LOCK_UNLOCKED_BYTE	= 2,
1347 	SES_STATUS_DOOR_LOCK_UNLOCKED_MASK	= 0x01,
1348 	SES_STATUS_DOOR_LOCK_UNLOCKED_SHIFT	= 0
1349 };
1350 
1351 #define GEN_SES_STATUS_DOOR_LOCK_ACCESSORS(LCASE, UCASE)	\
1352     GEN_GETTER(ses_status_door_lock, SES_STATUS_DOOR_LOCK, LCASE, UCASE)
1353 GEN_SES_STATUS_DOOR_LOCK_ACCESSORS(ident,    IDENT)
1354 GEN_SES_STATUS_DOOR_LOCK_ACCESSORS(fail,     FAIL)
1355 GEN_SES_STATUS_DOOR_LOCK_ACCESSORS(unlocked, UNLOCKED)
1356 #undef GEN_SES_STATUS_DOOR_LOCK_ACCESSORS
1357 
1358 /*----------------------- Audible Alarm Status Element -----------------------*/
1359 struct ses_status_audible_alarm {
1360 	struct ses_status_common common;
1361 	uint8_t bytes[3];
1362 };
1363 
1364 enum ses_status_audible_alarm_field_data {
1365 	SES_STATUS_AUDIBLE_ALARM_IDENT_BYTE			= 0,
1366 	SES_STATUS_AUDIBLE_ALARM_IDENT_MASK			= 0x80,
1367 	SES_STATUS_AUDIBLE_ALARM_IDENT_SHIFT			= 7,
1368 
1369 	SES_STATUS_AUDIBLE_ALARM_FAIL_BYTE			= 0,
1370 	SES_STATUS_AUDIBLE_ALARM_FAIL_MASK			= 0x40,
1371 	SES_STATUS_AUDIBLE_ALARM_FAIL_SHIFT			= 6,
1372 
1373 	SES_STATUS_AUDIBLE_ALARM_RQST_MUTE_BYTE			= 2,
1374 	SES_STATUS_AUDIBLE_ALARM_RQST_MUTE_MASK			= 0x80,
1375 	SES_STATUS_AUDIBLE_ALARM_RQST_MUTE_SHIFT		= 7,
1376 
1377 	SES_STATUS_AUDIBLE_ALARM_MUTED_BYTE			= 2,
1378 	SES_STATUS_AUDIBLE_ALARM_MUTED_MASK			= 0x40,
1379 	SES_STATUS_AUDIBLE_ALARM_MUTED_SHIFT			= 6,
1380 
1381 	SES_STATUS_AUDIBLE_ALARM_REMIND_BYTE			= 2,
1382 	SES_STATUS_AUDIBLE_ALARM_REMIND_MASK			= 0x10,
1383 	SES_STATUS_AUDIBLE_ALARM_REMIND_SHIFT			= 4,
1384 
1385 	SES_STATUS_AUDIBLE_ALARM_TONE_INDICATOR_BYTE		= 2,
1386 	SES_STATUS_AUDIBLE_ALARM_TONE_INDICATOR_MASK		= 0x0F,
1387 	SES_STATUS_AUDIBLE_ALARM_TONE_INDICATOR_SHIFT		= 0,
1388 	SES_STATUS_AUDIBLE_ALARM_TONE_INDICATOR_INFO		= 0x08,
1389 	SES_STATUS_AUDIBLE_ALARM_TONE_INDICATOR_NON_CRIT	= 0x04,
1390 	SES_STATUS_AUDIBLE_ALARM_TONE_INDICATOR_CRIT		= 0x02,
1391 	SES_STATUS_AUDIBLE_ALARM_TONE_INDICATOR_UNRECOV		= 0x01
1392 };
1393 
1394 #define GEN_SES_STATUS_AUDIBLE_ALARM_ACCESSORS(LCASE, UCASE)	\
1395     GEN_GETTER(ses_status_audible_alarm, SES_STATUS_AUDIBLE_ALARM, LCASE, UCASE)
1396 GEN_SES_STATUS_AUDIBLE_ALARM_ACCESSORS(ident,          IDENT)
1397 GEN_SES_STATUS_AUDIBLE_ALARM_ACCESSORS(fail,           FAIL)
1398 GEN_SES_STATUS_AUDIBLE_ALARM_ACCESSORS(rqst_mute,      RQST_MUTE)
1399 GEN_SES_STATUS_AUDIBLE_ALARM_ACCESSORS(muted,          MUTED)
1400 GEN_SES_STATUS_AUDIBLE_ALARM_ACCESSORS(remind,         REMIND)
1401 GEN_SES_STATUS_AUDIBLE_ALARM_ACCESSORS(tone_indicator, TONE_INDICATOR)
1402 #undef GEN_SES_STATUS_AUDIBLE_ALARM_ACCESSORS
1403 
1404 /*---------- Enclosure Services Statusler Electronics Status Element ---------*/
1405 struct ses_status_ecc_electronics {
1406 	struct ses_status_common common;
1407 	uint8_t bytes[3];
1408 };
1409 
1410 enum ses_status_ecc_electronics_field_data {
1411 	SES_STATUS_ECC_ELECTRONICS_IDENT_BYTE		= 0,
1412 	SES_STATUS_ECC_ELECTRONICS_IDENT_MASK		= 0x80,
1413 	SES_STATUS_ECC_ELECTRONICS_IDENT_SHIFT		= 7,
1414 
1415 	SES_STATUS_ECC_ELECTRONICS_FAIL_BYTE		= 0,
1416 	SES_STATUS_ECC_ELECTRONICS_FAIL_MASK		= 0x40,
1417 	SES_STATUS_ECC_ELECTRONICS_FAIL_SHIFT		= 6,
1418 
1419 	SES_STATUS_ECC_ELECTRONICS_REPORT_BYTE		= 1,
1420 	SES_STATUS_ECC_ELECTRONICS_REPORT_MASK		= 0x01,
1421 	SES_STATUS_ECC_ELECTRONICS_REPORT_SHIFT		= 0,
1422 
1423 	SES_STATUS_ECC_ELECTRONICS_HOT_SWAP_BYTE	= 2,
1424 	SES_STATUS_ECC_ELECTRONICS_HOT_SWAP_MASK	= 0x80,
1425 	SES_STATUS_ECC_ELECTRONICS_HOT_SWAP_SHIFT	= 7
1426 };
1427 
1428 #define GEN_SES_STATUS_ECC_ELECTRONICS_ACCESSORS(LCASE, UCASE)		\
1429     GEN_GETTER(ses_status_ecc_electronics, SES_STATUS_ECC_ELECTRONICS,	\
1430 		  LCASE, UCASE)
1431 GEN_SES_STATUS_ECC_ELECTRONICS_ACCESSORS(ident,     IDENT)
1432 GEN_SES_STATUS_ECC_ELECTRONICS_ACCESSORS(fail,      FAIL)
1433 GEN_SES_STATUS_ECC_ELECTRONICS_ACCESSORS(report,    REPORT)
1434 GEN_SES_STATUS_ECC_ELECTRONICS_ACCESSORS(hot_swap,  HOT_SWAP)
1435 #undef GEN_SES_STATUS_ECC_ELECTRONICS_ACCESSORS
1436 
1437 /*------------ SCSI Services Statusler Electronics Status Element ------------*/
1438 struct ses_status_scc_electronics {
1439 	struct ses_status_common common;
1440 	uint8_t bytes[3];
1441 };
1442 
1443 enum ses_status_scc_electronics_field_data {
1444 	SES_STATUS_SCC_ELECTRONICS_IDENT_BYTE	= 0,
1445 	SES_STATUS_SCC_ELECTRONICS_IDENT_MASK	= 0x80,
1446 	SES_STATUS_SCC_ELECTRONICS_IDENT_SHIFT	= 7,
1447 
1448 	SES_STATUS_SCC_ELECTRONICS_FAIL_BYTE	= 0,
1449 	SES_STATUS_SCC_ELECTRONICS_FAIL_MASK	= 0x40,
1450 	SES_STATUS_SCC_ELECTRONICS_FAIL_SHIFT	= 6,
1451 
1452 	SES_STATUS_SCC_ELECTRONICS_REPORT_BYTE	= 1,
1453 	SES_STATUS_SCC_ELECTRONICS_REPORT_MASK	= 0x01,
1454 	SES_STATUS_SCC_ELECTRONICS_REPORT_SHIFT	= 0
1455 };
1456 
1457 #define GEN_SES_STATUS_SCC_ELECTRONICS_ACCESSORS(LCASE, UCASE)		\
1458     GEN_GETTER(ses_status_scc_electronics, SES_STATUS_SCC_ELECTRONICS,	\
1459 		  LCASE, UCASE)
1460 GEN_SES_STATUS_SCC_ELECTRONICS_ACCESSORS(ident,     IDENT)
1461 GEN_SES_STATUS_SCC_ELECTRONICS_ACCESSORS(fail,      FAIL)
1462 GEN_SES_STATUS_SCC_ELECTRONICS_ACCESSORS(report,    REPORT)
1463 #undef GEN_SES_STATUS_SCC_ELECTRONICS_ACCESSORS
1464 
1465 /*--------------------- Nonvolatile Cache Status Element ---------------------*/
1466 struct ses_status_nv_cache {
1467 	struct ses_status_common common;
1468 	uint8_t bytes[1];
1469 	uint8_t cache_size[2];
1470 };
1471 
1472 enum ses_status_nv_cache_field_data {
1473 	SES_STATUS_NV_CACHE_IDENT_BYTE			= 0,
1474 	SES_STATUS_NV_CACHE_IDENT_MASK			= 0x80,
1475 	SES_STATUS_NV_CACHE_IDENT_SHIFT			= 7,
1476 
1477 	SES_STATUS_NV_CACHE_FAIL_BYTE			= 0,
1478 	SES_STATUS_NV_CACHE_FAIL_MASK			= 0x40,
1479 	SES_STATUS_NV_CACHE_FAIL_SHIFT			= 6,
1480 
1481 	SES_STATUS_NV_CACHE_SIZE_MULTIPLIER_BYTE	= 0,
1482 	SES_STATUS_NV_CACHE_SIZE_MULTIPLIER_MASK	= 0x03,
1483 	SES_STATUS_NV_CACHE_SIZE_MULTIPLIER_SHIFT	= 0,
1484 	SES_STATUS_NV_CACHE_SIZE_MULTIPLIER_BYTES	= 0x0,
1485 	SES_STATUS_NV_CACHE_SIZE_MULTIPLIER_KBYTES	= 0x1,
1486 	SES_STATUS_NV_CACHE_SIZE_MULTIPLIER_MBYTES	= 0x2,
1487 	SES_STATUS_NV_CACHE_SIZE_MULTIPLIER_GBYTES	= 0x3
1488 };
1489 
1490 #define GEN_SES_STATUS_NV_CACHE_ACCESSORS(LCASE, UCASE)		\
1491     GEN_GETTER(ses_status_nv_cache, SES_STATUS_NV_CACHE, LCASE, UCASE)
1492 GEN_SES_STATUS_NV_CACHE_ACCESSORS(ident,           IDENT)
1493 GEN_SES_STATUS_NV_CACHE_ACCESSORS(fail,            FAIL)
1494 GEN_SES_STATUS_NV_CACHE_ACCESSORS(size_multiplier, SIZE_MULTIPLIER)
1495 #undef GEN_SES_STATUS_NV_CACHE_ACCESSORS
1496 
1497 static inline uintmax_t
1498 ses_status_nv_cache_get_cache_size(struct ses_status_nv_cache *elem)
1499 {
1500 	uintmax_t cache_size;
1501 	int multiplier;
1502 
1503 	/* Multiplier is in units of 2^10 */
1504 	cache_size = scsi_2btoul(elem->cache_size);
1505 	multiplier = 10 * ses_status_nv_cache_get_size_multiplier(elem);
1506 	return (cache_size << multiplier);
1507 }
1508 
1509 /*----------------- Invalid Operation Reason Status Element ------------------*/
1510 struct ses_status_invalid_op_reason {
1511 	struct ses_status_common common;
1512 	uint8_t bytes[3];
1513 };
1514 
1515 enum ses_status_invalid_op_field_data {
1516 	SES_STATUS_INVALID_OP_REASON_TYPE_BYTE				= 0,
1517 	SES_STATUS_INVALID_OP_REASON_TYPE_MASK				= 0xC0,
1518 	SES_STATUS_INVALID_OP_REASON_TYPE_SHIFT				= 6,
1519 	SES_STATUS_INVALID_OP_REASON_TYPE_PC_ERROR			= 0x00,
1520 	SES_STATUS_INVALID_OP_REASON_TYPE_PF_ERROR			= 0x01,
1521 	SES_STATUS_INVALID_OP_REASON_TYPE_VS_ERROR			= 0x03,
1522 
1523 	SES_STATUS_INVALID_OP_REASON_PC_ERROR_PC_NOT_SUPPORTED_BYTE	= 0,
1524 	SES_STATUS_INVALID_OP_REASON_PC_ERROR_PC_NOT_SUPPORTED_MASK	= 0x01,
1525 	SES_STATUS_INVALID_OP_REASON_PC_ERROR_PC_NOT_SUPPORTED_SHIFT	= 0,
1526 
1527 	SES_STATUS_INVALID_OP_REASON_PF_ERROR_BIT_NUMBER_BYTE		= 0,
1528 	SES_STATUS_INVALID_OP_REASON_PF_ERROR_BIT_NUMBER_MASK		= 0x03,
1529 	SES_STATUS_INVALID_OP_REASON_PF_ERROR_BIT_NUMBER_SHIFT		= 0
1530 };
1531 
1532 #define GEN_SES_STATUS_INVALID_OP_REASON_ACCESSORS(LCASE, UCASE)	   \
1533     GEN_GETTER(ses_status_invalid_op_reason, SES_STATUS_INVALID_OP_REASON, \
1534 	       LCASE, UCASE)
1535 GEN_SES_STATUS_INVALID_OP_REASON_ACCESSORS(type, TYPE)
1536 GEN_SES_STATUS_INVALID_OP_REASON_ACCESSORS(pc_error_pc_not_supported,
1537 					   PC_ERROR_PC_NOT_SUPPORTED)
1538 GEN_SES_STATUS_INVALID_OP_REASON_ACCESSORS(pf_error_bit_number,
1539 					   PF_ERROR_BIT_NUMBER)
1540 #undef GEN_SES_STATUS_INVALID_OP_ACCESSORS
1541 
1542 /*--------------- Uninterruptible Power Supply Status Element ----------------*/
1543 struct ses_status_ups {
1544 	struct ses_status_common common;
1545 	/* Minutes of remaining capacity. */
1546 	uint8_t battery_status;
1547 	uint8_t bytes[2];
1548 };
1549 
1550 enum ses_status_ups_field_data {
1551 	SES_STATUS_UPS_AC_LO_BYTE	= 0,
1552 	SES_STATUS_UPS_AC_LO_MASK	= 0x80,
1553 	SES_STATUS_UPS_AC_LO_SHIFT	= 7,
1554 
1555 	SES_STATUS_UPS_AC_HI_BYTE	= 0,
1556 	SES_STATUS_UPS_AC_HI_MASK	= 0x40,
1557 	SES_STATUS_UPS_AC_HI_SHIFT	= 6,
1558 
1559 	SES_STATUS_UPS_AC_QUAL_BYTE	= 0,
1560 	SES_STATUS_UPS_AC_QUAL_MASK	= 0x20,
1561 	SES_STATUS_UPS_AC_QUAL_SHIFT	= 5,
1562 
1563 	SES_STATUS_UPS_AC_FAIL_BYTE	= 0,
1564 	SES_STATUS_UPS_AC_FAIL_MASK	= 0x10,
1565 	SES_STATUS_UPS_AC_FAIL_SHIFT	= 4,
1566 
1567 	SES_STATUS_UPS_DC_FAIL_BYTE	= 0,
1568 	SES_STATUS_UPS_DC_FAIL_MASK	= 0x08,
1569 	SES_STATUS_UPS_DC_FAIL_SHIFT	= 3,
1570 
1571 	SES_STATUS_UPS_UPS_FAIL_BYTE	= 0,
1572 	SES_STATUS_UPS_UPS_FAIL_MASK	= 0x04,
1573 	SES_STATUS_UPS_UPS_FAIL_SHIFT	= 2,
1574 
1575 	SES_STATUS_UPS_WARN_BYTE	= 0,
1576 	SES_STATUS_UPS_WARN_MASK	= 0x02,
1577 	SES_STATUS_UPS_WARN_SHIFT	= 1,
1578 
1579 	SES_STATUS_UPS_INTF_FAIL_BYTE	= 0,
1580 	SES_STATUS_UPS_INTF_FAIL_MASK	= 0x01,
1581 	SES_STATUS_UPS_INTF_FAIL_SHIFT	= 0,
1582 
1583 	SES_STATUS_UPS_IDENT_BYTE	= 0,
1584 	SES_STATUS_UPS_IDENT_MASK	= 0x80,
1585 	SES_STATUS_UPS_IDENT_SHIFT	= 7,
1586 
1587 	SES_STATUS_UPS_FAIL_BYTE	= 1,
1588 	SES_STATUS_UPS_FAIL_MASK	= 0x40,
1589 	SES_STATUS_UPS_FAIL_SHIFT	= 6,
1590 
1591 	SES_STATUS_UPS_BATT_FAIL_BYTE	= 1,
1592 	SES_STATUS_UPS_BATT_FAIL_MASK	= 0x02,
1593 	SES_STATUS_UPS_BATT_FAIL_SHIFT	= 1,
1594 
1595 	SES_STATUS_UPS_BPF_BYTE		= 1,
1596 	SES_STATUS_UPS_BPF_MASK		= 0x01,
1597 	SES_STATUS_UPS_BPF_SHIFT	= 0
1598 };
1599 
1600 #define GEN_SES_STATUS_UPS_ACCESSORS(LCASE, UCASE)	\
1601     GEN_GETTER(ses_status_ups, SES_STATUS_UPS, LCASE, UCASE)
1602 GEN_SES_STATUS_UPS_ACCESSORS(ac_lo,           AC_LO)
1603 GEN_SES_STATUS_UPS_ACCESSORS(ac_hi,            AC_HI)
1604 GEN_SES_STATUS_UPS_ACCESSORS(ac_qual,          AC_QUAL)
1605 GEN_SES_STATUS_UPS_ACCESSORS(ac_fail,          AC_FAIL)
1606 GEN_SES_STATUS_UPS_ACCESSORS(dc_fail,          DC_FAIL)
1607 GEN_SES_STATUS_UPS_ACCESSORS(ups_fail,         UPS_FAIL)
1608 GEN_SES_STATUS_UPS_ACCESSORS(warn,             WARN)
1609 GEN_SES_STATUS_UPS_ACCESSORS(intf_fail,        INTF_FAIL)
1610 GEN_SES_STATUS_UPS_ACCESSORS(ident,            IDENT)
1611 GEN_SES_STATUS_UPS_ACCESSORS(fail,             FAIL)
1612 GEN_SES_STATUS_UPS_ACCESSORS(batt_fail,        BATT_FAIL)
1613 GEN_SES_STATUS_UPS_ACCESSORS(bpf,              BPF)
1614 #undef GEN_SES_STATUS_UPS_ACCESSORS
1615 
1616 /*-------------------------- Display Status Element --------------------------*/
1617 struct ses_status_display {
1618 	struct ses_status_common common;
1619 	uint8_t bytes[1];
1620 	uint8_t display_character[2];
1621 };
1622 
1623 enum ses_status_display_field_data {
1624 	SES_STATUS_DISPLAY_IDENT_BYTE			= 0,
1625 	SES_STATUS_DISPLAY_IDENT_MASK			= 0x80,
1626 	SES_STATUS_DISPLAY_IDENT_SHIFT			= 7,
1627 
1628 	SES_STATUS_DISPLAY_FAIL_BYTE			= 0,
1629 	SES_STATUS_DISPLAY_FAIL_MASK			= 0x40,
1630 	SES_STATUS_DISPLAY_FAIL_SHIFT			= 6,
1631 
1632 	SES_STATUS_DISPLAY_DISPLAY_MODE_BYTE		= 0,
1633 	SES_STATUS_DISPLAY_DISPLAY_MODE_MASK		= 0x03,
1634 	SES_STATUS_DISPLAY_DISPLAY_MODE_SHIFT		= 6,
1635 	SES_STATUS_DISPLAY_DISPLAY_MODE_DC_FIELD_UNSUPP	= 0x0,
1636 	SES_STATUS_DISPLAY_DISPLAY_MODE_DC_FIELD_SUPP	= 0x1,
1637 	SES_STATUS_DISPLAY_DISPLAY_MODE_DC_FIELD	= 0x2
1638 };
1639 
1640 #define GEN_SES_STATUS_DISPLAY_ACCESSORS(LCASE, UCASE)	\
1641     GEN_GETTER(ses_status_display, SES_STATUS_DISPLAY, LCASE, UCASE)
1642 GEN_SES_STATUS_DISPLAY_ACCESSORS(ident,        IDENT)
1643 GEN_SES_STATUS_DISPLAY_ACCESSORS(fail,         FAIL)
1644 GEN_SES_STATUS_DISPLAY_ACCESSORS(display_mode, DISPLAY_MODE)
1645 #undef GEN_SES_STATUS_DISPLAY_ACCESSORS
1646 
1647 /*----------------------- Key Pad Entry Status Element -----------------------*/
1648 struct ses_status_key_pad_entry {
1649 	struct ses_status_common common;
1650 	uint8_t bytes[3];
1651 };
1652 
1653 enum ses_status_key_pad_entry_field_data {
1654 	SES_STATUS_KEY_PAD_ENTRY_IDENT_BYTE	= 0,
1655 	SES_STATUS_KEY_PAD_ENTRY_IDENT_MASK	= 0x80,
1656 	SES_STATUS_KEY_PAD_ENTRY_IDENT_SHIFT	= 7,
1657 
1658 	SES_STATUS_KEY_PAD_ENTRY_FAIL_BYTE	= 0,
1659 	SES_STATUS_KEY_PAD_ENTRY_FAIL_MASK	= 0x40,
1660 	SES_STATUS_KEY_PAD_ENTRY_FAIL_SHIFT	= 6
1661 };
1662 
1663 #define GEN_SES_STATUS_KEY_PAD_ENTRY_ACCESSORS(LCASE, UCASE)	\
1664     GEN_GETTER(ses_status_key_pad_entry, SES_STATUS_KEY_PAD_ENTRY, LCASE, UCASE)
1665 GEN_SES_STATUS_KEY_PAD_ENTRY_ACCESSORS(ident, IDENT)
1666 GEN_SES_STATUS_KEY_PAD_ENTRY_ACCESSORS(fail,  FAIL)
1667 #undef GEN_SES_STATUS_KEY_PAD_ENTRY_ACCESSORS
1668 
1669 /*------------------------- Enclosure Status Element -------------------------*/
1670 struct ses_status_enclosure {
1671 	struct ses_status_common common;
1672 	uint8_t bytes[3];
1673 };
1674 
1675 enum ses_status_enclosure_field_data {
1676 	SES_STATUS_ENCLOSURE_IDENT_BYTE					= 0,
1677 	SES_STATUS_ENCLOSURE_IDENT_MASK					= 0x80,
1678 	SES_STATUS_ENCLOSURE_IDENT_SHIFT				= 7,
1679 
1680 	SES_STATUS_ENCLOSURE_TIME_UNTIL_POWER_CYCLE_BYTE		= 1,
1681 	SES_STATUS_ENCLOSURE_TIME_UNTIL_POWER_CYCLE_MASK		= 0xFC,
1682 	SES_STATUS_ENCLOSURE_TIME_UNTIL_POWER_CYCLE_SHIFT		= 2,
1683 
1684 	SES_STATUS_ENCLOSURE_FAIL_BYTE					= 1,
1685 	SES_STATUS_ENCLOSURE_FAIL_MASK					= 0x02,
1686 	SES_STATUS_ENCLOSURE_FAIL_SHIFT					= 1,
1687 
1688 	SES_STATUS_ENCLOSURE_WARN_BYTE					= 1,
1689 	SES_STATUS_ENCLOSURE_WARN_MASK					= 0x01,
1690 	SES_STATUS_ENCLOSURE_WARN_SHIFT					= 0,
1691 
1692 	SES_STATUS_ENCLOSURE_REQUESTED_POWER_OFF_DURATION_BYTE		= 2,
1693 	SES_STATUS_ENCLOSURE_REQUESTED_POWER_OFF_DURATION_MASK		= 0xFC,
1694 	SES_STATUS_ENCLOSURE_REQUESTED_POWER_OFF_DURATION_SHIFT		= 2,
1695 	SES_STATUS_ENCLOSURE_REQUESTED_POWER_OFF_DURATION_MAX_AUTO	= 60,
1696 	SES_STATUS_ENCLOSURE_REQUESTED_POWER_OFF_DURATION_MANUAL	= 63,
1697 
1698 	SES_STATUS_ENCLOSURE_REQUESTED_FAIL_BYTE			= 2,
1699 	SES_STATUS_ENCLOSURE_REQUESTED_FAIL_MASK			= 0x02,
1700 	SES_STATUS_ENCLOSURE_REQUESTED_FAIL_SHIFT			= 1,
1701 
1702 	SES_STATUS_ENCLOSURE_REQUESTED_WARN_BYTE			= 2,
1703 	SES_STATUS_ENCLOSURE_REQUESTED_WARN_MASK			= 0x01,
1704 	SES_STATUS_ENCLOSURE_REQUESTED_WARN_SHIFT			= 0
1705 };
1706 
1707 #define GEN_SES_STATUS_ENCLOSURE_ACCESSORS(LCASE, UCASE)		\
1708     GEN_GETTER(ses_status_enclosure, SES_STATUS_ENCLOSURE, LCASE, UCASE)
1709 GEN_SES_STATUS_ENCLOSURE_ACCESSORS(ident,          IDENT)
1710 GEN_SES_STATUS_ENCLOSURE_ACCESSORS(time_until_power_cycle,
1711 				   TIME_UNTIL_POWER_CYCLE)
1712 GEN_SES_STATUS_ENCLOSURE_ACCESSORS(fail,           FAIL)
1713 GEN_SES_STATUS_ENCLOSURE_ACCESSORS(warn,           WARN)
1714 GEN_SES_STATUS_ENCLOSURE_ACCESSORS(requested_power_off_duration,
1715 				   REQUESTED_POWER_OFF_DURATION)
1716 GEN_SES_STATUS_ENCLOSURE_ACCESSORS(requested_fail, REQUESTED_FAIL)
1717 GEN_SES_STATUS_ENCLOSURE_ACCESSORS(requested_warn, REQUESTED_WARN)
1718 #undef GEN_SES_STATUS_ENCLOSURE_ACCESSORS
1719 
1720 /*------------------- SCSI Port/Transceiver Status Element -------------------*/
1721 struct ses_status_scsi_port_or_xcvr {
1722 	struct ses_status_common common;
1723 	uint8_t bytes[3];
1724 };
1725 
1726 enum ses_status_scsi_port_or_xcvr_field_data {
1727 	SES_STATUS_SCSI_PORT_OR_XCVR_IDENT_BYTE		= 0,
1728 	SES_STATUS_SCSI_PORT_OR_XCVR_IDENT_MASK		= 0x80,
1729 	SES_STATUS_SCSI_PORT_OR_XCVR_IDENT_SHIFT	= 7,
1730 
1731 	SES_STATUS_SCSI_PORT_OR_XCVR_FAIL_BYTE		= 0,
1732 	SES_STATUS_SCSI_PORT_OR_XCVR_FAIL_MASK		= 0x40,
1733 	SES_STATUS_SCSI_PORT_OR_XCVR_FAIL_SHIFT		= 6,
1734 
1735 	SES_STATUS_SCSI_PORT_OR_XCVR_REPORT_BYTE	= 1,
1736 	SES_STATUS_SCSI_PORT_OR_XCVR_REPORT_MASK	= 0x01,
1737 	SES_STATUS_SCSI_PORT_OR_XCVR_REPORT_SHIFT	= 0,
1738 
1739 	SES_STATUS_SCSI_PORT_OR_XCVR_DISABLED_BYTE	= 2,
1740 	SES_STATUS_SCSI_PORT_OR_XCVR_DISABLED_MASK	= 0x10,
1741 	SES_STATUS_SCSI_PORT_OR_XCVR_DISABLED_SHIFT	= 4,
1742 
1743 	SES_STATUS_SCSI_PORT_OR_XCVR_LOL_BYTE		= 2,
1744 	SES_STATUS_SCSI_PORT_OR_XCVR_LOL_MASK		= 0x02,
1745 	SES_STATUS_SCSI_PORT_OR_XCVR_LOL_SHIFT		= 1,
1746 
1747 	SES_STATUS_SCSI_PORT_OR_XCVR_XMIT_FAIL_BYTE	= 2,
1748 	SES_STATUS_SCSI_PORT_OR_XCVR_XMIT_FAIL_MASK	= 0x01,
1749 	SES_STATUS_SCSI_PORT_OR_XCVR_XMIT_FAIL_SHIFT	= 0
1750 };
1751 
1752 #define GEN_SES_STATUS_SCSI_PORT_OR_XCVR_ACCESSORS(LCASE, UCASE)	 \
1753     GEN_GETTER(ses_status_scsi_port_or_xcvr, SES_STATUS_SCSI_PORT_OR_XCVR,\
1754 	       LCASE, UCASE)
1755 GEN_SES_STATUS_SCSI_PORT_OR_XCVR_ACCESSORS(ident,     IDENT)
1756 GEN_SES_STATUS_SCSI_PORT_OR_XCVR_ACCESSORS(fail,      FAIL)
1757 GEN_SES_STATUS_SCSI_PORT_OR_XCVR_ACCESSORS(report,    REPORT)
1758 GEN_SES_STATUS_SCSI_PORT_OR_XCVR_ACCESSORS(disable,   DISABLED)
1759 GEN_SES_STATUS_SCSI_PORT_OR_XCVR_ACCESSORS(lol,       LOL)
1760 GEN_SES_STATUS_SCSI_PORT_OR_XCVR_ACCESSORS(xmit_fail, XMIT_FAIL)
1761 #undef GEN_SES_STATUS_SCSI_PORT_OR_XCVR_ACCESSORS
1762 
1763 /*------------------------- Language Status Element --------------------------*/
1764 struct ses_status_language {
1765 	struct ses_status_common common;
1766 	uint8_t bytes[1];
1767 	uint8_t language_code[2];
1768 };
1769 
1770 enum ses_status_language_field_data {
1771 	SES_STATUS_LANGUAGE_IDENT_BYTE	= 0,
1772 	SES_STATUS_LANGUAGE_IDENT_MASK	= 0x80,
1773 	SES_STATUS_LANGUAGE_IDENT_SHIFT	= 7
1774 };
1775 
1776 #define GEN_SES_STATUS_LANGUAGE_ACCESSORS(LCASE, UCASE)		 \
1777     GEN_GETTER(ses_status_language, SES_STATUS_LANGUAGE, LCASE, UCASE)
1778 GEN_SES_STATUS_LANGUAGE_ACCESSORS(ident, IDENT)
1779 #undef GEN_SES_STATUS_LANGUAGE_ACCESSORS
1780 
1781 /*-------------------- Communication Port Status Element ---------------------*/
1782 struct ses_status_comm_port {
1783 	struct ses_status_common common;
1784 	uint8_t bytes[3];
1785 };
1786 
1787 enum ses_status_comm_port_field_data {
1788 	SES_STATUS_COMM_PORT_IDENT_BYTE		= 0,
1789 	SES_STATUS_COMM_PORT_IDENT_MASK		= 0x80,
1790 	SES_STATUS_COMM_PORT_IDENT_SHIFT	= 7,
1791 
1792 	SES_STATUS_COMM_PORT_FAIL_BYTE		= 0,
1793 	SES_STATUS_COMM_PORT_FAIL_MASK		= 0x40,
1794 	SES_STATUS_COMM_PORT_FAIL_SHIFT		= 6,
1795 
1796 	SES_STATUS_COMM_PORT_DISABLED_BYTE	= 2,
1797 	SES_STATUS_COMM_PORT_DISABLED_MASK	= 0x01,
1798 	SES_STATUS_COMM_PORT_DISABLED_SHIFT	= 0
1799 };
1800 
1801 #define GEN_SES_STATUS_COMM_PORT_ACCESSORS(LCASE, UCASE)		 \
1802     GEN_GETTER(ses_status_comm_port, SES_STATUS_COMM_PORT, LCASE, UCASE)
1803 GEN_SES_STATUS_COMM_PORT_ACCESSORS(ident,    IDENT)
1804 GEN_SES_STATUS_COMM_PORT_ACCESSORS(fail,     FAIL)
1805 GEN_SES_STATUS_COMM_PORT_ACCESSORS(disabled, DISABLED)
1806 #undef GEN_SES_STATUS_COMM_PORT_ACCESSORS
1807 
1808 /*---------------------- Voltage Sensor Status Element -----------------------*/
1809 struct ses_status_voltage_sensor {
1810 	struct ses_status_common common;
1811 	uint8_t bytes[1];
1812 	uint8_t voltage[2];
1813 };
1814 
1815 enum ses_status_voltage_sensor_field_data {
1816 	SES_STATUS_VOLTAGE_SENSOR_IDENT_BYTE		= 0,
1817 	SES_STATUS_VOLTAGE_SENSOR_IDENT_MASK		= 0x80,
1818 	SES_STATUS_VOLTAGE_SENSOR_IDENT_SHIFT		= 7,
1819 
1820 	SES_STATUS_VOLTAGE_SENSOR_FAIL_BYTE		= 0,
1821 	SES_STATUS_VOLTAGE_SENSOR_FAIL_MASK		= 0x40,
1822 	SES_STATUS_VOLTAGE_SENSOR_FAIL_SHIFT		= 6,
1823 
1824 	SES_STATUS_VOLTAGE_SENSOR_WARN_OVER_BYTE	= 0,
1825 	SES_STATUS_VOLTAGE_SENSOR_WARN_OVER_MASK	= 0x08,
1826 	SES_STATUS_VOLTAGE_SENSOR_WARN_OVER_SHIFT	= 3,
1827 
1828 	SES_STATUS_VOLTAGE_SENSOR_WARN_UNDER_BYTE	= 0,
1829 	SES_STATUS_VOLTAGE_SENSOR_WARN_UNDER_MASK	= 0x04,
1830 	SES_STATUS_VOLTAGE_SENSOR_WARN_UNDER_SHIFT	= 2,
1831 
1832 	SES_STATUS_VOLTAGE_SENSOR_CRIT_OVER_BYTE	= 0,
1833 	SES_STATUS_VOLTAGE_SENSOR_CRIT_OVER_MASK	= 0x02,
1834 	SES_STATUS_VOLTAGE_SENSOR_CRIT_OVER_SHIFT	= 1,
1835 
1836 	SES_STATUS_VOLTAGE_SENSOR_CRIT_UNDER_BYTE	= 0,
1837 	SES_STATUS_VOLTAGE_SENSOR_CRIT_UNDER_MASK	= 0x01,
1838 	SES_STATUS_VOLTAGE_SENSOR_CRIT_UNDER_SHIFT	= 0
1839 };
1840 
1841 #define GEN_SES_STATUS_VOLTAGE_SENSOR_ACCESSORS(LCASE, UCASE)		\
1842     GEN_GETTER(ses_status_voltage_sensor, SES_STATUS_VOLTAGE_SENSOR,	\
1843 		  LCASE, UCASE)
1844 GEN_SES_STATUS_VOLTAGE_SENSOR_ACCESSORS(ident,      IDENT)
1845 GEN_SES_STATUS_VOLTAGE_SENSOR_ACCESSORS(fail,       FAIL)
1846 GEN_SES_STATUS_VOLTAGE_SENSOR_ACCESSORS(warn_over,  WARN_OVER)
1847 GEN_SES_STATUS_VOLTAGE_SENSOR_ACCESSORS(warn_under, WARN_UNDER)
1848 GEN_SES_STATUS_VOLTAGE_SENSOR_ACCESSORS(crit_over,  CRIT_OVER)
1849 GEN_SES_STATUS_VOLTAGE_SENSOR_ACCESSORS(crit_under, CRIT_UNDER)
1850 #undef GEN_SES_STATUS_VOLTAGE_SENSOR_ACCESSORS
1851 
1852 /*---------------------- Current Sensor Status Element -----------------------*/
1853 struct ses_status_current_sensor {
1854 	struct ses_status_common common;
1855 	uint8_t bytes[3];
1856 };
1857 
1858 enum ses_status_current_sensor_field_data {
1859 	SES_STATUS_CURRENT_SENSOR_IDENT_BYTE		= 0,
1860 	SES_STATUS_CURRENT_SENSOR_IDENT_MASK		= 0x80,
1861 	SES_STATUS_CURRENT_SENSOR_IDENT_SHIFT		= 7,
1862 
1863 	SES_STATUS_CURRENT_SENSOR_FAIL_BYTE		= 0,
1864 	SES_STATUS_CURRENT_SENSOR_FAIL_MASK		= 0x40,
1865 	SES_STATUS_CURRENT_SENSOR_FAIL_SHIFT		= 6,
1866 
1867 	SES_STATUS_CURRENT_SENSOR_WARN_OVER_BYTE	= 0,
1868 	SES_STATUS_CURRENT_SENSOR_WARN_OVER_MASK	= 0x08,
1869 	SES_STATUS_CURRENT_SENSOR_WARN_OVER_SHIFT	= 3,
1870 
1871 	SES_STATUS_CURRENT_SENSOR_CRIT_OVER_BYTE	= 0,
1872 	SES_STATUS_CURRENT_SENSOR_CRIT_OVER_MASK	= 0x02,
1873 	SES_STATUS_CURRENT_SENSOR_CRIT_OVER_SHIFT	= 1
1874 };
1875 
1876 #define GEN_SES_STATUS_CURRENT_SENSOR_ACCESSORS(LCASE, UCASE)		\
1877     GEN_GETTER(ses_status_current_sensor, SES_STATUS_CURRENT_SENSOR,	\
1878 		  LCASE, UCASE)
1879 GEN_SES_STATUS_CURRENT_SENSOR_ACCESSORS(ident,      IDENT)
1880 GEN_SES_STATUS_CURRENT_SENSOR_ACCESSORS(fail,       FAIL)
1881 GEN_SES_STATUS_CURRENT_SENSOR_ACCESSORS(warn_over,  WARN_OVER)
1882 GEN_SES_STATUS_CURRENT_SENSOR_ACCESSORS(crit_over,  CRIT_OVER)
1883 #undef GEN_SES_STATUS_CURRENT_SENSOR_ACCESSORS
1884 
1885 /*--------------------- SCSI Target Port Status Element ----------------------*/
1886 struct ses_status_target_port {
1887 	struct ses_status_common common;
1888 	uint8_t bytes[3];
1889 };
1890 
1891 enum ses_status_scsi_target_port_field_data {
1892 	SES_STATUS_TARGET_PORT_IDENT_BYTE	= 0,
1893 	SES_STATUS_TARGET_PORT_IDENT_MASK	= 0x80,
1894 	SES_STATUS_TARGET_PORT_IDENT_SHIFT	= 7,
1895 
1896 	SES_STATUS_TARGET_PORT_FAIL_BYTE	= 0,
1897 	SES_STATUS_TARGET_PORT_FAIL_MASK	= 0x40,
1898 	SES_STATUS_TARGET_PORT_FAIL_SHIFT	= 6,
1899 
1900 	SES_STATUS_TARGET_PORT_REPORT_BYTE	= 1,
1901 	SES_STATUS_TARGET_PORT_REPORT_MASK	= 0x01,
1902 	SES_STATUS_TARGET_PORT_REPORT_SHIFT	= 0,
1903 
1904 	SES_STATUS_TARGET_PORT_ENABLED_BYTE	= 2,
1905 	SES_STATUS_TARGET_PORT_ENABLED_MASK	= 0x01,
1906 	SES_STATUS_TARGET_PORT_ENABLED_SHIFT	= 0
1907 };
1908 
1909 #define GEN_SES_STATUS_TARGET_PORT_ACCESSORS(LCASE, UCASE)	\
1910     GEN_GETTER(ses_status_target_port, SES_STATUS_TARGET_PORT, LCASE, UCASE)
1911 GEN_SES_STATUS_TARGET_PORT_ACCESSORS(ident,   IDENT)
1912 GEN_SES_STATUS_TARGET_PORT_ACCESSORS(fail,    FAIL)
1913 GEN_SES_STATUS_TARGET_PORT_ACCESSORS(report,  REPORT)
1914 GEN_SES_STATUS_TARGET_PORT_ACCESSORS(enabled, ENABLED)
1915 #undef GEN_SES_STATUS_TARGET_PORT_ACCESSORS
1916 
1917 /*-------------------- SCSI Initiator Port Status Element --------------------*/
1918 struct ses_status_initiator_port {
1919 	struct ses_status_common common;
1920 	uint8_t bytes[3];
1921 };
1922 
1923 enum ses_status_scsi_initiator_port_field_data {
1924 	SES_STATUS_INITIATOR_PORT_IDENT_BYTE	= 0,
1925 	SES_STATUS_INITIATOR_PORT_IDENT_MASK	= 0x80,
1926 	SES_STATUS_INITIATOR_PORT_IDENT_SHIFT	= 7,
1927 
1928 	SES_STATUS_INITIATOR_PORT_FAIL_BYTE	= 0,
1929 	SES_STATUS_INITIATOR_PORT_FAIL_MASK	= 0x40,
1930 	SES_STATUS_INITIATOR_PORT_FAIL_SHIFT	= 6,
1931 
1932 	SES_STATUS_INITIATOR_PORT_REPORT_BYTE	= 1,
1933 	SES_STATUS_INITIATOR_PORT_REPORT_MASK	= 0x01,
1934 	SES_STATUS_INITIATOR_PORT_REPORT_SHIFT	= 0,
1935 
1936 	SES_STATUS_INITIATOR_PORT_ENABLED_BYTE	= 2,
1937 	SES_STATUS_INITIATOR_PORT_ENABLED_MASK	= 0x01,
1938 	SES_STATUS_INITIATOR_PORT_ENABLED_SHIFT	= 0
1939 };
1940 
1941 #define GEN_SES_STATUS_INITIATOR_PORT_ACCESSORS(LCASE, UCASE)		\
1942     GEN_GETTER(ses_status_initiator_port, SES_STATUS_INITIATOR_PORT,	\
1943 	       LCASE, UCASE)
1944 GEN_SES_STATUS_INITIATOR_PORT_ACCESSORS(ident,   IDENT)
1945 GEN_SES_STATUS_INITIATOR_PORT_ACCESSORS(fail,    FAIL)
1946 GEN_SES_STATUS_INITIATOR_PORT_ACCESSORS(report,  REPORT)
1947 GEN_SES_STATUS_INITIATOR_PORT_ACCESSORS(enabled, ENABLED)
1948 #undef GEN_SES_STATUS_INITIATOR_PORT_ACCESSORS
1949 
1950 /*-------------------- Simple Subenclosure Status Element --------------------*/
1951 struct ses_status_simple_subses {
1952 	struct ses_status_common common;
1953 	uint8_t bytes[2];
1954 	uint8_t short_enclosure_status;
1955 };
1956 
1957 enum ses_status_simple_subses_field_data {
1958 	SES_STATUS_SIMPlE_SUBSES_IDENT_BYTE	= 0,
1959 	SES_STATUS_SIMPlE_SUBSES_IDENT_MASK	= 0x80,
1960 	SES_STATUS_SIMPlE_SUBSES_IDENT_SHIFT	= 7,
1961 
1962 	SES_STATUS_SIMPlE_SUBSES_FAIL_BYTE	= 0,
1963 	SES_STATUS_SIMPlE_SUBSES_FAIL_MASK	= 0x40,
1964 	SES_STATUS_SIMPlE_SUBSES_FAIL_SHIFT	= 6
1965 };
1966 
1967 #define GEN_SES_STATUS_SIMPlE_SUBSES_ACCESSORS(LCASE, UCASE)		\
1968     GEN_GETTER(ses_status_simple_subses, SES_STATUS_SIMPlE_SUBSES,	\
1969 		  LCASE, UCASE)
1970 GEN_SES_STATUS_SIMPlE_SUBSES_ACCESSORS(ident, IDENT)
1971 GEN_SES_STATUS_SIMPlE_SUBSES_ACCESSORS(fail,  FAIL)
1972 #undef GEN_SES_STATUS_SIMPlE_SUBSES_ACCESSORS
1973 
1974 /*----------------------- SAS Expander Status Element ------------------------*/
1975 struct ses_status_sas_expander {
1976 	struct ses_status_common common;
1977 	uint8_t bytes[3];
1978 };
1979 
1980 enum ses_status_sas_expander_field_data {
1981 	SES_STATUS_SAS_EXPANDER_IDENT_BYTE	= 0,
1982 	SES_STATUS_SAS_EXPANDER_IDENT_MASK	= 0x80,
1983 	SES_STATUS_SAS_EXPANDER_IDENT_SHIFT	= 7,
1984 
1985 	SES_STATUS_SAS_EXPANDER_FAIL_BYTE	= 0,
1986 	SES_STATUS_SAS_EXPANDER_FAIL_MASK	= 0x40,
1987 	SES_STATUS_SAS_EXPANDER_FAIL_SHIFT	= 6
1988 };
1989 
1990 #define GEN_SES_STATUS_SAS_EXPANDER_ACCESSORS(LCASE, UCASE)	\
1991     GEN_GETTER(ses_status_sas_expander, SES_STATUS_SAS_EXPANDER,	LCASE, UCASE)
1992 GEN_SES_STATUS_SAS_EXPANDER_ACCESSORS(ident, IDENT)
1993 GEN_SES_STATUS_SAS_EXPANDER_ACCESSORS(fail,  FAIL)
1994 #undef GEN_SES_STATUS_SAS_EXPANDER_ACCESSORS
1995 
1996 /*----------------------- SAS Connector Status Element -----------------------*/
1997 struct ses_status_sas_connector {
1998 	struct ses_status_common common;
1999 	uint8_t bytes[3];
2000 };
2001 
2002 enum ses_status_sas_connector_field_data {
2003 	SES_STATUS_SAS_CONNECTOR_IDENT_BYTE		= 0,
2004 	SES_STATUS_SAS_CONNECTOR_IDENT_MASK		= 0x80,
2005 	SES_STATUS_SAS_CONNECTOR_IDENT_SHIFT		= 7,
2006 
2007 	SES_STATUS_SAS_CONNECTOR_TYPE_BYTE		= 0,
2008 	SES_STATUS_SAS_CONNECTOR_TYPE_MASK		= 0x7F,
2009 	SES_STATUS_SAS_CONNECTOR_TYPE_SHIFT		= 0,
2010 
2011 	SES_STATUS_SAS_CONNECTOR_PHYS_LINK_BYTE		= 1,
2012 	SES_STATUS_SAS_CONNECTOR_PHYS_LINK_MASK		= 0xFF,
2013 	SES_STATUS_SAS_CONNECTOR_PHYS_LINK_SHIFT	= 0,
2014 	SES_STATUS_SAS_CONNECTOR_PHYS_LINK_ALL		= 0xFF,
2015 
2016 	SES_STATUS_SAS_CONNECTOR_FAIL_BYTE		= 2,
2017 	SES_STATUS_SAS_CONNECTOR_FAIL_MASK		= 0x40,
2018 	SES_STATUS_SAS_CONNECTOR_FAIL_SHIFT		= 6,
2019 };
2020 
2021 #define GEN_SES_STATUS_SAS_CONNECTOR_ACCESSORS(LCASE, UCASE)		\
2022     GEN_GETTER(ses_status_sas_connector, SES_STATUS_SAS_CONNECTOR,	\
2023 		  LCASE, UCASE)
2024 GEN_SES_STATUS_SAS_CONNECTOR_ACCESSORS(ident,     IDENT)
2025 GEN_SES_STATUS_SAS_CONNECTOR_ACCESSORS(type,      TYPE)
2026 GEN_SES_STATUS_SAS_CONNECTOR_ACCESSORS(phys_link, PHYS_LINK)
2027 GEN_SES_STATUS_SAS_CONNECTOR_ACCESSORS(fail,      FAIL)
2028 #undef GEN_SES_STATUS_SAS_CONNECTOR_ACCESSORS
2029 
2030 /*------------------------- Universal Status Element -------------------------*/
2031 union ses_status_element {
2032 	struct ses_status_common            common;
2033 	struct ses_status_dev_slot          dev_slot;
2034 	struct ses_status_array_dev_slot    array_dev_slot;
2035 	struct ses_status_power_supply      power_supply;
2036 	struct ses_status_cooling           cooling;
2037 	struct ses_status_temp_sensor       temp_sensor;
2038 	struct ses_status_door_lock         door_lock;
2039 	struct ses_status_audible_alarm     audible_alarm;
2040 	struct ses_status_ecc_electronics   ecc_electronics;
2041 	struct ses_status_scc_electronics   scc_electronics;
2042 	struct ses_status_nv_cache          nv_cache;
2043 	struct ses_status_invalid_op_reason invalid_op_reason;
2044 	struct ses_status_ups               ups;
2045 	struct ses_status_display           display;
2046 	struct ses_status_key_pad_entry     key_pad_entry;
2047 	struct ses_status_scsi_port_or_xcvr scsi_port_or_xcvr;
2048 	struct ses_status_language          language;
2049 	struct ses_status_comm_port         comm_port;
2050 	struct ses_status_voltage_sensor    voltage_sensor;
2051 	struct ses_status_current_sensor    current_sensor;
2052 	struct ses_status_target_port       target_port;
2053 	struct ses_status_initiator_port    initiator_port;
2054 	struct ses_status_simple_subses     simple_subses;
2055 	struct ses_status_sas_expander      sas_expander;
2056 	struct ses_status_sas_connector     sas_connector;
2057 	uint8_t				    bytes[4];
2058 };
2059 
2060 /*===================== SCSI SES Status Diagnostic Page =====================*/
2061 struct ses_status_page {
2062 	struct ses_page_hdr  hdr;
2063 	union ses_status_element  elements[];
2064 };
2065 
2066 enum ses_status_page_field_data {
2067 	SES_STATUS_PAGE_INVOP_MASK	= 0x10,
2068 	SES_STATUS_PAGE_INVOP_SHIFT	= 4,
2069 
2070 	SES_STATUS_PAGE_INFO_MASK	= 0x08,
2071 	SES_STATUS_PAGE_INFO_SHIFT	= 3,
2072 
2073 	SES_STATUS_PAGE_NON_CRIT_MASK	= 0x04,
2074 	SES_STATUS_PAGE_NON_CRIT_SHIFT	= 2,
2075 
2076 	SES_STATUS_PAGE_CRIT_MASK	= 0x02,
2077 	SES_STATUS_PAGE_CRIT_SHIFT	= 1,
2078 
2079 	SES_STATUS_PAGE_UNRECOV_MASK	= 0x01,
2080 	SES_STATUS_PAGE_UNRECOV_SHIFT	= 0,
2081 
2082 	SES_STATUS_PAGE_CHANGED_MASK	= SES_STATUS_PAGE_INVOP_MASK
2083 					| SES_STATUS_PAGE_INFO_MASK
2084 					| SES_STATUS_PAGE_NON_CRIT_MASK
2085 					| SES_STATUS_PAGE_CRIT_MASK
2086 					| SES_STATUS_PAGE_UNRECOV_MASK,
2087 	SES_STATUS_PAGE_CHANGED_SHIFT	= 0,
2088 };
2089 
2090 #define GEN_SES_STATUS_PAGE_ACCESSORS(LCASE, UCASE) \
2091     GEN_HDR_ACCESSORS(ses_status_page, SES_STATUS_PAGE, LCASE, UCASE)
2092 
2093 GEN_SES_STATUS_PAGE_ACCESSORS(invop,    INVOP)
2094 GEN_SES_STATUS_PAGE_ACCESSORS(info,     INFO)
2095 GEN_SES_STATUS_PAGE_ACCESSORS(non_crit, NON_CRIT)
2096 GEN_SES_STATUS_PAGE_ACCESSORS(crit,     CRIT)
2097 GEN_SES_STATUS_PAGE_ACCESSORS(unrecov,  UNRECOV)
2098 GEN_SES_STATUS_PAGE_ACCESSORS(changed,  CHANGED)
2099 #undef GEN_SES_STATUS_PAGE_ACCESSORS
2100 
2101 /*================ SCSI SES Element Descriptor Diagnostic Page ===============*/
2102 struct ses_elem_descr {
2103 	uint8_t	reserved[2];
2104 	uint8_t	length[2];
2105 	char	description[];
2106 };
2107 
2108 struct ses_elem_descr_page {
2109 	struct ses_page_hdr   hdr;
2110 	struct ses_elem_descr descrs[];
2111 };
2112 
2113 /*============ SCSI SES Additional Element Status Diagnostic Page ============*/
2114 struct ses_addl_elem_status_page {
2115 	struct ses_page_hdr   hdr;
2116 };
2117 
2118 /*====================== Legacy (Deprecated) Structures ======================*/
2119 struct ses_control_page_hdr {
2120 	uint8_t page_code;
2121 	uint8_t control_flags;
2122 	uint8_t length[2];
2123 	uint8_t gen_code[4];
2124 /* Followed by variable length array of descriptors. */
2125 };
2126 
2127 struct ses_status_page_hdr {
2128 	uint8_t page_code;
2129 	uint8_t status_flags;
2130 	uint8_t length[2];
2131 	uint8_t gen_code[4];
2132 /* Followed by variable length array of descriptors. */
2133 };
2134 
2135 /* ses_page_hdr.reserved values */
2136 /*
2137  * Enclosure Status Diagnostic Page:
2138  * uint8_t	reserved : 3,
2139  * 		invop : 1,
2140  * 		info : 1,
2141  * 		noncritical : 1,
2142  * 		critical : 1,
2143  * 		unrecov : 1;
2144  */
2145 #define	SES_ENCSTAT_UNRECOV		0x01
2146 #define	SES_ENCSTAT_CRITICAL		0x02
2147 #define	SES_ENCSTAT_NONCRITICAL		0x04
2148 #define	SES_ENCSTAT_INFO		0x08
2149 #define	SES_ENCSTAT_INVOP		0x10
2150 /* Status mask: All of the above OR'd together */
2151 #define	SES_STATUS_MASK			0x1f
2152 #define	SES_SET_STATUS_MASK		0xf
2153 /* Element Descriptor Diagnostic Page: unused */
2154 /* Additional Element Status Diagnostic Page: unused */
2155 
2156 
2157 
2158 /* Summary SES Status Defines, Common Status Codes */
2159 #define	SES_OBJSTAT_UNSUPPORTED		0
2160 #define	SES_OBJSTAT_OK			1
2161 #define	SES_OBJSTAT_CRIT		2
2162 #define	SES_OBJSTAT_NONCRIT		3
2163 #define	SES_OBJSTAT_UNRECOV		4
2164 #define	SES_OBJSTAT_NOTINSTALLED	5
2165 #define	SES_OBJSTAT_UNKNOWN		6
2166 #define	SES_OBJSTAT_NOTAVAIL		7
2167 #define	SES_OBJSTAT_NOACCESS		8
2168 
2169 /*
2170  * For control pages, cstat[0] is the same for the
2171  * enclosure and is common across all device types.
2172  *
2173  * If SESCTL_CSEL is set, then PRDFAIL, DISABLE and RSTSWAP
2174  * are checked, otherwise bits that are specific to the device
2175  * type in the other 3 bytes of cstat or checked.
2176  */
2177 #define	SESCTL_CSEL		0x80
2178 #define	SESCTL_PRDFAIL		0x40
2179 #define	SESCTL_DISABLE		0x20
2180 #define	SESCTL_RSTSWAP		0x10
2181 
2182 
2183 /* Control bits, Device Elements, byte 2 */
2184 #define	SESCTL_DRVLCK	0x40	/* "DO NOT REMOVE" */
2185 #define	SESCTL_RQSINS	0x08	/* RQST INSERT */
2186 #define	SESCTL_RQSRMV	0x04	/* RQST REMOVE */
2187 #define	SESCTL_RQSID	0x02	/* RQST IDENT */
2188 /* Control bits, Device Elements, byte 3 */
2189 #define	SESCTL_RQSFLT	0x20	/* RQST FAULT */
2190 #define	SESCTL_DEVOFF	0x10	/* DEVICE OFF */
2191 
2192 /* Control bits, Generic, byte 3 */
2193 #define	SESCTL_RQSTFAIL	0x40
2194 #define	SESCTL_RQSTON	0x20
2195 
2196 /*
2197  * Getting text for an object type is a little
2198  * trickier because it's string data that can
2199  * go up to 64 KBytes. Build this union and
2200  * fill the obj_id with the id of the object who's
2201  * help text you want, and if text is available,
2202  * obj_text will be filled in, null terminated.
2203  */
2204 
2205 typedef union {
2206 	unsigned int obj_id;
2207 	char obj_text[1];
2208 } ses_hlptxt;
2209 
2210 /*============================================================================*/
2211 struct ses_elm_desc_hdr {
2212 	uint8_t reserved[2];
2213 	uint8_t length[2];
2214 };
2215 
2216 /*
2217  * SES v2 r20 6.1.13 - Element Additional Status diagnostic page
2218  * Tables 26-28 (general), 29-32 (FC), 33-41 (SAS)
2219  *
2220  * Protocol identifier uses definitions in scsi_all.h;
2221  * SPSP_PROTO_FC, SPSP_PROTO_SAS are the only ones used here.
2222  */
2223 
2224 struct ses_elm_fc_eip_hdr {
2225 	uint8_t num_phys;
2226 	uint8_t reserved[2];
2227 	uint8_t dev_slot_num;
2228 	uint8_t node_name[8];
2229 };
2230 
2231 struct ses_elm_fc_noneip_hdr {
2232 	uint8_t num_phys;
2233 	uint8_t reserved;
2234 	uint8_t node_name[8];
2235 };
2236 
2237 struct ses_elm_fc_base_hdr {
2238 	uint8_t num_phys;
2239 };
2240 
2241 union ses_elm_fc_hdr {
2242 	struct ses_elm_fc_base_hdr	base_hdr;
2243 	struct ses_elm_fc_eip_hdr	eip_hdr;
2244 	struct ses_elm_fc_noneip_hdr	noneip_hdr;
2245 };
2246 
2247 struct ses_elm_fc_port {
2248 	uint8_t port_loop_position;
2249 	uint8_t bypass_reason;
2250 #define SES_FC_PORT_BYPASS_UNBYPASSED			0x00
2251 
2252 #define	SES_FC_PORT_BYPASS_LINKFAIL_RATE_TOO_HIGH	0x10
2253 #define	SES_FC_PORT_BYPASS_SYNC_LOSS_RATE_TOO_HIGH	0x11
2254 #define	SES_FC_PORT_BYPASS_SIGNAL_LOSS_RATE_TOO_HIGH	0x12
2255 #define	SES_FC_PORT_BYPASS_SEQPROTO_ERR_RATE_TOO_HIGH	0x13
2256 #define	SES_FC_PORT_BYPASS_INVAL_XMIT_RATE_TOO_HIGH	0x14
2257 #define	SES_FC_PORT_BYPASS_CRC_ERR_RATE_TOO_HIGH	0x15
2258 
2259 #define	SES_FC_PORT_BYPASS_ERR_RATE_RESERVED_BEGIN	0x16
2260 #define	SES_FC_PORT_BYPASS_ERR_RATE_RESERVED_END	0x1F
2261 
2262 #define	SES_FC_PORT_BYPASS_LINKFAIL_COUNT_TOO_HIGH	0x20
2263 #define	SES_FC_PORT_BYPASS_SYNC_LOSS_COUNT_TOO_HIGH	0x21
2264 #define	SES_FC_PORT_BYPASS_SIGNAL_LOSS_COUNT_TOO_HIGH	0x22
2265 #define	SES_FC_PORT_BYPASS_SEQPROTO_ERR_COUNT_TOO_HIGH	0x23
2266 #define	SES_FC_PORT_BYPASS_INVAL_XMIT_COUNT_TOO_HIGH	0x24
2267 #define	SES_FC_PORT_BYPASS_CRC_ERR_COUNT_TOO_HIGH	0x25
2268 
2269 #define	SES_FC_PORT_BYPASS_ERR_COUNT_RESERVED_BEGIN	0x26
2270 #define	SES_FC_PORT_BYPASS_ERR_COUNT_RESERVED_END	0x2F
2271 
2272 #define	SES_FC_PORT_BYPASS_RESERVED_BEGIN		0x30
2273 #define	SES_FC_PORT_BYPASS_RESERVED_END			0xBF
2274 
2275 #define	SES_FC_PORT_BYPASS_VENDOR_SPECIFIC_BEGIN	0xC0
2276 #define	SES_FC_PORT_BYPASS_VENDOR_SPECIFIC_END		0xFF
2277 	uint8_t port_req_hard_addr;
2278 	uint8_t n_port_id[3];
2279 	uint8_t n_port_name[8];
2280 };
2281 
2282 struct ses_elm_sas_device_phy {
2283 	uint8_t byte0;
2284 	/*
2285 	 * uint8_t reserved0 : 1,
2286 	 * uint8_t device_type : 3,
2287 	 * uint8_t reserved1 : 4;
2288 	 */
2289 
2290 	uint8_t reserved0;
2291 
2292 	/* Bit positions for initiator and target port protocols */
2293 #define	SES_SASOBJ_DEV_PHY_SMP		0x2
2294 #define	SES_SASOBJ_DEV_PHY_STP		0x4
2295 #define	SES_SASOBJ_DEV_PHY_SSP		0x8
2296 	/* Select all of the above protocols */
2297 #define	SES_SASOBJ_DEV_PHY_PROTOMASK	0xe
2298 	uint8_t initiator_ports;
2299 	/*
2300 	 * uint8_t reserved0 : 4,
2301 	 * uint8_t ssp : 1,
2302 	 * uint8_t stp : 1,
2303 	 * uint8_t smp : 1,
2304 	 * uint8_t reserved1 : 3;
2305 	 */
2306 	uint8_t target_ports;
2307 	/*
2308 	 * uint8_t sata_port_selector : 1,
2309 	 * uint8_t reserved : 3,
2310 	 * uint8_t ssp : 1,
2311 	 * uint8_t stp : 1,
2312 	 * uint8_t smp : 1,
2313 	 * uint8_t sata_device : 1;
2314 	 */
2315 	uint8_t parent_addr[8];		/* SAS address of parent */
2316 	uint8_t phy_addr[8];		/* SAS address of this phy */
2317 	uint8_t phy_id;
2318 	uint8_t reserved1[7];
2319 };
2320 #ifdef _KERNEL
2321 int ses_elm_sas_dev_phy_sata_dev(struct ses_elm_sas_device_phy *);
2322 int ses_elm_sas_dev_phy_sata_port(struct ses_elm_sas_device_phy *);
2323 int ses_elm_sas_dev_phy_dev_type(struct ses_elm_sas_device_phy *);
2324 #endif	/* _KERNEL */
2325 
2326 struct ses_elm_sas_expander_phy {
2327 	uint8_t connector_index;
2328 	uint8_t other_index;
2329 };
2330 
2331 struct ses_elm_sas_port_phy {
2332 	uint8_t phy_id;
2333 	uint8_t reserved;
2334 	uint8_t connector_index;
2335 	uint8_t other_index;
2336 	uint8_t phy_addr[8];
2337 };
2338 
2339 struct ses_elm_sas_type0_base_hdr {
2340 	uint8_t num_phys;
2341 	uint8_t byte1;
2342 	/*
2343 	 * uint8_t descriptor_type : 2,
2344 	 * uint8_t reserved : 5,
2345 	 * uint8_t not_all_phys : 1;
2346 	 */
2347 #define	SES_SASOBJ_TYPE0_NOT_ALL_PHYS(obj)	\
2348 	((obj)->byte1 & 0x1)
2349 };
2350 
2351 struct ses_elm_sas_type0_eip_hdr {
2352 	struct ses_elm_sas_type0_base_hdr base;
2353 	uint8_t reserved;
2354 	uint8_t dev_slot_num;
2355 };
2356 
2357 struct ses_elm_sas_type1_expander_hdr {
2358 	uint8_t num_phys;
2359 	uint8_t byte1;
2360 	/*
2361 	 * uint8_t descriptor_type : 2,
2362 	 * uint8_t reserved : 6;
2363 	 */
2364 	uint8_t reserved[2];
2365 	uint8_t sas_addr[8];
2366 };
2367 
2368 struct ses_elm_sas_type1_nonexpander_hdr {
2369 	uint8_t num_phys;
2370 	uint8_t byte1;
2371 	/*
2372 	 * uint8_t descriptor_type : 2,
2373 	 * uint8_t reserved : 6;
2374 	 */
2375 	uint8_t reserved[2];
2376 };
2377 
2378 /* NB: This is only usable for as long as the headers happen to match */
2379 struct ses_elm_sas_base_hdr {
2380 	uint8_t num_phys;
2381 	uint8_t byte1;
2382 	/*
2383 	 * uint8_t descriptor_type : 2,
2384 	 * uint8_t descr_specific : 6;
2385 	 */
2386 #define	SES_SASOBJ_TYPE_SLOT	0
2387 #define	SES_SASOBJ_TYPE_OTHER	1
2388 };
2389 
2390 union ses_elm_sas_hdr {
2391 	struct ses_elm_sas_base_hdr 			base_hdr;
2392 	struct ses_elm_sas_type0_base_hdr		type0_noneip;
2393 	struct ses_elm_sas_type0_eip_hdr		type0_eip;
2394 	struct ses_elm_sas_type1_expander_hdr		type1_exp;
2395 	struct ses_elm_sas_type1_nonexpander_hdr	type1_nonexp;
2396 };
2397 int ses_elm_sas_type0_not_all_phys(union ses_elm_sas_hdr *);
2398 int ses_elm_sas_descr_type(union ses_elm_sas_hdr *);
2399 
2400 struct ses_elm_addlstatus_base_hdr {
2401 	uint8_t byte0;
2402 	/*
2403 	 * uint8_t invalid : 1,
2404 	 * uint8_t reserved : 2,
2405 	 * uint8_t eip : 1,
2406 	 * uint8_t proto_id : 4;
2407 	 */
2408 	uint8_t length;
2409 };
2410 int ses_elm_addlstatus_proto(struct ses_elm_addlstatus_base_hdr *);
2411 int ses_elm_addlstatus_eip(struct ses_elm_addlstatus_base_hdr *);
2412 int ses_elm_addlstatus_invalid(struct ses_elm_addlstatus_base_hdr *);
2413 
2414 struct ses_elm_addlstatus_eip_hdr {
2415 	struct ses_elm_addlstatus_base_hdr base;
2416 	uint8_t byte2;
2417 #define	SES_ADDL_EIP_EIIOE	1
2418 	uint8_t element_index;
2419 	/* NB: This define (currently) applies to all eip=1 headers */
2420 #define	SES_EIP_HDR_EXTRA_LEN	2
2421 };
2422 
2423 union ses_elm_addlstatus_descr_hdr {
2424 	struct ses_elm_addlstatus_base_hdr	base;
2425 	struct ses_elm_addlstatus_eip_hdr	eip;
2426 };
2427 
2428 union ses_elm_addlstatus_proto_hdr {
2429 	union ses_elm_fc_hdr	fc;
2430 	union ses_elm_sas_hdr	sas;
2431 };
2432 
2433 /*============================= Namespace Cleanup ============================*/
2434 #undef GEN_HDR_ACCESSORS
2435 #undef GEN_ACCESSORS
2436 #undef GEN_HDR_SETTER
2437 #undef GEN_HDR_GETTER
2438 #undef GEN_SETTER
2439 #undef GEN_GETTER
2440 #undef MK_ENUM
2441 
2442 #endif	/* _SCSI_SES_H_ */
2443