示例#1
0
int
dev_list_gather(topo_mod_t *mod, topo_list_t *listp)
{
	di_node_t		devtree;
	di_devlink_handle_t	devhdl;
	disk_cbdata_t		dcb;

	if ((devtree = topo_mod_devinfo(mod)) == DI_NODE_NIL) {
		topo_mod_dprintf(mod, "disk_list_gather: "
		    "topo_mod_devinfo() failed");
		return (-1);
	}

	if ((devhdl = di_devlink_init(NULL, 0)) == DI_NODE_NIL) {
		topo_mod_dprintf(mod, "disk_list_gather: "
		    "di_devlink_init() failed");
		return (-1);
	}

	dcb.dcb_mod = mod;
	dcb.dcb_list = listp;
	dcb.dcb_devhdl = devhdl;

	/* walk the devinfo snapshot looking for disk nodes */
	(void) di_walk_node(devtree, DI_WALK_CLDFIRST, &dcb,
	    dev_walk_di_nodes);

	(void) di_devlink_fini(&devhdl);

	return (0);
}
/*
 * Create a hostbridge node.
 */
static tnode_t *
cpuboard_hb_node_create(topo_mod_t *mp, tnode_t *parent, int inst)
{
	int err;
	tnode_t *hbn;

	topo_mod_dprintf(mp, "cpuboard_hb_node_create: parent=%p, inst=%d\n",
	    parent, inst);

	hbn = cpuboard_node_create(mp, parent, HOSTBRIDGE, inst, NULL);
	if (hbn == NULL) {
		topo_mod_dprintf(mp, "cpuboard_hb_node_create: "
		    "cpuboard_node_create() failed.\n");
		return (NULL);
	}

	/* Inherit parent FRU's label */
	(void) topo_node_fru_set(hbn, NULL, 0, &err);
	(void) topo_node_label_set(hbn, NULL, &err);

	/* Make room for children */
	(void) topo_node_range_create(mp, hbn, PCIEX_ROOT, 0, CPUBOARD_MAX);

	topo_mod_dprintf(mp, "cpuboard_hb_node_create: EXIT hbn=%p\n", hbn);

	return (hbn);
}
示例#3
0
static int
disk_declare(topo_mod_t *mod, tnode_t *parent, dev_di_node_t *dnode,
    tnode_t **childp)
{
	tnode_t		*dtn = NULL;
	int		rval;

	rval = disk_tnode_create(mod, parent, dnode, DISK, 0, &dtn);
	if (dtn == NULL) {
		if (rval == 0)
			return (0);
		topo_mod_dprintf(mod, "disk_declare: "
		    "disk_tnode_create error %s\n",
		    topo_strerror(topo_mod_errno(mod)));
		return (-1);
	}

	/* register disk_methods against the disk topo node */
	if (topo_method_register(mod, dtn, disk_methods) != 0) {
		topo_mod_dprintf(mod, "disk_declare: "
		    "topo_method_register error %s\n",
		    topo_strerror(topo_mod_errno(mod)));
		topo_node_unbind(dtn);
		return (-1);
	}
	if (childp != NULL)
		*childp = dtn;
	return (0);
}
示例#4
0
/*
 * Try to find a disk based on the bridge-port property. This is most often used
 * for SATA devices which are attached to a SAS controller and are therefore
 * behind a SATL bridge port. SES only knows of devices based on this SAS WWN,
 * not based on any SATA GUIDs.
 */
int
disk_declare_bridge(topo_mod_t *mod, tnode_t *parent, topo_list_t *listp,
    const char *addr, tnode_t **childp)
{
	dev_di_node_t *dnode;
	int i;

	/* Check for match using addr. */
	for (dnode = topo_list_next(listp); dnode != NULL;
	    dnode = topo_list_next(dnode)) {
		if (dnode->ddn_bridge_port == NULL)
			continue;

		for (i = 0; i < dnode->ddn_ppath_count; i++) {
			if ((dnode->ddn_bridge_port[i] != NULL) &&
			    (strncmp(dnode->ddn_bridge_port[i], addr,
			    strcspn(dnode->ddn_bridge_port[i], ":"))) == 0) {
				topo_mod_dprintf(mod, "disk_declare_bridge: "
				    "found disk matching bridge %s", addr);
				return (disk_declare(mod, parent, dnode,
				    childp));
			}
		}
	}

	topo_mod_dprintf(mod, "disk_declare_bridge: "
	    "failed to find disk matching bridge %s", addr);

	return (1);
}
示例#5
0
static int
niu_asru_set(tnode_t *tn, di_node_t dn, topo_mod_t *mod)
{
	char *path;
	nvlist_t *fmri;
	int e;

	if ((path = di_devfs_path(dn)) != NULL) {
		fmri = topo_mod_devfmri(mod, FM_DEV_SCHEME_VERSION, path, NULL);
		if (fmri == NULL) {
			topo_mod_dprintf(mod,
			    "dev:///%s fmri creation failed.\n", path);
			di_devfs_path_free(path);
			return (-1);
		}
		di_devfs_path_free(path);
	} else {
		topo_mod_dprintf(mod, "NULL di_devfs_path.\n");
		if (topo_prop_get_fmri(tn, TOPO_PGROUP_PROTOCOL,
		    TOPO_PROP_RESOURCE, &fmri, &e) < 0)
			return (topo_mod_seterrno(mod, e));
	}
	if (topo_node_asru_set(tn, fmri, 0, &e) < 0) {
		nvlist_free(fmri);
		return (topo_mod_seterrno(mod, e));
	}
	nvlist_free(fmri);
	return (0);
}
示例#6
0
/*ARGSUSED*/
static int
mb_enum(topo_mod_t *mod, tnode_t *pn, const char *name,
	topo_instance_t min, topo_instance_t max, void *arg, void *notused)
{
	tnode_t *mbn;

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

	mb_mod_hdl = mod;

	mbn = mb_declare(pn, name, 0, NULL, mod);

	if (mbn == NULL) {
		topo_mod_dprintf(mod, "Enumeration of motherboard "
		    "failed: %s\n",
		    topo_strerror(topo_mod_errno(mod)));
		return (-1); /* mod_errno already set */
	}

	return (0);
}
示例#7
0
int
did_props_set(tnode_t *tn, did_t *pd, txprop_t txarray[], int txnum)
{
	topo_mod_t *mp;
	int i, r, e;

	mp = did_mod(pd);
	for (i = 0; i < txnum; i++) {
		/*
		 * Ensure the property group has been created.
		 */
		if (txarray[i].tx_tpgroup != NULL) {
			if (topo_pgroup_create(tn, txarray[i].tx_tpgroup, &e)
			    < 0) {
				if (e != ETOPO_PROP_DEFD)
					return (topo_mod_seterrno(mp, e));
			}
		}

		topo_mod_dprintf(mp,
		    "Setting property %s in group %s.\n",
		    txarray[i].tx_tprop, txarray[i].tx_tpgroup->tpi_name);
		r = txarray[i].tx_xlate(tn, pd,
		    txarray[i].tx_diprop, txarray[i].tx_tpgroup->tpi_name,
		    txarray[i].tx_tprop);
		if (r != 0) {
			topo_mod_dprintf(mp, "failed.\n");
			topo_mod_dprintf(mp, "Error was %s.\n",
			    topo_strerror(topo_mod_errno(mp)));
			return (-1);
		}
		topo_mod_dprintf(mp, "succeeded.\n");
	}
	return (0);
}
示例#8
0
int
disk_mptsas_find_disk(topo_mod_t *mod, tnode_t *baynode, char **sas_address)
{
	char *devctl = NULL;
	uint32_t enclosure, slot;
	int err;
	char *elem, *lastp;
	int ret = -1;

	/*
	 * Get the required properties from the node.  These come from
	 * the static XML mapping.
	 */
	if (topo_prop_get_string(baynode, TOPO_PGROUP_BINDING,
	    TOPO_BINDING_DEVCTL, &devctl, &err) != 0 ||
	    topo_prop_get_uint32(baynode, TOPO_PGROUP_BINDING,
	    TOPO_BINDING_ENCLOSURE, &enclosure, &err) != 0 ||
	    topo_prop_get_uint32(baynode, TOPO_PGROUP_BINDING,
	    TOPO_BINDING_SLOT, &slot, &err) != 0) {
		if (devctl != NULL)
			topo_mod_strfree(mod, devctl);
		topo_mod_dprintf(mod, "bay node was missing mpt_sas binding "
		    "properties\n");
		return (-1);
	}

	/*
	 * devctl is a (potentially) pipe-separated list of different device
	 * paths to try.
	 */
	if ((elem = topo_mod_strsplit(mod, devctl, "|", &lastp)) != NULL) {
		boolean_t done = B_FALSE;
		do {
			topo_mod_dprintf(mod, "trying mpt_sas instance at %s\n",
			    elem);

			ret = get_sas_address(mod, elem, enclosure,
			    slot, sas_address);

			/*
			 * Only try further devctl paths from the list if this
			 * one was not found:
			 */
			if (ret == 0 || errno != ENOENT) {
				done = B_TRUE;
			} else {
				topo_mod_dprintf(mod, "instance not found\n");
			}

			topo_mod_strfree(mod, elem);

		} while (!done && (elem = topo_mod_strsplit(mod, NULL, "|",
		    &lastp)) != NULL);
	}

	topo_mod_strfree(mod, devctl);
	return (ret);
}
示例#9
0
文件: ioboard.c 项目: andreiw/polaris
static tnode_t *
iob_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) {
		topo_mod_dprintf(mod,
		    "Unable to make nvlist for %s bind.\n", name);
		return (NULL);
	}
	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, Iob_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);
}
示例#10
0
/*
 * Extract from the PRI the processor, strand and their fru identity
 */
int
cpu_mdesc_init(topo_mod_t *mod, md_info_t *chip)
{
	int rc = -1;
	md_t *mdp;
	ssize_t bufsiz = 0;
	uint64_t *bufp;
	ldom_hdl_t *lhp;
	uint32_t type = 0;

	/* get the PRI/MD */
	if ((lhp = ldom_init(cpu_alloc, cpu_free)) == NULL) {
		topo_mod_dprintf(mod, "ldom_init() failed\n");
		return (topo_mod_seterrno(mod, EMOD_NOMEM));
	}

	(void) ldom_get_type(lhp, &type);
	if ((type & LDOM_TYPE_CONTROL) != 0) {
		bufsiz = ldom_get_core_md(lhp, &bufp);
	} else {
		bufsiz = ldom_get_local_md(lhp, &bufp);
	}
	if (bufsiz <= 0) {
		topo_mod_dprintf(mod, "failed to get the PRI/MD\n");
		ldom_fini(lhp);
		return (-1);
	}

	if ((mdp = md_init_intern(bufp, cpu_alloc, cpu_free)) == NULL ||
	    md_node_count(mdp) <= 0) {
		cpu_free(bufp, (size_t)bufsiz);
		ldom_fini(lhp);
		return (-1);
	}

	/*
	 * N1 MD contains cpu nodes while N2 MD contains component nodes.
	 */
	if (md_find_name(mdp, MD_STR_COMPONENT) != MDE_INVAL_STR_COOKIE) {
		rc = cpu_n2_mdesc_init(mod, mdp, chip);
	} else if (md_find_name(mdp, MD_STR_CPU) != MDE_INVAL_STR_COOKIE) {
		rc =  cpu_n1_mdesc_init(mod, mdp, chip);
	} else {
		topo_mod_dprintf(mod, "Unsupported PRI/MD\n");
		rc = -1;
	}

	cpu_free(bufp, (size_t)bufsiz);
	(void) md_fini(mdp);
	ldom_fini(lhp);

	return (rc);
}
示例#11
0
文件: ioboard.c 项目: andreiw/polaris
did_t *
split_bus_address(did_hash_t *dhash, di_node_t dp, uint_t baseaddr,
    uint_t bussep, int minbrd, int maxbrd, int *brd, int *br, int *bus,
    di_prom_handle_t promtree, topo_mod_t *mod)
{
	uint_t bc, ac;
	char *comma;
	char *bac;
	char *ba;
	int e;

	if ((ba = di_bus_addr(dp)) == NULL ||
	    (bac = topo_mod_strdup(mod, ba)) == NULL)
		return (NULL);

	topo_mod_dprintf(mod,
	    "Transcribing %s into board, bus, etc.\n", bac);

	if ((comma = strchr(bac, ',')) == NULL) {
		topo_mod_strfree(mod, bac);
		return (NULL);
	}
	*comma = '\0';
	bc = strtonum(mod, bac, &e);
	*comma = ',';
	if (e < 0) {
		topo_mod_dprintf(mod,
		    "Trouble interpreting %s before comma.\n", bac);
		topo_mod_strfree(mod, bac);
		return (NULL);
	}
	ac = strtonum(mod, comma + 1, &e);
	if (e < 0) {
		topo_mod_dprintf(mod,
		    "Trouble interpreting %s after comma.\n", bac);
		topo_mod_strfree(mod, bac);
		return (NULL);
	}
	topo_mod_strfree(mod, bac);

	*brd = ((bc - baseaddr) / bussep) + minbrd;
	*br = (bc - baseaddr) % bussep;
	*bus = ((ac == IOB_BUSADDR1) ? 0 : 1);
	if (*brd < minbrd || *brd > maxbrd || (*br != 0 && *br != 1) ||
	    (ac != IOB_BUSADDR1 && ac != IOB_BUSADDR2)) {
		topo_mod_dprintf(mod, "Trouble with transcription\n");
		topo_mod_dprintf(mod, "brd=%d br=%d bus=%d bc=%x ac=%x\n",
		    *brd, *br, *bus, bc, ac);
		return (NULL);
	}
	return (did_create(dhash, dp, *brd, *br, NO_RC, *bus, promtree));
}
示例#12
0
文件: ioboard.c 项目: andreiw/polaris
void
_topo_init(topo_mod_t *modhdl)
{
	/*
	 * Turn on module debugging output
	 */
	if (getenv("TOPOIOBDBG") != NULL)
		topo_mod_setdebug(modhdl, TOPO_DBG_ALL);
	topo_mod_dprintf(modhdl, "initializing ioboard enumerator\n");

	topo_mod_register(modhdl, &Iob_info, NULL);
	topo_mod_dprintf(modhdl, "Ioboard enumr initd\n");
}
示例#13
0
static tnode_t *
hb_tnode_create(topo_mod_t *mod, tnode_t *parent,
    const char *name, topo_instance_t i, void *priv)
{
	int err;
	nvlist_t *fmri;
	tnode_t *ntn;
	nvlist_t *auth = topo_mod_auth(mod, parent);

	fmri = topo_mod_hcfmri(mod, parent, FM_HC_SCHEME_VERSION, name, i,
	    NULL, auth, NULL, NULL, NULL);
	nvlist_free(auth);
	if (fmri == NULL) {
		topo_mod_dprintf(mod,
		    "Unable to make nvlist for %s bind: %s.\n",
		    name, topo_mod_errmsg(mod));
		return (NULL);
	}

	ntn = topo_node_bind(mod, parent, name, i, fmri);
	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);
	topo_node_setspecific(ntn, priv);

	if (topo_pgroup_create(ntn, &hb_auth_pgroup, &err) == 0) {
		(void) topo_prop_inherit(ntn, FM_FMRI_AUTHORITY,
		    FM_FMRI_AUTH_PRODUCT, &err);
		(void) topo_prop_inherit(ntn, FM_FMRI_AUTHORITY,
		    FM_FMRI_AUTH_PRODUCT_SN, &err);
		(void) topo_prop_inherit(ntn, FM_FMRI_AUTHORITY,
		    FM_FMRI_AUTH_CHASSIS, &err);
		(void) topo_prop_inherit(ntn, FM_FMRI_AUTHORITY,
		    FM_FMRI_AUTH_SERVER, &err);
	}

	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);
}
示例#14
0
/*ARGSUSED*/
static int
disk_temp_reading(topo_mod_t *mod, tnode_t *node, topo_version_t vers,
    nvlist_t *in, nvlist_t **out)
{
	char *devid;
	uint32_t temp;
	dm_descriptor_t drive_descr = NULL;
	nvlist_t *drive_stats, *pargs, *nvl;
	int err;

	if (vers > TOPO_METH_DISK_TEMP_VERSION)
		return (topo_mod_seterrno(mod, ETOPO_METHOD_VERNEW));

	if (nvlist_lookup_nvlist(in, TOPO_PROP_ARGS, &pargs) != 0 ||
	    nvlist_lookup_string(pargs, TOPO_IO_DEVID, &devid) != 0) {
		topo_mod_dprintf(mod, "Failed to lookup %s arg",
		    TOPO_IO_DEVID);
		return (topo_mod_seterrno(mod, EMOD_NVL_INVAL));
	}

	if ((drive_descr = dm_get_descriptor_by_name(DM_DRIVE, devid,
	    &err)) == NULL) {
		topo_mod_dprintf(mod, "failed to get drive decriptor for %s",
		    devid);
		return (topo_mod_seterrno(mod, EMOD_UNKNOWN));
	}

	if ((drive_stats = dm_get_stats(drive_descr, DM_DRV_STAT_TEMPERATURE,
	    &err)) == NULL ||
	    nvlist_lookup_uint32(drive_stats, DM_TEMPERATURE, &temp) != 0) {
		topo_mod_dprintf(mod, "failed to read disk temp for %s",
		    devid);
		dm_free_descriptor(drive_descr);
		return (topo_mod_seterrno(mod, EMOD_UNKNOWN));
	}
	dm_free_descriptor(drive_descr);

	if (topo_mod_nvalloc(mod, &nvl, NV_UNIQUE_NAME) != 0 ||
	    nvlist_add_string(nvl, TOPO_PROP_VAL_NAME,
	    TOPO_SENSOR_READING) != 0 ||
	    nvlist_add_uint32(nvl, TOPO_PROP_VAL_TYPE, TOPO_TYPE_DOUBLE) !=
	    0 || nvlist_add_double(nvl, TOPO_PROP_VAL_VAL, (double)temp) != 0) {
		topo_mod_dprintf(mod, "Failed to allocate 'out' nvlist\n");
		nvlist_free(nvl);
		return (topo_mod_seterrno(mod, EMOD_NOMEM));
	}
	*out = nvl;

	return (0);
}
示例#15
0
文件: ioboard.c 项目: andreiw/polaris
/*ARGSUSED*/
static int
iob_enum(topo_mod_t *mp, tnode_t *pn, const char *name, topo_instance_t imin,
    topo_instance_t imax, void *notused)
{
	topo_mod_t *hbmod;
	int rv;
	did_hash_t *didhash;
	di_prom_handle_t promtree;

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

	if ((promtree = di_prom_init()) == DI_PROM_HANDLE_NIL) {
		topo_mod_dprintf(mp,
		    "Ioboard enumerator: di_prom_handle_init failed.\n");
		return (-1);
	}

	/*
	 * Load the hostbridge enumerator, we'll soon need it!
	 */
	if ((hbmod = hb_enumr_load(mp, pn)) == NULL) {
		di_prom_fini(promtree);
		return (-1);
	}

	if ((didhash = did_hash_init(mp)) == NULL) {
		topo_mod_dprintf(mp,
		    "Hash initialization for ioboard enumerator failed.\n");
		di_prom_fini(promtree);
		topo_mod_unload(hbmod);
		return (-1);
	}

	rv = platform_iob_enum(pn, imin, imax, didhash, promtree, mp);

	did_hash_fini(didhash);
	di_prom_fini(promtree);
	topo_mod_unload(hbmod);

	if (rv < 0)
		return (topo_mod_seterrno(mp, EMOD_PARTIAL_ENUM));
	else
		return (0);
}
示例#16
0
void
pi_walker_fini(topo_mod_t *mod)
{
	topo_mod_dprintf(mod, "pi_walker_fini: enter\n");
	nvlist_free(pi_enum_fns);
	nvlist_free(pi_meths);
}
示例#17
0
/*
 * Set the label for a topo node.
 */
int
x86pi_set_label(topo_mod_t *mod, const char *label, const char *name,
    tnode_t *t_node)
{
	int	result;
	int	err;

	if (mod == NULL) {
		return (-1);
	}

	/*
	 * Set the label for this topology node.
	 * Note that a NULL label will inherit the label from topology
	 * node's parent.
	 */
	result = topo_node_label_set(t_node, (char *)label, &err);
	if (result != 0) {
		(void) topo_mod_seterrno(mod, err);
		topo_mod_dprintf(mod, "x86pi_set_label: failed with label %s "
		    "on %s node: %s\n", (label == NULL ? "NULL" : label),
		    name, topo_strerror(err));
	}

	return (result);
}
示例#18
0
/*ARGSUSED*/
static tnode_t *
niufn_declare(tnode_t *parent, const char *name, topo_instance_t i,
	void *priv, topo_mod_t *mod)
{
	tnode_t *ntn;
	int err;

	if ((ntn = niu_tnode_create(mod, parent, name, i, priv)) == NULL)
		return (NULL);

	/* inherit FRU from parent */
	(void) topo_node_fru_set(ntn, NULL, 0, &err);
	/* inherit parent's label */
	(void) topo_node_label_set(ntn, NULL, &err);

	/* set ASRU */
	(void) niu_asru_set(ntn, priv, mod);

	if (topo_node_range_create(mod, ntn, XAUI, 0, XAUI_MAX) < 0) {
		topo_node_unbind(ntn);
		topo_mod_dprintf(mod, "child_range_add of XAUI"
		    "failed: %s\n",
		    topo_strerror(topo_mod_errno(mod)));
		return (NULL); /* mod_errno already set */
	}
	return (ntn);
}
示例#19
0
/*
 * Get copy of SMBIOS.
 */
smbios_hdl_t *
x86pi_smb_open(topo_mod_t *mod)
{
	smbios_hdl_t *smb_hdl;
	char *f = "x86pi_smb_open";

	topo_mod_dprintf(mod, "%s\n", f);

	smb_hdl = topo_mod_smbios(mod);
	if (smb_hdl == NULL) {
		topo_mod_dprintf(mod, "%s: failed to load SMBIOS\n", f);
		return (NULL);
	}

	return (smb_hdl);
}
示例#20
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);
}
示例#21
0
int
disk_declare_path(topo_mod_t *mod, tnode_t *parent, topo_list_t *listp,
    const char *path)
{
	dev_di_node_t		*dnode;
	int i;

	/*
	 * Check for match using physical phci (ddn_ppath). Use
	 * di_devfs_path_match so generic.vs.non-generic names match.
	 */
	for (dnode = topo_list_next(listp); dnode != NULL;
	    dnode = topo_list_next(dnode)) {
		if (dnode->ddn_ppath == NULL)
			continue;

		for (i = 0; i < dnode->ddn_ppath_count; i++) {
			if (di_devfs_path_match(dnode->ddn_ppath[0], path))
				return (disk_declare(mod, parent, dnode, NULL));
		}
	}

	topo_mod_dprintf(mod, "disk_declare_path: "
	    "failed to find disk matching path %s", path);
	return (0);
}
示例#22
0
int
_topo_init(topo_mod_t *mod, topo_version_t version)
{
	dladm_handle_t handle;

	if (getenv("TOPONICDEBUG") != NULL)
		topo_mod_setdebug(mod);

	topo_mod_dprintf(mod, "_mod_init: "
	    "initializing %s enumerator\n", NIC);

	if (version != NIC_VERSION) {
		return (-1);
	}

	if (dladm_open(&handle) != 0)
		return (-1);

	if (topo_mod_register(mod, &nic_mod, TOPO_VERSION) != 0) {
		dladm_close(handle);
		return (-1);
	}

	topo_mod_setspecific(mod, handle);

	return (0);
}
示例#23
0
int
pi_enum_mem(topo_mod_t *mod, md_t *mdp, mde_cookie_t mde_node,
    topo_instance_t inst, tnode_t *t_parent, const char *hc_name,
    tnode_t **t_node)
{
	int		result;
	int		err;
	nvlist_t	*rsrc = NULL;

	*t_node = NULL;

	/*
	 * Create the basic topology node for the DIMM using the generic
	 * enumerator.  The dimm serial is added to the resource so
	 * the retire agent can retire correct page whether the dimm
	 * has been moved or not.
	 */
	result = pi_enum_generic_impl(mod, mdp, mde_node, inst, t_parent,
	    t_parent, hc_name, _ENUM_NAME, t_node, SUN4VPI_ENUM_ADD_SERIAL);
	if (result != 0) {
		/* Error messages are printed by the generic routine */
		return (result);
	}

	/*
	 * Set ASRU compute method, using resource as argument.
	 */
	result = topo_node_resource(*t_node, &rsrc, &err);
	if (result != 0) {
		topo_mod_dprintf(mod,
		    "%s node_0x%llx failed to get resource: %s\n",
		    _ENUM_NAME, (uint64_t)mde_node, topo_strerror(err));
		return (-1);
	}

	/* Set the ASRU on the node with COMPUTE flag */
	result = topo_node_asru_set(*t_node, rsrc, TOPO_ASRU_COMPUTE, &err);
	nvlist_free(rsrc);
	if (result != 0) {
		topo_mod_dprintf(mod,
		    "%s node_0x%llx failed to set ASRU: %s\n", _ENUM_NAME,
		    (uint64_t)mde_node, topo_strerror(err));
		return (-1);
	}

	return (0);
}
示例#24
0
/*ARGSUSED*/
static int
fac_prov_mptsas_enum(topo_mod_t *mod, tnode_t *rnode, const char *name,
    topo_instance_t min, topo_instance_t max, void *arg, void *unused)
{
	if (topo_node_flags(rnode) == TOPO_NODE_FACILITY) {
		if (topo_method_register(mod, rnode, mptsas_fac_methods) != 0) {
			topo_mod_dprintf(mod, "%s: topo_method_register() "
			    "failed: %s", __func__, topo_mod_errmsg(mod));
			return (-1);
		}
		return (0);
	}

	topo_mod_dprintf(mod, "%s: unexpected node flags %x", __func__,
	    topo_node_flags(rnode));
	return (-1);
}
示例#25
0
/*
 * Get the server hostname (the ID as far as the topo authority is
 * concerned) from sysinfo and return a copy to the caller.
 *
 * The string must be freed with topo_mod_strfree()
 */
char *
x86pi_get_serverid(topo_mod_t *mod)
{
	int result;
	char hostname[MAXNAMELEN];

	topo_mod_dprintf(mod, "x86pi_get_serverid\n");

	result = sysinfo(SI_HOSTNAME, hostname, sizeof (hostname));
	/* Everything is freed up and it's time to return the platform-id */
	if (result == -1) {
		return (NULL);
	}
	topo_mod_dprintf(mod, "x86pi_get_serverid: hostname = %s\n", hostname);

	return (topo_mod_strdup(mod, hostname));
}
示例#26
0
/*ARGSUSED*/
void
_topo_init(topo_mod_t *mod, topo_version_t version)
{
	/*
	 * Turn on module debugging output
	 */
	if (getenv("TOPOMBDBG") != NULL)
		topo_mod_setdebug(mod);
	topo_mod_dprintf(mod, "initializing motherboard enumerator\n");

	if (topo_mod_register(mod, &mb_info, TOPO_VERSION) < 0) {
		topo_mod_dprintf(mod, "motherboard registration failed: %s\n",
		    topo_mod_errmsg(mod));
		return; /* mod errno already set */
	}
	topo_mod_dprintf(mod, "MB enumr initd\n");
}
示例#27
0
/*
 * Clean up any data used by the module before it is unloaded.
 */
void
_topo_fini(topo_mod_t *mod)
{
	topo_mod_dprintf(mod, "module finishing.\n");

	/* Unregister from libtopo */
	topo_mod_unregister(mod);
}
示例#28
0
int
pi_walker_init(topo_mod_t *mod)
{
	int			result;
	pi_enum_functions_t	*fp;
	pi_methods_t		*mp;

	result = topo_mod_nvalloc(mod, &pi_enum_fns, NV_UNIQUE_NAME);
	result |= topo_mod_nvalloc(mod, &pi_meths, NV_UNIQUE_NAME);
	if (result != 0) {
		topo_mod_dprintf(mod, "pi_walker_init failed\n");
		nvlist_free(pi_enum_fns);
		nvlist_free(pi_meths);
		return (-1);
	}

	/* Add the builtin functions to the list */
	fp = pi_enum_fns_builtin;
	while (fp != NULL && fp->hc_name != NULL) {
		uint64_t	faddr;

		faddr = (uint64_t)(uintptr_t)*(fp->func);
		result |= nvlist_add_uint64(pi_enum_fns, fp->hc_name, faddr);
		fp++;
	}

	/* Add the builtin methods to the list */
	mp = pi_meths_builtin;
	while (mp != NULL && mp->hc_name != NULL) {
		uint64_t	maddr;

		maddr = (uint64_t)(uintptr_t)mp->meths;
		result |= nvlist_add_uint64(pi_meths, mp->hc_name, maddr);
		mp++;
	}

	if (result != 0) {
		topo_mod_dprintf(mod, "pi_walker_init failed\n");
		nvlist_free(pi_enum_fns);
		nvlist_free(pi_meths);
		return (-1);
	}

	return (0);
}
示例#29
0
int
sw_init(topo_mod_t *mod, topo_version_t version)
{
	if (getenv("TOPOSWDEBUG"))
		topo_mod_setdebug(mod);
	topo_mod_dprintf(mod, "initializing sw builtin\n");

	if (version != SW_VERSION)
		return (topo_mod_seterrno(mod, EMOD_VER_NEW));

	if (topo_mod_register(mod, &sw_info, TOPO_VERSION) != 0) {
		topo_mod_dprintf(mod, "failed to register sw_info: "
		    "%s\n", topo_mod_errmsg(mod));
		return (-1);
	}

	return (0);
}
示例#30
0
static int
do_led_control(topo_mod_t *mod, char *devctl, uint16_t enclosure,
    uint16_t slot, uint8_t led, uint32_t *ledmode, boolean_t set)
{
	int fd;
	mptsas_led_control_t lc;

	bzero(&lc, sizeof (lc));

	lc.Command = set ? MPTSAS_LEDCTL_FLAG_SET : MPTSAS_LEDCTL_FLAG_GET;
	lc.Enclosure = enclosure;
	lc.Slot = slot;
	lc.Led = led;
	lc.LedStatus = *ledmode;

	if ((fd = open(devctl, (set ? O_RDWR : O_RDONLY))) == -1) {
		topo_mod_dprintf(mod, "devctl open failed: %s",
		    strerror(errno));
		return (-1);
	}

	if (ioctl(fd, MPTIOCTL_LED_CONTROL, &lc) == -1) {
		if (errno == ENOENT) {
			/*
			 * If there is not presently a target attached for
			 * a particular enclosure/slot pair then the driver
			 * does not track LED status for this bay.  Assume
			 * all LEDs are off.
			 */
			lc.LedStatus = 0;
		} else {
			topo_mod_dprintf(mod, "led control ioctl failed: %s",
			    strerror(errno));
			(void) close(fd);
			return (-1);
		}
	}

	*ledmode = lc.LedStatus ? TOPO_LED_STATE_ON : TOPO_LED_STATE_OFF;

	(void) close(fd);
	return (0);
}