usr/src/lib/fm/topo/libtopo/common/topo_node.c
author Robert Johnston <Robert.Johnston@Sun.COM>
Tue, 01 Sep 2009 13:28:49 -0700
changeset 10438 dac6771300a8
parent 8526 8159d305568c
child 10462 ec0e4f3134ef
permissions -rw-r--r--
6875268 missing power supplies may be reported as faulted 6874918 sensor-transport produces ereports too aggresively 6877019 topo_node_facility tries to release lock it doesn't own
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
     1
/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
     2
 * CDDL HEADER START
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
     3
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
     5
 * Common Development and Distribution License (the "License").
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
     6
 * You may not use this file except in compliance with the License.
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
     7
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    11
 * and limitations under the License.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    12
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    18
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    19
 * CDDL HEADER END
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    20
 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    21
/*
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7585
diff changeset
    22
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    23
 * Use is subject to license terms.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    24
 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    25
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    26
/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    27
 * Topology Nodes
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    28
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    29
 * Topology nodes, tnode_t, are data structures containing per-FMRI
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    30
 * information and are linked together to form the topology tree.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    31
 * Nodes are created during the enumeration process of topo_snap_hold()
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    32
 * and destroyed during topo_snap_rele().  For the most part, tnode_t data
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    33
 * is read-only and no lock protection is required.  Nodes are
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    34
 * held in place during tree walk functions.  Tree walk functions
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    35
 * may access node data safely without locks.  The exception to this rule
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    36
 * is data associated with node properties (topo_prop.c).  Properties
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    37
 * may change at anytime and are protected by a per-property locking
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    38
 * strategy.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    39
 *
4087
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    40
 * Enumerator plugin modules may also safely access topology nodes within their
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    41
 * scope of operation: the parent node passed into the enumeration op or those
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    42
 * nodes created by the enumerator.  Enumeration occurs only during
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    43
 * topo_snap_hold() where a per-topo_hdl_t lock prevents multi-threaded access
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    44
 * to the topology trees.
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    45
 *
4087
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    46
 * Enumerator method operation functions may safely access and change topology
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    47
 * node property data, and contruct or destroy child nodes for the node
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    48
 * on which the operation applies.  The method may also be called to destroy
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    49
 * the node for which the method operation is called.  This permits
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    50
 * dynamic topology tree snapshots and partial enumerations for branches that
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    51
 * may not be needed right away.
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    52
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    53
 * Node Interfaces
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    54
 *
4087
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    55
 * Nodes are created when an enumerator calls topo_node_bind().  Prior to
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    56
 * calling topo_node_bind(), the enumerator should have reserved a range of
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    57
 * node instances with topo_node_range_create().  topo_node_range_create()
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    58
 * does not allocate any node resources but creates the infrastruture
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    59
 * required for a fully populated topology level.  This allows enumerators
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    60
 * reading from a <scheme>-topology.xml file to parse the file for a range
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    61
 * of resources before confirming the existence of a resource via a helper
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    62
 * plugin.  Only when the resource has been confirmed to exist should
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    63
 * the node be bound.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    64
 *
4087
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    65
 * Node range and node linkage and unlinkage is performed during enumeration and
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    66
 * method operations when it is safe to change node hash lists. Nodes and node
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    67
 * ranges are deallocated when all references to the node have been released:
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    68
 * last walk completes and topo_snap_rele() is called.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    69
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    70
 * Node Hash/Ranges
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    71
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    72
 * Each parent node may have one or more ranges of child nodes.  Each range
4087
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    73
 * is uniquely named and serves as a hash list of like sibling nodes with
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    74
 * different instance numbers.  A parent may have more than one node hash
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    75
 * (child range). If that is the case, the hash lists are strung together to
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    76
 * form sibling relationships between ranges.  Hash/Ranges are sparsely
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    77
 * populated with only nodes that have represented resources in the system.
4087
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    78
 *
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    79
 *	_________________
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    80
 *	|		|
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    81
 *      |   tnode_t	|    -----------------------------
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    82
 *      |      tn_phash ---> |  topo_nodehash_t          |
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    83
 *      |     (children)|    |     th_nodearr (instances)|
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    84
 *      -----------------    |     -------------------   |
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    85
 *                           |  ---| 0 | 1  | ...| N |   |
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    86
 *                           |  |  -------------------   |  -------------------
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    87
 *                           |  |  th_list (siblings) ----->| topo_nodehash_t |
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    88
 *                           |  |                        |  -------------------
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    89
 *                           ---|-------------------------
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    90
 *                              |
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    91
 *                              v
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    92
 *                           -----------
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    93
 *                           | tnode_t |
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
    94
 *                           -----------
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
    95
 *
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
    96
 * Facility Nodes
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
    97
 *
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
    98
 * Facility nodes are always leaf nodes in the topology and represent a FMRI
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
    99
 * sensor or indicator facility for the path to which it is connected.
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   100
 * Facility nodes are bound to the topology with topo_node_facbind() and
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   101
 * unbound with topo_node_unbind().
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   102
 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   103
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   104
#include <assert.h>
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   105
#include <pthread.h>
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   106
#include <strings.h>
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   107
#include <sys/fm/protocol.h>
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   108
#include <topo_alloc.h>
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   109
#include <topo_error.h>
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   110
#include <topo_list.h>
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   111
#include <topo_method.h>
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   112
#include <topo_subr.h>
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   113
#include <topo_tree.h>
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   114
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   115
static topo_pgroup_info_t protocol_pgroup = {
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   116
	TOPO_PGROUP_PROTOCOL,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   117
	TOPO_STABILITY_PRIVATE,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   118
	TOPO_STABILITY_PRIVATE,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   119
	1
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   120
};
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   121
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   122
static const topo_pgroup_info_t auth_pgroup = {
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   123
	FM_FMRI_AUTHORITY,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   124
	TOPO_STABILITY_PRIVATE,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   125
	TOPO_STABILITY_PRIVATE,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   126
	1
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   127
};
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   128
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   129
static void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   130
topo_node_destroy(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   131
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   132
	int i;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   133
	tnode_t *pnode = node->tn_parent;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   134
	topo_nodehash_t *nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   135
	topo_mod_t *hmod, *mod = node->tn_enum;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   136
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   137
	if (node == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   138
		return;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   139
4328
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   140
	topo_dprintf(mod->tm_hdl, TOPO_DBG_MODSVC, "destroying node %s=%d\n",
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   141
	    topo_node_name(node), topo_node_instance(node));
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   142
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   143
	assert(node->tn_refs == 0);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   144
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   145
	/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   146
	 * If not a root node, remove this node from the parent's node hash
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   147
	 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   148
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   149
	if (!(node->tn_state & TOPO_NODE_ROOT)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   150
		topo_node_lock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   151
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   152
		nhp = node->tn_phash;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   153
		for (i = 0; i < nhp->th_arrlen; i++) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   154
			if (node == nhp->th_nodearr[i]) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   155
				nhp->th_nodearr[i] = NULL;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   156
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   157
				/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   158
				 * Release hold on parent
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   159
				 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   160
				--pnode->tn_refs;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   161
				if (pnode->tn_refs == 0)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   162
					topo_node_destroy(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   163
			}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   164
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   165
		topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   166
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   167
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   168
	topo_node_unlock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   169
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   170
	/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   171
	 * Allow enumerator to clean-up private data and then release
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   172
	 * ref count
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   173
	 */
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   174
	if (mod->tm_info->tmi_ops->tmo_release != NULL)
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   175
		mod->tm_info->tmi_ops->tmo_release(mod, node);
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   176
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   177
	topo_method_unregister_all(mod, node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   178
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   179
	/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   180
	 * Destroy all node hash lists
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   181
	 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   182
	while ((nhp = topo_list_next(&node->tn_children)) != NULL) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   183
		for (i = 0; i < nhp->th_arrlen; i++) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   184
			assert(nhp->th_nodearr[i] == NULL);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   185
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   186
		hmod = nhp->th_enum;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   187
		topo_mod_strfree(hmod, nhp->th_name);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   188
		topo_mod_free(hmod, nhp->th_nodearr,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   189
		    nhp->th_arrlen * sizeof (tnode_t *));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   190
		topo_list_delete(&node->tn_children, nhp);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   191
		topo_mod_free(hmod, nhp, sizeof (topo_nodehash_t));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   192
		topo_mod_rele(hmod);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   193
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   194
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   195
	/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   196
	 * Destroy all property data structures, free the node and release
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   197
	 * the module that created it
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   198
	 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   199
	topo_pgroup_destroy_all(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   200
	topo_mod_free(mod, node, sizeof (tnode_t));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   201
	topo_mod_rele(mod);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   202
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   203
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   204
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   205
topo_node_lock(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   206
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   207
	(void) pthread_mutex_lock(&node->tn_lock);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   208
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   209
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   210
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   211
topo_node_unlock(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   212
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   213
	(void) pthread_mutex_unlock(&node->tn_lock);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   214
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   215
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   216
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   217
topo_node_hold(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   218
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   219
	topo_node_lock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   220
	++node->tn_refs;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   221
	topo_node_unlock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   222
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   223
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   224
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   225
topo_node_rele(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   226
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   227
	topo_node_lock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   228
	--node->tn_refs;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   229
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   230
	/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   231
	 * Ok to remove this node from the topo tree and destroy it
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   232
	 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   233
	if (node->tn_refs == 0)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   234
		topo_node_destroy(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   235
	else
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   236
		topo_node_unlock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   237
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   238
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   239
char *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   240
topo_node_name(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   241
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   242
	return (node->tn_name);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   243
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   244
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   245
topo_instance_t
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   246
topo_node_instance(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   247
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   248
	return (node->tn_instance);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   249
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   250
5068
06d88145c7f7 6492246 x64 cpu/mem topology/diagnosis should include FRU labels
robj
parents: 4328
diff changeset
   251
tnode_t *
06d88145c7f7 6492246 x64 cpu/mem topology/diagnosis should include FRU labels
robj
parents: 4328
diff changeset
   252
topo_node_parent(tnode_t *node)
06d88145c7f7 6492246 x64 cpu/mem topology/diagnosis should include FRU labels
robj
parents: 4328
diff changeset
   253
{
06d88145c7f7 6492246 x64 cpu/mem topology/diagnosis should include FRU labels
robj
parents: 4328
diff changeset
   254
	return (node->tn_parent);
06d88145c7f7 6492246 x64 cpu/mem topology/diagnosis should include FRU labels
robj
parents: 4328
diff changeset
   255
}
06d88145c7f7 6492246 x64 cpu/mem topology/diagnosis should include FRU labels
robj
parents: 4328
diff changeset
   256
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   257
int
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   258
topo_node_flags(tnode_t *node)
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   259
{
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   260
	return (node->tn_fflags);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   261
}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   262
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   263
void
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   264
topo_node_setspecific(tnode_t *node, void *data)
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   265
{
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   266
	node->tn_priv = data;
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   267
}
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   268
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   269
void *
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   270
topo_node_getspecific(tnode_t *node)
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   271
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   272
	return (node->tn_priv);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   273
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   274
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   275
static int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   276
node_create_seterror(topo_mod_t *mod, tnode_t *pnode, topo_nodehash_t *nhp,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   277
    int err)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   278
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   279
	topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   280
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   281
	topo_dprintf(mod->tm_hdl, TOPO_DBG_ERR, "unable to insert child:"
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   282
	    "%s\n", topo_strerror(err));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   283
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   284
	if (nhp != NULL) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   285
		if (nhp->th_name != NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   286
			topo_mod_strfree(mod, nhp->th_name);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   287
		if (nhp->th_nodearr != NULL) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   288
			topo_mod_free(mod, nhp->th_nodearr,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   289
			    nhp->th_arrlen * sizeof (tnode_t *));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   290
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   291
		topo_mod_free(mod, nhp, sizeof (topo_nodehash_t));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   292
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   293
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   294
	return (topo_mod_seterrno(mod, err));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   295
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   296
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   297
int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   298
topo_node_range_create(topo_mod_t *mod, tnode_t *pnode, const char *name,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   299
    topo_instance_t min, topo_instance_t max)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   300
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   301
	topo_nodehash_t *nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   302
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   303
	topo_node_lock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   304
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   305
	assert((pnode->tn_state & TOPO_NODE_BOUND) ||
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   306
	    (pnode->tn_state & TOPO_NODE_ROOT));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   307
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   308
	for (nhp = topo_list_next(&pnode->tn_children); nhp != NULL;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   309
	    nhp = topo_list_next(nhp)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   310
		if (strcmp(nhp->th_name, name) == 0)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   311
			return (node_create_seterror(mod, pnode, NULL,
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   312
			    EMOD_NODE_DUP));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   313
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   314
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   315
	if (min < 0 || max < min)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   316
		return (node_create_seterror(mod, pnode, NULL,
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   317
		    EMOD_NODE_RANGE));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   318
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   319
	if ((nhp = topo_mod_zalloc(mod, sizeof (topo_nodehash_t))) == NULL)
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   320
		return (node_create_seterror(mod, pnode, nhp, EMOD_NOMEM));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   321
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   322
	if ((nhp->th_name = topo_mod_strdup(mod, name)) == NULL)
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   323
		return (node_create_seterror(mod, pnode, nhp, EMOD_NOMEM));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   324
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   325
	nhp->th_arrlen = max - min + 1;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   326
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   327
	if ((nhp->th_nodearr = topo_mod_zalloc(mod,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   328
	    nhp->th_arrlen * sizeof (tnode_t *))) == NULL)
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   329
		return (node_create_seterror(mod, pnode, nhp, EMOD_NOMEM));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   330
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   331
	nhp->th_range.tr_min = min;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   332
	nhp->th_range.tr_max = max;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   333
	nhp->th_enum = mod;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   334
	topo_mod_hold(mod);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   335
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   336
	/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   337
	 * Add these nodes to parent child list
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   338
	 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   339
	topo_list_append(&pnode->tn_children, nhp);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   340
	topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   341
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   342
	topo_dprintf(mod->tm_hdl, TOPO_DBG_MODSVC,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   343
	    "created node range %s[%d-%d]\n", name, min, max);
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   344
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   345
	return (0);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   346
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   347
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   348
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   349
topo_node_range_destroy(tnode_t *pnode, const char *name)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   350
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   351
	int i;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   352
	topo_nodehash_t *nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   353
	topo_mod_t *mod;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   354
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   355
	topo_node_lock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   356
	for (nhp = topo_list_next(&pnode->tn_children); nhp != NULL;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   357
	    nhp = topo_list_next(nhp)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   358
		if (strcmp(nhp->th_name, name) == 0) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   359
			break;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   360
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   361
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   362
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   363
	if (nhp == NULL) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   364
		topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   365
		return;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   366
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   367
4328
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   368
	for (i = 0; i < nhp->th_arrlen; i++)
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   369
		assert(nhp->th_nodearr[i] == NULL);
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   370
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   371
	topo_list_delete(&pnode->tn_children, nhp);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   372
	topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   373
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   374
	mod = nhp->th_enum;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   375
	if (nhp->th_name != NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   376
		topo_mod_strfree(mod, nhp->th_name);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   377
	if (nhp->th_nodearr != NULL) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   378
		topo_mod_free(mod, nhp->th_nodearr,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   379
		    nhp->th_arrlen * sizeof (tnode_t *));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   380
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   381
	topo_mod_free(mod, nhp, sizeof (topo_nodehash_t));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   382
	topo_mod_rele(mod);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   383
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   384
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   385
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   386
tnode_t *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   387
topo_node_lookup(tnode_t *pnode, const char *name, topo_instance_t inst)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   388
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   389
	int h;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   390
	tnode_t *node;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   391
	topo_nodehash_t *nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   392
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   393
	topo_node_lock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   394
	for (nhp = topo_list_next(&pnode->tn_children); nhp != NULL;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   395
	    nhp = topo_list_next(nhp)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   396
		if (strcmp(nhp->th_name, name) == 0) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   397
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   398
			if (inst > nhp->th_range.tr_max ||
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   399
			    inst < nhp->th_range.tr_min) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   400
				topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   401
				return (NULL);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   402
			}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   403
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   404
			h = topo_node_hash(nhp, inst);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   405
			node = nhp->th_nodearr[h];
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   406
			topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   407
			return (node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   408
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   409
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   410
	topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   411
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   412
	return (NULL);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   413
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   415
int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   416
topo_node_hash(topo_nodehash_t *nhp, topo_instance_t inst)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   417
{
5254
38162db71c7d PSARC 2007/591 Generic x86 Machine Check Architecture
gavinm
parents: 5068
diff changeset
   418
	return ((inst - nhp->th_range.tr_min) % nhp->th_arrlen);
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   419
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   420
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   421
static tnode_t *
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   422
node_bind_seterror(topo_mod_t *mod, tnode_t *pnode, tnode_t *node,
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   423
    boolean_t pnode_locked, int err)
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   424
{
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   425
	if (pnode_locked)
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   426
		topo_node_unlock(pnode);
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   427
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   428
	(void) topo_mod_seterrno(mod, err);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   429
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   430
	if (node == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   431
		return (NULL);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   432
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   433
	topo_dprintf(mod->tm_hdl, TOPO_DBG_ERR, "unable to bind %s=%d: "
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   434
	    "%s\n", (node->tn_name != NULL ? node->tn_name : "unknown"),
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   435
	    node->tn_instance, topo_strerror(err));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   436
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   437
	topo_node_lock(node); /* expected to be locked */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   438
	topo_node_destroy(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   439
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   440
	return (NULL);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   441
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   442
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   443
tnode_t *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   444
topo_node_bind(topo_mod_t *mod, tnode_t *pnode, const char *name,
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   445
    topo_instance_t inst, nvlist_t *fmri)
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   446
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   447
	int h, err;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   448
	tnode_t *node;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   449
	topo_nodehash_t *nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   450
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   451
	topo_node_lock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   452
	for (nhp = topo_list_next(&pnode->tn_children); nhp != NULL;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   453
	    nhp = topo_list_next(nhp)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   454
		if (strcmp(nhp->th_name, name) == 0) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   455
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   456
			if (inst > nhp->th_range.tr_max ||
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   457
			    inst < nhp->th_range.tr_min)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   458
				return (node_bind_seterror(mod, pnode, NULL,
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   459
				    B_TRUE, EMOD_NODE_RANGE));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   460
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   461
			h = topo_node_hash(nhp, inst);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   462
			if (nhp->th_nodearr[h] != NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   463
				return (node_bind_seterror(mod, pnode, NULL,
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   464
				    B_TRUE, EMOD_NODE_BOUND));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   465
			else
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   466
				break;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   467
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   468
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   469
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   470
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   471
	if (nhp == NULL)
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   472
		return (node_bind_seterror(mod, pnode, NULL, B_TRUE,
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   473
		    EMOD_NODE_NOENT));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   474
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   475
	if ((node = topo_mod_zalloc(mod, sizeof (tnode_t))) == NULL)
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   476
		return (node_bind_seterror(mod, pnode, NULL, B_TRUE,
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   477
		    EMOD_NOMEM));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   478
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   479
	(void) pthread_mutex_init(&node->tn_lock, NULL);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   480
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   481
	node->tn_enum = mod;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   482
	node->tn_hdl = mod->tm_hdl;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   483
	node->tn_parent = pnode;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   484
	node->tn_name = nhp->th_name;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   485
	node->tn_instance = inst;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   486
	node->tn_phash = nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   487
	node->tn_refs = 0;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   488
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   489
	/* Ref count module that bound this node */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   490
	topo_mod_hold(mod);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   491
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   492
	if (fmri == NULL)
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   493
		return (node_bind_seterror(mod, pnode, node, B_TRUE,
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   494
		    EMOD_NVL_INVAL));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   495
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   496
	if (topo_pgroup_create(node, &protocol_pgroup, &err) < 0)
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   497
		return (node_bind_seterror(mod, pnode, node, B_TRUE, err));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   498
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   499
	if (topo_prop_set_fmri(node, TOPO_PGROUP_PROTOCOL, TOPO_PROP_RESOURCE,
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   500
	    TOPO_PROP_IMMUTABLE, fmri, &err) < 0)
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   501
		return (node_bind_seterror(mod, pnode, node, B_TRUE, err));
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   502
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   503
	topo_dprintf(mod->tm_hdl, TOPO_DBG_MODSVC,
4328
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   504
	    "node bound %s=%d/%s=%d\n", topo_node_name(pnode),
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   505
	    topo_node_instance(pnode), node->tn_name, node->tn_instance);
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   506
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   507
	node->tn_state |= TOPO_NODE_BOUND;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   508
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   509
	topo_node_hold(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   510
	nhp->th_nodearr[h] = node;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   511
	++pnode->tn_refs;
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   512
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   513
	topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   514
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   515
	if (topo_pgroup_create(node, &auth_pgroup, &err) == 0) {
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   516
		(void) topo_prop_inherit(node, FM_FMRI_AUTHORITY,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   517
		    FM_FMRI_AUTH_PRODUCT, &err);
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   518
		(void) topo_prop_inherit(node, FM_FMRI_AUTHORITY,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   519
		    FM_FMRI_AUTH_CHASSIS, &err);
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   520
		(void) topo_prop_inherit(node, FM_FMRI_AUTHORITY,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   521
		    FM_FMRI_AUTH_SERVER, &err);
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   522
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   523
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   524
	return (node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   525
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   526
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   527
tnode_t *
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   528
topo_node_facbind(topo_mod_t *mod, tnode_t *pnode, const char *name,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   529
    const char *type)
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   530
{
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   531
	int h, err;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   532
	tnode_t *node;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   533
	topo_nodehash_t *nhp;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   534
	topo_instance_t inst = 0;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   535
	nvlist_t *pfmri, *fnvl;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   536
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   537
	/*
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   538
	 * Create a single entry range for this facility
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   539
	 */
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   540
	if (topo_node_range_create(mod, pnode, name, 0, 0) < 0)
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   541
		return (NULL);  /* mod errno set */
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   542
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   543
	topo_node_hold(pnode);
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   544
	topo_node_lock(pnode);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   545
	for (nhp = topo_list_next(&pnode->tn_children); nhp != NULL;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   546
	    nhp = topo_list_next(nhp)) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   547
		if (strcmp(nhp->th_name, name) == 0) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   548
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   549
			if (inst > nhp->th_range.tr_max ||
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   550
			    inst < nhp->th_range.tr_min) {
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   551
				topo_node_rele(pnode);
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   552
				return (node_bind_seterror(mod, pnode, NULL,
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   553
				    B_TRUE, EMOD_NVL_INVAL));
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   554
			}
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   555
			h = topo_node_hash(nhp, inst);
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   556
			if (nhp->th_nodearr[h] != NULL) {
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   557
				topo_node_rele(pnode);
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   558
				return (node_bind_seterror(mod, pnode, NULL,
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   559
				    B_TRUE, EMOD_NODE_BOUND));
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   560
			} else
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   561
				break;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   562
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   563
		}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   564
	}
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   565
	topo_node_unlock(pnode);
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   566
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   567
	if (nhp == NULL) {
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   568
		topo_node_rele(pnode);
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   569
		return (node_bind_seterror(mod, pnode, NULL, B_FALSE,
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   570
		    EMOD_NODE_NOENT));
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   571
	}
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   572
	if ((node = topo_mod_zalloc(mod, sizeof (tnode_t))) == NULL) {
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   573
		topo_node_rele(pnode);
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   574
		return (node_bind_seterror(mod, pnode, NULL, B_FALSE,
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   575
		    EMOD_NOMEM));
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   576
	}
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   577
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   578
	(void) pthread_mutex_init(&node->tn_lock, NULL);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   579
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   580
	node->tn_enum = mod;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   581
	node->tn_hdl = mod->tm_hdl;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   582
	node->tn_parent = pnode;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   583
	node->tn_name = nhp->th_name;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   584
	node->tn_instance = inst;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   585
	node->tn_phash = nhp;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   586
	node->tn_refs = 0;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   587
	node->tn_fflags = TOPO_NODE_FACILITY;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   588
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   589
	/* Ref count module that bound this node */
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   590
	topo_mod_hold(mod);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   591
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   592
	if (topo_pgroup_create(node, &protocol_pgroup, &err) < 0) {
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   593
		topo_node_rele(pnode);
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   594
		return (node_bind_seterror(mod, pnode, node, B_FALSE, err));
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   595
	}
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   596
	if (topo_mod_nvalloc(mod, &fnvl, NV_UNIQUE_NAME) < 0) {
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   597
		topo_node_rele(pnode);
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   598
		return (node_bind_seterror(mod, pnode, node, B_FALSE,
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   599
		    EMOD_NOMEM));
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   600
	}
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   601
	if (nvlist_add_string(fnvl, FM_FMRI_FACILITY_NAME, name) != 0 ||
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   602
	    nvlist_add_string(fnvl, FM_FMRI_FACILITY_TYPE, type) != 0) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   603
		nvlist_free(fnvl);
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   604
		topo_node_rele(pnode);
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   605
		return (node_bind_seterror(mod, pnode, node,  B_FALSE,
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   606
		    EMOD_FMRI_NVL));
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   607
	}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   608
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   609
	if (topo_node_resource(pnode, &pfmri, &err) < 0) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   610
		nvlist_free(fnvl);
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   611
		topo_node_rele(pnode);
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   612
		return (node_bind_seterror(mod, pnode, node, B_FALSE, err));
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   613
	}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   614
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   615
	if (nvlist_add_nvlist(pfmri, FM_FMRI_FACILITY, fnvl) != 0) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   616
		nvlist_free(fnvl);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   617
		nvlist_free(pfmri);
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   618
		topo_node_rele(pnode);
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   619
		return (node_bind_seterror(mod, pnode, node,  B_FALSE,
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   620
		    EMOD_FMRI_NVL));
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   621
	}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   622
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   623
	nvlist_free(fnvl);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   624
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   625
	if (topo_prop_set_fmri(node, TOPO_PGROUP_PROTOCOL, TOPO_PROP_RESOURCE,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   626
	    TOPO_PROP_IMMUTABLE, pfmri, &err) < 0) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   627
		nvlist_free(pfmri);
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   628
		topo_node_rele(pnode);
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   629
		return (node_bind_seterror(mod, pnode, node, B_FALSE, err));
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   630
	}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   631
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   632
	nvlist_free(pfmri);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   633
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   634
	topo_dprintf(mod->tm_hdl, TOPO_DBG_MODSVC,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   635
	    "facility node bound %s=%s\n", type, node->tn_name);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   636
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   637
	node->tn_state |= TOPO_NODE_BOUND;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   638
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   639
	topo_node_hold(node);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   640
	nhp->th_nodearr[h] = node;
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   641
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   642
	topo_node_lock(pnode);
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   643
	++pnode->tn_refs;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   644
	topo_node_unlock(pnode);
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   645
	topo_node_rele(pnode);
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   646
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   647
	if (topo_pgroup_create(node, &auth_pgroup, &err) == 0) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   648
		(void) topo_prop_inherit(node, FM_FMRI_AUTHORITY,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   649
		    FM_FMRI_AUTH_PRODUCT, &err);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   650
		(void) topo_prop_inherit(node, FM_FMRI_AUTHORITY,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   651
		    FM_FMRI_AUTH_CHASSIS, &err);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   652
		(void) topo_prop_inherit(node, FM_FMRI_AUTHORITY,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   653
		    FM_FMRI_AUTH_SERVER, &err);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   654
	}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   655
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   656
	return (node);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   657
}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   658
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   659
int
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   660
topo_node_facility(topo_hdl_t *thp, tnode_t *node, const char *fac_type,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   661
    uint32_t fac_subtype, topo_faclist_t *faclist, int *errp)
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   662
{
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   663
	tnode_t *tmp;
7585
6bd9ced8f8a6 6735704 deadlock in topo_node_facility()
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7345
diff changeset
   664
	nvlist_t *rsrc, *fac;
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   665
	char *tmp_factype;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   666
	uint32_t tmp_facsubtype;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   667
	boolean_t list_empty = 1;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   668
	topo_faclist_t *fac_ele;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   669
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   670
	bzero(faclist, sizeof (topo_faclist_t));
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   671
	for (tmp = topo_child_first(node); tmp != NULL;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   672
	    tmp = topo_child_next(node, tmp)) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   673
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   674
		topo_node_hold(tmp);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   675
		/*
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   676
		 * If it's not a facility node, move on
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   677
		 */
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   678
		if (topo_node_flags(tmp) != TOPO_NODE_FACILITY) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   679
			topo_node_rele(tmp);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   680
			continue;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   681
		}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   682
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   683
		/*
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   684
		 * Lookup whether the fac type is sensor or indicator and if
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   685
		 * it's not the type we're looking for, move on
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   686
		 */
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   687
		if (topo_node_resource(tmp, &rsrc, errp) != 0) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   688
			topo_dprintf(thp, TOPO_DBG_ERR,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   689
			    "Failed to get resource for node %s=%d (%s)\n",
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   690
			    topo_node_name(node), topo_node_instance(node),
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   691
			    topo_strerror(*errp));
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   692
			topo_node_rele(tmp);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   693
			return (-1);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   694
		}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   695
		if ((nvlist_lookup_nvlist(rsrc, "facility", &fac) != 0) ||
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   696
		    (nvlist_lookup_string(fac, FM_FMRI_FACILITY_TYPE,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   697
		    &tmp_factype) != 0)) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   698
7345
ca4ab7af4867 6737553 topo_node_facility() leaks resource
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7243
diff changeset
   699
			nvlist_free(rsrc);
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   700
			topo_node_rele(tmp);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   701
			return (-1);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   702
		}
7345
ca4ab7af4867 6737553 topo_node_facility() leaks resource
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7243
diff changeset
   703
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   704
		if (strcmp(fac_type, tmp_factype) != 0) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   705
			topo_node_rele(tmp);
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7585
diff changeset
   706
			nvlist_free(rsrc);
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   707
			continue;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   708
		}
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7585
diff changeset
   709
		nvlist_free(rsrc);
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   710
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   711
		/*
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   712
		 * Finally, look up the subtype, which is a property in the
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   713
		 * facility propgroup.  If it's a match return a pointer to the
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   714
		 * node.  Otherwise, move on.
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   715
		 */
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   716
		if (topo_prop_get_uint32(tmp, TOPO_PGROUP_FACILITY,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   717
		    TOPO_FACILITY_TYPE, &tmp_facsubtype, errp) != 0) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   718
			topo_node_rele(tmp);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   719
			return (-1);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   720
		}
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7585
diff changeset
   721
		if (fac_subtype == tmp_facsubtype ||
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 7585
diff changeset
   722
		    fac_subtype == TOPO_FAC_TYPE_ANY) {
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   723
			if ((fac_ele = topo_mod_zalloc(tmp->tn_enum,
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   724
			    sizeof (topo_faclist_t))) == NULL) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   725
				*errp = ETOPO_NOMEM;
7345
ca4ab7af4867 6737553 topo_node_facility() leaks resource
Eric Schrock <Eric.Schrock@Sun.COM>
parents: 7243
diff changeset
   726
				topo_node_rele(tmp);
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   727
				return (-1);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   728
			}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   729
			fac_ele->tf_node = tmp;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   730
			topo_list_append(&faclist->tf_list, fac_ele);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   731
			list_empty = 0;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   732
		}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   733
		topo_node_rele(tmp);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   734
	}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   735
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   736
	if (list_empty) {
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   737
		*errp = ETOPO_FAC_NOENT;
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   738
		return (-1);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   739
	}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   740
	return (0);
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   741
}
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   742
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   743
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   744
topo_node_unbind(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   745
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   746
	if (node == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   747
		return;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   748
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   749
	topo_node_lock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   750
	if (!(node->tn_state & TOPO_NODE_BOUND)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   751
		topo_node_unlock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   752
		return;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   753
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   754
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   755
	node->tn_state &= ~TOPO_NODE_BOUND;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   756
	topo_node_unlock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   757
4328
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   758
	topo_dprintf(node->tn_hdl, TOPO_DBG_MODSVC,
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   759
	    "node unbound %s=%d/%s=%d refs = %d\n",
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   760
	    topo_node_name(node->tn_parent),
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   761
	    topo_node_instance(node->tn_parent), node->tn_name,
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   762
	    node->tn_instance, node->tn_refs);
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   763
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   764
	topo_node_rele(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   765
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   766
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   767
/*ARGSUSED*/
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   768
int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   769
topo_node_present(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   770
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   771
	return (0);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   772
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   773
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   774
/*ARGSUSED*/
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   775
int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   776
topo_node_contains(tnode_t *er, tnode_t *ee)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   777
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   778
	return (0);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   779
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   780
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   781
/*ARGSUSED*/
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   782
int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   783
topo_node_unusable(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   784
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   785
	return (0);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   786
}
4087
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   787
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   788
topo_walk_t *
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   789
topo_node_walk_init(topo_hdl_t *thp, topo_mod_t *mod, tnode_t *node,
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   790
    int (*cb_f)(), void *pdata, int *errp)
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   791
{
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   792
	tnode_t *child;
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   793
	topo_walk_t *wp;
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   794
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   795
	topo_node_hold(node);
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   796
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   797
	if ((wp = topo_hdl_zalloc(thp, sizeof (topo_walk_t))) == NULL) {
7243
2f11e164daec PSARC 2008/428 Extending libnvpair for type double
robj
parents: 5501
diff changeset
   798
		*errp = ETOPO_HDL_NOMEM;
4087
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   799
		topo_node_rele(node);
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   800
		return (NULL);
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   801
	}
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   802
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   803
	/*
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   804
	 * If this is the root of the scheme tree, start with the first
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   805
	 * child
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   806
	 */
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   807
	topo_node_lock(node);
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   808
	if (node->tn_state & TOPO_NODE_ROOT) {
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   809
		if ((child = topo_child_first(node)) == NULL) {
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   810
			/* Nothing to walk */
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   811
			*errp = ETOPO_WALK_EMPTY;
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   812
			topo_node_unlock(node);
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   813
			topo_node_rele(node);
5501
cca063572f37 6625091 zpool cachefile property has incorrect value help message
eschrock
parents: 5254
diff changeset
   814
			topo_hdl_free(thp, wp, sizeof (topo_walk_t));
4087
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   815
			return (NULL);
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   816
		}
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   817
		topo_node_unlock(node);
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   818
		topo_node_hold(child);
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   819
		wp->tw_node = child;
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   820
	} else {
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   821
		topo_node_unlock(node);
4328
fe6ac87d8e60 6547176 libtopo leaks memory on failure
cindi
parents: 4087
diff changeset
   822
		topo_node_hold(node); /* rele at walk end */
4087
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   823
		wp->tw_node = node;
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   824
	}
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   825
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   826
	wp->tw_root = node;
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   827
	wp->tw_cb = cb_f;
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   828
	wp->tw_pdata = pdata;
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   829
	wp->tw_thp = thp;
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   830
	wp->tw_mod = mod;
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   831
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   832
	return (wp);
b986877655d2 6521594 fmtopo '[-Cdev]' usage doesn't make sense
cindi
parents: 3062
diff changeset
   833
}