2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#include <sys/types.h>
2N/A#include <stddef.h>
2N/A#include <stdio.h>
2N/A#include <string.h>
2N/A#include <libnvpair.h>
2N/A
2N/A#include <scsi/libses.h>
2N/A#include <scsi/libses_plugin.h>
2N/A#include <scsi/plugins/ses/framework/ses2.h>
2N/A#include <scsi/plugins/ses/framework/ses2_impl.h>
2N/A#include <scsi/plugins/ses/vendor/sun.h>
2N/A#include <scsi/plugins/ses/vendor/sun_impl.h>
2N/A
2N/Astatic int
2N/Aelem_parse_sunw_fanmodule(const ses2_elem_status_impl_t *esip, nvlist_t *nvl)
2N/A{
2N/A sun_fanmodule_status_impl_t *fip = (sun_fanmodule_status_impl_t *)esip;
2N/A int nverr;
2N/A
2N/A SES_NV_ADD(boolean_value, nverr, nvl, SES_PROP_IDENT, fip->sfsi_ident);
2N/A SES_NV_ADD(boolean_value, nverr, nvl, SES_PROP_FAIL, fip->sfsi_fail);
2N/A
2N/A return (0);
2N/A}
2N/A
2N/Astatic const struct status_parser {
2N/A ses2_element_type_t type;
2N/A int (*func)(const ses2_elem_status_impl_t *, nvlist_t *);
2N/A} status_parsers[] = {
2N/A { SES_ET_SUNW_FANMODULE, elem_parse_sunw_fanmodule },
2N/A { (ses2_element_type_t)-1, NULL }
2N/A};
2N/A
2N/Astatic int
2N/Aelem_parse_sd(ses_plugin_t *spp, ses_node_t *np)
2N/A{
2N/A ses2_elem_status_impl_t *esip;
2N/A const struct status_parser *sp;
2N/A nvlist_t *nvl = ses_node_props(np);
2N/A size_t len;
2N/A int nverr;
2N/A uint64_t type;
2N/A
2N/A if ((esip = ses_plugin_page_lookup(spp,
2N/A ses_node_snapshot(np), SES2_DIAGPAGE_ENCLOSURE_CTL_STATUS,
2N/A np, &len)) == NULL)
2N/A return (0);
2N/A
2N/A VERIFY(nvlist_lookup_uint64(nvl, SES_PROP_ELEMENT_TYPE,
2N/A &type) == 0);
2N/A
2N/A SES_NV_ADD(uint64, nverr, nvl, SES_PROP_STATUS_CODE,
2N/A esip->sesi_common.sesi_status_code);
2N/A SES_NV_ADD(boolean_value, nverr, nvl, SES_PROP_SWAP,
2N/A esip->sesi_common.sesi_swap);
2N/A SES_NV_ADD(boolean_value, nverr, nvl, SES_PROP_DISABLED,
2N/A esip->sesi_common.sesi_disabled);
2N/A SES_NV_ADD(boolean_value, nverr, nvl, SES_PROP_PRDFAIL,
2N/A esip->sesi_common.sesi_prdfail);
2N/A
2N/A for (sp = &status_parsers[0]; sp->type != (ses2_element_type_t)-1; sp++)
2N/A if (sp->type == type && sp->func != NULL)
2N/A return (sp->func(esip, nvl));
2N/A
2N/A return (0);
2N/A}
2N/A
2N/Astatic int
2N/Aelem_parse_descr(ses_plugin_t *sp, ses_node_t *np)
2N/A{
2N/A char *desc;
2N/A size_t len;
2N/A nvlist_t *props = ses_node_props(np);
2N/A int nverr;
2N/A
2N/A if ((desc = ses_plugin_page_lookup(sp, ses_node_snapshot(np),
2N/A SES2_DIAGPAGE_ELEMENT_DESC, np, &len)) == NULL)
2N/A return (0);
2N/A
2N/A SES_NV_ADD(fixed_string, nverr, props, SES_PROP_DESCRIPTION,
2N/A desc, len);
2N/A
2N/A return (0);
2N/A}
2N/A
2N/Aint
2N/Asun_fill_element_node(ses_plugin_t *sp, ses_node_t *np)
2N/A{
2N/A ses_snap_t *snap = ses_node_snapshot(np);
2N/A nvlist_t *props = ses_node_props(np);
2N/A sun_fru_descr_impl_t *sfdip;
2N/A size_t len;
2N/A int err;
2N/A
2N/A if ((err = elem_parse_sd(sp, np)) != 0)
2N/A return (err);
2N/A
2N/A if ((err = elem_parse_descr(sp, np)) != 0)
2N/A return (err);
2N/A
2N/A if ((sfdip = ses_plugin_page_lookup(sp, snap,
2N/A SUN_DIAGPAGE_FRUID, np, &len)) != NULL) {
2N/A if ((err = sun_fruid_parse_common(sfdip, props)) != 0)
2N/A return (err);
2N/A }
2N/A
2N/A return (0);
2N/A}