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