275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * CDDL HEADER START
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * The contents of this file are subject to the terms of the
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * Common Development and Distribution License (the "License").
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * You may not use this file except in compliance with the License.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * See the License for the specific language governing permissions
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * and limitations under the License.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * When distributing Covered Code, include this CDDL HEADER in each
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * If applicable, add the following below this CDDL HEADER, with the
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * fields enclosed by brackets "[]" replaced with your own identifying
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * information: Portions Copyright [yyyy] [name of copyright owner]
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * CDDL HEADER END
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
a8be79fa54c16403e012b2993a3edbe079777feeAlexander Stetsenko * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_ctl_common_setdef(ses_node_t *np, ses2_diag_page_t page, void *data)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock return (0);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock SES_NV_CTLBOOL_INVERT(props, SES_PROP_SWAP, eip->seci_rst_swap);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock SES_NV_CTLBOOL(props, SES_PROP_DISABLED, eip->seci_disable);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock SES_NV_CTLBOOL(props, SES_PROP_PRDFAIL, eip->seci_prdfail);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock return (0);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockstatic void *
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_aes_index(ses_plugin_t *sp, ses_node_t *np, void *data, size_t pagelen,
ed0f0083c8d203139464f17b5910f25f44b9e48aHyon Kim VERIFY(nvlist_lookup_uint64(props, SES_PROP_ELEMENT_ONLY_INDEX,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock VERIFY(nvlist_lookup_uint64(props, SES_PROP_ELEMENT_TYPE,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock if (pagelen < offsetof(ses2_aes_page_impl_t, sapi_data))
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock return (0);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock for (dep = (ses2_aes_descr_eip_impl_t *)apip->sapi_data, pos = 0, i = 0;
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock dep = (ses2_aes_descr_eip_impl_t *)(apip->sapi_data + pos), i++) {
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_aes_descr_eip_impl_t, sadei_length) +
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * We can't really do anything with this, because
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * while the standard requires that these descriptors
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * be in the same order as those in the status page,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * some element types may optionally include AES
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * data. This means we cannot know which element
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * this descriptor refers to unless EIP is 1. Sadly,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * the standard only says that this "should" be true.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * It's impossible to guess what use this is supposed
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * to have otherwise. See 6.1.13.1.
ed0f0083c8d203139464f17b5910f25f44b9e48aHyon Kim * The element index field from AES descriptor is
ed0f0083c8d203139464f17b5910f25f44b9e48aHyon Kim * element only index which doesn't include the OVERALL
ed0f0083c8d203139464f17b5910f25f44b9e48aHyon Kim * STATUS fields so we should compare with
ed0f0083c8d203139464f17b5910f25f44b9e48aHyon Kim * SES_PROP_ELEMENT_ONLY_INDEX not
ed0f0083c8d203139464f17b5910f25f44b9e48aHyon Kim * SES_PROP_ELEMENT_INDEX.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockstatic void *
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_threshold_index(ses_plugin_t *sp, ses_node_t *np, void *data,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock VERIFY(nvlist_lookup_uint64(props, SES_PROP_ELEMENT_INDEX,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockstatic void *
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_element_index(ses_plugin_t *sp, ses_node_t *np, void *data,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock if (nvlist_lookup_uint64(props, SES_PROP_ELEMENT_INDEX, &index) != 0)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock if (!SES_WITHIN_PAGE(data, sizeof (*dp), data, pagelen))
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * This variable-length list of variable-length strings format sucks
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * for performance; we ALWAYS have to walk the whole bloody thing to
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock * find a particular node's entry.
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock for (i = 0, dp = (ses2_elem_descriptor_impl_t *)edip->sedpi_data;
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock *len + offsetof(ses2_elem_descriptor_impl_t, sedi_descriptor),
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockstatic void *
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_status_index(ses_plugin_t *sp, ses_node_t *np, void *data,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock if (nvlist_lookup_uint64(props, SES_PROP_ELEMENT_INDEX,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock if ((index + 1) * sizeof (ses2_elem_status_impl_t) +
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_status_page_impl_t, sspi_data) > pagelen)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock return ((ses2_elem_status_impl_t *)spip->sspi_data + index);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_ctl_len(uint_t nelem, int page, size_t datalen)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock ASSERT(page == SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockstatic void *
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_ctl_fill(ses_plugin_t *sp, void *pagedata, size_t pagelen,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock ses2_diag_page_t page = SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS;
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock if (nvlist_lookup_uint64(props, SES_PROP_ELEMENT_INDEX,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock (void) ses_error(ESES_BAD_RESPONSE, "missing element index "
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock "for enclosure node");
a8be79fa54c16403e012b2993a3edbe079777feeAlexander Stetsenko * if control element was already modified "select" field is non-zero,
a8be79fa54c16403e012b2993a3edbe079777feeAlexander Stetsenko * so skip setting default values to avoid fields overriding
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_stringout_len(uint_t nelem, int page, size_t datalen)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock return (datalen + offsetof(ses2_string_out_page_impl_t, ssopi_data[0]));
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_threshout_len(uint_t nelem, int page, size_t datalen)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_threshold_out_page_impl_t, stopi_thresholds[0]));
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockstatic void *
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_threshout_ctl_fill(ses_plugin_t *sp, void *pagedata, size_t pagelen,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock ses2_diag_page_t page = SES2_DIAGPAGE_THRESHOLD_IO;
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock VERIFY(nvlist_lookup_uint64(props, SES_PROP_ELEMENT_INDEX,
a8be79fa54c16403e012b2993a3edbe079777feeAlexander Stetsenko data = tip = &pip->stopi_thresholds[index];
a8be79fa54c16403e012b2993a3edbe079777feeAlexander Stetsenko /* check if threshold is dirty, so no need to set default values */
a8be79fa54c16403e012b2993a3edbe079777feeAlexander Stetsenko if ((tip->sti_high_crit | tip->sti_low_crit | tip->sti_high_warn |
a8be79fa54c16403e012b2993a3edbe079777feeAlexander Stetsenko if (ses2_element_setdef(np, page, data) != 0)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_substrout_len(uint_t nelem, int page, size_t datalen)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock ASSERT(page == SES2_DIAGPAGE_SUBENCLOSURE_STRING_IO);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_substring_out_page_impl_t, ssopi_data[0]));
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_ucodeout_len(uint_t nelem, int page, size_t datalen)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock ASSERT(page == SES2_DIAGPAGE_DL_MICROCODE_CTL_STATUS);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_ucode_ctl_page_impl_t, sucpi_ucode_data[0]);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockstatic void *
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_ucodeout_ctl_fill(ses_plugin_t *sp, void *data, size_t pagelen,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock "microcode download page only valid for enclosure "
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock VERIFY(nvlist_lookup_uint64(props, SES_EN_PROP_EID, &eid) == 0);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/*ARGSUSED*/
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrockses2_subnickout_len(uint_t nelem, int page, size_t datalen)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock ASSERT(page == SES2_DIAGPAGE_SUBENCLOSURE_NICKNAME_CTL_STATUS);
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock return (sizeof (ses2_subnick_ctl_page_impl_t));
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_gcoff = offsetof(ses2_config_page_impl_t, scpi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_gcoff = offsetof(ses2_status_page_impl_t, sspi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_threshold_in_page_impl_t, stipi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_gcoff = offsetof(ses2_elem_desc_page_impl_t, sedpi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_gcoff = offsetof(ses2_aes_page_impl_t, sapi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_pagenum = SES2_DIAGPAGE_SUBENCLOSURE_HELP_TEXT,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_gcoff = offsetof(ses2_subhelp_page_impl_t, sspi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_pagenum = SES2_DIAGPAGE_SUBENCLOSURE_STRING_IO,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_substring_in_page_impl_t, ssipi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_pagenum = SES2_DIAGPAGE_DL_MICROCODE_CTL_STATUS,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_ucode_status_page_impl_t, suspi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_pagenum = SES2_DIAGPAGE_SUBENCLOSURE_NICKNAME_CTL_STATUS,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_subnick_status_page_impl_t, sspci_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock/* Control pages */
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_gcoff = offsetof(ses2_control_page_impl_t, scpi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_threshold_out_page_impl_t, stopi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_pagenum = SES2_DIAGPAGE_SUBENCLOSURE_STRING_IO,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_substring_out_page_impl_t, ssopi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_pagenum = SES2_DIAGPAGE_DL_MICROCODE_CTL_STATUS,
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock offsetof(ses2_ucode_ctl_page_impl_t, sucpi_generation_code)
275c9da86e89f8abf71135cf63d9fc23671b2e60eschrock .spd_pagenum = SES2_DIAGPAGE_SUBENCLOSURE_NICKNAME_CTL_STATUS,