blob: 8beda763c65a2e25361f1ca2a6949914b3d18098 [file] [log] [blame]
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -05001extern "C"
2{
3#include <libpdbg.h>
4#include <libpdbg_sbe.h>
5}
6
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -05007#include "create_pel.hpp"
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -05008#include "sbe_consts.hpp"
9#include "sbe_dump_collector.hpp"
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -050010#include "sbe_type.hpp"
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -050011
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -050012#include <ekb/hwpf/fapi2/include/target_types.H>
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -050013#include <libphal.H>
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -050014#include <phal_exception.H>
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -050015
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -050016#include <phosphor-logging/elog-errors.hpp>
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -050017#include <phosphor-logging/lg2.hpp>
18#include <phosphor-logging/log.hpp>
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -050019#include <sbe_consts.hpp>
20#include <xyz/openbmc_project/Common/File/error.hpp>
21#include <xyz/openbmc_project/Common/error.hpp>
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -050022
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -050023#include <cstdint>
24#include <filesystem>
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -050025#include <format>
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -050026#include <fstream>
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -050027#include <stdexcept>
28
29namespace openpower::dump::sbe_chipop
30{
31
32using namespace phosphor::logging;
33using namespace openpower::dump::SBE;
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -050034using Severity = sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level;
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -050035
36void SbeDumpCollector::collectDump(uint8_t type, uint32_t id,
37 uint64_t failingUnit,
38 const std::filesystem::path& path)
39{
40 lg2::error("Starting dump collection: type:{TYPE} id:{ID} "
41 "failingUnit:{FAILINGUNIT}, path:{PATH}",
42 "TYPE", type, "ID", id, "FAILINGUNIT", failingUnit, "PATH",
43 path.string());
44
45 initializePdbg();
46
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -050047 TargetMap targets;
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -050048
49 struct pdbg_target* target = nullptr;
50 pdbg_for_each_class_target("proc", target)
51 {
52 if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED ||
53 !openpower::phal::pdbg::isTgtFunctional(target))
54 {
55 continue;
56 }
57
Dhruvaraj Subhashchandranf9f65b82022-10-13 06:46:43 -050058 bool includeTarget = true;
59 // if the dump type is hostboot then call stop instructions
60 if (type == SBE_DUMP_TYPE_HOSTBOOT)
61 {
SwethaParasaed53dc72025-01-24 01:07:01 -060062 includeTarget = executeThreadStop(target, path);
Dhruvaraj Subhashchandranf9f65b82022-10-13 06:46:43 -050063 }
64 if (includeTarget)
65 {
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -050066 targets[target] = std::vector<struct pdbg_target*>();
67
68 // Hardware dump needs OCMB data if present
69 if (type == openpower::dump::SBE::SBE_DUMP_TYPE_HARDWARE)
70 {
71 struct pdbg_target* ocmbTarget;
72 pdbg_for_each_target("ocmb", target, ocmbTarget)
73 {
74 if (!is_ody_ocmb_chip(ocmbTarget))
75 {
76 continue;
77 }
78
79 if (pdbg_target_probe(ocmbTarget) != PDBG_TARGET_ENABLED)
80 {
81 continue;
82 }
83
84 if (!openpower::phal::pdbg::isTgtFunctional(ocmbTarget))
85 {
86 continue;
87 }
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -050088 targets[target].push_back(ocmbTarget);
89 }
90 }
Dhruvaraj Subhashchandranf9f65b82022-10-13 06:46:43 -050091 }
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -050092 }
93
94 std::vector<uint8_t> clockStates = {SBE_CLOCK_ON, SBE_CLOCK_OFF};
95 for (auto cstate : clockStates)
96 {
Dhruvaraj Subhashchandran9098d8c2022-12-01 00:40:20 -060097 // Skip collection for performance dump if clock state is not ON
98 if (type == SBE_DUMP_TYPE_PERFORMANCE && cstate != SBE_CLOCK_ON)
99 {
100 continue;
101 }
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -0500102 auto futures = spawnDumpCollectionProcesses(type, id, path, failingUnit,
103 cstate, targets);
104
105 // Wait for all asynchronous tasks to complete
106 for (auto& future : futures)
107 {
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500108 try
109 {
110 future.wait();
111 }
112 catch (const std::exception& e)
113 {
114 lg2::error("Failed to collect dump from SBE ErrorMsg({ERROR})",
115 "ERROR", e);
116 }
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -0500117 }
118 lg2::info(
119 "Dump collection completed for clock state({CSTATE}): type({TYPE}) "
120 "id({ID}) failingUnit({FAILINGUNIT}), path({PATH})",
121 "CSTATE", cstate, "TYPE", type, "ID", id, "FAILINGUNIT",
122 failingUnit, "PATH", path.string());
123 }
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500124 if (std::filesystem::is_empty(path))
125 {
126 lg2::error("Failed to collect the dump");
127 throw std::runtime_error("Failed to collect the dump");
128 }
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -0500129 lg2::info("Dump collection completed");
130}
131
132void SbeDumpCollector::initializePdbg()
133{
134 openpower::phal::pdbg::init();
135}
136
137std::vector<std::future<void>> SbeDumpCollector::spawnDumpCollectionProcesses(
138 uint8_t type, uint32_t id, const std::filesystem::path& path,
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -0500139 uint64_t failingUnit, uint8_t cstate, const TargetMap& targetMap)
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -0500140{
141 std::vector<std::future<void>> futures;
142
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -0500143 for (const auto& [procTarget, ocmbTargets] : targetMap)
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -0500144 {
Patrick Williams540521e2024-08-16 15:20:03 -0400145 auto future = std::async(std::launch::async, [this, procTarget,
146 ocmbTargets, path, id,
147 type, cstate,
148 failingUnit]() {
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500149 try
150 {
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -0500151 this->collectDumpFromSBE(procTarget, path, id, type, cstate,
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500152 failingUnit);
153 }
154 catch (const std::exception& e)
155 {
156 lg2::error(
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -0500157 "Failed to collect dump from SBE on Proc-({PROCINDEX}) {ERROR}",
158 "PROCINDEX", pdbg_target_index(procTarget), "ERROR", e);
159 }
160
161 // Collect OCMBs only with clock on
162 if (cstate == SBE_CLOCK_ON)
163 {
164 // Handle OCMBs serially after handling the proc
165 for (auto ocmbTarget : ocmbTargets)
166 {
167 try
168 {
169 this->collectDumpFromSBE(ocmbTarget, path, id, type,
170 cstate, failingUnit);
171 }
172 catch (const std::exception& e)
173 {
174 lg2::error(
175 "Failed to collect dump from OCMB -({OCMBINDEX}) {ERROR}",
176 "OCMBINDEX", pdbg_target_index(ocmbTarget), "ERROR",
177 e);
178 }
179 }
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500180 }
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -0500181 });
182
183 futures.push_back(std::move(future));
184 }
185
186 return futures;
187}
188
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500189bool SbeDumpCollector::logErrorAndCreatePEL(
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -0500190 const openpower::phal::sbeError_t& sbeError, uint64_t chipPos,
SwethaParasaed53dc72025-01-24 01:07:01 -0600191 SBETypes sbeType, uint32_t cmdClass, uint32_t cmdType,
192 const std::filesystem::path& path)
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -0500193{
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500194 namespace fs = std::filesystem;
195
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -0500196 std::string chipName;
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500197 std::string event;
198 bool dumpIsRequired = false;
199 bool isDumpFailure = true;
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -0500200 try
201 {
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -0500202 chipName = sbeTypeAttributes.at(sbeType).chipName;
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500203 event = sbeTypeAttributes.at(sbeType).chipOpFailure;
Dhruvaraj Subhashchandran5f5c94d2021-10-19 07:18:30 -0500204
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500205 lg2::info("log error {CHIP} {POSITION}", "CHIP", chipName, "POSITION",
206 chipPos);
207
208 // Common FFDC data
209 openpower::dump::pel::FFDCData pelAdditionalData = {
Dhruvaraj Subhashchandran778d1db2024-05-20 09:13:08 -0500210 {"SRC6", std::format("0x{:X}{:X}", chipPos, (cmdClass | cmdType))}};
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500211
212 if (sbeType == SBETypes::OCMB)
213 {
214 pelAdditionalData.emplace_back(
215 "CHIP_TYPE", std::to_string(fapi2::TARGET_TYPE_OCMB_CHIP));
216 }
217
218 // Check the error type
Dhruvaraj Subhashchandran5f5c94d2021-10-19 07:18:30 -0500219 if (sbeError.errType() == openpower::phal::exception::SBE_CMD_TIMEOUT)
220 {
221 event = sbeTypeAttributes.at(sbeType).chipOpTimeout;
222 dumpIsRequired = true;
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500223 // For timeout, we do not expect any FFDC packets
224 }
225 else if (sbeError.errType() ==
226 openpower::phal::exception::SBE_FFDC_NO_DATA)
227 {
228 // We will create a PEL without FFDC with the common information we
229 // added
230 lg2::error("No FFDC data after a chip-op failure {CHIP} {POSITION}",
231 "CHIP", chipName, "POSITION", chipPos);
232 event = sbeTypeAttributes.at(sbeType).noFfdc;
233 }
234 else
235 {
236 if (sbeError.errType() ==
237 openpower::phal::exception::SBE_INTERNAL_FFDC_DATA)
238 {
239 lg2::info(
240 "FFDC Not related to chip-op present {CHIP} {POSITION}",
241 "CHIP", chipName, "POSITION", chipPos);
242 event = sbeTypeAttributes.at(sbeType).sbeInternalFFDCData;
243 isDumpFailure = false;
244 }
245 else
246 {
247 lg2::error("Process FFDC {CHIP} {POSITION}", "CHIP", chipName,
248 "POSITION", chipPos);
249 }
250 // Processor FFDC Packets
SwethaParasaed53dc72025-01-24 01:07:01 -0600251 std::vector<uint32_t> logIdList =
252 openpower::dump::pel::processFFDCPackets(sbeError, event,
253 pelAdditionalData);
254 for (auto logId : logIdList)
255 {
256 try
257 {
258 auto logInfo = openpower::dump::pel::getLogInfo(logId);
259 addLogDataToDump(std::get<0>(logInfo), std::get<1>(logInfo),
260 chipName, chipPos, path.parent_path());
261 }
262 catch (const std::exception& e)
263 {
264 lg2::error("Failed to get error Info: {ERROR} ", "ERROR",
265 e);
266 }
267 }
Dhruvaraj Subhashchandran5f5c94d2021-10-19 07:18:30 -0500268 }
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -0500269
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500270 // If dump is required, request it
Dhruvaraj Subhashchandran5f5c94d2021-10-19 07:18:30 -0500271 if (dumpIsRequired)
272 {
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500273 auto logId = openpower::dump::pel::createSbeErrorPEL(
274 event, sbeError, pelAdditionalData);
SwethaParasaed53dc72025-01-24 01:07:01 -0600275 try
276 {
277 auto logInfo = openpower::dump::pel::getLogInfo(logId);
278 addLogDataToDump(std::get<0>(logInfo), std::get<1>(logInfo),
279 chipName, chipPos, path.parent_path());
280 util::requestSBEDump(chipPos, std::get<0>(logInfo), sbeType);
281 }
282 catch (const std::exception& e)
283 {
284 lg2::error(
285 "Failed to get error Info, failed to create sbe dump: {ERROR}",
286 "ERROR", e);
287 }
Dhruvaraj Subhashchandran5f5c94d2021-10-19 07:18:30 -0500288 }
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -0500289 }
290 catch (const std::out_of_range& e)
291 {
292 lg2::error("Unknown SBE Type({SBETYPE}) ErrorMsg({ERROR})", "SBETYPE",
293 sbeType, "ERROR", e);
294 }
Dhruvaraj Subhashchandran5f5c94d2021-10-19 07:18:30 -0500295 catch (const std::exception& e)
296 {
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -0500297 lg2::error("SBE Dump request failed, chip type({CHIPTYPE}) "
298 "position({CHIPPOS}), Error: {ERROR}",
299 "CHIPTYPE", chipName, "CHIPPOS", chipPos, "ERROR", e);
Dhruvaraj Subhashchandran5f5c94d2021-10-19 07:18:30 -0500300 }
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500301
302 return isDumpFailure;
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -0500303}
304
Patrick Williams540521e2024-08-16 15:20:03 -0400305void SbeDumpCollector::collectDumpFromSBE(
306 struct pdbg_target* chip, const std::filesystem::path& path, uint32_t id,
307 uint8_t type, uint8_t clockState, uint64_t failingUnit)
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -0500308{
309 auto chipPos = pdbg_target_index(chip);
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -0500310 SBETypes sbeType = getSBEType(chip);
311 auto chipName = sbeTypeAttributes.at(sbeType).chipName;
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -0500312 lg2::info(
Dhruvaraj Subhashchandrane74e9162024-04-01 09:53:13 -0500313 "Collecting dump from ({CHIPTYPE}) ({POSITION}): path({PATH}) id({ID}) "
314 "type({TYPE}) clockState({CLOCKSTATE}) failingUnit({FAILINGUNIT})",
315 "CHIPTYPE", chipName, "POSITION", chipPos, "PATH", path.string(), "ID",
316 id, "TYPE", type, "CLOCKSTATE", clockState, "FAILINGUNIT", failingUnit);
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500317
318 util::DumpDataPtr dataPtr;
319 uint32_t len = 0;
320 uint8_t collectFastArray =
321 checkFastarrayCollectionNeeded(clockState, type, failingUnit, chipPos);
322
323 try
324 {
325 openpower::phal::sbe::getDump(chip, type, clockState, collectFastArray,
326 dataPtr.getPtr(), &len);
327 }
328 catch (const openpower::phal::sbeError_t& sbeError)
329 {
330 if (sbeError.errType() ==
331 openpower::phal::exception::SBE_CHIPOP_NOT_ALLOWED)
332 {
333 // SBE is not ready to accept chip-ops,
334 // Skip the request, no additional error handling required.
335 lg2::info("Collect dump: Skipping ({ERROR}) dump({TYPE}) "
336 "on proc({PROC}) clock state({CLOCKSTATE})",
337 "ERROR", sbeError, "TYPE", type, "PROC", chipPos,
338 "CLOCKSTATE", clockState);
339 return;
340 }
341
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500342 // If the FFDC is from actual chip-op failure this function will
343 // return true, if the chip-op is not failed but FFDC is present
344 // then create PELs with FFDC but write the dump contents to the
345 // file.
346 if (logErrorAndCreatePEL(sbeError, chipPos, sbeType,
SwethaParasaed53dc72025-01-24 01:07:01 -0600347 SBEFIFO_CMD_CLASS_DUMP, SBEFIFO_CMD_GET_DUMP,
348 path))
Dhruvaraj Subhashchandranf2298892024-04-21 04:42:55 -0500349 {
350 lg2::error("Error in collecting dump dump type({TYPE}), "
351 "clockstate({CLOCKSTATE}), chip type({CHIPTYPE}) "
352 "position({POSITION}), "
353 "collectFastArray({COLLECTFASTARRAY}) error({ERROR})",
354 "TYPE", type, "CLOCKSTATE", clockState, "CHIPTYPE",
355 chipName, "POSITION", chipPos, "COLLECTFASTARRAY",
356 collectFastArray, "ERROR", sbeError);
357 return;
358 }
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500359 }
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -0500360 writeDumpFile(path, id, clockState, 0, chipName, chipPos, dataPtr, len);
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500361}
362
363void SbeDumpCollector::writeDumpFile(
364 const std::filesystem::path& path, const uint32_t id,
Dhruvaraj Subhashchandran6feeebd2021-10-19 05:03:59 -0500365 const uint8_t clockState, const uint8_t nodeNum,
366 const std::string& chipName, const uint8_t chipPos,
367 util::DumpDataPtr& dataPtr, const uint32_t len)
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500368{
369 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
370 namespace fileError = sdbusplus::xyz::openbmc_project::Common::File::Error;
371
372 // Construct the filename
373 std::ostringstream filenameBuilder;
Dhruvaraj Subhashchandranb394bf22024-05-18 15:38:56 -0500374 filenameBuilder << std::hex << std::setw(8) << std::setfill('0') << id
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500375 << ".SbeDataClocks"
376 << (clockState == SBE_CLOCK_ON ? "On" : "Off") << ".node"
Dhruvaraj Subhashchandranb394bf22024-05-18 15:38:56 -0500377 << std::dec << static_cast<int>(nodeNum) << "." << chipName
Dhruvaraj Subhashchandrana699e312021-10-27 07:20:34 -0500378 << static_cast<int>(chipPos);
379
380 auto dumpPath = path / filenameBuilder.str();
381
382 // Attempt to open the file
383 std::ofstream outfile(dumpPath, std::ios::out | std::ios::binary);
384 if (!outfile)
385 {
386 using namespace sdbusplus::xyz::openbmc_project::Common::File::Error;
387 using metadata = xyz::openbmc_project::Common::File::Open;
388 // Unable to open the file for writing
389 auto err = errno;
390 lg2::error("Error opening file to write dump, "
391 "errno({ERRNO}), filepath({FILEPATH})",
392 "ERRNO", err, "FILEPATH", dumpPath.string());
393
394 report<Open>(metadata::ERRNO(err), metadata::PATH(dumpPath.c_str()));
395 // Just return here, so that the dumps collected from other
396 // SBEs can be packaged.
397 return;
398 }
399
400 // Write to the file
401 try
402 {
403 outfile.write(reinterpret_cast<const char*>(dataPtr.getData()), len);
404
405 lg2::info("Successfully wrote dump file "
406 "path=({PATH}) size=({SIZE})",
407 "PATH", dumpPath.string(), "SIZE", len);
408 }
409 catch (const std::ofstream::failure& oe)
410 {
411 using namespace sdbusplus::xyz::openbmc_project::Common::File::Error;
412 using metadata = xyz::openbmc_project::Common::File::Write;
413
414 lg2::error(
415 "Failed to write to dump file, "
416 "errorMsg({ERROR}), error({ERRORCODE}), filepath({FILEPATH})",
417 "ERROR", oe, "ERRORCODE", oe.code().value(), "FILEPATH",
418 dumpPath.string());
419 report<Write>(metadata::ERRNO(oe.code().value()),
420 metadata::PATH(dumpPath.c_str()));
421 // Just return here so dumps collected from other SBEs can be
422 // packaged.
423 }
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -0500424}
425
SwethaParasaed53dc72025-01-24 01:07:01 -0600426bool SbeDumpCollector::executeThreadStop(struct pdbg_target* target,
427 const std::filesystem::path& path)
Dhruvaraj Subhashchandranf9f65b82022-10-13 06:46:43 -0500428{
429 try
430 {
431 openpower::phal::sbe::threadStopProc(target);
432 return true;
433 }
434 catch (const openpower::phal::sbeError_t& sbeError)
435 {
436 uint64_t chipPos = pdbg_target_index(target);
437 if (sbeError.errType() ==
438 openpower::phal::exception::SBE_CHIPOP_NOT_ALLOWED)
439 {
440 lg2::info("SBE is not ready to accept chip-op: Skipping "
441 "stop instruction on proc-({POSITION}) error({ERROR}) ",
442 "POSITION", chipPos, "ERROR", sbeError);
443 return false; // Do not include the target for dump collection
444 }
445
446 lg2::error("Stop instructions failed on "
447 "proc-({POSITION}) error({ERROR}) ",
448 "POSITION", chipPos, "ERROR", sbeError);
449
450 logErrorAndCreatePEL(sbeError, chipPos, SBETypes::PROC,
451 SBEFIFO_CMD_CLASS_INSTRUCTION,
SwethaParasaed53dc72025-01-24 01:07:01 -0600452 SBEFIFO_CMD_CONTROL_INSN, path);
Dhruvaraj Subhashchandranf9f65b82022-10-13 06:46:43 -0500453 // For TIMEOUT, log the error and skip adding the processor for dump
454 // collection
455 if (sbeError.errType() == openpower::phal::exception::SBE_CMD_TIMEOUT)
456 {
457 return false;
458 }
459 }
460 // Include the target for dump collection for SBE_CMD_FAILED or any other
461 // non-critical errors
462 return true;
463}
464
SwethaParasaed53dc72025-01-24 01:07:01 -0600465void SbeDumpCollector::addLogDataToDump(uint32_t pelId, std::string src,
466 std::string chipName, uint64_t chipPos,
467 const std::filesystem::path& path)
468{
469 std::filesystem::path info = path / "errorInfo";
470 auto fileExists = std::filesystem::exists(info);
471 std::ofstream fout;
472 fout.open(info, std::ios::app);
473 if (!fout)
474 {
475 lg2::error("Error: Failed to open the file! {FILE}", "FILE", info);
476 lg2::error("No error Info is added to dump file");
477 return;
478 }
479 if (!fileExists)
480 {
481 fout << "ErrorInfo:" << std::endl;
482 }
483 auto pel = " " + std::format("{:08x}", pelId) + ":";
484 fout << pel << std::endl;
485 fout << " src: " << src << std::endl;
486 auto resource = chipName + " " + std::to_string(chipPos);
487 fout << " Resource: " << resource << std::endl;
488}
489
Dhruvaraj Subhashchandran858d1aa2021-10-27 03:26:06 -0500490} // namespace openpower::dump::sbe_chipop