blob: 4be14f5afb34b972dd7d9bd2615efbd3c3f8b40d [file] [log] [blame]
Zane Shelleyd84ed6e2020-06-08 13:41:48 -05001#include <assert.h>
Zane Shelley9fb73932020-09-15 13:34:57 -05002#include <unistd.h>
Ben Tyner87eabc62020-05-14 17:56:54 -05003
Zane Shelleyebff0d32021-11-21 10:52:07 -06004#include <analyzer/analyzer_main.hpp>
Zane Shelleya9b44342021-08-08 17:15:52 -05005#include <analyzer/ras-data/ras-data-parser.hpp>
Zane Shelley4ed4be52021-02-15 17:53:40 -06006#include <analyzer/service_data.hpp>
Ben Tyner7029e522021-08-09 19:18:24 -05007#include <attn/attn_dump.hpp>
Ben Tyner0205f3b2020-02-24 10:24:47 -06008#include <hei_main.hpp>
Zane Shelleyf4bd5ff2020-11-05 22:26:04 -06009#include <util/pdbg.hpp>
Zane Shelleyd84ed6e2020-06-08 13:41:48 -050010#include <util/trace.hpp>
Ben Tyner0205f3b2020-02-24 10:24:47 -060011
12namespace analyzer
13{
14
Zane Shelleyf4bd5ff2020-11-05 22:26:04 -060015//------------------------------------------------------------------------------
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050016
Zane Shelleyf4bd5ff2020-11-05 22:26:04 -060017// Forward references for externally defined functions.
Ben Tyner87eabc62020-05-14 17:56:54 -050018
Zane Shelleyd3b9bac2020-11-17 21:59:12 -060019/**
20 * @brief Will get the list of active chip and initialize the isolator.
21 * @param o_chips The returned list of active chips.
22 */
Zane Shelley171a2e02020-11-13 13:56:13 -060023void initializeIsolator(std::vector<libhei::Chip>& o_chips);
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050024
Zane Shelleyd3b9bac2020-11-17 21:59:12 -060025/**
Zane Shelley65fefb22021-10-18 15:35:26 -050026 * @brief Will get the list of active chip and initialize the isolator.
Zane Shelleyec227c22021-12-09 15:54:40 -060027 * @param i_type The type of analysis to perform. See enum for details.
Zane Shelley65fefb22021-10-18 15:35:26 -050028 * @param i_isoData The data gathered during isolation (for FFDC).
29 * @param o_rootCause The returned root cause signature.
30 * @return True, if root cause has been found. False, otherwise.
31 */
Zane Shelleyec227c22021-12-09 15:54:40 -060032bool filterRootCause(AnalysisType i_type,
33 const libhei::IsolationData& i_isoData,
Zane Shelley65fefb22021-10-18 15:35:26 -050034 libhei::Signature& o_rootCause);
35
36/**
Zane Shelleyd3b9bac2020-11-17 21:59:12 -060037 * @brief Will create and submit a PEL using the given data.
Zane Shelleyd3b9bac2020-11-17 21:59:12 -060038 * @param i_isoData The data gathered during isolation (for FFDC).
Zane Shelley4ed4be52021-02-15 17:53:40 -060039 * @param i_servData Data regarding service actions gathered during analysis.
Zane Shelley611b3442021-11-19 16:02:01 -060040 * @return The platform log ID. Will return zero if no PEL is generated.
Zane Shelleyd3b9bac2020-11-17 21:59:12 -060041 */
Zane Shelley611b3442021-11-19 16:02:01 -060042uint32_t createPel(const libhei::IsolationData& i_isoData,
43 const ServiceData& i_servData);
Zane Shelleyd3b9bac2020-11-17 21:59:12 -060044
Zane Shelleyd84ed6e2020-06-08 13:41:48 -050045//------------------------------------------------------------------------------
46
Zane Shelleyebff0d32021-11-21 10:52:07 -060047const char* __attn(libhei::AttentionType_t i_type)
Zane Shelley2f263182020-07-10 21:41:21 -050048{
49 const char* str = "";
Zane Shelleyebff0d32021-11-21 10:52:07 -060050 switch (i_type)
Zane Shelley2f263182020-07-10 21:41:21 -050051 {
52 case libhei::ATTN_TYPE_CHECKSTOP:
53 str = "CHECKSTOP";
54 break;
55 case libhei::ATTN_TYPE_UNIT_CS:
56 str = "UNIT_CS";
57 break;
58 case libhei::ATTN_TYPE_RECOVERABLE:
59 str = "RECOVERABLE";
60 break;
61 case libhei::ATTN_TYPE_SP_ATTN:
62 str = "SP_ATTN";
63 break;
64 case libhei::ATTN_TYPE_HOST_ATTN:
65 str = "HOST_ATTN";
66 break;
67 default:
Zane Shelleyebff0d32021-11-21 10:52:07 -060068 trace::err("Unsupported attention type: %u", i_type);
Zane Shelley2f263182020-07-10 21:41:21 -050069 assert(0);
70 }
71 return str;
72}
73
Zane Shelley2f263182020-07-10 21:41:21 -050074//------------------------------------------------------------------------------
75
Zane Shelleyebff0d32021-11-21 10:52:07 -060076const char* __analysisType(AnalysisType i_type)
77{
78 const char* str = "";
79 switch (i_type)
80 {
81 case AnalysisType::SYSTEM_CHECKSTOP:
82 str = "SYSTEM_CHECKSTOP";
83 break;
84 case AnalysisType::TERMINATE_IMMEDIATE:
85 str = "TERMINATE_IMMEDIATE";
86 break;
87 case AnalysisType::MANUAL:
88 str = "MANUAL";
89 break;
90 default:
91 trace::err("Unsupported analysis type: %u", i_type);
92 assert(0);
93 }
94 return str;
95}
96
97//------------------------------------------------------------------------------
98
99uint32_t analyzeHardware(AnalysisType i_type, attn::DumpParameters& o_dump)
Zane Shelley9fb73932020-09-15 13:34:57 -0500100{
Zane Shelley611b3442021-11-19 16:02:01 -0600101 uint32_t o_plid = 0; // default, zero indicates PEL was not created
Zane Shelley9fb73932020-09-15 13:34:57 -0500102
Zane Shelleye5411f02021-08-04 22:41:35 -0500103 if (!util::pdbg::queryHardwareAnalysisSupported())
104 {
105 trace::err("Hardware error analysis is not supported on this system");
Zane Shelley611b3442021-11-19 16:02:01 -0600106 return o_plid;
Zane Shelleye5411f02021-08-04 22:41:35 -0500107 }
108
Zane Shelleyebff0d32021-11-21 10:52:07 -0600109 trace::inf(">>> enter analyzeHardware(%s)", __analysisType(i_type));
Zane Shelleye5411f02021-08-04 22:41:35 -0500110
111 // Initialize the isolator and get all of the chips to be analyzed.
112 trace::inf("Initializing the isolator...");
113 std::vector<libhei::Chip> chips;
114 initializeIsolator(chips);
115
116 // Isolate attentions.
117 trace::inf("Isolating errors: # of chips=%u", chips.size());
118 libhei::IsolationData isoData{};
119 libhei::isolate(chips, isoData);
120
Zane Shelley65fefb22021-10-18 15:35:26 -0500121 // For debug, trace out the original list of signatures before filtering.
122 for (const auto& sig : isoData.getSignatureList())
123 {
124 trace::inf("Signature: %s 0x%0" PRIx32 " %s",
125 util::pdbg::getPath(sig.getChip()), sig.toUint32(),
126 __attn(sig.getAttnType()));
127 }
128
Zane Shelleye5411f02021-08-04 22:41:35 -0500129 // Filter for root cause attention.
Zane Shelleycb457382020-11-02 20:55:06 -0600130 libhei::Signature rootCause{};
Zane Shelleyec227c22021-12-09 15:54:40 -0600131 bool attnFound = filterRootCause(i_type, isoData, rootCause);
Zane Shelleycb457382020-11-02 20:55:06 -0600132
Zane Shelleyb7879d32021-12-06 18:02:03 -0600133 // If a root cause attention was found, or if this was a system checkstop,
134 // generate a PEL.
135 if (attnFound || AnalysisType::SYSTEM_CHECKSTOP == i_type)
Zane Shelley9fb73932020-09-15 13:34:57 -0500136 {
Zane Shelleyb7879d32021-12-06 18:02:03 -0600137 if (attnFound)
138 {
139 trace::inf("Root cause attention: %s 0x%0" PRIx32 " %s",
140 util::pdbg::getPath(rootCause.getChip()),
141 rootCause.toUint32(), __attn(rootCause.getAttnType()));
142 }
143 else
144 {
145 // This is bad. Analysis should have found a root cause attention
146 // for a system checkstop. Issues could range from code bugs to SCOM
147 // errors. Regardless, generate a PEL with FFDC to assist with
148 // debug.
149 trace::err("System checkstop with no root cause attention");
150 rootCause = libhei::Signature{}; // just in case
151 }
Zane Shelleycb457382020-11-02 20:55:06 -0600152
Zane Shelleyb7879d32021-12-06 18:02:03 -0600153 // Start building the service data.
Zane Shelley82be3ab2021-12-07 10:36:08 -0600154 ServiceData servData{rootCause, i_type};
Zane Shelleyb7879d32021-12-06 18:02:03 -0600155
156 // Apply any service actions, if needed. Note that there are no
157 // resolutions for manual analysis.
158 if (AnalysisType::MANUAL != i_type)
159 {
160 if (attnFound)
161 {
162 // Resolve the root cause attention.
163 RasDataParser rasData{};
164 rasData.getResolution(rootCause)->resolve(servData);
165 }
166 else
167 {
168 // Analysis failed so apply the Level 2 Support resolution.
169 ProcedureCalloutResolution res{callout::Procedure::NEXTLVL,
170 callout::Priority::HIGH};
171 res.resolve(servData);
172 }
173 }
Zane Shelleyd3b9bac2020-11-17 21:59:12 -0600174
175 // Create and commit a PEL.
Zane Shelley611b3442021-11-19 16:02:01 -0600176 o_plid = createPel(isoData, servData);
Ben Tyner7029e522021-08-09 19:18:24 -0500177
Zane Shelley611b3442021-11-19 16:02:01 -0600178 if (0 == o_plid)
179 {
180 trace::err("Failed to create PEL");
181 }
182 else
183 {
184 trace::inf("PEL created: PLID=0x%0" PRIx32, o_plid);
Zane Shelleybf3326f2021-11-12 13:41:39 -0600185
Zane Shelley611b3442021-11-19 16:02:01 -0600186 // Gather/return information needed for dump. A hardware dump will
187 // always be used for system checkstop attenions. Software dumps
188 // will be reserved for MP-IPLs during TI analysis.
189 // TODO: Need ID from root cause. At the moment, HUID does not exist
190 // in devtree. Will need a better ID definition.
Zane Shelleyebff0d32021-11-21 10:52:07 -0600191 o_dump.unitId = 0;
192 o_dump.dumpType = attn::DumpType::Hardware;
Zane Shelley611b3442021-11-19 16:02:01 -0600193 }
Zane Shelley9fb73932020-09-15 13:34:57 -0500194 }
Zane Shelleyb7879d32021-12-06 18:02:03 -0600195 else
196 {
197 // It is possible for TI handling, or manually initiated analysis via
198 // the command line, that there will not be an active attention. In
199 // which case, we will do nothing and let the caller of this function
200 // determine if this is the expected behavior.
201 trace::inf("No active attentions found");
202 }
Zane Shelley9fb73932020-09-15 13:34:57 -0500203
Zane Shelleye5411f02021-08-04 22:41:35 -0500204 // All done, clean up the isolator.
205 trace::inf("Uninitializing isolator...");
206 libhei::uninitialize();
Ben Tyner87eabc62020-05-14 17:56:54 -0500207
Zane Shelley2f263182020-07-10 21:41:21 -0500208 trace::inf("<<< exit analyzeHardware()");
209
Zane Shelley611b3442021-11-19 16:02:01 -0600210 return o_plid;
Ben Tyner0205f3b2020-02-24 10:24:47 -0600211}
212
Ben Tynereea45422021-04-15 10:54:14 -0500213//------------------------------------------------------------------------------
214
215/**
216 * @brief Get error isolator build information
217 *
218 * @return Pointer to build information
219 */
220const char* getBuildInfo()
221{
222 return libhei::getBuildInfo();
223}
224
Ben Tyner0205f3b2020-02-24 10:24:47 -0600225} // namespace analyzer