changeset 9296:22970d0a688b

6799896 SES enumerator uses incorrect target for enclosure node-specific data 6799897 SES enumerator should prefer targets with enclosure element descriptor 6799898 SES enumerator should export all paths to an enclosure 6826455 SES discrete sensors need to be of type GENERIC_FAILURE
author Eric Schrock <Eric.Schrock@Sun.COM>
date Mon, 06 Apr 2009 17:17:49 -0700
parents e7d2aa3969bc
children f96deff17645
files usr/src/lib/fm/topo/modules/common/ses/ses.c usr/src/lib/fm/topo/modules/common/ses/ses.h usr/src/lib/fm/topo/modules/common/ses/ses_facility.c
diffstat 3 files changed, 63 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/fm/topo/modules/common/ses/ses.c	Mon Apr 06 15:57:51 2009 -0700
+++ b/usr/src/lib/fm/topo/modules/common/ses/ses.c	Mon Apr 06 17:17:49 2009 -0700
@@ -20,10 +20,11 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
+#include <alloca.h>
 #include <dirent.h>
 #include <devid.h>
 #include <fm/libdiskstatus.h>
@@ -832,11 +833,14 @@
 	char *manufacturer = NULL, *model = NULL, *product = NULL;
 	char *revision = NULL;
 	char *serial;
+	char **paths;
 	size_t prodlen;
 	tnode_t *tn;
 	nvlist_t *fmri = NULL, *auth = NULL;
 	int ret = -1;
 	ses_enum_node_t *snp;
+	ses_enum_target_t *stp;
+	int i, err;
 
 	/*
 	 * Ignore any internal enclosures.
@@ -939,6 +943,31 @@
 		goto error;
 
 	/*
+	 * For enclosures, we want to include all possible targets (for upgrade
+	 * purposes).
+	 */
+	for (i = 0, stp = topo_list_next(&cp->sec_targets); stp != NULL;
+	    stp = topo_list_next(stp), i++)
+		;
+
+	verify(i != 0);
+	paths = alloca(i * sizeof (char *));
+
+	for (i = 0, stp = topo_list_next(&cp->sec_targets); stp != NULL;
+	    stp = topo_list_next(stp), i++)
+		paths[i] = stp->set_devpath;
+
+
+	if (topo_prop_set_string_array(tn, TOPO_PGROUP_SES,
+	    TOPO_PROP_PATHS, TOPO_PROP_IMMUTABLE, (const char **)paths,
+	    i, &err) != 0) {
+		topo_mod_dprintf(mod,
+		    "failed to create property %s: %s\n",
+		    TOPO_PROP_PATHS, topo_strerror(err));
+		goto error;
+	}
+
+	/*
 	 * Create the nodes for power supplies, fans, and devices.
 	 */
 	if (ses_create_children(sdp, tn, SES_ET_POWER_SUPPLY,
@@ -953,8 +982,8 @@
 	    BAY, "BAY", cp, B_TRUE) != 0)
 		goto error;
 
-	snp->sen_target->set_refcount++;
-	topo_node_setspecific(tn, snp->sen_target);
+	cp->sec_target->set_refcount++;
+	topo_node_setspecific(tn, cp->sec_target);
 
 	ret = 0;
 error:
@@ -1017,7 +1046,7 @@
 	char *csn;
 	uint64_t instance, type;
 	uint64_t prevstatus, status;
-	boolean_t report, internal;
+	boolean_t report, internal, ident;
 
 	if (ses_node_type(np) == SES_NODE_ENCLOSURE) {
 		/*
@@ -1062,6 +1091,23 @@
 			cp->sec_target = sdp->sed_target;
 			cp->sec_instance = sdp->sed_instance++;
 			topo_list_append(&sdp->sed_chassis, cp);
+		} else {
+			/*
+			 * For the enclosure node, it is possible to have
+			 * multiple targets, only one of which support an
+			 * enclosure element descriptor.  We assume that this
+			 * is the one that is responsible for managing the
+			 * enclosure itself, so we prefer one with the
+			 * SES_PROP_IDENT property (which is only present for a
+			 * target that has an enclosure element descriptor).
+			 */
+			if (nvlist_lookup_boolean_value(props, SES_PROP_IDENT,
+			    &ident) == 0) {
+				topo_mod_dprintf(mod,
+				    "overriding enclosure node");
+				cp->sec_enclosure = np;
+				cp->sec_target = sdp->sed_target;
+			}
 		}
 
 		topo_list_append(&cp->sec_targets, sdp->sed_target);
--- a/usr/src/lib/fm/topo/modules/common/ses/ses.h	Mon Apr 06 15:57:51 2009 -0700
+++ b/usr/src/lib/fm/topo/modules/common/ses/ses.h	Mon Apr 06 17:17:49 2009 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -61,6 +61,7 @@
 #define	TOPO_PROP_NODE_ID	"node-id"
 #define	TOPO_PROP_TARGET_PATH	"target-path"
 #define	TOPO_PROP_SAS_ADDR	"sas-address"
+#define	TOPO_PROP_PATHS		"paths"
 
 #ifndef	NDEBUG
 #define	verify(x)	assert(x)
--- a/usr/src/lib/fm/topo/modules/common/ses/ses_facility.c	Mon Apr 06 15:57:51 2009 -0700
+++ b/usr/src/lib/fm/topo/modules/common/ses/ses_facility.c	Mon Apr 06 17:17:49 2009 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -311,7 +311,7 @@
     nvlist_t *in, nvlist_t **out)
 {
 	nvlist_t *nvl, *args, *props;
-	boolean_t value, asserted;
+	boolean_t value;
 	uint64_t status;
 	uint32_t state;
 	ses_node_t *np;
@@ -333,26 +333,20 @@
 	if (nvlist_lookup_uint64(props, SES_PROP_STATUS_CODE, &status) != 0)
 		status = SES_ESC_UNSUPPORTED;
 
-	if (nvlist_lookup_uint64(props, SES_PROP_STATUS_CODE, &status) != 0)
-		status = SES_ESC_UNSUPPORTED;
-
 	state = 0;
 	if (nvlist_lookup_string(args, TOPO_METH_SES_STATE_PROP,
 	    &prop) == 0) {
 		/* discrete (fault) sensor */
 
-		asserted = B_FALSE;
-		if (nvlist_lookup_boolean_value(props, prop, &value) == 0 &&
-		    value)
-			asserted = B_TRUE;
-		if (status == SES_ESC_UNRECOVERABLE ||
-		    status == SES_ESC_CRITICAL)
-			asserted = B_TRUE;
-
-		if (asserted)
-			state |= TOPO_SENSOR_STATE_GENERIC_STATE_ASSERTED;
+		if (status == SES_ESC_UNRECOVERABLE)
+			state |= TOPO_SENSOR_STATE_GENERIC_FAIL_NONRECOV;
+		else if (status == SES_ESC_CRITICAL)
+			state |= TOPO_SENSOR_STATE_GENERIC_FAIL_CRITICAL;
+		else if (nvlist_lookup_boolean_value(props, prop,
+		    &value) == 0 && value)
+			state |= TOPO_SENSOR_STATE_GENERIC_FAIL_NONRECOV;
 		else
-			state |= TOPO_SENSOR_STATE_GENERIC_STATE_DEASSERTED;
+			state |= TOPO_SENSOR_STATE_GENERIC_FAIL_DEASSERTED;
 	} else {
 		/* threshold sensor */
 		if (nvlist_lookup_boolean_value(props,
@@ -697,7 +691,7 @@
 
 	if ((tn = ses_add_sensor_common(mod, pnode, nodeid, name,
 	    TOPO_SENSOR_CLASS_DISCRETE,
-	    TOPO_SENSOR_TYPE_GENERIC_STATE)) == NULL)
+	    TOPO_SENSOR_TYPE_GENERIC_FAILURE)) == NULL)
 		return (-1);
 
 	nvl = NULL;