diff options
| author | cindi <none@none> | 2006-11-04 01:18:55 -0800 | 
|---|---|---|
| committer | cindi <none@none> | 2006-11-04 01:18:55 -0800 | 
| commit | 0eb822a1c0c2bea495647510b75f77f0e57633eb (patch) | |
| tree | d104741eef4bddb27171407d1243e37790c7d499 /usr/src/lib/fm/topo/modules/common/hostbridge.c | |
| parent | 389056bd4327caca73482e60b80da00f4eaf3de9 (diff) | |
| download | illumos-joyent-0eb822a1c0c2bea495647510b75f77f0e57633eb.tar.gz | |
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
--HG--
rename : usr/src/lib/fm/topo/files/SUNW,Sun-Blade-T6300/Makefile => deleted_files/usr/src/lib/fm/topo/files/SUNW,Sun-Blade-T6300/Makefile
rename : usr/src/lib/fm/topo/modules/common/pcifn_enum.c => deleted_files/usr/src/lib/fm/topo/modules/common/pcibus/pcifn_enum.c
rename : usr/src/lib/fm/topo/modules/common/pcifn_enum.h => deleted_files/usr/src/lib/fm/topo/modules/common/pcibus/pcifn_enum.h
rename : usr/src/lib/fm/topo/modules/sun4v/ioboard/Makefile => deleted_files/usr/src/lib/fm/topo/modules/sun4v/ioboard/Makefile
rename : usr/src/lib/fm/topo/modules/sun4v/ioboard/iob_platform.c => deleted_files/usr/src/lib/fm/topo/modules/sun4v/ioboard/iob_platform.c
rename : usr/src/lib/fm/topo/libtopo/common/hc_canon.h => usr/src/lib/fm/topo/libtopo/common/topo_hc.h
rename : usr/src/lib/fm/topo/files/Makefile => usr/src/lib/fm/topo/maps/Makefile
rename : usr/src/lib/fm/topo/files/Makefile.file => usr/src/lib/fm/topo/maps/Makefile.map
rename : usr/src/lib/fm/topo/files/SUNW,SPARC-Enterprise/Makefile => usr/src/lib/fm/topo/maps/SUNW,SPARC-Enterprise/Makefile
rename : usr/src/lib/fm/topo/files/SUNW,SPARC-Enterprise/hc-topology.xml => usr/src/lib/fm/topo/maps/SUNW,SPARC-Enterprise/SPARC-Enterprise-hc-topology.xml
rename : usr/src/lib/fm/topo/files/SUNW,Sun-Fire-15000/Makefile => usr/src/lib/fm/topo/maps/SUNW,Sun-Fire-15000/Makefile
rename : usr/src/lib/fm/topo/files/SUNW,Sun-Fire-15000/hc-topology.xml => usr/src/lib/fm/topo/maps/SUNW,Sun-Fire-15000/Sun-Fire-15000-hc-topology.xml
rename : usr/src/lib/fm/topo/files/SUNW,Sun-Fire-T200/Makefile => usr/src/lib/fm/topo/maps/SUNW,Sun-Fire-T200/Makefile
rename : usr/src/lib/fm/topo/files/SUNW,Sun-Blade-T6300/hc-topology.xml => usr/src/lib/fm/topo/maps/SUNW,Sun-Fire-T200/Sun-Blade-T6300-hc-topology.xml
rename : usr/src/lib/fm/topo/files/SUNW,Sun-Fire-T200/hc-topology.xml => usr/src/lib/fm/topo/maps/SUNW,Sun-Fire-T200/Sun-Fire-T200-hc-topology.xml
rename : usr/src/lib/fm/topo/files/SUNW,Sun-Fire/Makefile => usr/src/lib/fm/topo/maps/SUNW,Sun-Fire/Makefile
rename : usr/src/lib/fm/topo/files/SUNW,Sun-Fire/hc-topology.xml => usr/src/lib/fm/topo/maps/SUNW,Sun-Fire/Sun-Fire-hc-topology.xml
rename : usr/src/lib/fm/topo/files/common/topology.dtd.1 => usr/src/lib/fm/topo/maps/common/topology.dtd.1
rename : usr/src/lib/fm/topo/files/i86pc/Makefile => usr/src/lib/fm/topo/maps/i86pc/Makefile
rename : usr/src/lib/fm/topo/files/i86pc/hc-topology.xml => usr/src/lib/fm/topo/maps/i86pc/i86pc-hc-topology.xml
rename : usr/src/lib/fm/topo/files/sun4u/Makefile => usr/src/lib/fm/topo/maps/sun4u/Makefile
rename : usr/src/lib/fm/topo/files/sun4u/hc-topology.xml => usr/src/lib/fm/topo/maps/sun4u/sun4u-hc-topology.xml
rename : usr/src/lib/fm/topo/files/sun4v/Makefile => usr/src/lib/fm/topo/maps/sun4v/Makefile
rename : usr/src/lib/fm/topo/files/sun4v/hc-topology.xml => usr/src/lib/fm/topo/maps/sun4v/sun4v-hc-topology.xml
rename : usr/src/lib/fm/topo/modules/common/hostbridge.c => usr/src/lib/fm/topo/modules/common/hostbridge/hostbridge.c
rename : usr/src/lib/fm/topo/modules/common/hostbridge.h => usr/src/lib/fm/topo/modules/common/hostbridge/hostbridge.h
rename : usr/src/lib/fm/topo/modules/common/did.c => usr/src/lib/fm/topo/modules/common/pcibus/did.c
rename : usr/src/lib/fm/topo/modules/common/did.h => usr/src/lib/fm/topo/modules/common/pcibus/did.h
rename : usr/src/lib/fm/topo/modules/common/did_hash.c => usr/src/lib/fm/topo/modules/common/pcibus/did_hash.c
rename : usr/src/lib/fm/topo/modules/common/did_impl.h => usr/src/lib/fm/topo/modules/common/pcibus/did_impl.h
rename : usr/src/lib/fm/topo/modules/common/did_props.c => usr/src/lib/fm/topo/modules/common/pcibus/did_props.c
rename : usr/src/lib/fm/topo/modules/common/did_props.h => usr/src/lib/fm/topo/modules/common/pcibus/did_props.h
rename : usr/src/lib/fm/topo/modules/common/pcibus.c => usr/src/lib/fm/topo/modules/common/pcibus/pcibus.c
rename : usr/src/lib/fm/topo/modules/common/pcibus.h => usr/src/lib/fm/topo/modules/common/pcibus/pcibus.h
rename : usr/src/lib/fm/topo/modules/common/pcibus_labels.c => usr/src/lib/fm/topo/modules/common/pcibus/pcibus_labels.c
rename : usr/src/lib/fm/topo/modules/common/pcibus_labels.h => usr/src/lib/fm/topo/modules/common/pcibus/pcibus_labels.h
rename : usr/src/lib/fm/topo/modules/common/util.c => usr/src/lib/fm/topo/modules/common/pcibus/util.c
rename : usr/src/lib/fm/topo/modules/common/util.h => usr/src/lib/fm/topo/modules/common/pcibus/util.h
Diffstat (limited to 'usr/src/lib/fm/topo/modules/common/hostbridge.c')
| -rw-r--r-- | usr/src/lib/fm/topo/modules/common/hostbridge.c | 421 | 
1 files changed, 0 insertions, 421 deletions
| diff --git a/usr/src/lib/fm/topo/modules/common/hostbridge.c b/usr/src/lib/fm/topo/modules/common/hostbridge.c deleted file mode 100644 index 7dbca54af6..0000000000 --- a/usr/src/lib/fm/topo/modules/common/hostbridge.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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" - -#include <string.h> -#include <fm/topo_mod.h> -#include <libdevinfo.h> -#include <limits.h> -#include <sys/fm/protocol.h> -#include <sys/param.h> -#include <sys/systeminfo.h> -#include <assert.h> -#include <pthread.h> - -#include "pcibus.h" -#include "hostbridge.h" -#include "did.h" -#include "did_props.h" -#include "util.h" - -/* - * hostbridge.c - *	Generic code shared by all the hostbridge enumerators - */ - -static void hb_release(topo_mod_t *, tnode_t *); -static int hb_contains(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *, -    nvlist_t **); -static int hb_present(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *, -    nvlist_t **); -static int hb_label(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *, -    nvlist_t **); -static int hb_enum(topo_mod_t *, tnode_t *, const char *, topo_instance_t, -    topo_instance_t, void *); - -extern txprop_t ExHB_common_props[]; -extern txprop_t HB_common_props[]; -extern txprop_t RC_common_props[]; -extern int ExHB_propcnt; -extern int HB_propcnt; -extern int RC_propcnt; - -static int specific_hb_enum(tnode_t *, const char *, topo_instance_t, -    topo_instance_t, di_prom_handle_t, topo_mod_t *); - -const topo_modinfo_t Hb_info = -	{ HOSTBRIDGE, HB_ENUMR_VERS, hb_enum, hb_release }; - -const topo_method_t Hb_methods[] = { -	{ "hb_contains", "hb element contains other element", HB_ENUMR_VERS, -	    TOPO_STABILITY_INTERNAL, hb_contains }, -	{ "hb_present", "hb element currently present", HB_ENUMR_VERS, -	    TOPO_STABILITY_INTERNAL, hb_present }, -	{ TOPO_METH_LABEL, TOPO_METH_LABEL_DESC, -	    TOPO_METH_LABEL_VERSION, TOPO_STABILITY_INTERNAL, hb_label }, -	{ NULL } -}; - -void -_topo_init(topo_mod_t *modhdl) -{ -	/* -	 * Turn on module debugging output -	 */ -	if (getenv("TOPOHBDBG") != NULL) -		topo_mod_setdebug(modhdl, TOPO_DBG_ALL); -	topo_mod_dprintf(modhdl, "initializing hostbridge enumerator\n"); - -	topo_mod_register(modhdl, &Hb_info, NULL); -	topo_mod_dprintf(modhdl, "Hostbridge enumr initd\n"); -} - -void -_topo_fini(topo_mod_t *modhdl) -{ -	topo_mod_unregister(modhdl); -} - -/*ARGSUSED*/ -static int -hb_contains(topo_mod_t *mp, tnode_t *node, topo_version_t version, -    nvlist_t *in, nvlist_t **out) -{ -	return (0); -} - -/*ARGSUSED*/ -static int -hb_present(topo_mod_t *mp, tnode_t *node, topo_version_t version, -    nvlist_t *in, nvlist_t **out) -{ -	return (0); -} - -static int -hb_label(topo_mod_t *mp, tnode_t *node, topo_version_t version, -    nvlist_t *in, nvlist_t **out) -{ -	if (version > TOPO_METH_LABEL_VERSION) -		return (topo_mod_seterrno(mp, EMOD_VER_NEW)); -	return (platform_hb_label(node, in, out, mp)); -} - -static topo_mod_t * -pci_enumr_load(topo_mod_t *mp, tnode_t *parent) -{ -	topo_mod_t *rp = NULL; -	char *plat, *mach; -	char *pcipath; -	char *rootdir; -	int err; - -	plat = mach = NULL; - -	if (topo_prop_get_string(parent, -	    TOPO_PGROUP_SYSTEM, TOPO_PROP_PLATFORM, &plat, &err) < 0) { -		(void) topo_mod_seterrno(mp, err); -		return (NULL); -	} -	if (topo_prop_get_string(parent, -	    TOPO_PGROUP_SYSTEM, TOPO_PROP_MACHINE, &mach, &err) < 0) { -		(void) topo_mod_seterrno(mp, err); -		return (NULL); -	} -	pcipath = topo_mod_alloc(mp, PATH_MAX); -	rootdir = topo_mod_rootdir(mp); -	(void) snprintf(pcipath, -	    PATH_MAX, PATH_TO_PCI_ENUM, rootdir ? rootdir : "", plat); - -	if ((rp = topo_mod_load(mp, pcipath)) == NULL) { -		topo_mod_dprintf(mp, -		    "%s enumerator could not load %s.\n", HOSTBRIDGE, pcipath); -		(void) snprintf(pcipath, -		    PATH_MAX, PATH_TO_PCI_ENUM, rootdir ? rootdir : "", mach); -		if ((rp = topo_mod_load(mp, pcipath)) == NULL) { -			topo_mod_dprintf(mp, -			    "%s enumerator could not load %s.\n", -			    HOSTBRIDGE, pcipath); -		} -	} -	topo_mod_strfree(mp, plat); -	topo_mod_strfree(mp, mach); -	topo_mod_free(mp, pcipath, PATH_MAX); -	return (rp); -} - -/*ARGSUSED*/ -static int -hb_enum(topo_mod_t *mp, tnode_t *pn, const char *name, topo_instance_t imin, -    topo_instance_t imax, void *notused) -{ -	topo_mod_t *pcimod; -	did_hash_t *didhash; -	di_prom_handle_t promtree; -	int rv; - -	if (strcmp(name, HOSTBRIDGE) != 0) { -		topo_mod_dprintf(mp, -		    "Currently only know how to enumerate %s components.\n", -		    HOSTBRIDGE); -		return (0); -	} - -	/* -	 * Load the pcibus enumerator, we'll soon need it! -	 */ -	if ((pcimod = pci_enumr_load(mp, pn)) == NULL) -		return (-1); - -	if ((promtree = di_prom_init()) == DI_PROM_HANDLE_NIL) { -		topo_mod_unload(pcimod); -		topo_mod_dprintf(mp, -		    "Hostbridge enumerator: di_prom_handle_init failed.\n"); -		return (-1); -	} - -	/* -	 * If we're asked to enumerate a whole range of hostbridges, then -	 * we need to find them all.  If we're just asked to enumerate a -	 * single hostbridge, we expect our caller to have passed us linked -	 * did_t structures we can use to enumerate the singled out hostbridge. -	 */ -	if (imin != imax) { - -		if ((didhash = did_hash_init(mp)) == NULL) { -			topo_mod_dprintf(mp, -			    "Hash initialization for hostbridge " -			    "enumerator failed.\n"); -			topo_mod_unload(pcimod); -			return (-1); -		} -		if ((rv = platform_hb_enum(pn, name, imin, imax, didhash, -		    promtree, mp)) < 0) -			topo_mod_seterrno(mp, EMOD_PARTIAL_ENUM); -		di_prom_fini(promtree); -		did_hash_fini(didhash); -		topo_mod_unload(pcimod); -		return (rv); -	} else { -		rv = specific_hb_enum(pn, name, imin, imax, promtree, mp); -		di_prom_fini(promtree); -		topo_mod_unload(pcimod); -		return (rv); -	} -} - -/*ARGSUSED*/ -static void -hb_release(topo_mod_t *mp, tnode_t *node) -{ -	topo_method_unregister_all(mp, node); -} - -static tnode_t * -hb_tnode_create(tnode_t *parent, -    const char *name, topo_instance_t i, void *priv, topo_mod_t *mod) -{ -	topo_hdl_t *thp; -	nvlist_t *args, *fmri, *pfmri; -	tnode_t *ntn; -	int err; - -	thp = topo_mod_handle(mod); - -	if (topo_node_resource(parent, &pfmri, &err) < 0) { -		topo_mod_seterrno(mod, err); -		topo_mod_dprintf(mod, -		    "Unable to retrieve parent resource.\n"); -		return (NULL); -	} -	if (topo_mod_nvalloc(mod, &args, NV_UNIQUE_NAME) != 0) { -		(void) topo_mod_seterrno(mod, EMOD_FMRI_NVL); -		nvlist_free(pfmri); -		return (NULL); -	} -	err = nvlist_add_nvlist(args, TOPO_METH_FMRI_ARG_PARENT, pfmri); -	if (err != 0) { -		nvlist_free(pfmri); -		nvlist_free(args); -		(void) topo_mod_seterrno(mod, EMOD_FMRI_NVL); -		return (NULL); -	} - -	fmri = topo_fmri_create(thp, FM_FMRI_SCHEME_HC, name, i, args, &err); -	if (fmri == NULL) { -		nvlist_free(pfmri); -		nvlist_free(args); -		(void) topo_mod_seterrno(mod, err); -		topo_mod_dprintf(mod, -		    "Unable to make nvlist for %s bind: %s.\n", -		    name, topo_strerror(err)); -		return (NULL); -	} - -	nvlist_free(pfmri); -	nvlist_free(args); -	ntn = topo_node_bind(mod, parent, name, i, fmri, priv); -	if (ntn == NULL) { -		topo_mod_dprintf(mod, -		    "topo_node_bind (%s%d/%s%d) failed: %s\n", -		    topo_node_name(parent), topo_node_instance(parent), -		    name, i, -		    topo_strerror(topo_mod_errno(mod))); -		nvlist_free(fmri); -		return (NULL); -	} -	nvlist_free(fmri); -	if (topo_method_register(mod, ntn, Hb_methods) < 0) { -		topo_mod_dprintf(mod, "topo_method_register failed: %s\n", -		    topo_strerror(topo_mod_errno(mod))); -		topo_node_unbind(ntn); -		return (NULL); -	} -	return (ntn); -} - -tnode_t * -pcihostbridge_declare(tnode_t *parent, di_node_t din, topo_instance_t i, -    did_hash_t *didhash, di_prom_handle_t promtree, topo_mod_t *mod) -{ -	did_t *pd; -	tnode_t *ntn; - -	if ((pd = did_find(didhash, din)) == NULL) -		return (NULL); -	if ((ntn = hb_tnode_create(parent, HOSTBRIDGE, i, pd, mod)) == NULL) -		return (NULL); -	if (did_props_set(ntn, pd, HB_common_props, HB_propcnt, -	    promtree) < 0) { -		topo_node_unbind(ntn); -		return (NULL); -	} -	/* -	 * We expect to find pci buses beneath the hostbridge. -	 */ -	if (child_range_add(mod, ntn, PCI_BUS, 0, MAX_HB_BUSES) < 0) { -		topo_node_unbind(ntn); -		return (NULL); -	} -	return (ntn); -} - -tnode_t * -pciexhostbridge_declare(tnode_t *parent, di_node_t din, topo_instance_t hi, -    did_hash_t *didhash, di_prom_handle_t promtree, topo_mod_t *mod) -{ -	did_t *pd; -	tnode_t *ntn; - -	if ((pd = did_find(didhash, din)) == NULL) -		return (NULL); -	if ((ntn = hb_tnode_create(parent, HOSTBRIDGE, hi, din, mod)) == NULL) -		return (NULL); -	if (did_props_set(ntn, pd, ExHB_common_props, ExHB_propcnt, -	    promtree) < 0) { -		topo_node_unbind(ntn); -		return (NULL); -	} -	/* -	 * We expect to find root complexes beneath the hostbridge. -	 */ -	if (child_range_add(mod, ntn, PCIEX_ROOT, 0, MAX_HB_BUSES) < 0) { -		topo_node_unbind(ntn); -		return (NULL); -	} -	return (ntn); -} - -tnode_t * -pciexrc_declare(tnode_t *parent, di_node_t din, topo_instance_t ri, -    did_hash_t *didhash, di_prom_handle_t promtree, topo_mod_t *mod) -{ -	did_t *pd; -	tnode_t *ntn; - -	if ((pd = did_find(didhash, din)) == NULL) -		return (NULL); -	did_markrc(pd); -	if ((ntn = hb_tnode_create(parent, PCIEX_ROOT, ri, din, mod)) == NULL) -		return (NULL); -	if (did_props_set(ntn, pd, RC_common_props, RC_propcnt, -	    promtree) < 0) { -		topo_node_unbind(ntn); -		return (NULL); -	} -	/* -	 * We expect to find pci-express buses beneath a root complex -	 */ -	if (child_range_add(mod, ntn, PCIEX_BUS, 0, MAX_HB_BUSES) < 0) { -		topo_node_range_destroy(ntn, PCIEX_BUS); -		return (NULL); -	} -	return (ntn); -} - -/*ARGSUSED*/ -static int -specific_hb_enum(tnode_t *pn, const char *name, topo_instance_t imin, -    topo_instance_t imax, di_prom_handle_t promtree, topo_mod_t *mod) -{ -	tnode_t *hb; -	did_t *iodid, *didp; -	did_hash_t *didhash; -	char *pname; -	int brc = 0; -	int bus; - -	pname = topo_node_name(pn); -	if ((iodid = topo_node_private(pn)) == NULL) { -		topo_mod_dprintf(mod, -		    "Parent %s node missing private data.\n" -		    "Unable to proceed with %s enumeration.\n", -		    pname, name); -		return (-1); -	} -	didhash = did_hash(iodid); - -	/* -	 * Find the hostbridge of interest -	 */ -	didp = iodid; -	for (brc = 0; brc < imin; brc++) -		didp = did_chain_get(didp); -	assert(didp != NULL); - -	if ((hb = pcihostbridge_declare(pn, did_dinode(didp), imin, didhash, -	    promtree, mod)) == NULL) -		return (-1); -	while (didp != NULL) { -		did_BDF(didp, &bus, NULL, NULL); -		if (topo_mod_enumerate(mod, -		    hb, PCI_BUS, PCI_BUS, bus, bus) != 0) -			return (topo_mod_seterrno(mod, EMOD_PARTIAL_ENUM)); -		didp = did_link_get(didp); -	} -	return (0); -} | 
