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