annotate usr/src/cmd/fm/modules/common/sensor-transport/sensor_transport.c @ 12979:ab9ae749152f

PSARC/2009/617 Software Events Notification Parameters CLI PSARC/2009/618 snmp-notify: SNMP Notification Daemon for Software Events PSARC/2009/619 smtp-notify: Email Notification Daemon for Software Events PSARC/2010/225 fmd for non-global Solaris zones PSARC/2010/226 Solaris Instance UUID PSARC/2010/227 nvlist_nvflag(3NVPAIR) PSARC/2010/228 libfmevent additions PSARC/2010/257 sysevent_evc_setpropnvl and sysevent_evc_getpropnvl PSARC/2010/265 FMRI and FMA Event Stabilty, 'ireport' category 1 event class, and the 'sw' FMRI scheme PSARC/2010/278 FMA/SMF integration: instance state transitions PSARC/2010/279 Modelling panics within FMA PSARC/2010/290 logadm.conf upgrade 6392476 fmdump needs to pretty-print 6393375 userland ereport/ireport event generation interfaces 6445732 Add email notification agent for FMA and software events 6804168 RFE: Allow an efficient means to monitor SMF services status changes 6866661 scf_values_destroy(3SCF) will segfault if is passed NULL 6884709 Add snmp notification agent for FMA and software events 6884712 Add private interface to tap into libfmd_msg macro expansion capabilities 6897919 fmd to run in a non-global zone 6897937 fmd use of non-private doors is not safe 6900081 add a UUID to Solaris kernel image for use in crashdump identification 6914884 model panic events as a defect diagnosis in FMA 6944862 fmd_case_open_uuid, fmd_case_uuisresolved, fmd_nvl_create_defect 6944866 log legacy sysevents in fmd 6944867 enumerate svc scheme in topo 6944868 software-diagnosis and software-response fmd modules 6944870 model SMF maintenance state as a defect diagnosis in FMA 6944876 savecore runs in foreground for systems with zfs root and dedicated dump 6965796 Implement notification parameters for SMF state transitions and FMA events 6968287 SUN-FM-MIB.mib needs to be updated to reflect Oracle information 6972331 logadm.conf upgrade PSARC/2010/290
author Gavin Maltby <gavin.maltby@oracle.com>
date Fri, 30 Jul 2010 17:04:17 +1000
parents dac6771300a8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
1 /*
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
2 * CDDL HEADER START
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
3 *
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
5 * Common Development and Distribution License (the "License").
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
6 * You may not use this file except in compliance with the License.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
7 *
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
10 * See the License for the specific language governing permissions
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
11 * and limitations under the License.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
12 *
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
18 *
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
19 * CDDL HEADER END
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
20 */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
21 /*
12979
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
22 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
23 */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
24
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
25 #include <fm/fmd_api.h>
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
26 #include <fm/libtopo.h>
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
27 #include <fm/topo_hc.h>
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
28 #include <fm/topo_mod.h>
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
29 #include <fm/topo_method.h>
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
30
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
31 #include <sys/fm/protocol.h>
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
32 #include <sys/systeminfo.h>
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
33
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
34 #include <string.h>
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
35
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
36 #define ST_EREPORT_CLASS "ereport.sensor.failure"
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
37
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
38 typedef struct sensor_fault {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
39 struct sensor_fault *sf_next;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
40 char *sf_fru;
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
41 uint32_t sf_num_fails;
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
42 boolean_t sf_last_faulted;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
43 boolean_t sf_faulted;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
44 boolean_t sf_unknown;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
45 } sensor_fault_t;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
46
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
47 typedef struct sensor_transport {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
48 fmd_hdl_t *st_hdl;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
49 fmd_xprt_t *st_xprt;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
50 hrtime_t st_interval;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
51 id_t st_timer;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
52 sensor_fault_t *st_faults;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
53 boolean_t st_first;
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
54 /*
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
55 * The number of consecutive sensor readings indicating failure that
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
56 * we'll tolerate before sending an ereport.
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
57 */
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
58 uint32_t st_tolerance;
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
59 } sensor_transport_t;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
60
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
61 typedef struct st_stats {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
62 fmd_stat_t st_bad_fmri;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
63 fmd_stat_t st_topo_errs;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
64 fmd_stat_t st_repairs;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
65 } st_stats_t;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
66
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
67 st_stats_t st_stats = {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
68 { "bad_fmri", FMD_TYPE_UINT64, "bad or missing resource/FRU FMRI" },
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
69 { "topo_errors", FMD_TYPE_UINT64, "errors walking topology" },
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
70 { "repairs", FMD_TYPE_UINT64, "auto repairs" }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
71 };
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
72
12979
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
73 static int st_check_component_complaints;
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
74 static int have_complained;
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
75
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
76 static int
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
77 st_check_component(topo_hdl_t *thp, tnode_t *node, void *arg)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
78 {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
79 sensor_transport_t *stp = arg;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
80 fmd_hdl_t *hdl = stp->st_hdl;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
81 const char *name = topo_node_name(node);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
82 nvlist_t *nvl, *props, *rsrc, *fru;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
83 char *fmri;
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
84 int err, ret;
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
85 int32_t last_source, source = -1;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
86 boolean_t nonrecov, faulted, predictive, source_diff;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
87 nvpair_t *nvp;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
88 uint64_t ena;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
89 nvlist_t *event;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
90 sensor_fault_t *sfp, **current;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
91
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
92 if (strcmp(name, FAN) != 0 && strcmp(name, PSU) != 0)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
93 return (0);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
94
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
95 if (topo_node_resource(node, &rsrc, NULL) != 0) {
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
96 st_stats.st_bad_fmri.fmds_value.ui64++;
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
97 return (0);
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
98 }
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
99
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
100 /*
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
101 * If the resource isn't present, don't bother invoking the sensor
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
102 * failure method. It may be that the sensors aren't part of the same
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
103 * physical FRU and will report failure if the FRU is no longer there.
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
104 */
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
105 if ((ret = topo_fmri_present(thp, rsrc, &err)) < 0) {
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
106 fmd_hdl_debug(hdl, "topo_fmri_present() failed for %s=%d",
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
107 name, topo_node_instance(node));
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
108 nvlist_free(rsrc);
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
109 return (0);
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
110 }
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
111
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
112 if (!ret) {
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
113 fmd_hdl_debug(hdl, "%s=%d is not present, ignoring",
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
114 name, topo_node_instance(node));
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
115 nvlist_free(rsrc);
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
116 return (0);
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
117 }
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
118
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
119 if (topo_method_invoke(node, TOPO_METH_SENSOR_FAILURE,
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
120 TOPO_METH_SENSOR_FAILURE_VERSION, NULL, &nvl, &err) != 0) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
121 if (err == ETOPO_METHOD_NOTSUP) {
12979
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
122 st_check_component_complaints++;
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
123 if (!have_complained) {
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
124 fmd_hdl_debug(hdl, "Method %s not supported "
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
125 "on %s=%d", TOPO_METH_SENSOR_FAILURE, name,
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
126 topo_node_instance(node));
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
127 }
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
128 nvlist_free(rsrc);
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
129 return (0);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
130 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
131 nvl = NULL;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
132 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
133
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
134 if (topo_node_fru(node, &fru, NULL, NULL) != 0) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
135 st_stats.st_bad_fmri.fmds_value.ui64++;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
136 nvlist_free(nvl);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
137 nvlist_free(rsrc);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
138 return (0);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
139 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
140
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
141 if (topo_fmri_nvl2str(thp, fru, &fmri, &err) != 0) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
142 st_stats.st_bad_fmri.fmds_value.ui64++;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
143 nvlist_free(nvl);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
144 nvlist_free(fru);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
145 nvlist_free(rsrc);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
146 return (0);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
147 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
148
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
149 nvlist_free(fru);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
150
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
151 faulted = nonrecov = source_diff = B_FALSE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
152 predictive = B_TRUE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
153 if (nvl != NULL) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
154 nvp = NULL;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
155 while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
156 if (nvpair_value_nvlist(nvp, &props) != 0)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
157 continue;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
158
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
159 faulted = B_TRUE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
160
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
161 /*
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
162 * We need some simple rules to handle the case where
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
163 * there are multiple facility nodes that indicate
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
164 * a problem with this FRU, but disagree on the values
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
165 * of nonrecov, predictive or source:
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
166 *
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
167 * 1) nonrecov will be set to true if one or more
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
168 * facility nodes indicates true. Otherwise it will
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
169 * default to false
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
170 *
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
171 * 2) predictive will default to false and remain false
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
172 * if one or more facility nodes indicate false.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
173 *
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
174 * 3) source will be set to unknown unless all facility
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
175 * nodes agree on the source
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
176 */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
177 if (nonrecov == B_FALSE)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
178 if (nvlist_lookup_boolean_value(props,
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
179 "nonrecov", &nonrecov) != 0)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
180 nonrecov = B_FALSE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
181 if (predictive == B_TRUE)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
182 if (nvlist_lookup_boolean_value(props,
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
183 "predictive", &predictive) != 0)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
184 predictive = B_FALSE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
185
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
186 last_source = source;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
187 if (nvlist_lookup_uint32(props, "source",
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
188 (uint32_t *)&source) != 0)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
189 source = TOPO_SENSOR_ERRSRC_UNKNOWN;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
190 if (last_source != -1 && last_source != source)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
191 source_diff = B_TRUE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
192 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
193 if (source_diff)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
194 source = TOPO_SENSOR_ERRSRC_UNKNOWN;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
195 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
196
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
197 /*
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
198 * See if we know about this fru.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
199 */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
200 for (current = &stp->st_faults; *current != NULL;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
201 current = &(*current)->sf_next) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
202 if (topo_fmri_strcmp(thp, fmri,
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
203 (*current)->sf_fru))
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
204 break;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
205 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
206
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
207 sfp = *current;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
208 if (sfp == NULL) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
209 /*
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
210 * We add this FRU to our list under two circumstances:
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
211 *
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
212 * 1. This FRU is faulted and needs to be remembered to
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
213 * avoid duplicate ereports.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
214 *
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
215 * 2. This is the initial pass, and we want to repair the
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
216 * FRU in case it was repaired while we were offline.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
217 */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
218 if (stp->st_first || faulted) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
219 sfp = fmd_hdl_zalloc(hdl, sizeof (sensor_fault_t),
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
220 FMD_SLEEP);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
221 sfp->sf_fru = fmd_hdl_strdup(hdl, fmri, FMD_SLEEP);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
222 sfp->sf_next = stp->st_faults;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
223 stp->st_faults = sfp;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
224 } else {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
225 goto out;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
226 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
227 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
228
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
229 if (faulted)
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
230 sfp->sf_num_fails++;
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
231
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
232 if (nvl == NULL)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
233 sfp->sf_unknown = B_TRUE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
234
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
235 if (faulted) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
236 /*
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
237 * Construct and post the ereport.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
238 *
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
239 * XXFM we only post one ereport per fru. It should be possible
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
240 * to uniquely identify faulty resources instead and post one
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
241 * per resource, even if they share the same FRU.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
242 */
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
243 if (!sfp->sf_last_faulted &&
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
244 (sfp->sf_num_fails > stp->st_tolerance)) {
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
245 ena = fmd_event_ena_create(hdl);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
246 event = fmd_nvl_alloc(hdl, FMD_SLEEP);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
247
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
248 (void) nvlist_add_string(event, "type", name);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
249 (void) nvlist_add_boolean_value(event, "nonrecov",
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
250 nonrecov);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
251 (void) nvlist_add_boolean_value(event, "predictive",
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
252 predictive);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
253 (void) nvlist_add_uint32(event, "source",
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
254 (uint32_t)source);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
255 (void) nvlist_add_nvlist(event, "details", nvl);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
256 (void) nvlist_add_string(event, FM_CLASS,
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
257 ST_EREPORT_CLASS);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
258 (void) nvlist_add_uint8(event, FM_VERSION,
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
259 FM_EREPORT_VERSION);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
260 (void) nvlist_add_uint64(event, FM_EREPORT_ENA, ena);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
261 (void) nvlist_add_nvlist(event, FM_EREPORT_DETECTOR,
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
262 rsrc);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
263
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
264 fmd_xprt_post(hdl, stp->st_xprt, event, 0);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
265 fmd_hdl_debug(hdl, "posted ereport: %s",
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
266 ST_EREPORT_CLASS);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
267 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
268
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
269 sfp->sf_faulted = B_TRUE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
270 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
271
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
272 out:
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
273 topo_hdl_strfree(thp, fmri);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
274 nvlist_free(rsrc);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
275 nvlist_free(nvl);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
276 return (0);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
277 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
278
12979
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
279 int st_timeout_verbose = 0;
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
280
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
281 /*ARGSUSED*/
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
282 static void
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
283 st_timeout(fmd_hdl_t *hdl, id_t id, void *data)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
284 {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
285 sensor_transport_t *stp;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
286 sensor_fault_t *sfp, **current;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
287 topo_hdl_t *thp;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
288 topo_walk_t *twp;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
289 int err;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
290
12979
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
291 if (st_timeout_verbose)
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
292 fmd_hdl_debug(hdl, "timeout: checking topology");
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
293
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
294 stp = fmd_hdl_getspecific(hdl);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
295 thp = fmd_hdl_topo_hold(hdl, TOPO_VERSION);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
296
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
297 if ((twp = topo_walk_init(thp, FM_FMRI_SCHEME_HC, st_check_component,
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
298 stp, &err)) == NULL) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
299 fmd_hdl_topo_rele(hdl, thp);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
300 fmd_hdl_error(hdl, "failed to walk topology: %s\n",
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
301 topo_strerror(err));
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
302 st_stats.st_topo_errs.fmds_value.ui64++;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
303 return;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
304 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
305
12979
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
306 if (st_check_component_complaints)
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
307 have_complained++;
ab9ae749152f PSARC/2009/617 Software Events Notification Parameters CLI
Gavin Maltby <gavin.maltby@oracle.com>
parents: 10438
diff changeset
308
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
309 /*
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
310 * Initialize values in our internal FRU list for this iteration of
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
311 * sensor reads. Keep track of whether the FRU was faulted in the
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
312 * previous pass so we don't send multiple ereports for the same
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
313 * problem.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
314 */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
315 for (sfp = stp->st_faults; sfp != NULL; sfp = sfp->sf_next) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
316 sfp->sf_unknown = B_FALSE;
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
317 if (sfp->sf_num_fails > stp->st_tolerance)
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
318 sfp->sf_last_faulted = sfp->sf_faulted;
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
319 sfp->sf_faulted = B_FALSE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
320 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
321
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
322 if (topo_walk_step(twp, TOPO_WALK_CHILD) == TOPO_WALK_ERR) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
323 topo_walk_fini(twp);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
324 fmd_hdl_topo_rele(hdl, thp);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
325 fmd_hdl_error(hdl, "failed to walk topology\n");
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
326 st_stats.st_topo_errs.fmds_value.ui64++;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
327 return;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
328 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
329
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
330 /*
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
331 * Remove any faults that weren't seen in the last pass.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
332 */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
333 for (current = &stp->st_faults; *current != NULL; ) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
334 sfp = *current;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
335 if (!sfp->sf_faulted && !sfp->sf_unknown) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
336 fmd_hdl_debug(hdl, "repairing %s", sfp->sf_fru);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
337 fmd_repair_fru(hdl, sfp->sf_fru);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
338 st_stats.st_repairs.fmds_value.ui64++;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
339 *current = sfp->sf_next;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
340 fmd_hdl_strfree(hdl, sfp->sf_fru);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
341 fmd_hdl_free(hdl, sfp, sizeof (sensor_fault_t));
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
342 } else {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
343 current = &sfp->sf_next;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
344 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
345 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
346
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
347 stp->st_first = B_FALSE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
348 topo_walk_fini(twp);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
349 fmd_hdl_topo_rele(hdl, thp);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
350
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
351 stp->st_timer = fmd_timer_install(hdl, NULL, NULL, stp->st_interval);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
352 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
353
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
354 static const fmd_prop_t fmd_props[] = {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
355 { "interval", FMD_TYPE_TIME, "1min" },
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
356 { "tolerance", FMD_TYPE_UINT32, "1" },
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
357 { NULL, 0, NULL }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
358 };
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
359
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
360 static const fmd_hdl_ops_t fmd_ops = {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
361 NULL, /* fmdo_recv */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
362 st_timeout, /* fmdo_timeout */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
363 NULL, /* fmdo_close */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
364 NULL, /* fmdo_stats */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
365 NULL, /* fmdo_gc */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
366 NULL, /* fmdo_send */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
367 NULL /* fmdo_topo */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
368 };
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
369
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
370 static const fmd_hdl_info_t fmd_info = {
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
371 "Sensor Transport Agent", "1.1", &fmd_ops, fmd_props
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
372 };
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
373
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
374 void
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
375 _fmd_init(fmd_hdl_t *hdl)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
376 {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
377 sensor_transport_t *stp;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
378 char buf[SYS_NMLN];
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
379
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
380 /*
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
381 * The sensor-transport module is currently only supported on x86
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
382 * platforms. So to avoid unnecessarily wasting cpu cycles on sparc
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
383 * walking the hc scheme tree every 60 seconds, we'll bail out before
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
384 * registering the handle.
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
385 */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
386 if ((sysinfo(SI_ARCHITECTURE, buf, sizeof (buf)) == -1) ||
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
387 (strcmp(buf, "i386") != 0))
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
388 return;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
389
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
390 if (fmd_hdl_register(hdl, FMD_API_VERSION, &fmd_info) != 0)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
391 return;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
392
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
393 (void) fmd_stat_create(hdl, FMD_STAT_NOALLOC,
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
394 sizeof (st_stats) / sizeof (fmd_stat_t),
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
395 (fmd_stat_t *)&st_stats);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
396
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
397 stp = fmd_hdl_zalloc(hdl, sizeof (sensor_transport_t), FMD_SLEEP);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
398 stp->st_interval = fmd_prop_get_int64(hdl, "interval");
10438
dac6771300a8 6875268 missing power supplies may be reported as faulted
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 8526
diff changeset
399 stp->st_tolerance = fmd_prop_get_int32(hdl, "tolerance");
8526
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
400
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
401 fmd_hdl_setspecific(hdl, stp);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
402
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
403 stp->st_xprt = fmd_xprt_open(hdl, FMD_XPRT_RDONLY, NULL, NULL);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
404 stp->st_hdl = hdl;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
405 stp->st_first = B_TRUE;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
406
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
407 /* kick off the first asynchronous discovery */
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
408 stp->st_timer = fmd_timer_install(hdl, NULL, NULL, 0);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
409 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
410
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
411 void
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
412 _fmd_fini(fmd_hdl_t *hdl)
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
413 {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
414 sensor_transport_t *stp;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
415 sensor_fault_t *sfp;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
416
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
417 stp = fmd_hdl_getspecific(hdl);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
418 if (stp != NULL) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
419 fmd_xprt_close(hdl, stp->st_xprt);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
420
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
421 while ((sfp = stp->st_faults) != NULL) {
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
422 stp->st_faults = sfp->sf_next;
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
423
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
424 fmd_hdl_strfree(hdl, sfp->sf_fru);
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
425 fmd_hdl_free(hdl, sfp, sizeof (sensor_fault_t));
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
426 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
427
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
428 fmd_hdl_free(hdl, stp, sizeof (sensor_transport_t));
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
429 }
8159d305568c PSARC 2008/753 Reflecting Fan/Power Supply Diagnosis in Solaris
Robert Johnston <Robert.Johnston@Sun.COM>
parents:
diff changeset
430 }