blob: f24594754124fa6fc02208fe1f69b39672aff2ec [file] [log] [blame]
Jayanth Othayothe8bdeea2021-06-03 03:01:16 -05001#pragma once
2
3#include "additional_data.hpp"
4#include "pel.hpp"
5
Jayanth Othayothc74c2202021-06-04 06:42:43 -05006#include <libekb.H>
7
Jayanth Othayothe8bdeea2021-06-03 03:01:16 -05008namespace openpower
9{
10namespace pels
11{
12namespace sbe
13{
14
15// SBE FFDC sub type.
16constexpr uint8_t sbeFFDCSubType = 0xCB;
17
18/** @class SbeFFDC
19 *
20 * @brief This class provides higher level interface to process SBE ffdc
21 * for PEL based error logging infrastructure.
22 * Key Functionalities included here
23 * - Process the SBE FFDC data with the help of FAPI infrastructure and
24 * and create PEL required format Callout and user data for hardware
25 * procedure failures specific reason code
26 * - Add the user data section with SBE FFDC data to support SBE provided
27 * parser tool usage.
28 * - Any SBE FFDC processing will result additional log message in journal
29 * and will continue to create Error log with available data. This is to
30 * help user to analyse the failure.
31 */
32class SbeFFDC
33{
34 public:
35 SbeFFDC() = delete;
36 SbeFFDC(const SbeFFDC&) = delete;
37 SbeFFDC& operator=(const SbeFFDC&) = delete;
38 SbeFFDC(SbeFFDC&&) = delete;
39 SbeFFDC& operator=(SbeFFDC&&) = delete;
40
41 /**
42 * @brief Constructor
43 *
44 * Create PEL required format data from SBE provided FFDC data.
45 *
46 * @param[in] data - The AdditionalData properties in this PEL event
47 * @param[in] files - FFDC files that go into UserData sections
48 */
49 SbeFFDC(const AdditionalData& data, const PelFFDC& files);
50
51 /**
52 * @brief Destructor
53 *
54 * Deletes the temporary files
55 */
56 ~SbeFFDC()
57 {
58
59 try
60 {
61 for (auto path : paths)
62 {
63 if (!path.empty())
64 {
65 // Delete temporary file from file system
66 std::error_code ec;
67 std::filesystem::remove(path, ec);
68 // Clear path to indicate file has been deleted
69 path.clear();
70 }
71 }
72 }
73 catch (...)
74 {
75 // Destructors should not throw exceptions
76 }
77 }
78
79 /**
80 * @brief Helper function to return FFDC files information, which
81 * includes SBE FFDC specific callout information.
82 *
83 * return PelFFDC - pel formated FFDC files.
84 */
85 const PelFFDC& getSbeFFDC()
86 {
87 return ffdcFiles;
88 }
89
90 private:
91 /**
Jayanth Othayothc74c2202021-06-04 06:42:43 -050092 * @brief Helper function to process SBE FFDC packet.
93 * This function call libekb function to process the
94 * FFDC packet and convert in to known format for PEL
95 * specific file creation. This function also creates
96 * json callout file and text type file, which includes
97 * the addition debug data included in SBE FFDC packet.
98 *
99 * @param ffdcPkt SBE FFDC packet
100 *
101 * Any failure during the process stops the function
102 * execution to support the raw SBE FFDC data based
103 * PEL creation.
104 */
105 void process(const sbeFfdcPacketType& ffdcPkt);
106 /**
Jayanth Othayothe8bdeea2021-06-03 03:01:16 -0500107 * @brief Temporary files path information created as part of FFDC
108 * processing.
109 */
110 std::vector<std::filesystem::path> paths;
111
112 /**
113 * @brief PEL FFDC files, which includes the user data sections and the
114 * added callout details if any, found during SBE FFDC processing.
115 */
116 PelFFDC ffdcFiles;
117
118 /**
119 * @brief Processor position associated to SBE FFDC
120 */
121 uint32_t procPos;
122};
123
124} // namespace sbe
125} // namespace pels
126} // namespace openpower