Jayanth Othayoth | e8bdeea | 2021-06-03 03:01:16 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "additional_data.hpp" |
| 4 | #include "pel.hpp" |
| 5 | |
Jayanth Othayoth | c74c220 | 2021-06-04 06:42:43 -0500 | [diff] [blame^] | 6 | #include <libekb.H> |
| 7 | |
Jayanth Othayoth | e8bdeea | 2021-06-03 03:01:16 -0500 | [diff] [blame] | 8 | namespace openpower |
| 9 | { |
| 10 | namespace pels |
| 11 | { |
| 12 | namespace sbe |
| 13 | { |
| 14 | |
| 15 | // SBE FFDC sub type. |
| 16 | constexpr 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 | */ |
| 32 | class 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 Othayoth | c74c220 | 2021-06-04 06:42:43 -0500 | [diff] [blame^] | 92 | * @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 Othayoth | e8bdeea | 2021-06-03 03:01:16 -0500 | [diff] [blame] | 107 | * @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 |