topo_node.c revision 0eb822a1c0c2bea495647510b75f77f0e57633eb
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Topology Nodes
*
* Topology nodes, tnode_t, are data structures containing per-FMRI
* information and are linked together to form the topology tree.
* Nodes are created during the enumeration process of topo_snap_hold()
* and destroyed during topo_snap_rele(). For the most part, tnode_t data
* is read-only and no lock protection is required. Nodes are
* held in place during tree walk functions. Tree walk functions
* may access node data safely without locks. The exception to this rule
* is data associated with node properties (topo_prop.c). Properties
* may change at anytime and are protected by a per-property locking
* strategy.
*
* Enumerator plugin modules may also safely access node data. Enumeration
* occurs only during topo_snap_hold() where a per-topo_hdl_t lock prevents
* multi-threaded access to the topology trees.
*
* Like tree walking functions, method plugin modules have access to read-only
* node data but may make changes to property information.
*
* Node Interfaces
*
* Nodes are created when an enumerator calls topo_node_bind(). Prior to the
* call to topo_node_bind(), the caller should have reserved a range of
* node instances with topo_node_range_create(). topo_node_range_create()
* does not allocate any node resources but creates the infrastruture
* required for a fully populated topology level. This allows enumerators
* reading from a <scheme>-topology.xml file to parse the file for a range
* of resources before confirming the existence of a resource via a helper
* plugin. Only when the resource has been confirmed to exist should
* the node be bound.
*
* Node range and node linkage is only performed during enumeration when it
* is safe to change node hash lists and next pointers. Nodes and node ranges
* are deallocated when all references to the node have been released:
* last walk completes and topo_snap_rele() is called.
*
*
* Each parent node may have one or more ranges of child nodes. Each range
* serves as a hash list of like sibling nodes all with the same name but
* different instance numbers. A parent may have more than one node hash
* (child range). If that is the case, the hash lists are strung together to
* populated with only nodes that have represented resources in the system.
*/
#include <assert.h>
#include <pthread.h>
#include <strings.h>
#include <topo_alloc.h>
#include <topo_error.h>
#include <topo_method.h>
#include <topo_subr.h>
#include <topo_tree.h>
static topo_pgroup_info_t protocol_pgroup = {
1
};
static const topo_pgroup_info_t auth_pgroup = {
1
};
static void
{
int i;
return;
/*
* If not a root node, remove this node from the parent's node hash
*/
/*
* Release hold on parent
*/
}
}
}
/*
* Allow enumerator to clean-up private data and then release
* ref count
*/
/*
* Destroy all node hash lists
*/
}
}
/*
* Destroy all property data structures, free the node and release
* the module that created it
*/
}
void
{
}
void
{
}
void
{
}
void
{
/*
* Ok to remove this node from the topo tree and destroy it
*/
else
}
char *
{
}
{
return (node->tn_instance);
}
void
{
}
void *
{
}
static int
int err)
{
}
}
}
int
{
}
/*
* Add these nodes to parent child list
*/
return (0);
}
void
{
int i;
break;
}
}
return;
}
/*
* Should be an empty node range
*/
}
}
}
tnode_t *
{
int h;
return (NULL);
}
return (node);
}
}
return (NULL);
}
int
{
}
static tnode_t *
{
return (NULL);
return (NULL);
}
tnode_t *
{
int h, err;
else
break;
}
}
/* Ref count module that bound this node */
}
return (node);
}
void
{
return;
return;
}
}
/*ARGSUSED*/
int
{
return (0);
}
/*ARGSUSED*/
int
{
return (0);
}
/*ARGSUSED*/
int
{
return (0);
}