예제 #1
0
static void
print_node(topo_hdl_t *thp, tnode_t *node, nvlist_t *nvl, const char *fmri)
{
	int err, ret;

	(void) printf("%s\n", (char *)fmri);

	if (opt_p && !(pcnt > 0 || opt_V || opt_all)) {
		char *aname = NULL, *fname = NULL, *lname = NULL;
		nvlist_t *asru = NULL;
		nvlist_t *fru = NULL;

		if (topo_node_asru(node, &asru, NULL, &err) == 0)
			(void) topo_fmri_nvl2str(thp, asru, &aname, &err);
		if (topo_node_fru(node, &fru, NULL, &err) == 0)
			(void) topo_fmri_nvl2str(thp, fru, &fname, &err);
		(void) topo_node_label(node, &lname, &err);
		if (aname != NULL) {
			nvlist_free(asru);
			(void) printf("\tASRU: %s\n", aname);
			topo_hdl_strfree(thp, aname);
		} else {
			(void) printf("\tASRU: -\n");
		}
		if (fname != NULL) {
			nvlist_free(fru);
			(void) printf("\tFRU: %s\n", fname);
			topo_hdl_strfree(thp, fname);
		} else {
			(void) printf("\tFRU: -\n");
		}
		if (lname != NULL) {
			(void) printf("\tLabel: %s\n", lname);
			topo_hdl_strfree(thp, lname);
		} else {
			(void) printf("\tLabel: -\n");
		}
	}

	if (opt_S) {
		if ((ret = topo_fmri_present(thp, nvl, &err)) < 0)
			(void) printf("\tPresent: -\n");
		else
			(void) printf("\tPresent: %s\n",
			    ret ? "true" : "false");

		if ((ret = topo_fmri_unusable(thp, nvl, &err)) < 0)
			(void) printf("\tUnusable: -\n");
		else
			(void) printf("\tUnusable: %s\n",
			    ret ? "true" : "false");
	}
}
예제 #2
0
파일: topo_fmri.c 프로젝트: andreiw/polaris
/*ARGSUSED*/
static int
get_prop(topo_hdl_t *thp, tnode_t *node, void *pdata)
{
	struct rsrc *rsp = (struct rsrc *)pdata;

	if (rsp->rs_flag == 0) {
		if (topo_node_asru(node, rsp->rs_fprop, rsp->rs_priv,
		    &rsp->rs_err) < 0)
			return (-1);

		return (0);
	} else {
		if (topo_node_fru(node, rsp->rs_fprop, rsp->rs_priv,
		    &rsp->rs_err) < 0)
			return (-1);

		return (0);
	}
}
예제 #3
0
static int
dimm_page_unretire(topo_mod_t *mod, tnode_t *node, topo_version_t version,
    nvlist_t *in, nvlist_t **out)
{
	uint32_t rc = FMD_AGENT_RETIRE_FAIL;
	nvlist_t *asru;
	int err;

	if (version > TOPO_METH_UNRETIRE_VERSION)
		return (topo_mod_seterrno(mod, EMOD_VER_NEW));

	if (pi_lhp != NULL && is_page_fmri(in) &&
	    topo_node_asru(node, &asru, in, &err) == 0) {
		err = ldom_fmri_unretire(pi_lhp, asru);

		if (err == 0 || err == EIO)
			rc = FMD_AGENT_RETIRE_DONE;
		nvlist_free(asru);
	}

	return (set_retnvl(mod, out, TOPO_METH_UNRETIRE_RET, rc));
}
예제 #4
0
static int
dimm_page_unusable(topo_mod_t *mod, tnode_t *node, topo_version_t version,
    nvlist_t *in, nvlist_t **out)
{
	uint32_t rc = 0;
	nvlist_t *asru;
	int err;

	if (version > TOPO_METH_UNUSABLE_VERSION)
		return (topo_mod_seterrno(mod, EMOD_VER_NEW));

	if (pi_lhp != NULL && is_page_fmri(in) &&
	    topo_node_asru(node, &asru, in, &err) == 0) {
		err = ldom_fmri_status(pi_lhp, asru);

		if (err == 0 || err == EINVAL)
			rc = 1;
		nvlist_free(asru);
	}

	return (set_retnvl(mod, out, TOPO_METH_UNUSABLE_RET, rc));
}
예제 #5
0
static int
dimm_page_service_state(topo_mod_t *mod, tnode_t *node, topo_version_t version,
    nvlist_t *in, nvlist_t **out)
{
	uint32_t rc = FMD_SERVICE_STATE_OK;
	nvlist_t *asru;
	int err;

	if (version > TOPO_METH_SERVICE_STATE_VERSION)
		return (topo_mod_seterrno(mod, EMOD_VER_NEW));

	if (pi_lhp != NULL && is_page_fmri(in) &&
	    topo_node_asru(node, &asru, in, &err) == 0) {
		err = ldom_fmri_status(pi_lhp, asru);

		if (err == 0 || err == EINVAL)
			rc = FMD_SERVICE_STATE_UNUSABLE;
		else if (err == EAGAIN)
			rc = FMD_SERVICE_STATE_ISOLATE_PENDING;
		nvlist_free(asru);
	}

	return (set_retnvl(mod, out, TOPO_METH_SERVICE_STATE_RET, rc));
}
예제 #6
0
/*
 * For each visited cpu node, call the callback function with its ASRU.
 */
static int
cpu_walker(topo_mod_t *mod, tnode_t *node, void *pdata)
{
	struct cpu_walk_data *swdp = pdata;
	nvlist_t *asru;
	int err, rc;

	/*
	 * Terminate the walk if we reach start-node's sibling
	 */
	if (node != swdp->parent &&
	    topo_node_parent(node) == topo_node_parent(swdp->parent))
		return (TOPO_WALK_TERMINATE);

	if (strcmp(topo_node_name(node), CPU) != 0 &&
	    strcmp(topo_node_name(node), STRAND) != 0)
		return (TOPO_WALK_NEXT);

	if (topo_node_asru(node, &asru, NULL, &err) != 0) {
		swdp->fail++;
		return (TOPO_WALK_NEXT);
	}

	rc = swdp->func(swdp->lhp, asru);

	/*
	 * The "offline" and "online" counter are only useful for the "status"
	 * callback.
	 */
	if (rc == P_OFFLINE || rc == P_FAULTED) {
		swdp->offline++;
		err = 0;
	} else if (rc == P_ONLINE) {
		swdp->online++;
		err = 0;
	} else {
		swdp->fail++;
		err = errno;
	}

	/* dump out status info if debug is turned on. */
	if (getenv("TOPOCHIPDBG") != NULL ||
	    getenv("TOPOSUN4VPIDBG") != NULL) {
		const char *op;
		char *fmristr = NULL;

		if (swdp->func == ldom_fmri_retire)
			op = "retire";
		else if (swdp->func == ldom_fmri_unretire)
			op = "unretire";
		else if (swdp->func == ldom_fmri_status)
			op = "check status";
		else
			op = "unknown op";

		(void) topo_mod_nvl2str(mod, asru, &fmristr);
		topo_mod_dprintf(mod, "%s cpu (%s): rc = %d, err = %s\n",
		    op, fmristr == NULL ? "unknown fmri" : fmristr,
		    rc, strerror(err));
		if (fmristr != NULL)
			topo_mod_strfree(mod, fmristr);
	}

	nvlist_free(asru);
	return (TOPO_WALK_NEXT);
}