1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25/*
26 * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
27 */
28
29#include <sys/types.h>
30#include <stddef.h>
31#include <stdio.h>
32#include <string.h>
33#include <libnvpair.h>
34
35#include <scsi/libses.h>
36#include "ses2_impl.h"
37
38static int
39elem_setprop_device(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
40    nvpair_t *nvp)
41{
42	ses2_device_ctl_impl_t *dip;
43	const char *name;
44	boolean_t v;
45
46	if ((dip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
47	    page, 0, np, B_FALSE)) == NULL)
48		return (-1);
49
50	name = nvpair_name(nvp);
51	(void) nvpair_value_boolean_value(nvp, &v);
52
53	if (strcmp(name, SES_PROP_IDENT) == 0)
54		dip->sdci_rqst_ident = v;
55	else if (strcmp(name, SES_PROP_RMV) == 0)
56		dip->sdci_rqst_remove = v;
57	else if (strcmp(name, SES_DEV_PROP_READY_TO_INSERT) == 0)
58		dip->sdci_rqst_insert = v;
59	else if (strcmp(name, SES_DEV_PROP_REQ_MISSING) == 0)
60		dip->sdci_rqst_missing = v;
61	else if (strcmp(name, SES_DEV_PROP_DO_NOT_REMOVE) == 0)
62		dip->sdci_do_not_remove = v;
63	else if (strcmp(name, SES_DEV_PROP_REQ_ACTIVE) == 0)
64		dip->sdci_rqst_active = v;
65	else if (strcmp(name, SES_DEV_PROP_BYP_B) == 0)
66		dip->sdci_enable_byp_b = v;
67	else if (strcmp(name, SES_DEV_PROP_BYP_A) == 0)
68		dip->sdci_enable_byp_a = v;
69	else if (strcmp(name, SES_PROP_OFF) == 0)
70		dip->sdci_device_off = v;
71	else if (strcmp(name, SES_DEV_PROP_FAULT_RQSTD) == 0)
72		dip->sdci_rqst_fault = v;
73	else
74		ses_panic("Bad property %s", name);
75
76	return (0);
77}
78
79static int
80elem_setprop_psu(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
81    nvpair_t *nvp)
82{
83	ses2_psu_ctl_impl_t *pip;
84	const char *name;
85	boolean_t v;
86
87	if ((pip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
88	    page, 0, np, B_FALSE)) == NULL)
89		return (-1);
90
91	name = nvpair_name(nvp);
92	(void) nvpair_value_boolean_value(nvp, &v);
93
94	if (strcmp(name, SES_PROP_IDENT) == 0)
95		pip->spci_rqst_ident = v;
96	else if (strcmp(name, SES_PROP_REQUESTED_ON) == 0)
97		pip->spci_rqst_on = v;
98	else if (strcmp(name, SES_PROP_FAIL) == 0)
99		pip->spci_rqst_fail = v;
100	else
101		ses_panic("Bad property %s", name);
102
103	return (0);
104}
105
106static int
107elem_setprop_cooling(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
108    nvpair_t *nvp)
109{
110	ses2_cooling_ctl_impl_t *cip;
111	const char *name;
112	boolean_t v1;
113	uint64_t v64;
114
115	if ((cip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
116	    page, 0, np, B_FALSE)) == NULL)
117		return (-1);
118
119	name = nvpair_name(nvp);
120
121	if (strcmp(name, SES_COOLING_PROP_SPEED_CODE) == 0) {
122		(void) nvpair_value_uint64(nvp, &v64);
123		cip->scci_requested_speed_code = v64;
124		return (0);
125	}
126
127	(void) nvpair_value_boolean_value(nvp, &v1);
128
129	if (strcmp(name, SES_PROP_IDENT) == 0)
130		cip->scci_rqst_ident = v1;
131	else if (strcmp(name, SES_PROP_REQUESTED_ON) == 0)
132		cip->scci_rqst_on = v1;
133	else if (strcmp(name, SES_PROP_FAIL) == 0)
134		cip->scci_rqst_fail = v1;
135	else
136		ses_panic("Bad property %s", name);
137
138	return (0);
139}
140
141static int
142elem_setprop_temp(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
143    nvpair_t *nvp)
144{
145	ses2_temp_ctl_impl_t *tip;
146	const char *name;
147	boolean_t v;
148
149	if ((tip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
150	    page, 0, np, B_FALSE)) == NULL)
151		return (-1);
152
153	name = nvpair_name(nvp);
154	(void) nvpair_value_boolean_value(nvp, &v);
155
156	if (strcmp(name, SES_PROP_FAIL) == 0)
157		tip->stci_rqst_fail = v;
158	else if (strcmp(name, SES_PROP_IDENT) == 0)
159		tip->stci_rqst_ident = v;
160	else
161		ses_panic("Bad property %s", name);
162
163	return (0);
164}
165
166static int
167elem_setprop_lock(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
168    nvpair_t *nvp)
169{
170	ses2_lock_ctl_impl_t *lip;
171	const char *name;
172	boolean_t v;
173
174	if ((lip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
175	    page, 0, np, B_FALSE)) == NULL)
176		return (-1);
177
178	name = nvpair_name(nvp);
179	(void) nvpair_value_boolean_value(nvp, &v);
180
181	if (strcmp(name, SES_PROP_FAIL) == 0)
182		lip->slci_rqst_fail = v;
183	else if (strcmp(name, SES_PROP_IDENT) == 0)
184		lip->slci_rqst_ident = v;
185	else if (strcmp(name, SES_LOCK_PROP_UNLOCKED) == 0)
186		lip->slci_unlock = v;
187	else
188		ses_panic("Bad property %s", name);
189
190	return (0);
191}
192
193static int
194elem_setprop_alarm(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
195    nvpair_t *nvp)
196{
197	ses2_alarm_ctl_impl_t *aip;
198	const char *name;
199	boolean_t v;
200
201	if ((aip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
202	    page, 0, np, B_FALSE)) == NULL)
203		return (-1);
204
205	name = nvpair_name(nvp);
206	(void) nvpair_value_boolean_value(nvp, &v);
207
208	if (strcmp(name, SES_PROP_FAIL) == 0)
209		aip->saci_rqst_fail = v;
210	else if (strcmp(name, SES_PROP_IDENT) == 0)
211		aip->saci_rqst_ident = v;
212	else if (strcmp(name, SES_ALARM_PROP_UNRECOV) == 0)
213		aip->saci_unrecov = v;
214	else if (strcmp(name, SES_ALARM_PROP_CRIT) == 0)
215		aip->saci_crit = v;
216	else if (strcmp(name, SES_ALARM_PROP_NONCRIT) == 0)
217		aip->saci_noncrit = v;
218	else if (strcmp(name, SES_ALARM_PROP_INFO) == 0)
219		aip->saci_info = v;
220	else if (strcmp(name, SES_ALARM_PROP_REMIND) == 0)
221		aip->saci_set_remind = v;
222	else if (strcmp(name, SES_ALARM_PROP_MUTED) == 0)
223		aip->saci_set_mute = v;
224	else
225		ses_panic("Bad property %s", name);
226
227	return (0);
228}
229
230static int
231elem_setprop_esc(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
232    nvpair_t *nvp)
233{
234	ses2_controller_ctl_impl_t *cip;
235	const char *name;
236	boolean_t v;
237
238	if ((cip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
239	    page, 0, np, B_FALSE)) == NULL)
240		return (-1);
241
242	name = nvpair_name(nvp);
243	(void) nvpair_value_boolean_value(nvp, &v);
244
245	if (strcmp(name, SES_PROP_FAIL) == 0)
246		cip->scci_rqst_fail = v;
247	else if (strcmp(name, SES_PROP_IDENT) == 0)
248		cip->scci_rqst_ident = v;
249	else if (strcmp(name, SES_ESC_PROP_SELECT) == 0)
250		cip->scci_select_element = v;
251	else
252		ses_panic("Bad property %s", name);
253
254	return (0);
255}
256
257static int
258elem_setprop_scc(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
259    nvpair_t *nvp)
260{
261	ses2_scc_ctl_impl_t *sip;
262	const char *name;
263	boolean_t v;
264
265	if ((sip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
266	    page, 0, np, B_FALSE)) == NULL)
267		return (-1);
268
269	name = nvpair_name(nvp);
270	(void) nvpair_value_boolean_value(nvp, &v);
271
272	if (strcmp(name, SES_PROP_FAIL) == 0)
273		sip->ssci_rqst_fail = v;
274	else if (strcmp(name, SES_PROP_IDENT) == 0)
275		sip->ssci_rqst_ident = v;
276	else
277		ses_panic("Bad property %s", name);
278
279	return (0);
280}
281
282static int
283elem_setprop_ups(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
284    nvpair_t *nvp)
285{
286	ses2_ups_ctl_impl_t *uip;
287	const char *name;
288	boolean_t v;
289
290	if ((uip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
291	    page, 0, np, B_FALSE)) == NULL)
292		return (-1);
293
294	name = nvpair_name(nvp);
295	(void) nvpair_value_boolean_value(nvp, &v);
296
297	if (strcmp(name, SES_PROP_FAIL) == 0)
298		uip->suci_rqst_fail = v;
299	else if (strcmp(name, SES_PROP_IDENT) == 0)
300		uip->suci_rqst_ident = v;
301	else
302		ses_panic("Bad property %s", name);
303
304	return (0);
305}
306
307static int
308elem_setprop_cache(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
309    nvpair_t *nvp)
310{
311	ses2_nvcache_ctl_impl_t *cip;
312	const char *name;
313	boolean_t v;
314
315	if ((cip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
316	    page, 0, np, B_FALSE)) == NULL)
317		return (-1);
318
319	name = nvpair_name(nvp);
320	(void) nvpair_value_boolean_value(nvp, &v);
321
322	if (strcmp(name, SES_PROP_FAIL) == 0)
323		cip->snci_rqst_fail = v;
324	else if (strcmp(name, SES_PROP_IDENT) == 0)
325		cip->snci_rqst_ident = v;
326	else
327		ses_panic("Bad property %s", name);
328
329	return (0);
330}
331
332static int
333elem_setprop_keypad(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
334    nvpair_t *nvp)
335{
336	ses2_keypad_ctl_impl_t *kip;
337	const char *name;
338	boolean_t v;
339
340	if ((kip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
341	    page, 0, np, B_FALSE)) == NULL)
342		return (-1);
343
344	name = nvpair_name(nvp);
345	(void) nvpair_value_boolean_value(nvp, &v);
346
347	if (strcmp(name, SES_PROP_FAIL) == 0)
348		kip->skci_rqst_fail = v;
349	else if (strcmp(name, SES_PROP_IDENT) == 0)
350		kip->skci_rqst_ident = v;
351	else
352		ses_panic("Bad property %s", name);
353
354	return (0);
355}
356
357static int
358elem_setprop_display(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
359    nvpair_t *nvp)
360{
361	ses2_display_ctl_impl_t *dip;
362	const char *name;
363	boolean_t v1;
364	uint16_t v16;
365	uint64_t v64;
366
367	if ((dip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
368	    page, 0, np, B_FALSE)) == NULL)
369		return (-1);
370
371
372	name = nvpair_name(nvp);
373
374	if (strcmp(name, SES_DPY_PROP_MODE) == 0) {
375		(void) nvpair_value_uint64(nvp, &v64);
376		dip->sdci_display_mode = v64;
377		return (0);
378	} else if (strcmp(name, SES_DPY_PROP_CHAR) == 0) {
379		(void) nvpair_value_uint16(nvp, &v16);
380		SCSI_WRITE16(&dip->sdci_display_character, v16);
381		return (0);
382	}
383
384	(void) nvpair_value_boolean_value(nvp, &v1);
385
386	if (strcmp(name, SES_PROP_FAIL) == 0)
387		dip->sdci_rqst_fail = v1;
388	else if (strcmp(name, SES_PROP_IDENT) == 0)
389		dip->sdci_rqst_ident = v1;
390	else
391		ses_panic("Bad property %s", name);
392	return (0);
393}
394
395static int
396elem_setprop_px(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
397    nvpair_t *nvp)
398{
399	ses2_port_ctl_impl_t *pip;
400	const char *name;
401	boolean_t v;
402
403	if ((pip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
404	    page, 0, np, B_FALSE)) == NULL)
405		return (-1);
406
407	name = nvpair_name(nvp);
408
409	(void) nvpair_value_boolean_value(nvp, &v);
410
411	if (strcmp(name, SES_PROP_FAIL) == 0)
412		pip->spci_rqst_fail = v;
413	else if (strcmp(name, SES_PROP_IDENT) == 0)
414		pip->spci_rqst_ident = v;
415	else if (strcmp(name, SES_PROP_DISABLED) == 0)
416		pip->spci_disable = v;
417	else
418		ses_panic("Bad property %s", name);
419
420	return (0);
421}
422
423static int
424elem_setprop_lang(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
425    nvpair_t *nvp)
426{
427	ses2_lang_ctl_impl_t *lip;
428	const char *name;
429	boolean_t v1;
430	uint64_t v64;
431
432	if ((lip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
433	    page, 0, np, B_FALSE)) == NULL)
434		return (-1);
435
436	name = nvpair_name(nvp);
437
438	if (strcmp(name, SES_LANG_PROP_LANGCODE) == 0) {
439		(void) nvpair_value_uint64(nvp, &v64);
440		SCSI_WRITE16(&lip->slci_language_code, v64);
441		return (0);
442	}
443
444	(void) nvpair_value_boolean_value(nvp, &v1);
445
446	if (strcmp(name, SES_PROP_IDENT) == 0)
447		lip->slci_rqst_ident = v1;
448	else
449		ses_panic("Bad property %s", name);
450
451	return (0);
452}
453
454static int
455elem_setprop_comm(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
456    nvpair_t *nvp)
457{
458	ses2_comm_ctl_impl_t *cip;
459	const char *name;
460	boolean_t v;
461
462	if ((cip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
463	    page, 0, np, B_FALSE)) == NULL)
464		return (-1);
465
466	name = nvpair_name(nvp);
467	(void) nvpair_value_boolean_value(nvp, &v);
468
469	if (strcmp(name, SES_PROP_FAIL) == 0)
470		cip->scci_rqst_fail = v;
471	else if (strcmp(name, SES_PROP_IDENT) == 0)
472		cip->scci_rqst_ident = v;
473	else if (strcmp(name, SES_PROP_DISABLED) == 0)
474		cip->scci_disable = v;
475	else
476		ses_panic("Bad property %s", name);
477
478	return (0);
479}
480
481static int
482elem_setprop_voltage(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
483    nvpair_t *nvp)
484{
485	ses2_voltage_ctl_impl_t *vip;
486	const char *name;
487	boolean_t v;
488
489	if ((vip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
490	    page, 0, np, B_FALSE)) == NULL)
491		return (-1);
492
493	name = nvpair_name(nvp);
494	(void) nvpair_value_boolean_value(nvp, &v);
495
496	if (strcmp(name, SES_PROP_FAIL) == 0)
497		vip->svci_rqst_fail = v;
498	else if (strcmp(name, SES_PROP_IDENT) == 0)
499		vip->svci_rqst_ident = v;
500	else
501		ses_panic("Bad property %s", name);
502
503	return (0);
504}
505
506static int
507elem_setprop_current(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
508    nvpair_t *nvp)
509{
510	ses2_current_ctl_impl_t *cip;
511	const char *name;
512	boolean_t v;
513
514	if ((cip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
515	    page, 0, np, B_FALSE)) == NULL)
516		return (-1);
517
518	name = nvpair_name(nvp);
519	(void) nvpair_value_boolean_value(nvp, &v);
520
521	if (strcmp(name, SES_PROP_FAIL) == 0)
522		cip->scci_rqst_fail = v;
523	else if (strcmp(name, SES_PROP_IDENT) == 0)
524		cip->scci_rqst_ident = v;
525	else
526		ses_panic("Bad property %s", name);
527
528	return (0);
529}
530
531static int
532elem_setprop_itp(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
533    nvpair_t *nvp)
534{
535	ses2_itp_ctl_impl_t *iip;
536	const char *name;
537	boolean_t v;
538
539	if ((iip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
540	    page, 0, np, B_FALSE)) == NULL)
541		return (-1);
542
543	name = nvpair_name(nvp);
544	(void) nvpair_value_boolean_value(nvp, &v);
545
546	if (strcmp(name, SES_PROP_FAIL) == 0)
547		iip->sici_rqst_fail = v;
548	else if (strcmp(name, SES_PROP_IDENT) == 0)
549		iip->sici_rqst_ident = v;
550	else if (strcmp(name, SES_ITP_PROP_ENABLED) == 0)
551		iip->sici_enable = v;
552	else
553		ses_panic("Bad property %s", name);
554
555	return (0);
556}
557
558static int
559elem_setprop_sse(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
560    nvpair_t *nvp)
561{
562	ses2_ss_ctl_impl_t *sip;
563	const char *name;
564	boolean_t v;
565
566	if ((sip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
567	    page, 0, np, B_FALSE)) == NULL)
568		return (-1);
569
570	name = nvpair_name(nvp);
571	(void) nvpair_value_boolean_value(nvp, &v);
572
573	if (strcmp(name, SES_PROP_FAIL) == 0)
574		sip->ssci_rqst_fail = v;
575	else if (strcmp(name, SES_PROP_IDENT) == 0)
576		sip->ssci_rqst_ident = v;
577	else
578		ses_panic("Bad property %s", name);
579
580	return (0);
581}
582
583static int
584elem_setprop_arraydev(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
585    nvpair_t *nvp)
586{
587	ses2_array_device_ctl_impl_t *aip;
588	const char *name;
589	boolean_t v;
590
591	if ((aip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
592	    page, 0, np, B_FALSE)) == NULL)
593		return (-1);
594
595	name = nvpair_name(nvp);
596	(void) nvpair_value_boolean_value(nvp, &v);
597
598	if (strcmp(name, SES_AD_PROP_RR_ABORT) == 0)
599		aip->sadci_rqst_rr_abort = v;
600	else if (strcmp(name, SES_AD_PROP_REBUILD) == 0)
601		aip->sadci_rqst_rebuild = v;
602	else if (strcmp(name, SES_AD_PROP_IN_FAILED_ARRAY) == 0)
603		aip->sadci_rqst_in_failed_array = v;
604	else if (strcmp(name, SES_AD_PROP_IN_CRIT_ARRAY) == 0)
605		aip->sadci_rqst_in_crit_array = v;
606	else if (strcmp(name, SES_AD_PROP_CONS_CHK) == 0)
607		aip->sadci_rqst_cons_check = v;
608	else if (strcmp(name, SES_AD_PROP_HOT_SPARE) == 0)
609		aip->sadci_rqst_hot_spare = v;
610	else if (strcmp(name, SES_AD_PROP_RSVD_DEVICE) == 0)
611		aip->sadci_rqst_rsvd_device = v;
612	else if (strcmp(name, SES_PROP_IDENT) == 0)
613		aip->sadci_rqst_ident = v;
614	else if (strcmp(name, SES_PROP_RMV) == 0)
615		aip->sadci_rqst_remove = v;
616	else if (strcmp(name, SES_DEV_PROP_READY_TO_INSERT) == 0)
617		aip->sadci_rqst_insert = v;
618	else if (strcmp(name, SES_DEV_PROP_REQ_MISSING) == 0)
619		aip->sadci_rqst_missing = v;
620	else if (strcmp(name, SES_DEV_PROP_DO_NOT_REMOVE) == 0)
621		aip->sadci_do_not_remove = v;
622	else if (strcmp(name, SES_DEV_PROP_REQ_ACTIVE) == 0)
623		aip->sadci_rqst_active = v;
624	else if (strcmp(name, SES_DEV_PROP_BYP_B) == 0)
625		aip->sadci_enable_byp_b = v;
626	else if (strcmp(name, SES_DEV_PROP_BYP_A) == 0)
627		aip->sadci_enable_byp_a = v;
628	else if (strcmp(name, SES_PROP_OFF) == 0)
629		aip->sadci_device_off = v;
630	else if (strcmp(name, SES_DEV_PROP_FAULT_RQSTD) == 0)
631		aip->sadci_rqst_fault = v;
632	else
633		ses_panic("Bad property %s", name);
634
635	return (0);
636}
637
638static int
639elem_setprop_expander(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
640    nvpair_t *nvp)
641{
642	ses2_expander_ctl_impl_t *eip;
643	const char *name;
644	boolean_t v;
645
646	if ((eip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
647	    page, 0, np, B_FALSE)) == NULL)
648		return (-1);
649
650	name = nvpair_name(nvp);
651	(void) nvpair_value_boolean_value(nvp, &v);
652
653	if (strcmp(name, SES_PROP_FAIL) == 0)
654		eip->seci_rqst_fail = v;
655	else if (strcmp(name, SES_PROP_IDENT) == 0)
656		eip->seci_rqst_ident = v;
657	else
658		ses_panic("Bad property %s", name);
659
660	return (0);
661}
662
663static int
664elem_setprop_sasconn(ses_plugin_t *sp, ses_node_t *np, ses2_diag_page_t page,
665    nvpair_t *nvp)
666{
667	ses2_sasconn_ctl_impl_t *sip;
668	const char *name;
669	boolean_t v;
670
671	if ((sip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
672	    page, 0, np, B_FALSE)) == NULL)
673		return (-1);
674
675	name = nvpair_name(nvp);
676	(void) nvpair_value_boolean_value(nvp, &v);
677
678	if (strcmp(name, SES_PROP_IDENT) == 0)
679		sip->ssci_rqst_ident = v;
680	else if (strcmp(name, SES_PROP_FAIL) == 0)
681		sip->ssci_rqst_fail = v;
682	else
683		ses_panic("Bad property %s", name);
684
685	return (0);
686}
687
688static int
689elem_common_setprop_threshold(ses_plugin_t *sp, ses_node_t *np,
690    ses2_diag_page_t page, nvpair_t *nvp)
691{
692	ses2_threshold_impl_t *tip;
693	ses2_threshold_in_page_impl_t *tp;
694	ses2_threshold_out_page_impl_t *tpout;
695	const char *name;
696	uint64_t v;
697	size_t len = 0;
698	size_t i, trnums;
699
700	ASSERT(page == SES2_DIAGPAGE_THRESHOLD_IO);
701
702	if ((tip = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
703	    page, 0, np, B_FALSE)) == NULL)
704		return (-1);
705
706	/* Get whole IN and OUT pages to copy filled thresholds */
707	if ((tpout = ses_plugin_ctlpage_lookup(sp, ses_node_snapshot(np),
708	    page, 0, NULL, B_FALSE)) == NULL)
709		return (-1);
710	if ((tp = ses_plugin_page_lookup(sp, ses_node_snapshot(np),
711	    page, NULL, &len)) == NULL)
712		return (-1);
713
714	len -= offsetof(ses2_threshold_in_page_impl_t, stipi_thresholds[0]);
715	trnums = len / sizeof (ses2_threshold_impl_t);
716
717	/* Do copy filled thresholds from In to Out page */
718	for (i = 0; i < trnums; i++) {
719		boolean_t filled = B_FALSE;
720		ses2_threshold_impl_t *toutp = &tpout->stopi_thresholds[i];
721		ses2_threshold_impl_t *tinp = &tp->stipi_thresholds[i];
722
723		if (tinp->sti_high_crit != 0 || tinp->sti_high_warn != 0 ||
724		    tinp->sti_low_crit != 0 || tinp->sti_low_warn != 0)
725			filled = B_TRUE;
726
727		if (toutp->sti_high_crit == 0 && toutp->sti_high_warn == 0 &&
728		    toutp->sti_low_crit == 0 && toutp->sti_low_warn == 0 &&
729		    filled)
730			*toutp = *tinp;
731	}
732
733	name = nvpair_name(nvp);
734	(void) nvpair_value_uint64(nvp, &v);
735
736	if (strcmp(name, SES_PROP_THRESH_CRIT_HI) == 0)
737		tip->sti_high_crit = v;
738	else if (strcmp(name, SES_PROP_THRESH_CRIT_LO) == 0)
739		tip->sti_low_crit = v;
740	else if (strcmp(name, SES_PROP_THRESH_WARN_HI) == 0)
741		tip->sti_high_warn = v;
742	else if (strcmp(name, SES_PROP_THRESH_WARN_LO) == 0)
743		tip->sti_low_warn = v;
744	else
745		ses_panic("Bad property %s", name);
746
747	return (0);
748}
749
750#define	SES_THRESHOLD_CTL_PROPS	\
751{	\
752	.scp_name = SES_PROP_THRESH_CRIT_HI,	\
753	.scp_type = DATA_TYPE_UINT64,	\
754	.scp_num = SES2_DIAGPAGE_THRESHOLD_IO,	\
755	.scp_setprop = elem_common_setprop_threshold	\
756},	\
757{	\
758	.scp_name = SES_PROP_THRESH_WARN_HI,	\
759	.scp_type = DATA_TYPE_UINT64,	\
760	.scp_num = SES2_DIAGPAGE_THRESHOLD_IO,	\
761	.scp_setprop = elem_common_setprop_threshold	\
762},	\
763{	\
764	.scp_name = SES_PROP_THRESH_CRIT_LO,	\
765	.scp_type = DATA_TYPE_UINT64,	\
766	.scp_num = SES2_DIAGPAGE_THRESHOLD_IO,	\
767	.scp_setprop = elem_common_setprop_threshold	\
768},	\
769{	\
770	.scp_name = SES_PROP_THRESH_WARN_LO,	\
771	.scp_type = DATA_TYPE_UINT64,	\
772	.scp_num = SES2_DIAGPAGE_THRESHOLD_IO,	\
773	.scp_setprop = elem_common_setprop_threshold	\
774}
775
776static const ses2_ctl_prop_t device_props[] = {
777	SES_COMMON_CTL_PROPS,
778{
779	.scp_name = SES_PROP_IDENT,
780	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
781	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
782	.scp_setprop = elem_setprop_device,
783},
784{
785	.scp_name = SES_PROP_RMV,
786	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
787	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
788	.scp_setprop = elem_setprop_device,
789},
790{
791	.scp_name = SES_DEV_PROP_READY_TO_INSERT,
792	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
793	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
794	.scp_setprop = elem_setprop_device,
795},
796{
797	.scp_name = SES_DEV_PROP_REQ_MISSING,
798	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
799	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
800	.scp_setprop = elem_setprop_device,
801},
802{
803	.scp_name = SES_DEV_PROP_DO_NOT_REMOVE,
804	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
805	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
806	.scp_setprop = elem_setprop_device,
807},
808{
809	.scp_name = SES_DEV_PROP_REQ_ACTIVE,
810	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
811	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
812	.scp_setprop = elem_setprop_device,
813},
814{
815	.scp_name = SES_DEV_PROP_BYP_B,
816	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
817	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
818	.scp_setprop = elem_setprop_device,
819},
820{
821	.scp_name = SES_DEV_PROP_BYP_A,
822	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
823	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
824	.scp_setprop = elem_setprop_device,
825},
826{
827	.scp_name = SES_PROP_OFF,
828	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
829	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
830	.scp_setprop = elem_setprop_device,
831},
832{
833	.scp_name = SES_DEV_PROP_FAULT_RQSTD,
834	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
835	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
836	.scp_setprop = elem_setprop_device,
837},
838{
839	NULL
840}
841};
842
843static const ses2_ctl_prop_t psu_props[] = {
844	SES_COMMON_CTL_PROPS,
845{
846	.scp_name = SES_PROP_IDENT,
847	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
848	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
849	.scp_setprop = elem_setprop_psu
850},
851{
852	.scp_name = SES_PROP_REQUESTED_ON,
853	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
854	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
855	.scp_setprop = elem_setprop_psu
856},
857{
858	.scp_name = SES_PROP_FAIL,
859	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
860	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
861	.scp_setprop = elem_setprop_psu
862},
863{
864	NULL
865}
866};
867
868static const ses2_ctl_prop_t cooling_props[] = {
869	SES_COMMON_CTL_PROPS,
870{
871	.scp_name = SES_PROP_IDENT,
872	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
873	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
874	.scp_setprop = elem_setprop_cooling
875},
876{
877	.scp_name = SES_COOLING_PROP_SPEED_CODE,
878	.scp_type = DATA_TYPE_UINT64,
879	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
880	.scp_setprop = elem_setprop_cooling
881},
882{
883	.scp_name = SES_PROP_REQUESTED_ON,
884	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
885	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
886	.scp_setprop = elem_setprop_cooling
887},
888{
889	.scp_name = SES_PROP_FAIL,
890	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
891	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
892	.scp_setprop = elem_setprop_cooling
893},
894{
895	NULL
896}
897};
898
899static const ses2_ctl_prop_t temp_props[] = {
900	SES_COMMON_CTL_PROPS,
901	SES_THRESHOLD_CTL_PROPS,
902{
903	.scp_name = SES_PROP_FAIL,
904	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
905	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
906	.scp_setprop = elem_setprop_temp
907},
908{
909	.scp_name = SES_PROP_IDENT,
910	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
911	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
912	.scp_setprop = elem_setprop_temp
913},
914{
915	NULL
916}
917};
918
919static const ses2_ctl_prop_t lock_props[] = {
920	SES_COMMON_CTL_PROPS,
921{
922	.scp_name = SES_PROP_FAIL,
923	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
924	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
925	.scp_setprop = elem_setprop_lock
926},
927{
928	.scp_name = SES_PROP_IDENT,
929	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
930	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
931	.scp_setprop = elem_setprop_lock
932},
933{
934	.scp_name = SES_LOCK_PROP_UNLOCKED,
935	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
936	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
937	.scp_setprop = elem_setprop_lock
938},
939{
940	NULL
941}
942};
943
944static const ses2_ctl_prop_t alarm_props[] = {
945	SES_COMMON_CTL_PROPS,
946{
947	.scp_name = SES_PROP_FAIL,
948	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
949	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
950	.scp_setprop = elem_setprop_alarm
951},
952{
953	.scp_name = SES_PROP_IDENT,
954	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
955	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
956	.scp_setprop = elem_setprop_alarm
957},
958{
959	.scp_name = SES_ALARM_PROP_UNRECOV,
960	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
961	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
962	.scp_setprop = elem_setprop_alarm
963},
964{
965	.scp_name = SES_ALARM_PROP_CRIT,
966	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
967	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
968	.scp_setprop = elem_setprop_alarm
969},
970{
971	.scp_name = SES_ALARM_PROP_NONCRIT,
972	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
973	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
974	.scp_setprop = elem_setprop_alarm
975},
976{
977	.scp_name = SES_ALARM_PROP_INFO,
978	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
979	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
980	.scp_setprop = elem_setprop_alarm
981},
982{
983	.scp_name = SES_ALARM_PROP_REMIND,
984	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
985	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
986	.scp_setprop = elem_setprop_alarm
987},
988{
989	.scp_name = SES_ALARM_PROP_MUTED,
990	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
991	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
992	.scp_setprop = elem_setprop_alarm
993},
994{
995	NULL
996}
997};
998
999static const ses2_ctl_prop_t esc_props[] = {
1000	SES_COMMON_CTL_PROPS,
1001{
1002	.scp_name = SES_PROP_FAIL,
1003	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1004	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1005	.scp_setprop = elem_setprop_esc
1006},
1007{
1008	.scp_name = SES_PROP_IDENT,
1009	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1010	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1011	.scp_setprop = elem_setprop_esc
1012},
1013{
1014	.scp_name = SES_ESC_PROP_SELECT,
1015	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1016	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1017	.scp_setprop = elem_setprop_esc
1018},
1019{
1020	NULL
1021}
1022};
1023
1024static const ses2_ctl_prop_t scc_props[] = {
1025	SES_COMMON_CTL_PROPS,
1026{
1027	.scp_name = SES_PROP_FAIL,
1028	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1029	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1030	.scp_setprop = elem_setprop_scc
1031},
1032{
1033	.scp_name = SES_PROP_IDENT,
1034	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1035	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1036	.scp_setprop = elem_setprop_scc
1037},
1038{
1039	NULL
1040}
1041};
1042
1043static const ses2_ctl_prop_t cache_props[] = {
1044	SES_COMMON_CTL_PROPS,
1045{
1046	.scp_name = SES_PROP_FAIL,
1047	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1048	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1049	.scp_setprop = elem_setprop_cache
1050},
1051{
1052	.scp_name = SES_PROP_IDENT,
1053	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1054	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1055	.scp_setprop = elem_setprop_cache
1056},
1057{
1058	NULL
1059}
1060};
1061
1062static const ses2_ctl_prop_t ups_props[] = {
1063	SES_COMMON_CTL_PROPS,
1064	SES_THRESHOLD_CTL_PROPS,
1065{
1066	.scp_name = SES_PROP_FAIL,
1067	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1068	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1069	.scp_setprop = elem_setprop_ups
1070},
1071{
1072	.scp_name = SES_PROP_IDENT,
1073	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1074	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1075	.scp_setprop = elem_setprop_ups
1076},
1077{
1078	NULL
1079}
1080};
1081
1082static const ses2_ctl_prop_t display_props[] = {
1083	SES_COMMON_CTL_PROPS,
1084{
1085	.scp_name = SES_DPY_PROP_MODE,
1086	.scp_type = DATA_TYPE_UINT64,
1087	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1088	.scp_setprop = elem_setprop_display
1089},
1090{
1091	.scp_name = SES_PROP_FAIL,
1092	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1093	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1094	.scp_setprop = elem_setprop_display
1095},
1096{
1097	.scp_name = SES_PROP_IDENT,
1098	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1099	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1100	.scp_setprop = elem_setprop_display
1101},
1102{
1103	.scp_name = SES_DPY_PROP_CHAR,
1104	.scp_type = DATA_TYPE_UINT16,
1105	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1106	.scp_setprop = elem_setprop_display
1107},
1108{
1109	NULL
1110}
1111};
1112
1113static const ses2_ctl_prop_t keypad_props[] = {
1114	SES_COMMON_CTL_PROPS,
1115{
1116	.scp_name = SES_PROP_FAIL,
1117	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1118	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1119	.scp_setprop = elem_setprop_keypad
1120},
1121{
1122	.scp_name = SES_PROP_IDENT,
1123	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1124	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1125	.scp_setprop = elem_setprop_keypad
1126},
1127{
1128	NULL
1129}
1130};
1131
1132static const ses2_ctl_prop_t px_props[] = {
1133	SES_COMMON_CTL_PROPS,
1134{
1135	.scp_name = SES_PROP_FAIL,
1136	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1137	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1138	.scp_setprop = elem_setprop_px
1139},
1140{
1141	.scp_name = SES_PROP_IDENT,
1142	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1143	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1144	.scp_setprop = elem_setprop_px
1145},
1146{
1147	.scp_name = SES_PROP_DISABLED,
1148	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1149	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1150	.scp_setprop = elem_setprop_px
1151},
1152{
1153	NULL
1154}
1155};
1156
1157static const ses2_ctl_prop_t lang_props[] = {
1158	SES_COMMON_CTL_PROPS,
1159{
1160	.scp_name = SES_PROP_IDENT,
1161	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1162	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1163	.scp_setprop = elem_setprop_lang
1164},
1165{
1166	.scp_name = SES_LANG_PROP_LANGCODE,
1167	.scp_type = DATA_TYPE_UINT64,
1168	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1169	.scp_setprop = elem_setprop_lang
1170},
1171{
1172	NULL
1173}
1174};
1175
1176static const ses2_ctl_prop_t comm_props[] = {
1177	SES_COMMON_CTL_PROPS,
1178{
1179	.scp_name = SES_PROP_FAIL,
1180	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1181	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1182	.scp_setprop = elem_setprop_comm
1183},
1184{
1185	.scp_name = SES_PROP_IDENT,
1186	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1187	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1188	.scp_setprop = elem_setprop_comm
1189},
1190{
1191	.scp_name = SES_PROP_DISABLED,
1192	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1193	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1194	.scp_setprop = elem_setprop_comm
1195},
1196{
1197	NULL
1198}
1199};
1200
1201static const ses2_ctl_prop_t voltage_props[] = {
1202	SES_COMMON_CTL_PROPS,
1203	SES_THRESHOLD_CTL_PROPS,
1204{
1205	.scp_name = SES_PROP_FAIL,
1206	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1207	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1208	.scp_setprop = elem_setprop_voltage
1209},
1210{
1211	.scp_name = SES_PROP_IDENT,
1212	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1213	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1214	.scp_setprop = elem_setprop_voltage
1215},
1216{
1217	NULL
1218}
1219};
1220
1221static const ses2_ctl_prop_t current_props[] = {
1222	SES_COMMON_CTL_PROPS,
1223	SES_THRESHOLD_CTL_PROPS,
1224{
1225	.scp_name = SES_PROP_FAIL,
1226	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1227	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1228	.scp_setprop = elem_setprop_current
1229},
1230{
1231	.scp_name = SES_PROP_IDENT,
1232	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1233	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1234	.scp_setprop = elem_setprop_current
1235},
1236{
1237	NULL
1238}
1239};
1240
1241static const ses2_ctl_prop_t itp_props[] = {
1242	SES_COMMON_CTL_PROPS,
1243{
1244	.scp_name = SES_PROP_FAIL,
1245	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1246	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1247	.scp_setprop = elem_setprop_itp
1248},
1249{
1250	.scp_name = SES_PROP_IDENT,
1251	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1252	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1253	.scp_setprop = elem_setprop_itp
1254},
1255{
1256	.scp_name = SES_ITP_PROP_ENABLED,
1257	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1258	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1259	.scp_setprop = elem_setprop_itp
1260},
1261{
1262	NULL
1263}
1264};
1265
1266static const ses2_ctl_prop_t sse_props[] = {
1267	SES_COMMON_CTL_PROPS,
1268{
1269	.scp_name = SES_PROP_FAIL,
1270	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1271	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1272	.scp_setprop = elem_setprop_sse
1273},
1274{
1275	.scp_name = SES_PROP_IDENT,
1276	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1277	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1278	.scp_setprop = elem_setprop_sse
1279},
1280{
1281	NULL
1282}
1283};
1284
1285static const ses2_ctl_prop_t arraydev_props[] = {
1286	SES_COMMON_CTL_PROPS,
1287{
1288	.scp_name = SES_AD_PROP_RR_ABORT,
1289	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1290	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1291	.scp_setprop = elem_setprop_arraydev
1292},
1293{
1294	.scp_name = SES_AD_PROP_REBUILD,
1295	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1296	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1297	.scp_setprop = elem_setprop_arraydev
1298},
1299{
1300	.scp_name = SES_AD_PROP_IN_FAILED_ARRAY,
1301	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1302	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1303	.scp_setprop = elem_setprop_arraydev
1304},
1305{
1306	.scp_name = SES_AD_PROP_IN_CRIT_ARRAY,
1307	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1308	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1309	.scp_setprop = elem_setprop_arraydev
1310},
1311{
1312	.scp_name = SES_AD_PROP_CONS_CHK,
1313	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1314	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1315	.scp_setprop = elem_setprop_arraydev
1316},
1317{
1318	.scp_name = SES_AD_PROP_HOT_SPARE,
1319	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1320	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1321	.scp_setprop = elem_setprop_arraydev
1322},
1323{
1324	.scp_name = SES_AD_PROP_RSVD_DEVICE,
1325	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1326	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1327	.scp_setprop = elem_setprop_arraydev
1328},
1329{
1330	.scp_name = SES_AD_PROP_OK,
1331	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1332	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1333	.scp_setprop = elem_setprop_arraydev
1334},
1335{
1336	.scp_name = SES_PROP_IDENT,
1337	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1338	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1339	.scp_setprop = elem_setprop_arraydev
1340},
1341{
1342	.scp_name = SES_PROP_RMV,
1343	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1344	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1345	.scp_setprop = elem_setprop_arraydev
1346},
1347{
1348	.scp_name = SES_DEV_PROP_READY_TO_INSERT,
1349	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1350	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1351	.scp_setprop = elem_setprop_arraydev
1352},
1353{
1354	.scp_name = SES_DEV_PROP_REQ_MISSING,
1355	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1356	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1357	.scp_setprop = elem_setprop_arraydev
1358},
1359{
1360	.scp_name = SES_DEV_PROP_DO_NOT_REMOVE,
1361	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1362	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1363	.scp_setprop = elem_setprop_arraydev
1364},
1365{
1366	.scp_name = SES_DEV_PROP_REQ_ACTIVE,
1367	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1368	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1369	.scp_setprop = elem_setprop_arraydev
1370},
1371{
1372	.scp_name = SES_DEV_PROP_BYP_B,
1373	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1374	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1375	.scp_setprop = elem_setprop_arraydev
1376},
1377{
1378	.scp_name = SES_DEV_PROP_BYP_A,
1379	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1380	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1381	.scp_setprop = elem_setprop_arraydev
1382},
1383{
1384	.scp_name = SES_PROP_OFF,
1385	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1386	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1387	.scp_setprop = elem_setprop_arraydev
1388},
1389{
1390	.scp_name = SES_DEV_PROP_FAULT_RQSTD,
1391	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1392	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1393	.scp_setprop = elem_setprop_arraydev
1394},
1395{
1396	NULL
1397}
1398};
1399
1400static const ses2_ctl_prop_t expander_props[] = {
1401	SES_COMMON_CTL_PROPS,
1402{
1403	.scp_name = SES_PROP_FAIL,
1404	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1405	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1406	.scp_setprop = elem_setprop_expander
1407},
1408{
1409	.scp_name = SES_PROP_IDENT,
1410	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1411	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1412	.scp_setprop = elem_setprop_expander
1413},
1414{
1415	NULL
1416}
1417};
1418
1419static const ses2_ctl_prop_t sasconn_props[] = {
1420	SES_COMMON_CTL_PROPS,
1421{
1422	.scp_name = SES_PROP_IDENT,
1423	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1424	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1425	.scp_setprop = elem_setprop_sasconn
1426},
1427{
1428	.scp_name = SES_PROP_FAIL,
1429	.scp_type = DATA_TYPE_BOOLEAN_VALUE,
1430	.scp_num = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
1431	.scp_setprop = elem_setprop_sasconn
1432},
1433{
1434	NULL
1435}
1436};
1437
1438/*ARGSUSED*/
1439static int
1440elem_setdef_threshold(ses_node_t *np, ses2_diag_page_t page, void *data)
1441{
1442	ses2_threshold_impl_t *tip = data;
1443	nvlist_t *props = ses_node_props(np);
1444
1445	SES_NV_CTL64(props, SES_PROP_THRESH_CRIT_HI, tip->sti_high_crit);
1446	SES_NV_CTL64(props, SES_PROP_THRESH_CRIT_LO, tip->sti_low_crit);
1447	SES_NV_CTL64(props, SES_PROP_THRESH_WARN_HI, tip->sti_high_warn);
1448	SES_NV_CTL64(props, SES_PROP_THRESH_WARN_LO, tip->sti_low_warn);
1449
1450	return (0);
1451}
1452
1453/*ARGSUSED*/
1454static int
1455elem_setdef_device(ses_node_t *np, ses2_diag_page_t page, void *data)
1456{
1457	ses2_device_ctl_impl_t *dip = data;
1458	nvlist_t *props = ses_node_props(np);
1459
1460	SES_NV_CTLBOOL(props, SES_PROP_IDENT, dip->sdci_rqst_ident);
1461	SES_NV_CTLBOOL(props, SES_PROP_RMV, dip->sdci_rqst_remove);
1462	SES_NV_CTLBOOL(props, SES_DEV_PROP_READY_TO_INSERT,
1463	    dip->sdci_rqst_insert);
1464	SES_NV_CTLBOOL(props, SES_DEV_PROP_REQ_MISSING,
1465	    dip->sdci_rqst_missing);
1466	SES_NV_CTLBOOL(props, SES_DEV_PROP_DO_NOT_REMOVE,
1467	    dip->sdci_do_not_remove);
1468	SES_NV_CTLBOOL(props, SES_DEV_PROP_REQ_ACTIVE,
1469	    dip->sdci_rqst_active);
1470	SES_NV_CTLBOOL(props, SES_DEV_PROP_BYP_B, dip->sdci_enable_byp_b);
1471	SES_NV_CTLBOOL(props, SES_DEV_PROP_BYP_A, dip->sdci_enable_byp_a);
1472	SES_NV_CTLBOOL(props, SES_PROP_OFF, dip->sdci_device_off);
1473	SES_NV_CTLBOOL(props, SES_DEV_PROP_FAULT_RQSTD,
1474	    dip->sdci_rqst_fault);
1475
1476	return (0);
1477}
1478
1479/*ARGSUSED*/
1480static int
1481elem_setdef_psu(ses_node_t *np, ses2_diag_page_t page, void *data)
1482{
1483	ses2_psu_ctl_impl_t *pip = data;
1484	nvlist_t *props = ses_node_props(np);
1485
1486	SES_NV_CTLBOOL(props, SES_PROP_IDENT, pip->spci_rqst_ident);
1487	SES_NV_CTLBOOL(props, SES_PROP_REQUESTED_ON, pip->spci_rqst_on);
1488	SES_NV_CTLBOOL(props, SES_PROP_FAIL, pip->spci_rqst_fail);
1489
1490	return (0);
1491}
1492
1493/*ARGSUSED*/
1494static int
1495elem_setdef_cooling(ses_node_t *np, ses2_diag_page_t page, void *data)
1496{
1497	ses2_cooling_ctl_impl_t *cip = data;
1498	nvlist_t *props = ses_node_props(np);
1499
1500	SES_NV_CTLBOOL(props, SES_PROP_IDENT, cip->scci_rqst_ident);
1501	SES_NV_CTL64(props, SES_COOLING_PROP_SPEED_CODE,
1502	    cip->scci_requested_speed_code);
1503	SES_NV_CTLBOOL(props, SES_PROP_REQUESTED_ON, cip->scci_rqst_on);
1504	SES_NV_CTLBOOL(props, SES_PROP_FAIL, cip->scci_rqst_fail);
1505
1506	return (0);
1507}
1508
1509/*ARGSUSED*/
1510static int
1511elem_setdef_temp(ses_node_t *np, ses2_diag_page_t page, void *data)
1512{
1513	ses2_temp_ctl_impl_t *tip = data;
1514	nvlist_t *props = ses_node_props(np);
1515
1516	if (page == SES2_DIAGPAGE_THRESHOLD_IO)
1517		return (elem_setdef_threshold(np, page, data));
1518
1519	SES_NV_CTLBOOL(props, SES_PROP_FAIL, tip->stci_rqst_fail);
1520	SES_NV_CTLBOOL(props, SES_PROP_IDENT, tip->stci_rqst_ident);
1521
1522	return (0);
1523}
1524
1525/*ARGSUSED*/
1526static int
1527elem_setdef_lock(ses_node_t *np, ses2_diag_page_t page, void *data)
1528{
1529	ses2_lock_ctl_impl_t *lip = data;
1530	nvlist_t *props = ses_node_props(np);
1531
1532	SES_NV_CTLBOOL(props, SES_PROP_FAIL, lip->slci_rqst_fail);
1533	SES_NV_CTLBOOL(props, SES_PROP_IDENT, lip->slci_rqst_ident);
1534	SES_NV_CTLBOOL(props, SES_LOCK_PROP_UNLOCKED, lip->slci_unlock);
1535
1536	return (0);
1537}
1538
1539/*ARGSUSED*/
1540static int
1541elem_setdef_alarm(ses_node_t *np, ses2_diag_page_t page, void *data)
1542{
1543	ses2_alarm_ctl_impl_t *aip = data;
1544	nvlist_t *props = ses_node_props(np);
1545
1546	SES_NV_CTLBOOL(props, SES_PROP_FAIL, aip->saci_rqst_fail);
1547	SES_NV_CTLBOOL(props, SES_PROP_IDENT, aip->saci_rqst_ident);
1548	SES_NV_CTLBOOL(props, SES_ALARM_PROP_UNRECOV, aip->saci_unrecov);
1549	SES_NV_CTLBOOL(props, SES_ALARM_PROP_CRIT, aip->saci_crit);
1550	SES_NV_CTLBOOL(props, SES_ALARM_PROP_NONCRIT, aip->saci_noncrit);
1551	SES_NV_CTLBOOL(props, SES_ALARM_PROP_INFO, aip->saci_info);
1552	SES_NV_CTLBOOL(props, SES_ALARM_PROP_REMIND, aip->saci_set_remind);
1553	SES_NV_CTLBOOL(props, SES_ALARM_PROP_MUTED, aip->saci_set_mute);
1554
1555	return (0);
1556}
1557
1558/*ARGSUSED*/
1559static int
1560elem_setdef_esc(ses_node_t *np, ses2_diag_page_t page, void *data)
1561{
1562	ses2_controller_ctl_impl_t *cip = data;
1563	nvlist_t *props = ses_node_props(np);
1564
1565	SES_NV_CTLBOOL(props, SES_PROP_FAIL, cip->scci_rqst_fail);
1566	SES_NV_CTLBOOL(props, SES_PROP_IDENT, cip->scci_rqst_ident);
1567	SES_NV_CTLBOOL(props, SES_ESC_PROP_SELECT,
1568	    cip->scci_select_element);
1569
1570	return (0);
1571}
1572
1573/*ARGSUSED*/
1574static int
1575elem_setdef_scc(ses_node_t *np, ses2_diag_page_t page, void *data)
1576{
1577	ses2_scc_ctl_impl_t *sip = data;
1578	nvlist_t *props = ses_node_props(np);
1579
1580	SES_NV_CTLBOOL(props, SES_PROP_FAIL, sip->ssci_rqst_fail);
1581	SES_NV_CTLBOOL(props, SES_PROP_IDENT, sip->ssci_rqst_ident);
1582
1583	return (0);
1584}
1585
1586/*ARGSUSED*/
1587static int
1588elem_setdef_cache(ses_node_t *np, ses2_diag_page_t page, void *data)
1589{
1590	ses2_nvcache_ctl_impl_t *cip = data;
1591	nvlist_t *props = ses_node_props(np);
1592
1593	SES_NV_CTLBOOL(props, SES_PROP_FAIL, cip->snci_rqst_fail);
1594	SES_NV_CTLBOOL(props, SES_PROP_IDENT, cip->snci_rqst_ident);
1595
1596	return (0);
1597}
1598
1599static int
1600elem_setdef_ups(ses_node_t *np, ses2_diag_page_t page, void *data)
1601{
1602	ses2_ups_ctl_impl_t *uip = data;
1603	nvlist_t *props = ses_node_props(np);
1604
1605	if (page == SES2_DIAGPAGE_THRESHOLD_IO)
1606		return (elem_setdef_threshold(np, page, data));
1607
1608	SES_NV_CTLBOOL(props, SES_PROP_FAIL, uip->suci_rqst_fail);
1609	SES_NV_CTLBOOL(props, SES_PROP_IDENT, uip->suci_rqst_ident);
1610
1611	return (0);
1612}
1613
1614/*ARGSUSED*/
1615static int
1616elem_setdef_display(ses_node_t *np, ses2_diag_page_t page, void *data)
1617{
1618	ses2_display_ctl_impl_t *dip = data;
1619	nvlist_t *props = ses_node_props(np);
1620
1621	SES_NV_CTL64(props, SES_DPY_PROP_MODE, dip->sdci_display_mode);
1622	SES_NV_CTLBOOL(props, SES_PROP_FAIL, dip->sdci_rqst_fail);
1623	SES_NV_CTLBOOL(props, SES_PROP_IDENT, dip->sdci_rqst_ident);
1624	SES_NV_CTL16(props, SES_DPY_PROP_CHAR,
1625	    dip->sdci_display_character);
1626
1627	return (0);
1628}
1629
1630/*ARGSUSED*/
1631static int
1632elem_setdef_keypad(ses_node_t *np, ses2_diag_page_t page, void *data)
1633{
1634	ses2_keypad_ctl_impl_t *kip = data;
1635	nvlist_t *props = ses_node_props(np);
1636
1637	SES_NV_CTLBOOL(props, SES_PROP_FAIL, kip->skci_rqst_fail);
1638	SES_NV_CTLBOOL(props, SES_PROP_IDENT, kip->skci_rqst_ident);
1639
1640	return (0);
1641}
1642
1643/*ARGSUSED*/
1644static int
1645elem_setdef_px(ses_node_t *np, ses2_diag_page_t page, void *data)
1646{
1647	ses2_port_ctl_impl_t *pip = data;
1648	nvlist_t *props = ses_node_props(np);
1649
1650	SES_NV_CTLBOOL(props, SES_PROP_FAIL, pip->spci_rqst_fail);
1651	SES_NV_CTLBOOL(props, SES_PROP_IDENT, pip->spci_rqst_ident);
1652	SES_NV_CTLBOOL(props, SES_PROP_DISABLED, pip->spci_disable);
1653
1654	return (0);
1655}
1656
1657/*ARGSUSED*/
1658static int
1659elem_setdef_lang(ses_node_t *np, ses2_diag_page_t page, void *data)
1660{
1661	ses2_lang_ctl_impl_t *lip = data;
1662	nvlist_t *props = ses_node_props(np);
1663
1664	SES_NV_CTLBOOL(props, SES_PROP_IDENT, lip->slci_rqst_ident);
1665	SES_NV_CTL16(props, SES_LANG_PROP_LANGCODE,
1666	    lip->slci_language_code);
1667
1668	return (0);
1669}
1670
1671/*ARGSUSED*/
1672static int
1673elem_setdef_comm(ses_node_t *np, ses2_diag_page_t page, void *data)
1674{
1675	ses2_comm_ctl_impl_t *cip = data;
1676	nvlist_t *props = ses_node_props(np);
1677
1678	SES_NV_CTLBOOL(props, SES_PROP_FAIL, cip->scci_rqst_fail);
1679	SES_NV_CTLBOOL(props, SES_PROP_IDENT, cip->scci_rqst_ident);
1680	SES_NV_CTLBOOL(props, SES_PROP_DISABLED, cip->scci_disable);
1681
1682	return (0);
1683}
1684
1685static int
1686elem_setdef_voltage(ses_node_t *np, ses2_diag_page_t page, void *data)
1687{
1688	ses2_voltage_ctl_impl_t *vip = data;
1689	nvlist_t *props = ses_node_props(np);
1690
1691	if (page == SES2_DIAGPAGE_THRESHOLD_IO)
1692		return (elem_setdef_threshold(np, page, data));
1693
1694	SES_NV_CTLBOOL(props, SES_PROP_FAIL, vip->svci_rqst_fail);
1695	SES_NV_CTLBOOL(props, SES_PROP_IDENT, vip->svci_rqst_ident);
1696
1697	return (0);
1698}
1699
1700static int
1701elem_setdef_current(ses_node_t *np, ses2_diag_page_t page, void *data)
1702{
1703	ses2_current_ctl_impl_t *cip = data;
1704	nvlist_t *props = ses_node_props(np);
1705
1706	if (page == SES2_DIAGPAGE_THRESHOLD_IO)
1707		return (elem_setdef_threshold(np, page, data));
1708
1709	SES_NV_CTLBOOL(props, SES_PROP_FAIL, cip->scci_rqst_fail);
1710	SES_NV_CTLBOOL(props, SES_PROP_IDENT, cip->scci_rqst_ident);
1711
1712	return (0);
1713}
1714
1715/*ARGSUSED*/
1716static int
1717elem_setdef_itp(ses_node_t *np, ses2_diag_page_t page, void *data)
1718{
1719	ses2_itp_ctl_impl_t *iip = data;
1720	nvlist_t *props = ses_node_props(np);
1721
1722	SES_NV_CTLBOOL(props, SES_PROP_FAIL, iip->sici_rqst_fail);
1723	SES_NV_CTLBOOL(props, SES_PROP_IDENT, iip->sici_rqst_ident);
1724	SES_NV_CTLBOOL(props, SES_ITP_PROP_ENABLED, iip->sici_enable);
1725
1726	return (0);
1727}
1728
1729/*ARGSUSED*/
1730static int
1731elem_setdef_sse(ses_node_t *np, ses2_diag_page_t page, void *data)
1732{
1733	ses2_ss_ctl_impl_t *sip = data;
1734	nvlist_t *props = ses_node_props(np);
1735
1736	SES_NV_CTLBOOL(props, SES_PROP_FAIL, sip->ssci_rqst_fail);
1737	SES_NV_CTLBOOL(props, SES_PROP_IDENT, sip->ssci_rqst_ident);
1738
1739	return (0);
1740}
1741
1742/*ARGSUSED*/
1743static int
1744elem_setdef_arraydev(ses_node_t *np, ses2_diag_page_t page, void *data)
1745{
1746	ses2_array_device_ctl_impl_t *aip = data;
1747	nvlist_t *props = ses_node_props(np);
1748
1749	SES_NV_CTLBOOL(props, SES_AD_PROP_RR_ABORT,
1750	    aip->sadci_rqst_rr_abort);
1751	SES_NV_CTLBOOL(props, SES_AD_PROP_REBUILD,
1752	    aip->sadci_rqst_rebuild);
1753	SES_NV_CTLBOOL(props, SES_AD_PROP_IN_FAILED_ARRAY,
1754	    aip->sadci_rqst_in_failed_array);
1755	SES_NV_CTLBOOL(props, SES_AD_PROP_IN_CRIT_ARRAY,
1756	    aip->sadci_rqst_in_crit_array);
1757	SES_NV_CTLBOOL(props, SES_AD_PROP_CONS_CHK,
1758	    aip->sadci_rqst_cons_check);
1759	SES_NV_CTLBOOL(props, SES_AD_PROP_HOT_SPARE,
1760	    aip->sadci_rqst_hot_spare);
1761	SES_NV_CTLBOOL(props, SES_AD_PROP_RSVD_DEVICE,
1762	    aip->sadci_rqst_rsvd_device);
1763
1764	SES_NV_CTLBOOL(props, SES_PROP_IDENT, aip->sadci_rqst_ident);
1765	SES_NV_CTLBOOL(props, SES_PROP_RMV, aip->sadci_rqst_remove);
1766	SES_NV_CTLBOOL(props, SES_DEV_PROP_READY_TO_INSERT,
1767	    aip->sadci_rqst_insert);
1768	SES_NV_CTLBOOL(props, SES_DEV_PROP_REQ_MISSING,
1769	    aip->sadci_rqst_missing);
1770	SES_NV_CTLBOOL(props, SES_DEV_PROP_DO_NOT_REMOVE,
1771	    aip->sadci_do_not_remove);
1772	SES_NV_CTLBOOL(props, SES_DEV_PROP_REQ_ACTIVE,
1773	    aip->sadci_rqst_active);
1774
1775	SES_NV_CTLBOOL(props, SES_DEV_PROP_BYP_B, aip->sadci_enable_byp_b);
1776	SES_NV_CTLBOOL(props, SES_DEV_PROP_BYP_A, aip->sadci_enable_byp_a);
1777	SES_NV_CTLBOOL(props, SES_PROP_OFF, aip->sadci_device_off);
1778	SES_NV_CTLBOOL(props, SES_DEV_PROP_FAULT_RQSTD,
1779	    aip->sadci_rqst_fault);
1780
1781	return (0);
1782}
1783
1784/*ARGSUSED*/
1785static int
1786elem_setdef_expander(ses_node_t *np, ses2_diag_page_t page, void *data)
1787{
1788	ses2_expander_ctl_impl_t *eip = data;
1789	nvlist_t *props = ses_node_props(np);
1790
1791	SES_NV_CTLBOOL(props, SES_PROP_FAIL, eip->seci_rqst_fail);
1792	SES_NV_CTLBOOL(props, SES_PROP_IDENT, eip->seci_rqst_ident);
1793
1794	return (0);
1795}
1796
1797/*ARGSUSED*/
1798static int
1799elem_setdef_sasconn(ses_node_t *np, ses2_diag_page_t page, void *data)
1800{
1801	ses2_sasconn_ctl_impl_t *sip = data;
1802	nvlist_t *props = ses_node_props(np);
1803
1804	SES_NV_CTLBOOL(props, SES_PROP_IDENT, sip->ssci_rqst_ident);
1805	SES_NV_CTLBOOL(props, SES_PROP_FAIL, sip->ssci_rqst_fail);
1806
1807	return (0);
1808}
1809
1810#define	CTL_DESC(_e, _n)	\
1811	{	\
1812		.scd_et = _e,	\
1813		.scd_props = _n##_props,	\
1814		.scd_setdef = elem_setdef_##_n	\
1815	}
1816
1817static const ses2_ctl_desc_t ctl_descs[] = {
1818	CTL_DESC(SES_ET_DEVICE, device),
1819	CTL_DESC(SES_ET_POWER_SUPPLY, psu),
1820	CTL_DESC(SES_ET_COOLING, cooling),
1821	CTL_DESC(SES_ET_TEMPERATURE_SENSOR, temp),
1822	CTL_DESC(SES_ET_DOOR_LOCK, lock),
1823	CTL_DESC(SES_ET_AUDIBLE_ALARM, alarm),
1824	CTL_DESC(SES_ET_ESC_ELECTRONICS, esc),
1825	CTL_DESC(SES_ET_SCC_ELECTRONICS, scc),
1826	CTL_DESC(SES_ET_NONVOLATILE_CACHE, cache),
1827	CTL_DESC(SES_ET_UPS, ups),
1828	CTL_DESC(SES_ET_DISPLAY, display),
1829	CTL_DESC(SES_ET_KEY_PAD_ENTRY, keypad),
1830	CTL_DESC(SES_ET_SCSI_PORT_XCVR, px),
1831	CTL_DESC(SES_ET_LANGUAGE, lang),
1832	CTL_DESC(SES_ET_COMMUNICATION_PORT, comm),
1833	CTL_DESC(SES_ET_VOLTAGE_SENSOR, voltage),
1834	CTL_DESC(SES_ET_CURRENT_SENSOR, current),
1835	CTL_DESC(SES_ET_SCSI_TARGET_PORT, itp),
1836	CTL_DESC(SES_ET_SCSI_INITIATOR_PORT, itp),
1837	CTL_DESC(SES_ET_SIMPLE_SUBENCLOSURE, sse),
1838	CTL_DESC(SES_ET_ARRAY_DEVICE, arraydev),
1839	CTL_DESC(SES_ET_SAS_EXPANDER, expander),
1840	CTL_DESC(SES_ET_SAS_CONNECTOR, sasconn),
1841	{ .scd_et = -1 }
1842};
1843
1844int
1845ses2_element_ctl(ses_plugin_t *sp, ses_node_t *np, const char *op,
1846    nvlist_t *nvl)
1847{
1848	const ses2_ctl_desc_t *dp;
1849	nvlist_t *props = ses_node_props(np);
1850	uint64_t type;
1851
1852	if (strcmp(op, SES_CTL_OP_SETPROP) != 0)
1853		return (0);
1854
1855	VERIFY(nvlist_lookup_uint64(props, SES_PROP_ELEMENT_TYPE,
1856	    &type) == 0);
1857
1858	for (dp = &ctl_descs[0]; dp->scd_et != -1; dp++)
1859		if (dp->scd_et == type)
1860			break;
1861
1862	if (dp->scd_et == -1)
1863		return (0);
1864
1865	return (ses2_setprop(sp, np, dp->scd_props, nvl));
1866}
1867
1868int
1869ses2_element_setdef(ses_node_t *np, ses2_diag_page_t page, void *data)
1870{
1871	const ses2_ctl_desc_t *dp;
1872	nvlist_t *props = ses_node_props(np);
1873	uint64_t type;
1874
1875	VERIFY(nvlist_lookup_uint64(props, SES_PROP_ELEMENT_TYPE, &type) == 0);
1876
1877	for (dp = &ctl_descs[0]; dp->scd_et != -1; dp++)
1878		if (dp->scd_et == type)
1879			break;
1880
1881	if (dp->scd_et == -1)
1882		return (0);
1883
1884	if (dp->scd_setdef(np, page, data) != 0)
1885		return (-1);
1886
1887	return (0);
1888}
1889