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 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#include <assert.h>
2N/A#include <pthread.h>
2N/A#include <strings.h>
2N/A#include <sys/fm/protocol.h>
2N/A
2N/A#include <topo_alloc.h>
2N/A#include <topo_error.h>
2N/A#include <topo_method.h>
2N/A#include <topo_prop.h>
2N/A#include <topo_protocol.h>
2N/A#include <topo_subr.h>
2N/A
2N/A#include <libtopo.h>
2N/A
2N/Aint
2N/Atopo_node_asru(tnode_t *node, nvlist_t **asru, nvlist_t *priv, int *err)
2N/A{
2N/A nvlist_t *prop, *ap;
2N/A
2N/A if (topo_prop_getprop(node, TOPO_PGROUP_PROTOCOL,
2N/A TOPO_PROP_ASRU, priv, &prop, err) < 0)
2N/A return (-1);
2N/A
2N/A if (nvlist_lookup_nvlist(prop, TOPO_PROP_VAL_VAL, &ap) != 0 ||
2N/A topo_hdl_nvdup(node->tn_hdl, ap, asru) < 0) {
2N/A *err = ETOPO_PROP_NVL;
2N/A nvlist_free(prop);
2N/A return (-1);
2N/A }
2N/A
2N/A nvlist_free(prop);
2N/A
2N/A return (0);
2N/A}
2N/A
2N/Aint
2N/Atopo_node_fru(tnode_t *node, nvlist_t **fru, nvlist_t *priv, int *err)
2N/A{
2N/A nvlist_t *prop, *fp;
2N/A
2N/A if (topo_prop_getprop(node, TOPO_PGROUP_PROTOCOL, TOPO_PROP_FRU,
2N/A priv, &prop, err) < 0)
2N/A return (-1);
2N/A
2N/A if (nvlist_lookup_nvlist(prop, TOPO_PROP_VAL_VAL, &fp) != 0 ||
2N/A topo_hdl_nvdup(node->tn_hdl, fp, fru) < 0) {
2N/A *err = ETOPO_PROP_NVL;
2N/A nvlist_free(prop);
2N/A return (-1);
2N/A }
2N/A
2N/A nvlist_free(prop);
2N/A
2N/A return (0);
2N/A}
2N/A
2N/Aint
2N/Atopo_node_resource(tnode_t *node, nvlist_t **resource, int *err)
2N/A{
2N/A
2N/A return (topo_prop_get_fmri(node, TOPO_PGROUP_PROTOCOL,
2N/A TOPO_PROP_RESOURCE, resource, err));
2N/A}
2N/A
2N/Aint
2N/Atopo_node_label(tnode_t *node, char **label, int *err)
2N/A{
2N/A
2N/A return (topo_prop_get_string(node, TOPO_PGROUP_PROTOCOL,
2N/A TOPO_PROP_LABEL, label, err));
2N/A}
2N/A
2N/Aint
2N/Atopo_node_asru_set(tnode_t *node, nvlist_t *asru, int flag, int *err)
2N/A{
2N/A /*
2N/A * Inherit ASRU property from our parent if asru not specified
2N/A */
2N/A if (asru == NULL) {
2N/A if (topo_prop_inherit(node, TOPO_PGROUP_PROTOCOL,
2N/A TOPO_PROP_ASRU, err) < 0) {
2N/A return (-1);
2N/A }
2N/A
2N/A return (0);
2N/A }
2N/A
2N/A if (flag & TOPO_ASRU_COMPUTE) {
2N/A if (topo_prop_method_register(node, TOPO_PGROUP_PROTOCOL,
2N/A TOPO_PROP_ASRU, TOPO_TYPE_FMRI, TOPO_METH_ASRU_COMPUTE,
2N/A asru, err) < 0)
2N/A return (-1);
2N/A } else {
2N/A if (topo_prop_set_fmri(node, TOPO_PGROUP_PROTOCOL,
2N/A TOPO_PROP_ASRU, TOPO_PROP_IMMUTABLE, asru, err) < 0)
2N/A return (-1);
2N/A }
2N/A
2N/A return (0);
2N/A}
2N/A
2N/Aint
2N/Atopo_node_fru_set(tnode_t *node, nvlist_t *fru, int flag, int *err)
2N/A{
2N/A
2N/A /*
2N/A * Inherit FRU property from our parent if not specified
2N/A */
2N/A if (fru == NULL) {
2N/A if (topo_prop_inherit(node, TOPO_PGROUP_PROTOCOL, TOPO_PROP_FRU,
2N/A err) < 0) {
2N/A return (-1);
2N/A }
2N/A } else if (flag & TOPO_FRU_COMPUTE) {
2N/A if (topo_prop_method_register(node, TOPO_PGROUP_PROTOCOL,
2N/A TOPO_PROP_FRU, TOPO_TYPE_FMRI, TOPO_METH_FRU_COMPUTE,
2N/A fru, err) < 0)
2N/A return (-1);
2N/A } else {
2N/A if (topo_prop_set_fmri(node, TOPO_PGROUP_PROTOCOL,
2N/A TOPO_PROP_FRU, TOPO_PROP_IMMUTABLE, fru, err) < 0)
2N/A return (-1);
2N/A }
2N/A
2N/A
2N/A return (0);
2N/A}
2N/A
2N/Aint
2N/Atopo_node_label_set(tnode_t *node, char *label, int *err)
2N/A{
2N/A
2N/A /*
2N/A * Inherit FRU property from our parent if * not specified
2N/A */
2N/A if (label == NULL) {
2N/A if (topo_prop_inherit(node, TOPO_PGROUP_PROTOCOL,
2N/A TOPO_PROP_LABEL, err) < 0) {
2N/A return (-1);
2N/A }
2N/A } else {
2N/A if (topo_prop_set_string(node, TOPO_PGROUP_PROTOCOL,
2N/A TOPO_PROP_LABEL, TOPO_PROP_IMMUTABLE, label, err) < 0)
2N/A return (-1);
2N/A }
2N/A
2N/A return (0);
2N/A}