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 /*
  23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 #include <stddef.h>
  27 #include <string.h>
  28 #include <strings.h>
  29 #include <alloca.h>
  30 #include <libnvpair.h>
  31 
  32 #include <scsi/libses.h>
  33 #include <scsi/libses_plugin.h>
  34 #include <scsi/plugins/ses/framework/libses.h>
  35 #include <scsi/plugins/ses/vendor/sun.h>
  36 #include <scsi/plugins/ses/vendor/sun_impl.h>
  37 
  38 #include "../../../../../../lib/libfru/libnvfru/nvfru.h"
  39 
  40 int
  41 sun_fruid_parse_common(sun_fru_descr_impl_t *sfdip, nvlist_t *nvl)
  42 {
  43         int nverr;
  44 
  45         SES_NV_ADD(boolean_value, nverr, nvl,
  46             LIBSES_PROP_FRU, sfdip-> sfdi_fru);
  47         SES_NV_ADD(uint64, nverr, nvl,
  48             LIBSES_PROP_PHYS_PARENT, sfdip->sfdi_parent_element_index);
  49 
  50         return (0);
  51 }
  52 
  53 static int
  54 sun_node_parse(ses_plugin_t *sp, ses_node_t *np)
  55 {
  56         switch (ses_node_type(np)) {
  57         case SES_NODE_ENCLOSURE:
  58                 return (sun_fill_enclosure_node(sp, np));
  59 
  60         case SES_NODE_AGGREGATE:
  61         case SES_NODE_ELEMENT:
  62                 return (sun_fill_element_node(sp, np));
  63 
  64         default:
  65                 return (0);
  66         }
  67 }
  68 
  69 int
  70 _ses_init(ses_plugin_t *sp)
  71 {
  72         ses_plugin_config_t config = {
  73                 .spc_pages = sun_pages,
  74                 .spc_node_parse = sun_node_parse
  75         };
  76 
  77         return (ses_plugin_register(sp, LIBSES_PLUGIN_VERSION,
  78             &config) != 0);
  79 }