| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 1 | #pragma once | 
|  | 2 |  | 
| Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 3 | #include "elog_block.hpp" | 
| Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 4 | #include "elog_entry.hpp" | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 5 | #include "xyz/openbmc_project/Collection/DeleteAll/server.hpp" | 
| Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Logging/Create/server.hpp" | 
|  | 7 | #include "xyz/openbmc_project/Logging/Entry/server.hpp" | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 8 | #include "xyz/openbmc_project/Logging/Internal/Manager/server.hpp" | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 9 | #include "xyz/openbmc_project/Logging/error.hpp" | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 10 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 11 | #include <phosphor-logging/log.hpp> | 
|  | 12 | #include <sdbusplus/bus.hpp> | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 13 |  | 
| Patrick Williams | 2544b41 | 2022-10-04 08:41:06 -0500 | [diff] [blame] | 14 | #include <list> | 
|  | 15 |  | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 16 | namespace phosphor | 
|  | 17 | { | 
|  | 18 | namespace logging | 
|  | 19 | { | 
| Adriana Kobylak | d722b3a | 2017-02-28 12:10:44 -0600 | [diff] [blame] | 20 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 21 | extern const std::map<std::string, std::vector<std::string>> g_errMetaMap; | 
|  | 22 | extern const std::map<std::string, level> g_errLevelMap; | 
| Adriana Kobylak | d722b3a | 2017-02-28 12:10:44 -0600 | [diff] [blame] | 23 |  | 
| Willy Tu | 6ddbf69 | 2023-09-05 10:54:16 -0700 | [diff] [blame] | 24 | using CreateIface = sdbusplus::server::xyz::openbmc_project::logging::Create; | 
| Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 25 | using DeleteAllIface = | 
| Willy Tu | 6ddbf69 | 2023-09-05 10:54:16 -0700 | [diff] [blame] | 26 | sdbusplus::server::xyz::openbmc_project::collection::DeleteAll; | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 27 |  | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 28 | using Severity = sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level; | 
|  | 29 | using LogsCleared = | 
|  | 30 | sdbusplus::xyz::openbmc_project::Logging::Error::LogsCleared; | 
|  | 31 |  | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 32 | namespace details | 
|  | 33 | { | 
| Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 34 | template <typename... T> | 
| Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 35 | using ServerObject = typename sdbusplus::server::object_t<T...>; | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 36 |  | 
|  | 37 | using ManagerIface = | 
| Willy Tu | 6ddbf69 | 2023-09-05 10:54:16 -0700 | [diff] [blame] | 38 | sdbusplus::server::xyz::openbmc_project::logging::internal::Manager; | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 39 |  | 
|  | 40 | } // namespace details | 
|  | 41 |  | 
| Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 42 | constexpr size_t ffdcFormatPos = 0; | 
|  | 43 | constexpr size_t ffdcSubtypePos = 1; | 
|  | 44 | constexpr size_t ffdcVersionPos = 2; | 
|  | 45 | constexpr size_t ffdcFDPos = 3; | 
|  | 46 |  | 
|  | 47 | using FFDCEntry = std::tuple<CreateIface::FFDCFormat, uint8_t, uint8_t, | 
|  | 48 | sdbusplus::message::unix_fd>; | 
|  | 49 |  | 
|  | 50 | using FFDCEntries = std::vector<FFDCEntry>; | 
|  | 51 |  | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 52 | namespace internal | 
|  | 53 | { | 
|  | 54 |  | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 55 | /** @class Manager | 
|  | 56 | *  @brief OpenBMC logging manager implementation. | 
|  | 57 | *  @details A concrete implementation for the | 
|  | 58 | *  xyz.openbmc_project.Logging.Internal.Manager DBus API. | 
|  | 59 | */ | 
| Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 60 | class Manager : public details::ServerObject<details::ManagerIface> | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 61 | { | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 62 | public: | 
|  | 63 | Manager() = delete; | 
|  | 64 | Manager(const Manager&) = delete; | 
|  | 65 | Manager& operator=(const Manager&) = delete; | 
|  | 66 | Manager(Manager&&) = delete; | 
|  | 67 | Manager& operator=(Manager&&) = delete; | 
|  | 68 | virtual ~Manager() = default; | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 69 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 70 | /** @brief Constructor to put object onto bus at a dbus path. | 
|  | 71 | *  @param[in] bus - Bus to attach to. | 
|  | 72 | *  @param[in] path - Path to attach at. | 
|  | 73 | */ | 
| Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 74 | Manager(sdbusplus::bus_t& bus, const char* objPath) : | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 75 | details::ServerObject<details::ManagerIface>(bus, objPath), busLog(bus), | 
|  | 76 | entryId(0), fwVersion(readFWVersion()){}; | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 77 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 78 | /* | 
|  | 79 | * @fn commit() | 
|  | 80 | * @brief sd_bus Commit method implementation callback. | 
|  | 81 | * @details Create an error/event log based on transaction id and | 
|  | 82 | *          error message. | 
|  | 83 | * @param[in] transactionId - Unique identifier of the journal entries | 
|  | 84 | *                            to be committed. | 
|  | 85 | * @param[in] errMsg - The error exception message associated with the | 
|  | 86 | *                     error log to be committed. | 
|  | 87 | */ | 
| Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 88 | uint32_t commit(uint64_t transactionId, std::string errMsg) override; | 
| Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 89 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 90 | /* | 
|  | 91 | * @fn commit() | 
|  | 92 | * @brief sd_bus CommitWithLvl method implementation callback. | 
|  | 93 | * @details Create an error/event log based on transaction id and | 
|  | 94 | *          error message. | 
|  | 95 | * @param[in] transactionId - Unique identifier of the journal entries | 
|  | 96 | *                            to be committed. | 
|  | 97 | * @param[in] errMsg - The error exception message associated with the | 
|  | 98 | *                     error log to be committed. | 
|  | 99 | * @param[in] errLvl - level of the error | 
|  | 100 | */ | 
| Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 101 | uint32_t commitWithLvl(uint64_t transactionId, std::string errMsg, | 
|  | 102 | uint32_t errLvl) override; | 
| Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 103 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 104 | /** @brief Erase specified entry d-bus object | 
|  | 105 | * | 
|  | 106 | * @param[in] entryId - unique identifier of the entry | 
|  | 107 | */ | 
|  | 108 | void erase(uint32_t entryId); | 
| Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 109 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 110 | /** @brief Construct error d-bus objects from their persisted | 
|  | 111 | *         representations. | 
|  | 112 | */ | 
|  | 113 | void restore(); | 
| Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 114 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 115 | /** @brief  Erase all error log entries | 
|  | 116 | * | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 117 | *  @return size_t - count of erased entries | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 118 | */ | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 119 | size_t eraseAll() | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 120 | { | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 121 | size_t entriesSize = entries.size(); | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 122 | auto iter = entries.begin(); | 
|  | 123 | while (iter != entries.end()) | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 124 | { | 
| Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 125 | auto e = iter->first; | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 126 | ++iter; | 
| Patrick Venture | 3443896 | 2018-10-30 13:17:37 -0700 | [diff] [blame] | 127 | erase(e); | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 128 | } | 
| Lotus Xu | d091a57 | 2021-05-24 13:59:21 +0800 | [diff] [blame] | 129 | entryId = 0; | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 130 |  | 
|  | 131 | return entriesSize; | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 132 | } | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 133 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 134 | /** @brief Returns the count of high severity errors | 
|  | 135 | * | 
|  | 136 | *  @return int - count of real errors | 
|  | 137 | */ | 
|  | 138 | int getRealErrSize(); | 
| Nagaraju Goruganti | 477b731 | 2018-06-25 23:28:58 -0500 | [diff] [blame] | 139 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 140 | /** @brief Returns the count of Info errors | 
|  | 141 | * | 
|  | 142 | *  @return int - count of info errors | 
|  | 143 | */ | 
|  | 144 | int getInfoErrSize(); | 
| Nagaraju Goruganti | 477b731 | 2018-06-25 23:28:58 -0500 | [diff] [blame] | 145 |  | 
| Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 146 | /** @brief Returns the number of blocking errors | 
|  | 147 | * | 
|  | 148 | *  @return int - count of blocking errors | 
|  | 149 | */ | 
|  | 150 | int getBlockingErrSize() | 
|  | 151 | { | 
|  | 152 | return blockingErrors.size(); | 
|  | 153 | } | 
|  | 154 |  | 
| Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 155 | /** @brief Returns the number of property change callback objects | 
|  | 156 | * | 
|  | 157 | *  @return int - count of property callback entries | 
|  | 158 | */ | 
|  | 159 | int getEntryCallbackSize() | 
|  | 160 | { | 
|  | 161 | return propChangedEntryCallback.size(); | 
|  | 162 | } | 
|  | 163 |  | 
| Matt Spinler | 44893cc | 2020-08-26 11:34:17 -0500 | [diff] [blame] | 164 | /** | 
|  | 165 | * @brief Returns the sdbusplus bus object | 
|  | 166 | * | 
| Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 167 | * @return sdbusplus::bus_t& | 
| Matt Spinler | 44893cc | 2020-08-26 11:34:17 -0500 | [diff] [blame] | 168 | */ | 
| Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 169 | sdbusplus::bus_t& getBus() | 
| Matt Spinler | 8ebfd31 | 2019-06-03 12:43:59 -0500 | [diff] [blame] | 170 | { | 
|  | 171 | return busLog; | 
|  | 172 | } | 
|  | 173 |  | 
| Matt Spinler | 44893cc | 2020-08-26 11:34:17 -0500 | [diff] [blame] | 174 | /** | 
|  | 175 | * @brief Returns the ID of the last created entry | 
|  | 176 | * | 
|  | 177 | * @return uint32_t - The ID | 
|  | 178 | */ | 
|  | 179 | uint32_t lastEntryID() const | 
|  | 180 | { | 
|  | 181 | return entryId; | 
|  | 182 | } | 
|  | 183 |  | 
| Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 184 | /** @brief Creates an event log | 
|  | 185 | * | 
|  | 186 | *  This is an alternative to the _commit() API.  It doesn't use | 
|  | 187 | *  the journal to look up event log metadata like _commit does. | 
|  | 188 | * | 
|  | 189 | * @param[in] errMsg - The error exception message associated with the | 
|  | 190 | *                     error log to be committed. | 
|  | 191 | * @param[in] severity - level of the error | 
|  | 192 | * @param[in] additionalData - The AdditionalData property for the error | 
|  | 193 | */ | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 194 | void create(const std::string& message, Severity severity, | 
|  | 195 | const std::map<std::string, std::string>& additionalData); | 
| Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 196 |  | 
| Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 197 | /** @brief Creates an event log, and accepts FFDC files | 
|  | 198 | * | 
|  | 199 | * This is the same as create(), but also takes an FFDC argument. | 
|  | 200 | * | 
|  | 201 | * The FFDC argument is a vector of tuples that allows one to pass in file | 
|  | 202 | * descriptors for files that contain FFDC (First Failure Data Capture). | 
|  | 203 | * These will be passed to any event logging extensions. | 
|  | 204 | * | 
|  | 205 | * @param[in] errMsg - The error exception message associated with the | 
|  | 206 | *                     error log to be committed. | 
|  | 207 | * @param[in] severity - level of the error | 
|  | 208 | * @param[in] additionalData - The AdditionalData property for the error | 
|  | 209 | * @param[in] ffdc - A vector of FFDC file info | 
|  | 210 | */ | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 211 | void | 
|  | 212 | createWithFFDC(const std::string& message, Severity severity, | 
|  | 213 | const std::map<std::string, std::string>& additionalData, | 
|  | 214 | const FFDCEntries& ffdc); | 
| Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 215 |  | 
| Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 216 | /** @brief Common wrapper for creating an Entry object | 
|  | 217 | * | 
|  | 218 | * @return true if quiesce on error setting is enabled, false otherwise | 
|  | 219 | */ | 
|  | 220 | bool isQuiesceOnErrorEnabled(); | 
|  | 221 |  | 
| Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 222 | /** @brief Create boot block association and quiesce host if running | 
| Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 223 | * | 
| Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 224 | * @param[in] entryId - The ID of the phosphor logging error | 
| Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 225 | */ | 
| Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 226 | void quiesceOnError(const uint32_t entryId); | 
| Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 227 |  | 
| Andrew Geissler | e4960ee | 2020-03-30 14:31:52 -0500 | [diff] [blame] | 228 | /** @brief Check if inventory callout present in input entry | 
|  | 229 | * | 
|  | 230 | * @param[in] entry - The error to check for callouts | 
|  | 231 | * | 
|  | 232 | * @return true if inventory item in associations, false otherwise | 
|  | 233 | */ | 
|  | 234 | bool isCalloutPresent(const Entry& entry); | 
|  | 235 |  | 
| Andrew Geissler | ced6e2a | 2020-04-07 16:15:29 -0500 | [diff] [blame] | 236 | /** @brief Check (and remove) entry being erased from blocking errors | 
|  | 237 | * | 
|  | 238 | * @param[in] entryId - The entry that is being erased | 
|  | 239 | */ | 
|  | 240 | void checkAndRemoveBlockingError(uint32_t entryId); | 
|  | 241 |  | 
| Adriana Kobylak | e7d271a | 2020-12-07 14:32:44 -0600 | [diff] [blame] | 242 | /** @brief Persistent map of Entry dbus objects and their ID */ | 
|  | 243 | std::map<uint32_t, std::unique_ptr<Entry>> entries; | 
|  | 244 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 245 | private: | 
|  | 246 | /* | 
|  | 247 | * @fn _commit() | 
|  | 248 | * @brief commit() helper | 
|  | 249 | * @param[in] transactionId - Unique identifier of the journal entries | 
|  | 250 | *                            to be committed. | 
|  | 251 | * @param[in] errMsg - The error exception message associated with the | 
|  | 252 | *                     error log to be committed. | 
|  | 253 | * @param[in] errLvl - level of the error | 
|  | 254 | */ | 
|  | 255 | void _commit(uint64_t transactionId, std::string&& errMsg, | 
|  | 256 | Entry::Level errLvl); | 
| Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 257 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 258 | /** @brief Call metadata handler(s), if any. Handlers may create | 
|  | 259 | *         associations. | 
|  | 260 | *  @param[in] errorName - name of the error | 
|  | 261 | *  @param[in] additionalData - list of metadata (in key=value format) | 
|  | 262 | *  @param[out] objects - list of error's association objects | 
|  | 263 | */ | 
|  | 264 | void processMetadata(const std::string& errorName, | 
|  | 265 | const std::vector<std::string>& additionalData, | 
|  | 266 | AssociationList& objects) const; | 
| Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 267 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 268 | /** @brief Reads the BMC code level | 
|  | 269 | * | 
|  | 270 | *  @return std::string - the version string | 
|  | 271 | */ | 
|  | 272 | static std::string readFWVersion(); | 
| Matt Spinler | 1275bd1 | 2018-05-01 15:13:53 -0500 | [diff] [blame] | 273 |  | 
| Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 274 | /** @brief Call any create() functions provided by any extensions. | 
|  | 275 | *  This is called right after an event log is created to allow | 
|  | 276 | *  extensions to create their own log based on this one. | 
|  | 277 | * | 
|  | 278 | *  @param[in] entry - the new event log entry | 
| Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 279 | *  @param[in] ffdc - A vector of FFDC file info | 
| Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 280 | */ | 
| Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 281 | void doExtensionLogCreate(const Entry& entry, const FFDCEntries& ffdc); | 
| Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 282 |  | 
| Matt Spinler | b60e755 | 2019-07-24 15:28:08 -0500 | [diff] [blame] | 283 | /** @brief Common wrapper for creating an Entry object | 
|  | 284 | * | 
|  | 285 | * @param[in] errMsg - The error exception message associated with the | 
|  | 286 | *                     error log to be committed. | 
|  | 287 | * @param[in] errLvl - level of the error | 
|  | 288 | * @param[in] additionalData - The AdditionalData property for the error | 
| Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 289 | * @param[in] ffdc - A vector of FFDC file info. Defaults to an empty | 
|  | 290 | * vector. | 
| Matt Spinler | b60e755 | 2019-07-24 15:28:08 -0500 | [diff] [blame] | 291 | */ | 
|  | 292 | void createEntry(std::string errMsg, Entry::Level errLvl, | 
| Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 293 | std::vector<std::string> additionalData, | 
|  | 294 | const FFDCEntries& ffdc = FFDCEntries{}); | 
| Matt Spinler | b60e755 | 2019-07-24 15:28:08 -0500 | [diff] [blame] | 295 |  | 
| Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 296 | /** @brief Notified on entry property changes | 
|  | 297 | * | 
|  | 298 | * If an entry is blocking, this callback will be registered to monitor for | 
|  | 299 | * the entry having it's Resolved field set to true. If it is then remove | 
|  | 300 | * the blocking object. | 
|  | 301 | * | 
|  | 302 | * @param[in] msg - sdbusplus dbusmessage | 
|  | 303 | */ | 
| Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 304 | void onEntryResolve(sdbusplus::message_t& msg); | 
| Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 305 |  | 
|  | 306 | /** @brief Remove block objects for any resolved entries  */ | 
|  | 307 | void findAndRemoveResolvedBlocks(); | 
|  | 308 |  | 
| Andrew Geissler | f6126a7 | 2020-05-08 10:41:09 -0500 | [diff] [blame] | 309 | /** @brief Quiesce host if it is running | 
|  | 310 | * | 
|  | 311 | * This is called when the user has requested the system be quiesced | 
|  | 312 | * if a log with a callout is created | 
|  | 313 | */ | 
|  | 314 | void checkAndQuiesceHost(); | 
|  | 315 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 316 | /** @brief Persistent sdbusplus DBus bus connection. */ | 
| Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 317 | sdbusplus::bus_t& busLog; | 
| Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 318 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 319 | /** @brief List of error ids for high severity errors */ | 
|  | 320 | std::list<uint32_t> realErrors; | 
| Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 321 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 322 | /** @brief List of error ids for Info(and below) severity */ | 
|  | 323 | std::list<uint32_t> infoErrors; | 
| Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 324 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 325 | /** @brief Id of last error log entry */ | 
|  | 326 | uint32_t entryId; | 
| Matt Spinler | 1275bd1 | 2018-05-01 15:13:53 -0500 | [diff] [blame] | 327 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 328 | /** @brief The BMC firmware version */ | 
|  | 329 | const std::string fwVersion; | 
| Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 330 |  | 
|  | 331 | /** @brief Array of blocking errors */ | 
|  | 332 | std::vector<std::unique_ptr<Block>> blockingErrors; | 
| Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 333 |  | 
|  | 334 | /** @brief Map of entry id to call back object on properties changed */ | 
| Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 335 | std::map<uint32_t, std::unique_ptr<sdbusplus::bus::match_t>> | 
| Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 336 | propChangedEntryCallback; | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 337 | }; | 
|  | 338 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 339 | } // namespace internal | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 340 |  | 
|  | 341 | /** @class Manager | 
| Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 342 | *  @brief Implementation for deleting all error log entries and | 
|  | 343 | *         creating new logs. | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 344 | *  @details A concrete implementation for the | 
| Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 345 | *           xyz.openbmc_project.Collection.DeleteAll and | 
|  | 346 | *           xyz.openbmc_project.Logging.Create interfaces. | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 347 | */ | 
| Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 348 | class Manager : public details::ServerObject<DeleteAllIface, CreateIface> | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 349 | { | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 350 | public: | 
|  | 351 | Manager() = delete; | 
|  | 352 | Manager(const Manager&) = delete; | 
|  | 353 | Manager& operator=(const Manager&) = delete; | 
|  | 354 | Manager(Manager&&) = delete; | 
|  | 355 | Manager& operator=(Manager&&) = delete; | 
|  | 356 | virtual ~Manager() = default; | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 357 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 358 | /** @brief Constructor to put object onto bus at a dbus path. | 
|  | 359 | *         Defer signal registration (pass true for deferSignal to the | 
|  | 360 | *         base class) until after the properties are set. | 
|  | 361 | *  @param[in] bus - Bus to attach to. | 
|  | 362 | *  @param[in] path - Path to attach at. | 
|  | 363 | *  @param[in] manager - Reference to internal manager object. | 
|  | 364 | */ | 
| Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 365 | Manager(sdbusplus::bus_t& bus, const std::string& path, | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 366 | internal::Manager& manager) : | 
| Patrick Williams | 6ef6b25 | 2022-03-30 14:28:27 -0500 | [diff] [blame] | 367 | details::ServerObject<DeleteAllIface, CreateIface>( | 
|  | 368 | bus, path.c_str(), | 
|  | 369 | details::ServerObject<DeleteAllIface, | 
|  | 370 | CreateIface>::action::defer_emit), | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 371 | manager(manager){}; | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 372 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 373 | /** @brief Delete all d-bus objects. | 
|  | 374 | */ | 
| Patrick Williams | ec4eaea | 2021-08-28 15:10:15 -0500 | [diff] [blame] | 375 | void deleteAll() override | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 376 | { | 
| Matt Spinler | f6f5123 | 2022-03-09 10:11:53 -0600 | [diff] [blame] | 377 | log<level::INFO>("Deleting all log entries"); | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 378 | auto numbersOfLogs = manager.eraseAll(); | 
|  | 379 | std::map<std::string, std::string> additionalData; | 
|  | 380 | additionalData.emplace("NUM_LOGS", std::to_string(numbersOfLogs)); | 
|  | 381 | manager.create(LogsCleared::errName, Severity::Informational, | 
|  | 382 | additionalData); | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 383 | } | 
|  | 384 |  | 
| Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 385 | /** @brief D-Bus method call implementation to create an event log. | 
|  | 386 | * | 
|  | 387 | * @param[in] errMsg - The error exception message associated with the | 
|  | 388 | *                     error log to be committed. | 
|  | 389 | * @param[in] severity - Level of the error | 
|  | 390 | * @param[in] additionalData - The AdditionalData property for the error | 
|  | 391 | */ | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 392 | void create(std::string message, Severity severity, | 
|  | 393 | std::map<std::string, std::string> additionalData) override | 
| Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 394 | { | 
|  | 395 | manager.create(message, severity, additionalData); | 
|  | 396 | } | 
|  | 397 |  | 
| Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 398 | /** @brief D-Bus method call implementation to create an event log with FFDC | 
|  | 399 | * | 
|  | 400 | * The same as create(), but takes an extra FFDC argument. | 
|  | 401 | * | 
|  | 402 | * @param[in] errMsg - The error exception message associated with the | 
|  | 403 | *                     error log to be committed. | 
|  | 404 | * @param[in] severity - Level of the error | 
|  | 405 | * @param[in] additionalData - The AdditionalData property for the error | 
|  | 406 | * @param[in] ffdc - A vector of FFDC file info | 
|  | 407 | */ | 
| Matt Spinler | fcbaf3e | 2020-03-23 09:22:45 -0500 | [diff] [blame] | 408 | void createWithFFDCFiles( | 
| BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame^] | 409 | std::string message, Severity severity, | 
| Matt Spinler | fcbaf3e | 2020-03-23 09:22:45 -0500 | [diff] [blame] | 410 | std::map<std::string, std::string> additionalData, | 
|  | 411 | std::vector<std::tuple<CreateIface::FFDCFormat, uint8_t, uint8_t, | 
|  | 412 | sdbusplus::message::unix_fd>> | 
|  | 413 | ffdc) override | 
|  | 414 | { | 
| Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 415 | manager.createWithFFDC(message, severity, additionalData, ffdc); | 
| Matt Spinler | fcbaf3e | 2020-03-23 09:22:45 -0500 | [diff] [blame] | 416 | } | 
|  | 417 |  | 
| Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 418 | private: | 
|  | 419 | /** @brief This is a reference to manager object */ | 
|  | 420 | internal::Manager& manager; | 
| Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 421 | }; | 
|  | 422 |  | 
| Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 423 | } // namespace logging | 
|  | 424 | } // namespace phosphor |