usr/src/lib/fm/topo/libtopo/common/topo_node.c
author cindi
Sat, 04 Nov 2006 01:18:55 -0800
changeset 3062 46d280f5351d
parent 1414 b4126407ac5b
child 4087 b986877655d2
permissions -rw-r--r--
6396916 verification of dtd file name is wrong 6399876 libtopo does not properly support an alternate root path 6399927 libtopo debug information indicates "no topology file found" when it is unable to parse file. 6421101 fmsim doesn't allow simulated topology to be specified with new libtopo 6422759 fmd memory leaks detected on system experiencing significant pcie fabric errors 6429072 memory leak in iob_tnode_create 6448718 libtopo needs better enum module APIs 6467144 topo_fmri_str2nvl doesn't handle authority or properties 6473916 fmd should return a full populated topo snapshot in fmd_hdl_topology() and fmd_fmri_topology() 6473918 hc scheme plugin is_present routine is broken 6477382 Need public header file for hc scheme component names and properties 6477385 fmtopo -V needs to be more friendly 6477426 fmtopo -d should not be so chatty 6477430 Need ability to load additional libtopo map files 6477442 libtopo should allow alternate platform topo map files 6477446 Remove unused topo methods from enumerator modules 6477453 pcibus and hostbridge interface boundaries are a mess 6477456 hc enumerators must support authority information 6477461 topo_fru_compute and topo_asru_compute should return static props when computation fails 6480930 fmtopo should support a -x option
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
/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    22
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
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
#pragma ident	"%Z%%M%	%I%	%E% SMI"
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    27
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
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    30
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    31
 * 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
    32
 * 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
    33
 * 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
    34
 * 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
    35
 * 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
    36
 * 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
    37
 * 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
    38
 * 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
    39
 * 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
    40
 * strategy.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    41
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    42
 * Enumerator plugin modules may also safely access node data.  Enumeration
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    43
 * occurs only during topo_snap_hold() where a per-topo_hdl_t lock prevents
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    44
 * multi-threaded access to the topology trees.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    45
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    46
 * Like tree walking functions, method plugin modules have access to read-only
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    47
 * node data but may make changes to property information.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    48
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    49
 * Node Interfaces
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    50
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    51
 * Nodes are created when an enumerator calls topo_node_bind().  Prior to the
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    52
 * call to topo_node_bind(), the caller should have reserved a range of
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    53
 * 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
    54
 * 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
    55
 * 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
    56
 * 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
    57
 * 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
    58
 * 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
    59
 * the node be bound.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    60
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    61
 * Node range and node linkage is only performed during enumeration when it
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    62
 * is safe to change node hash lists and next pointers. Nodes and node ranges
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    63
 * are deallocated when all references to the node have been released:
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    64
 * last walk completes and topo_snap_rele() is called.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    65
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    66
 * Node Hash/Ranges
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    67
 *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    68
 * Each parent node may have one or more ranges of child nodes.  Each range
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    69
 * serves as a hash list of like sibling nodes all with the same name but
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    70
 * 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
    71
 * (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
    72
 * form sibling relationships between ranges.  Hash/Ranges are sparsely
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    73
 * populated with only nodes that have represented resources in the system.
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    74
 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    75
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    76
#include <assert.h>
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    77
#include <pthread.h>
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    78
#include <strings.h>
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    79
#include <sys/fm/protocol.h>
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    80
#include <topo_alloc.h>
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    81
#include <topo_error.h>
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    82
#include <topo_method.h>
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    83
#include <topo_subr.h>
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    84
#include <topo_tree.h>
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    85
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    86
static topo_pgroup_info_t protocol_pgroup = {
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    87
	TOPO_PGROUP_PROTOCOL,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    88
	TOPO_STABILITY_PRIVATE,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    89
	TOPO_STABILITY_PRIVATE,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    90
	1
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    91
};
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    92
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    93
static const topo_pgroup_info_t auth_pgroup = {
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    94
	FM_FMRI_AUTHORITY,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    95
	TOPO_STABILITY_PRIVATE,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    96
	TOPO_STABILITY_PRIVATE,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    97
	1
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
    98
};
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
    99
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   100
static void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   101
topo_node_destroy(tnode_t *node)
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
	int i;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   104
	tnode_t *pnode = node->tn_parent;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   105
	topo_nodehash_t *nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   106
	topo_mod_t *hmod, *mod = node->tn_enum;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   107
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   108
	if (node == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   109
		return;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   110
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   111
	assert(node->tn_refs == 0);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   112
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   113
	/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   114
	 * 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
   115
	 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   116
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   117
	if (!(node->tn_state & TOPO_NODE_ROOT)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   118
		topo_node_lock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   119
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   120
		nhp = node->tn_phash;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   121
		for (i = 0; i < nhp->th_arrlen; i++) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   122
			if (node == nhp->th_nodearr[i]) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   123
				nhp->th_nodearr[i] = NULL;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   124
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   125
				/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   126
				 * Release hold on parent
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   127
				 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   128
				--pnode->tn_refs;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   129
				if (pnode->tn_refs == 0)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   130
					topo_node_destroy(pnode);
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
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   133
		topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   134
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   135
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   136
	topo_node_unlock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   137
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   138
	/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   139
	 * 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
   140
	 * ref count
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   141
	 */
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   142
	if (mod->tm_info->tmi_ops->tmo_release != NULL)
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   143
		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
   144
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   145
	topo_method_unregister_all(mod, node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   146
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
	 * Destroy all node hash lists
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   149
	 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   150
	while ((nhp = topo_list_next(&node->tn_children)) != NULL) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   151
		for (i = 0; i < nhp->th_arrlen; i++) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   152
			assert(nhp->th_nodearr[i] == NULL);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   153
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   154
		hmod = nhp->th_enum;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   155
		topo_mod_strfree(hmod, nhp->th_name);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   156
		topo_mod_free(hmod, nhp->th_nodearr,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   157
		    nhp->th_arrlen * sizeof (tnode_t *));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   158
		topo_list_delete(&node->tn_children, nhp);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   159
		topo_mod_free(hmod, nhp, sizeof (topo_nodehash_t));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   160
		topo_mod_rele(hmod);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   161
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   162
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
	 * 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
   165
	 * the module that created it
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
	topo_pgroup_destroy_all(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   168
	topo_mod_free(mod, node, sizeof (tnode_t));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   169
	topo_mod_rele(mod);
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
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   172
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   173
topo_node_lock(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   174
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   175
	(void) pthread_mutex_lock(&node->tn_lock);
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
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   178
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   179
topo_node_unlock(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   180
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   181
	(void) pthread_mutex_unlock(&node->tn_lock);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   182
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   183
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   184
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   185
topo_node_hold(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   186
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   187
	topo_node_lock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   188
	++node->tn_refs;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   189
	topo_node_unlock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   190
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   191
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   192
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   193
topo_node_rele(tnode_t *node)
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
	topo_node_lock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   196
	--node->tn_refs;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   197
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
	 * 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
   200
	 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   201
	if (node->tn_refs == 0)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   202
		topo_node_destroy(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   203
	else
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   204
		topo_node_unlock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   205
}
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
char *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   208
topo_node_name(tnode_t *node)
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
	return (node->tn_name);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   211
}
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
topo_instance_t
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   214
topo_node_instance(tnode_t *node)
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
	return (node->tn_instance);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   217
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   218
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   219
void
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   220
topo_node_setspecific(tnode_t *node, void *data)
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   221
{
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   222
	node->tn_priv = data;
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   223
}
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   224
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   225
void *
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   226
topo_node_getspecific(tnode_t *node)
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   227
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   228
	return (node->tn_priv);
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
static int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   232
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
   233
    int err)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   234
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   235
	topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   236
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   237
	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
   238
	    "%s\n", topo_strerror(err));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   239
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   240
	if (nhp != NULL) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   241
		if (nhp->th_name != NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   242
			topo_mod_strfree(mod, nhp->th_name);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   243
		if (nhp->th_nodearr != NULL) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   244
			topo_mod_free(mod, nhp->th_nodearr,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   245
			    nhp->th_arrlen * sizeof (tnode_t *));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   246
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   247
		topo_mod_free(mod, nhp, sizeof (topo_nodehash_t));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   248
	}
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
	return (topo_mod_seterrno(mod, err));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   251
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   252
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   253
int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   254
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
   255
    topo_instance_t min, topo_instance_t max)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   256
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   257
	topo_nodehash_t *nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   258
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   259
	topo_node_lock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   260
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   261
	assert((pnode->tn_state & TOPO_NODE_BOUND) ||
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   262
	    (pnode->tn_state & TOPO_NODE_ROOT));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   263
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   264
	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
   265
	    nhp = topo_list_next(nhp)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   266
		if (strcmp(nhp->th_name, name) == 0)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   267
			return (node_create_seterror(mod, pnode, NULL,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   268
			    ETOPO_NODE_DUP));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   269
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   270
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   271
	if (min < 0 || max < min)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   272
		return (node_create_seterror(mod, pnode, NULL,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   273
		    ETOPO_NODE_INVAL));
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
	if ((nhp = topo_mod_zalloc(mod, sizeof (topo_nodehash_t))) == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   276
		return (node_create_seterror(mod, pnode, nhp, ETOPO_NOMEM));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   277
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   278
	if ((nhp->th_name = topo_mod_strdup(mod, name)) == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   279
		return (node_create_seterror(mod, pnode, nhp, ETOPO_NOMEM));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   280
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   281
	nhp->th_arrlen = max - min + 1;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   282
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   283
	if ((nhp->th_nodearr = topo_mod_zalloc(mod,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   284
	    nhp->th_arrlen * sizeof (tnode_t *))) == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   285
		return (node_create_seterror(mod, pnode, nhp, ETOPO_NOMEM));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   286
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   287
	nhp->th_range.tr_min = min;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   288
	nhp->th_range.tr_max = max;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   289
	nhp->th_enum = mod;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   290
	topo_mod_hold(mod);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   291
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
	 * Add these nodes to parent child list
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   294
	 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   295
	topo_list_append(&pnode->tn_children, nhp);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   296
	topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   297
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   298
	topo_dprintf(mod->tm_hdl, TOPO_DBG_MODSVC,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   299
	    "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
   300
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   301
	return (0);
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
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   304
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   305
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
   306
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   307
	int i;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   308
	topo_nodehash_t *nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   309
	topo_mod_t *mod;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   310
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   311
	topo_node_lock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   312
	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
   313
	    nhp = topo_list_next(nhp)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   314
		if (strcmp(nhp->th_name, name) == 0) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   315
			break;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   316
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   317
	}
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 == NULL) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   320
		topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   321
		return;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   322
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   323
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   324
	topo_list_delete(&pnode->tn_children, nhp);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   325
	topo_node_unlock(pnode);
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
	/*
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   328
	 * Should be an empty node range
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   329
	 */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   330
	for (i = 0; i < nhp->th_arrlen; i++) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   331
		topo_node_unbind(nhp->th_nodearr[i]);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   332
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   333
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   334
	mod = nhp->th_enum;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   335
	if (nhp->th_name != NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   336
		topo_mod_strfree(mod, nhp->th_name);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   337
	if (nhp->th_nodearr != NULL) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   338
		topo_mod_free(mod, nhp->th_nodearr,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   339
		    nhp->th_arrlen * sizeof (tnode_t *));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   340
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   341
	topo_mod_free(mod, nhp, sizeof (topo_nodehash_t));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   342
	topo_mod_rele(mod);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   343
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
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   346
tnode_t *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   347
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
   348
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   349
	int h;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   350
	tnode_t *node;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   351
	topo_nodehash_t *nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   352
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   353
	topo_node_lock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   354
	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
   355
	    nhp = topo_list_next(nhp)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   356
		if (strcmp(nhp->th_name, name) == 0) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   357
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   358
			if (inst > nhp->th_range.tr_max ||
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   359
			    inst < nhp->th_range.tr_min) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   360
				topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   361
				return (NULL);
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
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   364
			h = topo_node_hash(nhp, inst);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   365
			node = nhp->th_nodearr[h];
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   366
			topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   367
			return (node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   368
		}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   369
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   370
	topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   371
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   372
	return (NULL);
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
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   375
int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   376
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
   377
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   378
	return (nhp->th_range.tr_max == 0 ?
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   379
	    nhp->th_range.tr_max : inst % (nhp->th_range.tr_max + 1));
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
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   382
static tnode_t *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   383
node_bind_seterror(topo_mod_t *mod, tnode_t *pnode, tnode_t *node, int err)
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
	topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   386
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   387
	(void) topo_mod_seterrno(mod, err);
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
	if (node == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   390
		return (NULL);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   391
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   392
	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
   393
	    "%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
   394
	    node->tn_instance, topo_strerror(err));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   395
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   396
	topo_node_lock(node); /* expected to be locked */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   397
	topo_node_destroy(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   398
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   399
	return (NULL);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   400
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   401
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   402
tnode_t *
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   403
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
   404
    topo_instance_t inst, nvlist_t *fmri)
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   405
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   406
	int h, err;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   407
	tnode_t *node;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   408
	topo_nodehash_t *nhp;
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_lock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   411
	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
   412
	    nhp = topo_list_next(nhp)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   413
		if (strcmp(nhp->th_name, name) == 0) {
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
			if (inst > nhp->th_range.tr_max ||
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   416
			    inst < nhp->th_range.tr_min)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   417
				return (node_bind_seterror(mod, pnode, NULL,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   418
				    ETOPO_NODE_INVAL));
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
			h = topo_node_hash(nhp, inst);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   421
			if (nhp->th_nodearr[h] != NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   422
				return (node_bind_seterror(mod, pnode, NULL,
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   423
				    ETOPO_NODE_BOUND));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   424
			else
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   425
				break;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   426
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
	}
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 (nhp == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   431
		return (node_bind_seterror(mod, pnode, NULL, ETOPO_NODE_NOENT));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   432
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   433
	if ((node = topo_mod_zalloc(mod, sizeof (tnode_t))) == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   434
		return (node_bind_seterror(mod, pnode, NULL, ETOPO_NOMEM));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   435
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   436
	(void) pthread_mutex_init(&node->tn_lock, NULL);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   437
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   438
	node->tn_enum = mod;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   439
	node->tn_hdl = mod->tm_hdl;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   440
	node->tn_parent = pnode;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   441
	node->tn_name = nhp->th_name;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   442
	node->tn_instance = inst;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   443
	node->tn_phash = nhp;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   444
	node->tn_refs = 0;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   445
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   446
	/* Ref count module that bound this node */
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   447
	topo_mod_hold(mod);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   448
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   449
	if (fmri == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   450
		return (node_bind_seterror(mod, pnode, node, ETOPO_NODE_INVAL));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   451
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   452
	if (topo_pgroup_create(node, &protocol_pgroup, &err) < 0)
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   453
		return (node_bind_seterror(mod, pnode, node, err));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   454
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   455
	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
   456
	    TOPO_PROP_IMMUTABLE, fmri, &err) < 0)
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   457
		return (node_bind_seterror(mod, pnode, node, err));
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   458
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   459
	topo_dprintf(mod->tm_hdl, TOPO_DBG_MODSVC,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   460
	    "node bound %s=%d\n", node->tn_name, node->tn_instance);
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   461
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   462
	node->tn_state |= TOPO_NODE_BOUND;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   463
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   464
	topo_node_hold(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   465
	nhp->th_nodearr[h] = node;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   466
	++pnode->tn_refs;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   467
	topo_node_unlock(pnode);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   468
3062
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   469
	if (topo_pgroup_create(node, &auth_pgroup, &err) == 0) {
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   470
		(void) topo_prop_inherit(node, FM_FMRI_AUTHORITY,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   471
		    FM_FMRI_AUTH_PRODUCT, &err);
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   472
		(void) topo_prop_inherit(node, FM_FMRI_AUTHORITY,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   473
		    FM_FMRI_AUTH_CHASSIS, &err);
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   474
		(void) topo_prop_inherit(node, FM_FMRI_AUTHORITY,
46d280f5351d 6396916 verification of dtd file name is wrong
cindi
parents: 1414
diff changeset
   475
		    FM_FMRI_AUTH_SERVER, &err);
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   476
	}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   477
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   478
	return (node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   479
}
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
void
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   482
topo_node_unbind(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   483
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   484
	if (node == NULL)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   485
		return;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   486
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   487
	topo_node_lock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   488
	if (!(node->tn_state & TOPO_NODE_BOUND)) {
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   489
		topo_node_unlock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   490
		return;
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
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   493
	node->tn_state &= ~TOPO_NODE_BOUND;
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   494
	topo_node_unlock(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   495
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   496
	topo_node_rele(node);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   497
}
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
/*ARGSUSED*/
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   500
int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   501
topo_node_present(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   502
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   503
	return (0);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   504
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   505
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   506
/*ARGSUSED*/
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   507
int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   508
topo_node_contains(tnode_t *er, tnode_t *ee)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   509
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   510
	return (0);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   511
}
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   512
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   513
/*ARGSUSED*/
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   514
int
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   515
topo_node_unusable(tnode_t *node)
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   516
{
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   517
	return (0);
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
diff changeset
   518
}