Example #1
0
static int
module_run(topo_mod_t *mp, tnode_t *parent, pfn_enum_t *ep)
{
	return (topo_mod_enumerate(mp, parent,
	    ep->pfne_modname, ep->pfne_childname,
	    ep->pfne_imin, ep->pfne_imax));
}
Example #2
0
/*ARGSUSED*/
static int
xaui_enum(topo_mod_t *mod, tnode_t *rnode, const char *name,
	topo_instance_t min, topo_instance_t max, void *arg, void *priv)
{
	tnode_t *xauin;

	if (strcmp(name, XAUI) != 0) {
		topo_mod_dprintf(mod,
		    "Currently only know how to enumerate %s components.\n",
		    XAUI);
		return (0);
	}

	xaui_mod_hdl = mod;

	/*
	 * Load XFP enum
	 */
	if (xfp_enum_load(mod) == NULL)
		return (-1);

	if ((xauin = xaui_declare(rnode, name, min, priv, mod)) == NULL)
		return (-1);

	/* set the private data to be the instance number of niufn */
	if (topo_mod_enumerate(mod,
	    xauin, XFP, XFP, 0, 0, NULL) != 0) {
		return (topo_mod_seterrno(mod, EMOD_PARTIAL_ENUM));
	}
	return (0);
}
Example #3
0
/*ARGSUSED*/
static int
specific_hb_enum(topo_mod_t *mod, tnode_t *pn, const char *name,
    topo_instance_t imin, topo_instance_t imax, void *priv)
{
	tnode_t *hb;
	did_t *iodid = (did_t *)priv;
	did_t *didp;
	int brc = 0;
	int bus;

	did_setspecific(mod, priv);

	/*
	 * 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(mod, pn, did_dinode(didp), imin))
	    == NULL) {
		return (-1);
	}
	while (didp != NULL) {
		did_BDF(didp, &bus, NULL, NULL);
		if (topo_mod_enumerate(mod,
		    hb, PCI_BUS, PCI_BUS, bus, bus, didp) != 0) {
			return (topo_mod_seterrno(mod, EMOD_PARTIAL_ENUM));
		}
		didp = did_link_get(didp);
	}

	return (0);
}
Example #4
0
static int
niufn_instantiate(tnode_t *parent, const char *name, di_node_t pnode,
	topo_mod_t *mod)
{
	di_node_t sib;
	tnode_t *ntn;
	topo_instance_t inst;

	if (strcmp(name, NIUFN) != 0) {
		topo_mod_dprintf(mod,
		    "Currently only know how to enumerate %s components.\n",
		    NIUFN);
		return (0);
	}

	sib = di_child_node(pnode);
	while (sib != DI_NODE_NIL) {
		if (niufn_instance_get(mod, sib, &inst) != 0) {
			topo_mod_dprintf(mod, "Enumeration of %s "
			    "instance failed.\n", NIUFN);
			sib = di_sibling_node(sib);
			continue;
		}
		if ((ntn = niufn_declare(parent, NIUFN, inst, sib, mod))
		    == NULL) {
			topo_mod_dprintf(mod, "Enumeration of %s=%d "
			    "failed: %s\n", NIUFN, inst,
			    topo_strerror(topo_mod_errno(mod)));
			return (-1);
		}
		if (topo_mod_enumerate(mod,
		    ntn, XAUI, XAUI, inst, inst, sib) != 0) {
			return (topo_mod_seterrno(mod, EMOD_PARTIAL_ENUM));
		}
		sib = di_sibling_node(sib);
	}
	return (0);
}
Example #5
0
/*ARGSUSED*/
int
platform_iob_enum(topo_mod_t *mod, tnode_t *parent, topo_instance_t imin,
    topo_instance_t imax)
{
	/*
	 * An E15K and its successors may have up to 18 I/O boards,
	 * numbered 0 through 17.  Each board has two hostbridges, and
	 * there are a pair of PCI buses under each hostbridge.  We can
	 * discover the existence of a board by the presence of
	 * devinfo nodes for those hostbridges.  We let the hostbridge
	 * enumerator actually create nodes for the hostbridges,
	 * passing them the did_t's for all the hostbridge nodes we
	 * know indicate that the ioboard exists.
	 */
	di_node_t devtree;
	di_node_t pnode;
	did_t *iobs[18][2][2];
	int brd, br, bus, i;

	devtree = topo_mod_devinfo(mod);
	if (devtree == DI_NODE_NIL) {
		topo_mod_dprintf(mod, "devinfo init failed.");
		return (-1);
	}

	for (i = 0; i < 18; i++) {
		iobs[i][0][0] = iobs[i][0][1] = NULL;
		iobs[i][1][0] = iobs[i][1][1] = NULL;
	}

	pnode = di_drv_first_node(SCHIZO, devtree);
	while (pnode != DI_NODE_NIL) {
		did_t *d;

		d = split_bus_address(mod,
		    pnode, IOB_BASEADDR, BUS_ADDRDIST, 0, 17, &brd, &br, &bus);
		if (d == NULL) {
			pnode = di_drv_next_node(pnode);
			continue;
		}
		iobs[brd][br][bus] = d;
		pnode = di_drv_next_node(pnode);
	}

	for (i = 0; i < 18; i++) {
		tnode_t *ion;
		/*
		 * Make sure we found all the buses and bridges
		 */
		if (iobs[i][0][0] == NULL || iobs[i][0][1] == NULL ||
		    iobs[i][1][0] == NULL || iobs[i][1][1] == NULL)
			continue;
		did_did_link_set(iobs[i][0][0], iobs[i][0][1]);
		did_did_link_set(iobs[i][1][0], iobs[i][1][1]);
		did_did_chain_set(iobs[i][0][0], iobs[i][1][0]);
		if ((ion = ioboard_declare(mod, parent, i, iobs[i][0][0]))
		    == NULL) {
			topo_mod_dprintf(mod,
			    "Creation of tnode for %s%d failed.\n", IOBOARD, i);
			continue;
		}
		if (topo_mod_enumerate(mod, ion, HOSTBRIDGE, HOSTBRIDGE, 0, 0,
		    iobs[i][0][0]) < 0) {
			topo_mod_dprintf(mod,
			    "Enumeration of %s%d/%s%d failed.\n",
			    IOBOARD, i, HOSTBRIDGE, 0);
			continue;
		}
		if (topo_mod_enumerate(mod, ion, HOSTBRIDGE, HOSTBRIDGE, 1, 1,
		    iobs[i][0][0]) < 0) {
			topo_mod_dprintf(mod,
			    "Enumeration of %s%d/%s%d failed.\n",
			    IOBOARD, i, HOSTBRIDGE, 1);
			continue;
		}
	}
	return (0);
}
Example #6
0
/*
 * Create a generic topo node based on the hcfmri strcuture passed in.
 */
int
x86pi_enum_generic(topo_mod_t *mod, x86pi_hcfmri_t *hcfmri,
    tnode_t *t_bindparent, tnode_t *t_fmriparent, tnode_t **t_node, int flag)
{
	int		rv;
	int		err;
	nvlist_t	*out;
	nvlist_t	*fmri;
	nvlist_t	*auth;

	topo_mod_dprintf(mod, "%s adding entry for type (%s)\n",
	    _ENUM_NAME, hcfmri->hc_name);

	if (t_bindparent == NULL) {
		topo_mod_dprintf(mod,
		    "%s called with NULL parent for type %s\n",
		    _ENUM_NAME, hcfmri->hc_name);
		return (-1);
	}

	/* Create the FMRI for this node */
	auth = topo_mod_auth(mod, t_bindparent);
	fmri = topo_mod_hcfmri(mod, t_fmriparent, FM_HC_SCHEME_VERSION,
	    hcfmri->hc_name, hcfmri->instance, NULL, auth,
	    hcfmri->part_number, hcfmri->version, hcfmri->serial_number);

	nvlist_free(auth);

	if (fmri == NULL) {
		topo_mod_dprintf(mod,
		    "%s failed to create %s fmri : %s\n", _ENUM_NAME,
		    hcfmri->hc_name, topo_strerror(topo_mod_errno(mod)));
		return (-1);
	}

	rv = topo_node_range_create(mod, t_bindparent, hcfmri->hc_name, 0, 4);
	if (rv != 0 && topo_mod_errno(mod) != EMOD_NODE_DUP) {
		topo_mod_dprintf(mod, "%s range create failed for node %s\n",
		    _ENUM_NAME, hcfmri->hc_name);
	}

	/* Bind this node to the parent */
	*t_node = x86pi_node_bind(mod, t_bindparent, hcfmri, fmri, flag);
	nvlist_free(fmri);
	if (*t_node == NULL) {
		topo_mod_dprintf(mod,
		    "%s failed to bind %s node instance %d: %s\n",
		    _ENUM_NAME, hcfmri->hc_name, hcfmri->instance,
		    topo_strerror(topo_mod_errno(mod)));
		return (-1);
	}

	/* call IPMI facility provider to register fac methods */
	if (topo_mod_load(mod, _FAC_PROV, TOPO_VERSION) == NULL) {
		topo_mod_dprintf(mod,
		    "%s: Failed to load %s module: %s\n", _ENUM_NAME, _FAC_PROV,
		    topo_mod_errmsg(mod));
		return (-1);
	}

	rv = topo_mod_enumerate(mod, *t_node, _FAC_PROV, _FAC_PROV, 0, 0, NULL);
	if (rv != 0) {
		topo_mod_dprintf(mod,
		    "%s: %s failed: %s\n", _ENUM_NAME, _FAC_PROV,
		    topo_mod_errmsg(mod));
		return (-1);
	}

	/* invoke fac_prov_ipmi_enum method */
	if (topo_method_supported(*t_node, TOPO_METH_FAC_ENUM, 0)) {
		if (topo_method_invoke(*t_node, TOPO_METH_FAC_ENUM, 0, NULL,
		    &out, &err) != 0) {
			/* log the error and drive on */
			topo_mod_dprintf(mod,
			    "%s: TOPO_METH_FAC_ENUM failed\n", _ENUM_NAME);
		} else {
			fac_done = 1;
		}
	}

	topo_mod_dprintf(mod, "%s added (%s) node\n", _ENUM_NAME,
	    topo_node_name(*t_node));

	return (0);
}
Example #7
0
/*
 * opl_hb_enum gets the ioboard instance passed in, and determines the
 * hostbridge and root complex instances numbers based on the bus addresses.
 */
int
opl_hb_enum(topo_mod_t *mp, const ioboard_contents_t *iob, tnode_t *ion,
    int brd)
{
	int hb;
	int rc;
	di_node_t p;
	tnode_t *hbnode;
	tnode_t *rcnode;
	topo_mod_t *pcimod;

	/* Load the pcibus module. We'll need it later. */
	pcimod = topo_mod_load(mp, PCI_BUS, PCI_BUS_VERS);
	if (pcimod == NULL) {
		topo_mod_dprintf(mp, "can't load pcibus module: %s\n",
		    topo_strerror(topo_mod_errno(mp)));
		return (-1);
	}

	/* For each hostbridge on an ioboard... */
	for (hb = 0; hb < OPL_HB_MAX; hb++) {
		hbnode = NULL;
		/* For each root complex in a hostbridge... */
		for (rc = 0; rc < OPL_RC_MAX; rc++) {
			p = iob->rcs[hb][rc];
			/* If no root complex, continue */
			if (p == DI_NODE_NIL) {
				continue;
			}

			/* The root complex exists! */
			topo_mod_dprintf(mp, "declaring "
			    "/chassis=0/ioboard=%d/hostbridge=%d/pciexrc=%d\n",
			    brd, hb, rc);

			/*
			 * If we haven't created a hostbridge node yet, do it
			 * now.
			 */
			if (hbnode == NULL) {
				hbnode = opl_hb_node_create(mp, ion, hb);
				if (hbnode == NULL) {
					topo_mod_dprintf(mp,
					    "unable to create hbnode: %s\n",
					    topo_strerror(topo_mod_errno(mp)));
					topo_mod_unload(pcimod);
					return (-1);
				}

			}

			/* Create the root complex node */
			rcnode = opl_rc_node_create(mp, hbnode, p, rc);
			if (rcnode == NULL) {
				topo_mod_dprintf(mp,
				    "unable to create rcnode: %s\n",
				    topo_strerror(topo_mod_errno(mp)));
				topo_mod_unload(pcimod);
				return (-1);
			}

			/* Enumerate pcibus nodes under the root complex */
			if (topo_mod_enumerate(pcimod, rcnode,
			    PCI_BUS, PCIEX_BUS, 0, 255, NULL) != 0) {
				topo_mod_dprintf(mp,
				    "error enumerating pcibus: %s\n",
				    topo_strerror(topo_mod_errno(mp)));
				topo_mod_unload(pcimod);
				return (-1);
			}
		}
	}
	topo_mod_unload(pcimod);
	return (0);
}
/*
 * Enumerate hostbridge on the cpuboard.  Hostbridge and root complex instances
 * match the cpuboard instance.
 */
int
cpuboard_hb_enum(topo_mod_t *mp, di_node_t dnode, char *rcpath,
    tnode_t *cpubn, int brd)
{
	int hb;
	int rc;
	tnode_t *hbnode;
	tnode_t *rcnode;
	topo_mod_t *pcimod;

	topo_mod_dprintf(mp, "cpuboard_hb_enum: brd: %d, cpubn=%p\n",
	    brd, cpubn);

	/* Load the pcibus module. We'll need it later. */
	pcimod = topo_mod_load(mp, PCI_BUS, PCI_BUS_VERS);
	if (pcimod == NULL) {
		topo_mod_dprintf(mp, "can't load pcibus module: %s\n",
		    topo_strerror(topo_mod_errno(mp)));
		return (-1);
	}
	hb = rc = brd;

	/* The root complex exists! */
	topo_mod_dprintf(mp, "declaring "
	    "/motherboard=0/cpuboard=%d/hostbridge=%d/"
	    "pciexrc=%d\n", brd, hb, rc);

	/* Create the hostbridge node */
	hbnode = cpuboard_hb_node_create(mp, cpubn, hb);
	if (hbnode == NULL) {
		topo_mod_dprintf(mp,
		    "unable to create hbnode: %s\n",
		    topo_strerror(topo_mod_errno(mp)));
		topo_mod_unload(pcimod);
		return (-1);
	}
	/* Create the root complex node */
	rcnode = cpuboard_rc_node_create(mp, hbnode, dnode, rcpath, rc);
	if (rcnode == NULL) {
		topo_mod_dprintf(mp,
		    "unable to create rcnode: %s\n",
		    topo_strerror(topo_mod_errno(mp)));
		topo_mod_unload(pcimod);
		return (-1);
	}
	/*
	 * If dnode not NULL, enumerate pcibus nodes under the root complex.
	 * If dnode NULL, skip enumeration.  Condition could occur if the RC
	 * is assigned to non-control domain.
	 */
	if ((dnode != NULL) && topo_mod_enumerate(pcimod, rcnode,
	    PCI_BUS, PCIEX_BUS, 0, 255, NULL) != 0) {
		topo_mod_dprintf(mp,
		    "error enumerating pcibus: %s\n",
		    topo_strerror(topo_mod_errno(mp)));
		topo_mod_unload(pcimod);
		return (-1);
	}
	topo_mod_unload(pcimod);
	return (0);
}