Matt Spinler | 711d51d | 2019-11-06 09:36:51 -0600 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2019 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 16 | #include "manager.hpp" |
| 17 | |
| 18 | #include "additional_data.hpp" |
Matt Spinler | 3387eac | 2023-07-06 14:56:02 -0500 | [diff] [blame] | 19 | #include "elog_serialize.hpp" |
Matt Spinler | 05c2c6c | 2019-12-18 14:02:09 -0600 | [diff] [blame] | 20 | #include "json_utils.hpp" |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 21 | #include "pel.hpp" |
Vijay Lobo | 2fb1021 | 2021-08-22 23:24:16 -0500 | [diff] [blame] | 22 | #include "pel_entry.hpp" |
Matt Spinler | 1962e08 | 2020-08-05 13:44:53 -0500 | [diff] [blame] | 23 | #include "service_indicators.hpp" |
Matt Spinler | 8b81ec0 | 2022-07-12 13:25:37 -0500 | [diff] [blame] | 24 | #include "severity.hpp" |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 25 | |
Matt Spinler | 22421b9 | 2020-07-17 09:41:08 -0500 | [diff] [blame] | 26 | #include <fmt/format.h> |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 27 | #include <sys/inotify.h> |
Matt Spinler | 6b1a5c8 | 2020-01-07 08:48:53 -0600 | [diff] [blame] | 28 | #include <unistd.h> |
| 29 | |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 30 | #include <phosphor-logging/lg2.hpp> |
Patrick Williams | 2544b41 | 2022-10-04 08:41:06 -0500 | [diff] [blame] | 31 | #include <xyz/openbmc_project/Common/error.hpp> |
| 32 | #include <xyz/openbmc_project/Logging/Create/server.hpp> |
| 33 | |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 34 | #include <filesystem> |
| 35 | #include <fstream> |
Matt Spinler | 0003af1 | 2022-06-08 10:46:17 -0500 | [diff] [blame] | 36 | #include <locale> |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 37 | |
| 38 | namespace openpower |
| 39 | { |
| 40 | namespace pels |
| 41 | { |
| 42 | |
| 43 | using namespace phosphor::logging; |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 44 | namespace fs = std::filesystem; |
Harisuddin Mohamed Isa | 0f717e1 | 2020-01-15 20:05:33 +0800 | [diff] [blame] | 45 | namespace rg = openpower::pels::message; |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 46 | |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 47 | namespace common_error = sdbusplus::xyz::openbmc_project::Common::Error; |
| 48 | |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 49 | using Create = sdbusplus::xyz::openbmc_project::Logging::server::Create; |
| 50 | |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 51 | namespace additional_data |
| 52 | { |
| 53 | constexpr auto rawPEL = "RAWPEL"; |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 54 | constexpr auto esel = "ESEL"; |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 55 | constexpr auto error = "ERROR_NAME"; |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 56 | } // namespace additional_data |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 57 | |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 58 | constexpr auto defaultLogMessage = "xyz.openbmc_project.Logging.Error.Default"; |
Matt Spinler | 0dd22c8 | 2023-05-04 15:28:12 -0500 | [diff] [blame] | 59 | constexpr uint32_t bmcThermalCompID = 0x2700; |
| 60 | constexpr uint32_t bmcFansCompID = 0x2800; |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 61 | |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 62 | Manager::~Manager() |
| 63 | { |
| 64 | if (_pelFileDeleteFD != -1) |
| 65 | { |
| 66 | if (_pelFileDeleteWatchFD != -1) |
| 67 | { |
| 68 | inotify_rm_watch(_pelFileDeleteFD, _pelFileDeleteWatchFD); |
| 69 | } |
| 70 | close(_pelFileDeleteFD); |
| 71 | } |
| 72 | } |
| 73 | |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 74 | void Manager::create(const std::string& message, uint32_t obmcLogID, |
| 75 | uint64_t timestamp, Entry::Level severity, |
| 76 | const std::vector<std::string>& additionalData, |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 77 | const std::vector<std::string>& associations, |
| 78 | const FFDCEntries& ffdc) |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 79 | { |
| 80 | AdditionalData ad{additionalData}; |
| 81 | |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 82 | // If a PEL was passed in via a filename or in an ESEL, |
| 83 | // use that. Otherwise, create one. |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 84 | auto rawPelPath = ad.getValue(additional_data::rawPEL); |
| 85 | if (rawPelPath) |
| 86 | { |
| 87 | addRawPEL(*rawPelPath, obmcLogID); |
| 88 | } |
| 89 | else |
| 90 | { |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 91 | auto esel = ad.getValue(additional_data::esel); |
| 92 | if (esel) |
| 93 | { |
| 94 | addESELPEL(*esel, obmcLogID); |
| 95 | } |
| 96 | else |
| 97 | { |
| 98 | createPEL(message, obmcLogID, timestamp, severity, additionalData, |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 99 | associations, ffdc); |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 100 | } |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 101 | } |
Adriana Kobylak | e7d271a | 2020-12-07 14:32:44 -0600 | [diff] [blame] | 102 | |
| 103 | setEntryPath(obmcLogID); |
Vijay Lobo | cbc93a4 | 2021-05-20 19:04:07 -0500 | [diff] [blame] | 104 | setServiceProviderNotifyFlag(obmcLogID); |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | void Manager::addRawPEL(const std::string& rawPelPath, uint32_t obmcLogID) |
| 108 | { |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 109 | if (fs::exists(rawPelPath)) |
| 110 | { |
| 111 | std::ifstream file(rawPelPath, std::ios::in | std::ios::binary); |
| 112 | |
| 113 | auto data = std::vector<uint8_t>(std::istreambuf_iterator<char>(file), |
| 114 | std::istreambuf_iterator<char>()); |
| 115 | if (file.fail()) |
| 116 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 117 | lg2::error( |
| 118 | "Filesystem error reading a raw PEL. File = {FILE}, obmcLogID = {LOGID}", |
| 119 | "FILE", rawPelPath, "LOGID", obmcLogID); |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 120 | // TODO, Decide what to do here. Maybe nothing. |
| 121 | return; |
| 122 | } |
| 123 | |
| 124 | file.close(); |
| 125 | |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 126 | addPEL(data, obmcLogID); |
Matt Spinler | 6741692 | 2021-07-19 12:34:57 -0600 | [diff] [blame] | 127 | |
| 128 | std::error_code ec; |
| 129 | fs::remove(rawPelPath, ec); |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 130 | } |
| 131 | else |
| 132 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 133 | lg2::error( |
| 134 | "Raw PEL file from BMC event log does not exit. File = {FILE}, obmcLogID = {LOGID}", |
| 135 | "FILE", rawPelPath, "LOGID", obmcLogID); |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 136 | } |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 137 | } |
| 138 | |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 139 | void Manager::addPEL(std::vector<uint8_t>& pelData, uint32_t obmcLogID) |
| 140 | { |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 141 | auto pel = std::make_unique<openpower::pels::PEL>(pelData, obmcLogID); |
| 142 | if (pel->valid()) |
| 143 | { |
Sumit Kumar | 8ec4156 | 2021-10-29 05:39:37 -0500 | [diff] [blame] | 144 | // PELs created by others still need this field set by us. |
| 145 | pel->setCommitTime(); |
| 146 | |
Sumit Kumar | a1e4084 | 2021-06-23 09:52:25 -0500 | [diff] [blame] | 147 | // Assign Id other than to Hostbot PEL |
| 148 | if ((pel->privateHeader()).creatorID() != |
| 149 | static_cast<uint8_t>(CreatorID::hostboot)) |
| 150 | { |
| 151 | pel->assignID(); |
| 152 | } |
Sumit Kumar | 2ccdcef | 2021-07-31 10:04:58 -0500 | [diff] [blame] | 153 | else |
| 154 | { |
| 155 | const Repository::LogID id{Repository::LogID::Pel(pel->id())}; |
| 156 | auto result = _repo.hasPEL(id); |
| 157 | if (result) |
| 158 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 159 | lg2::warning( |
| 160 | "Duplicate HostBoot PEL ID {ID} found, moving it to archive folder", |
| 161 | "ID", lg2::hex, pel->id()); |
Sumit Kumar | 2ccdcef | 2021-07-31 10:04:58 -0500 | [diff] [blame] | 162 | |
| 163 | _repo.archivePEL(*pel); |
Matt Spinler | d8fb5ba | 2022-01-25 13:01:14 -0600 | [diff] [blame] | 164 | |
| 165 | // No need to keep around the openBMC event log entry |
| 166 | scheduleObmcLogDelete(obmcLogID); |
Sumit Kumar | 2ccdcef | 2021-07-31 10:04:58 -0500 | [diff] [blame] | 167 | return; |
| 168 | } |
| 169 | } |
Sumit Kumar | a1e4084 | 2021-06-23 09:52:25 -0500 | [diff] [blame] | 170 | |
Sumit Kumar | 3160a54 | 2021-04-26 08:07:04 -0500 | [diff] [blame] | 171 | // Update System Info to Extended User Data |
| 172 | pel->updateSysInfoInExtendedUserDataSection(*_dataIface); |
| 173 | |
Sumit Kumar | 3e27443 | 2021-09-14 06:37:56 -0500 | [diff] [blame] | 174 | // Check for severity 0x51 and update boot progress SRC |
| 175 | updateProgressSRC(pel); |
| 176 | |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 177 | try |
| 178 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 179 | lg2::debug("Adding external PEL {ID} (BMC ID {BMCID}) to repo", |
| 180 | "ID", lg2::hex, pel->id(), "BMCID", obmcLogID); |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 181 | _repo.add(pel); |
Matt Spinler | 7e727a3 | 2020-07-07 15:00:17 -0500 | [diff] [blame] | 182 | |
| 183 | if (_repo.sizeWarning()) |
| 184 | { |
| 185 | scheduleRepoPrune(); |
| 186 | } |
Matt Spinler | 1962e08 | 2020-08-05 13:44:53 -0500 | [diff] [blame] | 187 | |
| 188 | // Activate any resulting service indicators if necessary |
| 189 | auto policy = service_indicators::getPolicy(*_dataIface); |
| 190 | policy->activate(*pel); |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 191 | } |
Patrick Williams | 66491c6 | 2021-10-06 12:23:37 -0500 | [diff] [blame] | 192 | catch (const std::exception& e) |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 193 | { |
| 194 | // Probably a full or r/o filesystem, not much we can do. |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 195 | lg2::error("Unable to add PEL {ID} to Repository", "ID", lg2::hex, |
| 196 | pel->id()); |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 197 | } |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 198 | |
Vijay Lobo | d354a39 | 2021-06-01 16:21:02 -0500 | [diff] [blame] | 199 | updateEventId(pel); |
Matt Spinler | 28d6ae2 | 2022-03-18 11:18:27 -0500 | [diff] [blame] | 200 | updateResolution(*pel); |
Matt Spinler | 3387eac | 2023-07-06 14:56:02 -0500 | [diff] [blame] | 201 | serializeLogEntry(obmcLogID); |
Vijay Lobo | afb1b46 | 2021-07-21 23:29:13 -0500 | [diff] [blame] | 202 | createPELEntry(obmcLogID); |
Matt Spinler | df5cb83 | 2022-07-12 12:47:26 -0500 | [diff] [blame] | 203 | |
| 204 | // Check if firmware should quiesce system due to error |
| 205 | checkPelAndQuiesce(pel); |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 206 | } |
| 207 | else |
| 208 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 209 | lg2::error("Invalid PEL received from the host. BMC ID = {ID}", "ID", |
| 210 | obmcLogID); |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 211 | |
| 212 | AdditionalData ad; |
| 213 | ad.add("PLID", getNumberString("0x%08X", pel->plid())); |
| 214 | ad.add("OBMC_LOG_ID", std::to_string(obmcLogID)); |
| 215 | ad.add("PEL_SIZE", std::to_string(pelData.size())); |
| 216 | |
| 217 | std::string asciiString; |
| 218 | auto src = pel->primarySRC(); |
| 219 | if (src) |
| 220 | { |
| 221 | asciiString = (*src)->asciiString(); |
| 222 | } |
| 223 | |
| 224 | ad.add("SRC", asciiString); |
| 225 | |
| 226 | _eventLogger.log("org.open_power.Logging.Error.BadHostPEL", |
| 227 | Entry::Level::Error, ad); |
Matt Spinler | fe72189 | 2020-04-02 10:28:08 -0500 | [diff] [blame] | 228 | |
| 229 | // Save it to a file for debug in the lab. Just keep the latest. |
| 230 | // Not adding it to the PEL because it could already be max size |
| 231 | // and don't want to truncate an already invalid PEL. |
| 232 | std::ofstream pelFile{getPELRepoPath() / "badPEL"}; |
| 233 | pelFile.write(reinterpret_cast<const char*>(pelData.data()), |
| 234 | pelData.size()); |
Matt Spinler | d8fb5ba | 2022-01-25 13:01:14 -0600 | [diff] [blame] | 235 | |
| 236 | // No need to keep around the openBMC event log entry |
| 237 | scheduleObmcLogDelete(obmcLogID); |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 238 | } |
| 239 | } |
| 240 | |
| 241 | void Manager::addESELPEL(const std::string& esel, uint32_t obmcLogID) |
| 242 | { |
| 243 | std::vector<uint8_t> data; |
| 244 | |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 245 | lg2::debug("Adding PEL from ESEL. BMC ID = {ID}", "ID", obmcLogID); |
Matt Spinler | 5f5352e | 2020-03-05 16:23:27 -0600 | [diff] [blame] | 246 | |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 247 | try |
| 248 | { |
| 249 | data = std::move(eselToRawData(esel)); |
| 250 | } |
Patrick Williams | 66491c6 | 2021-10-06 12:23:37 -0500 | [diff] [blame] | 251 | catch (const std::exception& e) |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 252 | { |
| 253 | // Try to add it below anyway, so it follows the usual bad data path. |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 254 | lg2::error("Problems converting ESEL string to a byte vector"); |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | addPEL(data, obmcLogID); |
| 258 | } |
| 259 | |
| 260 | std::vector<uint8_t> Manager::eselToRawData(const std::string& esel) |
| 261 | { |
| 262 | std::vector<uint8_t> data; |
| 263 | std::string byteString; |
| 264 | |
| 265 | // As the eSEL string looks like: "50 48 00 ab ..." there are 3 |
| 266 | // characters per raw byte, and since the actual PEL data starts |
| 267 | // at the 16th byte, the code will grab the PEL data starting at |
| 268 | // offset 48 in the string. |
| 269 | static constexpr size_t pelStart = 16 * 3; |
| 270 | |
| 271 | if (esel.size() <= pelStart) |
| 272 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 273 | lg2::error("ESEL data too short, length = {LEN}", "LEN", esel.size()); |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 274 | throw std::length_error("ESEL data too short"); |
| 275 | } |
| 276 | |
| 277 | for (size_t i = pelStart; i < esel.size(); i += 3) |
| 278 | { |
| 279 | if (i + 1 < esel.size()) |
| 280 | { |
| 281 | byteString = esel.substr(i, 2); |
| 282 | data.push_back(std::stoi(byteString, nullptr, 16)); |
| 283 | } |
| 284 | else |
| 285 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 286 | lg2::error("ESEL data too short, length = {LEN}", "LEN", |
| 287 | esel.size()); |
Matt Spinler | 19e7290 | 2020-01-24 11:05:20 -0600 | [diff] [blame] | 288 | throw std::length_error("ESEL data too short"); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | return data; |
| 293 | } |
| 294 | |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 295 | void Manager::erase(uint32_t obmcLogID) |
| 296 | { |
Matt Spinler | 475e574 | 2019-07-18 16:09:49 -0500 | [diff] [blame] | 297 | Repository::LogID id{Repository::LogID::Obmc(obmcLogID)}; |
| 298 | |
Vijay Lobo | afb1b46 | 2021-07-21 23:29:13 -0500 | [diff] [blame] | 299 | auto path = std::string(OBJ_ENTRY) + '/' + std::to_string(obmcLogID); |
| 300 | _pelEntries.erase(path); |
Matt Spinler | 475e574 | 2019-07-18 16:09:49 -0500 | [diff] [blame] | 301 | _repo.remove(id); |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 302 | } |
| 303 | |
Patrick Williams | d26fa3e | 2021-04-21 15:22:23 -0500 | [diff] [blame] | 304 | bool Manager::isDeleteProhibited(uint32_t /*obmcLogID*/) |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 305 | { |
| 306 | return false; |
| 307 | } |
| 308 | |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 309 | PelFFDC Manager::convertToPelFFDC(const FFDCEntries& ffdc) |
| 310 | { |
| 311 | PelFFDC pelFFDC; |
| 312 | |
| 313 | std::for_each(ffdc.begin(), ffdc.end(), [&pelFFDC](const auto& f) { |
| 314 | PelFFDCfile pf; |
| 315 | pf.subType = std::get<ffdcSubtypePos>(f); |
| 316 | pf.version = std::get<ffdcVersionPos>(f); |
| 317 | pf.fd = std::get<ffdcFDPos>(f); |
| 318 | |
| 319 | switch (std::get<ffdcFormatPos>(f)) |
| 320 | { |
| 321 | case Create::FFDCFormat::JSON: |
| 322 | pf.format = UserDataFormat::json; |
| 323 | break; |
| 324 | case Create::FFDCFormat::CBOR: |
| 325 | pf.format = UserDataFormat::cbor; |
| 326 | break; |
| 327 | case Create::FFDCFormat::Text: |
| 328 | pf.format = UserDataFormat::text; |
| 329 | break; |
| 330 | case Create::FFDCFormat::Custom: |
| 331 | pf.format = UserDataFormat::custom; |
| 332 | break; |
| 333 | } |
| 334 | |
| 335 | pelFFDC.push_back(pf); |
| 336 | }); |
| 337 | |
| 338 | return pelFFDC; |
| 339 | } |
| 340 | |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 341 | void Manager::createPEL(const std::string& message, uint32_t obmcLogID, |
| 342 | uint64_t timestamp, |
| 343 | phosphor::logging::Entry::Level severity, |
| 344 | const std::vector<std::string>& additionalData, |
Patrick Williams | d26fa3e | 2021-04-21 15:22:23 -0500 | [diff] [blame] | 345 | const std::vector<std::string>& /*associations*/, |
Matt Spinler | 56ad2a0 | 2020-03-26 14:00:52 -0500 | [diff] [blame] | 346 | const FFDCEntries& ffdc) |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 347 | { |
Harisuddin Mohamed Isa | 0f717e1 | 2020-01-15 20:05:33 +0800 | [diff] [blame] | 348 | auto entry = _registry.lookup(message, rg::LookupType::name); |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 349 | auto pelFFDC = convertToPelFFDC(ffdc); |
| 350 | AdditionalData ad{additionalData}; |
Matt Spinler | 1d4c74a | 2019-12-16 14:40:21 -0600 | [diff] [blame] | 351 | std::string msg; |
Matt Spinler | 67456c2 | 2019-10-21 12:22:49 -0500 | [diff] [blame] | 352 | |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 353 | if (!entry) |
Matt Spinler | 67456c2 | 2019-10-21 12:22:49 -0500 | [diff] [blame] | 354 | { |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 355 | // Instead, get the default entry that means there is no |
| 356 | // other matching entry. This error will still use the |
| 357 | // AdditionalData values of the original error, and this |
| 358 | // code will add the error message value that wasn't found |
| 359 | // to this AD. This way, there will at least be a PEL, |
| 360 | // possibly with callouts, to allow users to debug the |
| 361 | // issue that caused the error even without its own PEL. |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 362 | lg2::error("Event not found in PEL message registry: {MSG}", "MSG", |
| 363 | message); |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 364 | |
| 365 | entry = _registry.lookup(defaultLogMessage, rg::LookupType::name); |
| 366 | if (!entry) |
| 367 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 368 | lg2::error("Default event not found in PEL message registry"); |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 369 | return; |
| 370 | } |
| 371 | |
| 372 | ad.add(additional_data::error, message); |
| 373 | } |
| 374 | |
| 375 | auto pel = std::make_unique<openpower::pels::PEL>( |
Matt Spinler | 9d92109 | 2022-12-15 11:54:49 -0600 | [diff] [blame] | 376 | *entry, obmcLogID, timestamp, severity, ad, pelFFDC, *_dataIface, |
| 377 | *_journal); |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 378 | |
| 379 | _repo.add(pel); |
| 380 | |
| 381 | if (_repo.sizeWarning()) |
| 382 | { |
| 383 | scheduleRepoPrune(); |
| 384 | } |
| 385 | |
| 386 | auto src = pel->primarySRC(); |
| 387 | if (src) |
| 388 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 389 | auto asciiString = (*src)->asciiString(); |
| 390 | while (asciiString.back() == ' ') |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 391 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 392 | asciiString.pop_back(); |
Matt Spinler | 30ddc9f | 2020-07-16 15:39:59 -0500 | [diff] [blame] | 393 | } |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 394 | lg2::info("Created PEL {ID} (BMC ID {BMCID}) with SRC {SRC}", "ID", |
| 395 | lg2::hex, pel->id(), "BMCID", pel->obmcLogID(), "SRC", |
| 396 | asciiString); |
Matt Spinler | 1d4c74a | 2019-12-16 14:40:21 -0600 | [diff] [blame] | 397 | } |
Matt Spinler | 1962e08 | 2020-08-05 13:44:53 -0500 | [diff] [blame] | 398 | |
Sumit Kumar | 3e27443 | 2021-09-14 06:37:56 -0500 | [diff] [blame] | 399 | // Check for severity 0x51 and update boot progress SRC |
| 400 | updateProgressSRC(pel); |
| 401 | |
Matt Spinler | 1962e08 | 2020-08-05 13:44:53 -0500 | [diff] [blame] | 402 | // Activate any resulting service indicators if necessary |
| 403 | auto policy = service_indicators::getPolicy(*_dataIface); |
| 404 | policy->activate(*pel); |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 405 | |
Matt Spinler | 8b81ec0 | 2022-07-12 13:25:37 -0500 | [diff] [blame] | 406 | updateDBusSeverity(*pel); |
Vijay Lobo | d354a39 | 2021-06-01 16:21:02 -0500 | [diff] [blame] | 407 | updateEventId(pel); |
Matt Spinler | 28d6ae2 | 2022-03-18 11:18:27 -0500 | [diff] [blame] | 408 | updateResolution(*pel); |
Matt Spinler | 3387eac | 2023-07-06 14:56:02 -0500 | [diff] [blame] | 409 | serializeLogEntry(obmcLogID); |
Vijay Lobo | afb1b46 | 2021-07-21 23:29:13 -0500 | [diff] [blame] | 410 | createPELEntry(obmcLogID); |
Matt Spinler | df5cb83 | 2022-07-12 12:47:26 -0500 | [diff] [blame] | 411 | |
| 412 | // Check if firmware should quiesce system due to error |
| 413 | checkPelAndQuiesce(pel); |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 414 | } |
| 415 | |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 416 | sdbusplus::message::unix_fd Manager::getPEL(uint32_t pelID) |
| 417 | { |
| 418 | Repository::LogID id{Repository::LogID::Pel(pelID)}; |
| 419 | std::optional<int> fd; |
| 420 | |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 421 | lg2::debug("getPEL {ID}", "ID", lg2::hex, pelID); |
Matt Spinler | 5f5352e | 2020-03-05 16:23:27 -0600 | [diff] [blame] | 422 | |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 423 | try |
| 424 | { |
| 425 | fd = _repo.getPELFD(id); |
| 426 | } |
Patrick Williams | 66491c6 | 2021-10-06 12:23:37 -0500 | [diff] [blame] | 427 | catch (const std::exception& e) |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 428 | { |
| 429 | throw common_error::InternalFailure(); |
| 430 | } |
| 431 | |
| 432 | if (!fd) |
| 433 | { |
| 434 | throw common_error::InvalidArgument(); |
| 435 | } |
| 436 | |
Matt Spinler | 6b1a5c8 | 2020-01-07 08:48:53 -0600 | [diff] [blame] | 437 | scheduleFDClose(*fd); |
| 438 | |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 439 | return *fd; |
| 440 | } |
| 441 | |
Matt Spinler | 6b1a5c8 | 2020-01-07 08:48:53 -0600 | [diff] [blame] | 442 | void Manager::scheduleFDClose(int fd) |
| 443 | { |
| 444 | _fdCloserEventSource = std::make_unique<sdeventplus::source::Defer>( |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 445 | _event, std::bind(std::mem_fn(&Manager::closeFD), this, fd, |
| 446 | std::placeholders::_1)); |
Matt Spinler | 6b1a5c8 | 2020-01-07 08:48:53 -0600 | [diff] [blame] | 447 | } |
| 448 | |
Patrick Williams | d26fa3e | 2021-04-21 15:22:23 -0500 | [diff] [blame] | 449 | void Manager::closeFD(int fd, sdeventplus::source::EventBase& /*source*/) |
Matt Spinler | 6b1a5c8 | 2020-01-07 08:48:53 -0600 | [diff] [blame] | 450 | { |
| 451 | close(fd); |
| 452 | _fdCloserEventSource.reset(); |
| 453 | } |
| 454 | |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 455 | std::vector<uint8_t> Manager::getPELFromOBMCID(uint32_t obmcLogID) |
| 456 | { |
| 457 | Repository::LogID id{Repository::LogID::Obmc(obmcLogID)}; |
| 458 | std::optional<std::vector<uint8_t>> data; |
| 459 | |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 460 | lg2::debug("getPELFromOBMCID {BMCID}", "BMCID", obmcLogID); |
Matt Spinler | 5f5352e | 2020-03-05 16:23:27 -0600 | [diff] [blame] | 461 | |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 462 | try |
| 463 | { |
| 464 | data = _repo.getPELData(id); |
| 465 | } |
Patrick Williams | 66491c6 | 2021-10-06 12:23:37 -0500 | [diff] [blame] | 466 | catch (const std::exception& e) |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 467 | { |
| 468 | throw common_error::InternalFailure(); |
| 469 | } |
| 470 | |
| 471 | if (!data) |
| 472 | { |
| 473 | throw common_error::InvalidArgument(); |
| 474 | } |
| 475 | |
| 476 | return *data; |
| 477 | } |
| 478 | |
| 479 | void Manager::hostAck(uint32_t pelID) |
| 480 | { |
| 481 | Repository::LogID id{Repository::LogID::Pel(pelID)}; |
| 482 | |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 483 | lg2::debug("HostHack {ID}", "ID", lg2::hex, pelID); |
Matt Spinler | 5f5352e | 2020-03-05 16:23:27 -0600 | [diff] [blame] | 484 | |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 485 | if (!_repo.hasPEL(id)) |
| 486 | { |
| 487 | throw common_error::InvalidArgument(); |
| 488 | } |
| 489 | |
| 490 | if (_hostNotifier) |
| 491 | { |
| 492 | _hostNotifier->ackPEL(pelID); |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | void Manager::hostReject(uint32_t pelID, RejectionReason reason) |
| 497 | { |
| 498 | Repository::LogID id{Repository::LogID::Pel(pelID)}; |
| 499 | |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 500 | lg2::debug("HostReject {ID}, reason = {REASON}", "ID", lg2::hex, pelID, |
| 501 | "REASON", reason); |
Matt Spinler | 5f5352e | 2020-03-05 16:23:27 -0600 | [diff] [blame] | 502 | |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 503 | if (!_repo.hasPEL(id)) |
| 504 | { |
| 505 | throw common_error::InvalidArgument(); |
| 506 | } |
| 507 | |
Matt Spinler | 05c2c6c | 2019-12-18 14:02:09 -0600 | [diff] [blame] | 508 | if (reason == RejectionReason::BadPEL) |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 509 | { |
Matt Spinler | 05c2c6c | 2019-12-18 14:02:09 -0600 | [diff] [blame] | 510 | AdditionalData data; |
| 511 | data.add("BAD_ID", getNumberString("0x%08X", pelID)); |
| 512 | _eventLogger.log("org.open_power.Logging.Error.SentBadPELToHost", |
| 513 | Entry::Level::Informational, data); |
| 514 | if (_hostNotifier) |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 515 | { |
| 516 | _hostNotifier->setBadPEL(pelID); |
| 517 | } |
Matt Spinler | 05c2c6c | 2019-12-18 14:02:09 -0600 | [diff] [blame] | 518 | } |
| 519 | else if ((reason == RejectionReason::HostFull) && _hostNotifier) |
| 520 | { |
| 521 | _hostNotifier->setHostFull(pelID); |
Matt Spinler | a34ab72 | 2019-12-16 10:39:32 -0600 | [diff] [blame] | 522 | } |
| 523 | } |
| 524 | |
Matt Spinler | 7e727a3 | 2020-07-07 15:00:17 -0500 | [diff] [blame] | 525 | void Manager::scheduleRepoPrune() |
| 526 | { |
Matt Spinler | 7e727a3 | 2020-07-07 15:00:17 -0500 | [diff] [blame] | 527 | _repoPrunerEventSource = std::make_unique<sdeventplus::source::Defer>( |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 528 | _event, std::bind(std::mem_fn(&Manager::pruneRepo), this, |
| 529 | std::placeholders::_1)); |
Matt Spinler | 7e727a3 | 2020-07-07 15:00:17 -0500 | [diff] [blame] | 530 | } |
| 531 | |
Patrick Williams | d26fa3e | 2021-04-21 15:22:23 -0500 | [diff] [blame] | 532 | void Manager::pruneRepo(sdeventplus::source::EventBase& /*source*/) |
Matt Spinler | 7e727a3 | 2020-07-07 15:00:17 -0500 | [diff] [blame] | 533 | { |
Sumit Kumar | 027bf28 | 2022-01-24 11:25:19 -0600 | [diff] [blame] | 534 | auto idsWithHwIsoEntry = _dataIface->getLogIDWithHwIsolation(); |
| 535 | |
| 536 | auto idsToDelete = _repo.prune(idsWithHwIsoEntry); |
Matt Spinler | 7e727a3 | 2020-07-07 15:00:17 -0500 | [diff] [blame] | 537 | |
| 538 | // Remove the OpenBMC event logs for the PELs that were just removed. |
| 539 | std::for_each(idsToDelete.begin(), idsToDelete.end(), |
| 540 | [this](auto id) { this->_logManager.erase(id); }); |
| 541 | |
| 542 | _repoPrunerEventSource.reset(); |
| 543 | } |
| 544 | |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 545 | void Manager::setupPELDeleteWatch() |
| 546 | { |
| 547 | _pelFileDeleteFD = inotify_init1(IN_NONBLOCK); |
| 548 | if (-1 == _pelFileDeleteFD) |
| 549 | { |
| 550 | auto e = errno; |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 551 | lg2::error("inotify_init1 failed with errno {ERRNO}", "ERRNO", e); |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 552 | abort(); |
| 553 | } |
| 554 | |
| 555 | _pelFileDeleteWatchFD = inotify_add_watch( |
| 556 | _pelFileDeleteFD, _repo.repoPath().c_str(), IN_DELETE); |
| 557 | if (-1 == _pelFileDeleteWatchFD) |
| 558 | { |
| 559 | auto e = errno; |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 560 | lg2::error("inotify_add_watch failed with errno {ERRNO}", "ERRNO", e); |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 561 | abort(); |
| 562 | } |
| 563 | |
| 564 | _pelFileDeleteEventSource = std::make_unique<sdeventplus::source::IO>( |
| 565 | _event, _pelFileDeleteFD, EPOLLIN, |
| 566 | std::bind(std::mem_fn(&Manager::pelFileDeleted), this, |
| 567 | std::placeholders::_1, std::placeholders::_2, |
| 568 | std::placeholders::_3)); |
| 569 | } |
| 570 | |
Patrick Williams | d26fa3e | 2021-04-21 15:22:23 -0500 | [diff] [blame] | 571 | void Manager::pelFileDeleted(sdeventplus::source::IO& /*io*/, int /*fd*/, |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 572 | uint32_t revents) |
| 573 | { |
| 574 | if (!(revents & EPOLLIN)) |
| 575 | { |
| 576 | return; |
| 577 | } |
| 578 | |
| 579 | // An event for 1 PEL uses 48B. When all PELs are deleted at once, |
| 580 | // as many events as there is room for can be handled in one callback. |
| 581 | // A size of 2000 will allow 41 to be processed, with additional |
| 582 | // callbacks being needed to process the remaining ones. |
Matt Spinler | 9d59d58 | 2021-05-19 07:57:10 -0600 | [diff] [blame] | 583 | std::array<uint8_t, 2000> data{}; |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 584 | auto bytesRead = read(_pelFileDeleteFD, data.data(), data.size()); |
| 585 | if (bytesRead < 0) |
| 586 | { |
| 587 | auto e = errno; |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 588 | lg2::error("Failed reading data from inotify event, errno = {ERRNO}", |
| 589 | "ERRNO", e); |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 590 | abort(); |
| 591 | } |
| 592 | |
| 593 | auto offset = 0; |
| 594 | while (offset < bytesRead) |
| 595 | { |
| 596 | auto event = reinterpret_cast<inotify_event*>(&data[offset]); |
| 597 | if (event->mask & IN_DELETE) |
| 598 | { |
| 599 | std::string filename{event->name}; |
| 600 | |
| 601 | // Get the PEL ID from the filename and tell the |
| 602 | // repo it's been removed, and then delete the BMC |
| 603 | // event log if it's there. |
| 604 | auto pos = filename.find_first_of('_'); |
| 605 | if (pos != std::string::npos) |
| 606 | { |
| 607 | try |
| 608 | { |
| 609 | auto idString = filename.substr(pos + 1); |
| 610 | auto pelID = std::stoul(idString, nullptr, 16); |
| 611 | |
| 612 | Repository::LogID id{Repository::LogID::Pel(pelID)}; |
| 613 | auto removedLogID = _repo.remove(id); |
| 614 | if (removedLogID) |
| 615 | { |
| 616 | _logManager.erase(removedLogID->obmcID.id); |
| 617 | } |
| 618 | } |
| 619 | catch (const std::exception& e) |
| 620 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 621 | lg2::info("Could not find PEL ID from its filename {NAME}", |
| 622 | "NAME", filename); |
Matt Spinler | ff9cec2 | 2020-07-15 13:06:35 -0500 | [diff] [blame] | 623 | } |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | offset += offsetof(inotify_event, name) + event->len; |
| 628 | } |
| 629 | } |
Matt Spinler | 9cc3007 | 2020-09-16 15:39:34 -0500 | [diff] [blame] | 630 | |
| 631 | std::tuple<uint32_t, uint32_t> Manager::createPELWithFFDCFiles( |
| 632 | std::string message, Entry::Level severity, |
| 633 | std::map<std::string, std::string> additionalData, |
| 634 | std::vector<std::tuple< |
| 635 | sdbusplus::xyz::openbmc_project::Logging::server::Create::FFDCFormat, |
| 636 | uint8_t, uint8_t, sdbusplus::message::unix_fd>> |
| 637 | fFDC) |
| 638 | { |
Matt Spinler | 44893cc | 2020-08-26 11:34:17 -0500 | [diff] [blame] | 639 | _logManager.createWithFFDC(message, severity, additionalData, fFDC); |
| 640 | |
| 641 | return {_logManager.lastEntryID(), _repo.lastPelID()}; |
Matt Spinler | 9cc3007 | 2020-09-16 15:39:34 -0500 | [diff] [blame] | 642 | } |
| 643 | |
Matt Spinler | 8bd4ca4 | 2022-04-01 16:06:06 -0500 | [diff] [blame] | 644 | std::string Manager::getPELJSON(uint32_t obmcLogID) |
Matt Spinler | aa85a07 | 2022-03-23 11:26:41 -0500 | [diff] [blame] | 645 | { |
Matt Spinler | 8bd4ca4 | 2022-04-01 16:06:06 -0500 | [diff] [blame] | 646 | // Throws InvalidArgument if not found |
| 647 | auto pelID = getPELIdFromBMCLogId(obmcLogID); |
| 648 | |
| 649 | auto cmd = fmt::format("/usr/bin/peltool -i {:#x}", pelID); |
| 650 | |
| 651 | FILE* pipe = popen(cmd.c_str(), "r"); |
| 652 | if (!pipe) |
| 653 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 654 | lg2::error("Error running cmd: {CMD}", "CMD", cmd); |
Matt Spinler | 8bd4ca4 | 2022-04-01 16:06:06 -0500 | [diff] [blame] | 655 | throw common_error::InternalFailure(); |
| 656 | } |
| 657 | |
| 658 | std::string output; |
| 659 | std::array<char, 1024> buffer; |
| 660 | while (fgets(buffer.data(), buffer.size(), pipe) != nullptr) |
| 661 | { |
| 662 | output.append(buffer.data()); |
| 663 | } |
| 664 | |
| 665 | int rc = pclose(pipe); |
| 666 | if (WEXITSTATUS(rc) != 0) |
| 667 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 668 | lg2::error("Error running cmd: {CMD}, rc = {RC}", "CMD", cmd, "RC", rc); |
Matt Spinler | 8bd4ca4 | 2022-04-01 16:06:06 -0500 | [diff] [blame] | 669 | throw common_error::InternalFailure(); |
| 670 | } |
| 671 | |
| 672 | return output; |
Matt Spinler | aa85a07 | 2022-03-23 11:26:41 -0500 | [diff] [blame] | 673 | } |
| 674 | |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 675 | void Manager::checkPelAndQuiesce(std::unique_ptr<openpower::pels::PEL>& pel) |
| 676 | { |
Matt Spinler | b2abc04 | 2021-05-17 15:32:50 -0600 | [diff] [blame] | 677 | if ((pel->userHeader().severity() == |
| 678 | static_cast<uint8_t>(SeverityType::nonError)) || |
| 679 | (pel->userHeader().severity() == |
| 680 | static_cast<uint8_t>(SeverityType::recovered))) |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 681 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 682 | lg2::debug( |
Matt Spinler | b2abc04 | 2021-05-17 15:32:50 -0600 | [diff] [blame] | 683 | "PEL severity informational or recovered. no quiesce needed"); |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 684 | return; |
| 685 | } |
| 686 | if (!_logManager.isQuiesceOnErrorEnabled()) |
| 687 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 688 | lg2::debug("QuiesceOnHwError not enabled, no quiesce needed"); |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 689 | return; |
| 690 | } |
| 691 | |
Matt Spinler | 845c624 | 2022-03-01 16:45:08 -0600 | [diff] [blame] | 692 | CreatorID creatorID{pel->privateHeader().creatorID()}; |
| 693 | |
| 694 | if ((creatorID != CreatorID::openBMC) && |
| 695 | (creatorID != CreatorID::hostboot) && |
| 696 | (creatorID != CreatorID::ioDrawer) && (creatorID != CreatorID::occ) && |
| 697 | (creatorID != CreatorID::phyp)) |
| 698 | { |
| 699 | return; |
| 700 | } |
| 701 | |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 702 | // Now check if it has any type of callout |
Andrew Geissler | f8e750d | 2022-01-14 14:56:13 -0600 | [diff] [blame] | 703 | if (pel->isHwCalloutPresent()) |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 704 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 705 | lg2::info( |
Matt Spinler | b2abc04 | 2021-05-17 15:32:50 -0600 | [diff] [blame] | 706 | "QuiesceOnHwError enabled, PEL severity not nonError or recovered, " |
| 707 | "and callout is present"); |
Andrew Geissler | 44fc316 | 2020-07-09 09:21:31 -0500 | [diff] [blame] | 708 | |
| 709 | _logManager.quiesceOnError(pel->obmcLogID()); |
| 710 | } |
| 711 | } |
| 712 | |
Vijay Lobo | d354a39 | 2021-06-01 16:21:02 -0500 | [diff] [blame] | 713 | std::string Manager::getEventId(const openpower::pels::PEL& pel) const |
| 714 | { |
| 715 | std::string str; |
| 716 | auto src = pel.primarySRC(); |
| 717 | if (src) |
| 718 | { |
| 719 | const auto& hexwords = (*src)->hexwordData(); |
| 720 | |
| 721 | std::string refcode = (*src)->asciiString(); |
| 722 | size_t pos = refcode.find_last_not_of(0x20); |
| 723 | if (pos != std::string::npos) |
| 724 | { |
| 725 | refcode.erase(pos + 1); |
| 726 | } |
| 727 | str = refcode; |
| 728 | |
| 729 | for (auto& value : hexwords) |
| 730 | { |
| 731 | str += " "; |
| 732 | str += getNumberString("%08X", value); |
| 733 | } |
| 734 | } |
Matt Spinler | 0003af1 | 2022-06-08 10:46:17 -0500 | [diff] [blame] | 735 | return sanitizeFieldForDBus(str); |
Vijay Lobo | d354a39 | 2021-06-01 16:21:02 -0500 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | void Manager::updateEventId(std::unique_ptr<openpower::pels::PEL>& pel) |
| 739 | { |
| 740 | std::string eventIdStr = getEventId(*pel); |
| 741 | |
| 742 | auto entryN = _logManager.entries.find(pel->obmcLogID()); |
| 743 | if (entryN != _logManager.entries.end()) |
| 744 | { |
Matt Spinler | b25e8a3 | 2023-06-07 16:05:36 -0500 | [diff] [blame] | 745 | entryN->second->eventId(eventIdStr, true); |
Vijay Lobo | d354a39 | 2021-06-01 16:21:02 -0500 | [diff] [blame] | 746 | } |
| 747 | } |
| 748 | |
Matt Spinler | 0003af1 | 2022-06-08 10:46:17 -0500 | [diff] [blame] | 749 | std::string Manager::sanitizeFieldForDBus(std::string field) |
| 750 | { |
| 751 | std::for_each(field.begin(), field.end(), [](char& ch) { |
| 752 | if (((ch < ' ') || (ch > '~')) && (ch != '\n') && (ch != '\t')) |
| 753 | { |
| 754 | ch = ' '; |
| 755 | } |
| 756 | }); |
| 757 | return field; |
| 758 | } |
| 759 | |
Vijay Lobo | 593a4c6 | 2021-06-16 14:25:26 -0500 | [diff] [blame] | 760 | std::string Manager::getResolution(const openpower::pels::PEL& pel) const |
| 761 | { |
| 762 | std::string str; |
| 763 | std::string resolution; |
| 764 | auto src = pel.primarySRC(); |
| 765 | if (src) |
| 766 | { |
| 767 | // First extract the callout pointer and then go through |
| 768 | const auto& callouts = (*src)->callouts(); |
| 769 | namespace pv = openpower::pels::pel_values; |
| 770 | // All PELs dont have callout, check before parsing callout data |
| 771 | if (callouts) |
| 772 | { |
| 773 | const auto& entries = callouts->callouts(); |
| 774 | // Entry starts with index 1 |
| 775 | uint8_t index = 1; |
| 776 | for (auto& entry : entries) |
| 777 | { |
| 778 | resolution += std::to_string(index) + ". "; |
| 779 | // Adding Location code to resolution |
| 780 | if (!entry->locationCode().empty()) |
Patrick Williams | 2544b41 | 2022-10-04 08:41:06 -0500 | [diff] [blame] | 781 | resolution += "Location Code: " + entry->locationCode() + |
| 782 | ", "; |
Vijay Lobo | 593a4c6 | 2021-06-16 14:25:26 -0500 | [diff] [blame] | 783 | if (entry->fruIdentity()) |
| 784 | { |
| 785 | // Get priority and set the resolution string |
| 786 | str = pv::getValue(entry->priority(), |
| 787 | pel_values::calloutPriorityValues, |
| 788 | pel_values::registryNamePos); |
| 789 | str[0] = toupper(str[0]); |
| 790 | resolution += "Priority: " + str + ", "; |
| 791 | if (entry->fruIdentity()->getPN().has_value()) |
| 792 | { |
| 793 | resolution += |
| 794 | "PN: " + entry->fruIdentity()->getPN().value() + |
| 795 | ", "; |
| 796 | } |
| 797 | if (entry->fruIdentity()->getSN().has_value()) |
| 798 | { |
| 799 | resolution += |
| 800 | "SN: " + entry->fruIdentity()->getSN().value() + |
| 801 | ", "; |
| 802 | } |
| 803 | if (entry->fruIdentity()->getCCIN().has_value()) |
| 804 | { |
| 805 | resolution += |
| 806 | "CCIN: " + entry->fruIdentity()->getCCIN().value() + |
| 807 | ", "; |
| 808 | } |
| 809 | // Add the maintenance procedure |
| 810 | if (entry->fruIdentity()->getMaintProc().has_value()) |
| 811 | { |
| 812 | resolution += |
| 813 | "Procedure: " + |
| 814 | entry->fruIdentity()->getMaintProc().value() + ", "; |
| 815 | } |
| 816 | } |
| 817 | resolution.resize(resolution.size() - 2); |
| 818 | resolution += "\n"; |
| 819 | index++; |
| 820 | } |
| 821 | } |
| 822 | } |
Matt Spinler | 0003af1 | 2022-06-08 10:46:17 -0500 | [diff] [blame] | 823 | return sanitizeFieldForDBus(resolution); |
Vijay Lobo | 593a4c6 | 2021-06-16 14:25:26 -0500 | [diff] [blame] | 824 | } |
| 825 | |
Matt Spinler | 28d6ae2 | 2022-03-18 11:18:27 -0500 | [diff] [blame] | 826 | bool Manager::updateResolution(const openpower::pels::PEL& pel) |
Vijay Lobo | 593a4c6 | 2021-06-16 14:25:26 -0500 | [diff] [blame] | 827 | { |
Matt Spinler | 28d6ae2 | 2022-03-18 11:18:27 -0500 | [diff] [blame] | 828 | std::string callouts = getResolution(pel); |
| 829 | auto entryN = _logManager.entries.find(pel.obmcLogID()); |
Vijay Lobo | 593a4c6 | 2021-06-16 14:25:26 -0500 | [diff] [blame] | 830 | if (entryN != _logManager.entries.end()) |
| 831 | { |
Matt Spinler | 734ed2b | 2022-01-21 09:31:46 -0600 | [diff] [blame] | 832 | entryN->second->resolution(callouts, true); |
Vijay Lobo | 593a4c6 | 2021-06-16 14:25:26 -0500 | [diff] [blame] | 833 | } |
Matt Spinler | 28d6ae2 | 2022-03-18 11:18:27 -0500 | [diff] [blame] | 834 | |
| 835 | return false; |
Vijay Lobo | 593a4c6 | 2021-06-16 14:25:26 -0500 | [diff] [blame] | 836 | } |
| 837 | |
Matt Spinler | 3387eac | 2023-07-06 14:56:02 -0500 | [diff] [blame] | 838 | void Manager::serializeLogEntry(uint32_t obmcLogID) |
| 839 | { |
| 840 | auto entryN = _logManager.entries.find(obmcLogID); |
| 841 | if (entryN != _logManager.entries.end()) |
| 842 | { |
| 843 | serialize(*entryN->second); |
| 844 | } |
| 845 | } |
| 846 | |
Matt Spinler | 8b81ec0 | 2022-07-12 13:25:37 -0500 | [diff] [blame] | 847 | void Manager::updateDBusSeverity(const openpower::pels::PEL& pel) |
| 848 | { |
| 849 | // The final severity of the PEL may not agree with the |
| 850 | // original severity of the D-Bus event log. Update the |
| 851 | // D-Bus property to match in some cases. This is to |
| 852 | // ensure there isn't a Critical or Warning Redfish event |
| 853 | // log for an informational or recovered PEL (or vice versa). |
| 854 | // This doesn't make an explicit call to serialize the new |
| 855 | // event log property value because updateEventId() is called |
| 856 | // right after this and will do it. |
| 857 | auto sevType = |
| 858 | static_cast<SeverityType>(pel.userHeader().severity() & 0xF0); |
| 859 | |
| 860 | auto entryN = _logManager.entries.find(pel.obmcLogID()); |
| 861 | if (entryN != _logManager.entries.end()) |
| 862 | { |
Patrick Williams | 2544b41 | 2022-10-04 08:41:06 -0500 | [diff] [blame] | 863 | auto newSeverity = fixupLogSeverity(entryN->second->severity(), |
| 864 | sevType); |
Matt Spinler | 8b81ec0 | 2022-07-12 13:25:37 -0500 | [diff] [blame] | 865 | if (newSeverity) |
| 866 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 867 | lg2::info("Changing event log {ID} severity from {OLD} " |
| 868 | "to {NEW} to match PEL", |
| 869 | "ID", lg2::hex, entryN->second->id(), "OLD", |
| 870 | Entry::convertLevelToString(entryN->second->severity()), |
| 871 | "NEW", Entry::convertLevelToString(*newSeverity)); |
Matt Spinler | 8b81ec0 | 2022-07-12 13:25:37 -0500 | [diff] [blame] | 872 | |
| 873 | entryN->second->severity(*newSeverity, true); |
| 874 | } |
| 875 | } |
| 876 | } |
| 877 | |
Adriana Kobylak | e7d271a | 2020-12-07 14:32:44 -0600 | [diff] [blame] | 878 | void Manager::setEntryPath(uint32_t obmcLogID) |
| 879 | { |
| 880 | Repository::LogID id{Repository::LogID::Obmc(obmcLogID)}; |
| 881 | if (auto attributes = _repo.getPELAttributes(id); attributes) |
| 882 | { |
| 883 | auto& attr = attributes.value().get(); |
| 884 | auto entry = _logManager.entries.find(obmcLogID); |
| 885 | if (entry != _logManager.entries.end()) |
| 886 | { |
Matt Spinler | 734ed2b | 2022-01-21 09:31:46 -0600 | [diff] [blame] | 887 | entry->second->path(attr.path, true); |
Adriana Kobylak | e7d271a | 2020-12-07 14:32:44 -0600 | [diff] [blame] | 888 | } |
| 889 | } |
| 890 | } |
| 891 | |
Vijay Lobo | cbc93a4 | 2021-05-20 19:04:07 -0500 | [diff] [blame] | 892 | void Manager::setServiceProviderNotifyFlag(uint32_t obmcLogID) |
| 893 | { |
| 894 | Repository::LogID id{Repository::LogID::Obmc(obmcLogID)}; |
| 895 | if (auto attributes = _repo.getPELAttributes(id); attributes) |
| 896 | { |
| 897 | auto& attr = attributes.value().get(); |
| 898 | auto entry = _logManager.entries.find(obmcLogID); |
| 899 | if (entry != _logManager.entries.end()) |
| 900 | { |
Lakshmi Yadlapati | 7a3ede5 | 2022-11-18 13:26:17 -0600 | [diff] [blame] | 901 | if (attr.actionFlags.test(callHomeFlagBit)) |
| 902 | { |
Matt Spinler | b25e8a3 | 2023-06-07 16:05:36 -0500 | [diff] [blame] | 903 | entry->second->serviceProviderNotify(Entry::Notify::Notify, |
| 904 | true); |
Lakshmi Yadlapati | 7a3ede5 | 2022-11-18 13:26:17 -0600 | [diff] [blame] | 905 | } |
| 906 | else |
| 907 | { |
Matt Spinler | b25e8a3 | 2023-06-07 16:05:36 -0500 | [diff] [blame] | 908 | entry->second->serviceProviderNotify(Entry::Notify::Inhibit, |
| 909 | true); |
Lakshmi Yadlapati | 7a3ede5 | 2022-11-18 13:26:17 -0600 | [diff] [blame] | 910 | } |
Vijay Lobo | cbc93a4 | 2021-05-20 19:04:07 -0500 | [diff] [blame] | 911 | } |
| 912 | } |
| 913 | } |
| 914 | |
Matt Spinler | 734ed2b | 2022-01-21 09:31:46 -0600 | [diff] [blame] | 915 | void Manager::createPELEntry(uint32_t obmcLogID, bool skipIaSignal) |
Vijay Lobo | afb1b46 | 2021-07-21 23:29:13 -0500 | [diff] [blame] | 916 | { |
| 917 | std::map<std::string, PropertiesVariant> varData; |
| 918 | Repository::LogID id{Repository::LogID::Obmc(obmcLogID)}; |
| 919 | if (auto attributes = _repo.getPELAttributes(id); attributes) |
| 920 | { |
| 921 | namespace pv = openpower::pels::pel_values; |
| 922 | auto& attr = attributes.value().get(); |
Vijay Lobo | b2e541e | 2021-08-31 23:12:47 -0500 | [diff] [blame] | 923 | |
| 924 | // get the hidden flag values |
| 925 | auto sevType = static_cast<SeverityType>(attr.severity & 0xF0); |
| 926 | auto isHidden = true; |
| 927 | if (((sevType != SeverityType::nonError) && |
| 928 | attr.actionFlags.test(reportFlagBit) && |
| 929 | !attr.actionFlags.test(hiddenFlagBit)) || |
| 930 | ((sevType == SeverityType::nonError) && |
| 931 | attr.actionFlags.test(serviceActionFlagBit))) |
| 932 | { |
| 933 | isHidden = false; |
| 934 | } |
| 935 | varData.emplace(std::string("Hidden"), isHidden); |
Vijay Lobo | afb1b46 | 2021-07-21 23:29:13 -0500 | [diff] [blame] | 936 | varData.emplace( |
| 937 | std::string("Subsystem"), |
| 938 | pv::getValue(attr.subsystem, pel_values::subsystemValues)); |
Vijay Lobo | 2fb1021 | 2021-08-22 23:24:16 -0500 | [diff] [blame] | 939 | |
| 940 | varData.emplace( |
| 941 | std::string("ManagementSystemAck"), |
| 942 | (attr.hmcState == TransmissionState::acked ? true : false)); |
| 943 | |
Matt Spinler | 8e65f4e | 2023-05-02 13:40:08 -0500 | [diff] [blame] | 944 | varData.emplace("PlatformLogID", attr.plid); |
| 945 | varData.emplace("Deconfig", attr.deconfig); |
| 946 | varData.emplace("Guard", attr.guard); |
| 947 | varData.emplace("Timestamp", attr.creationTime); |
| 948 | |
Vijay Lobo | afb1b46 | 2021-07-21 23:29:13 -0500 | [diff] [blame] | 949 | // Path to create PELEntry Interface is same as PEL |
| 950 | auto path = std::string(OBJ_ENTRY) + '/' + std::to_string(obmcLogID); |
| 951 | // Create Interface for PELEntry and set properties |
Vijay Lobo | 2fb1021 | 2021-08-22 23:24:16 -0500 | [diff] [blame] | 952 | auto pelEntry = std::make_unique<PELEntry>(_logManager.getBus(), path, |
| 953 | varData, obmcLogID, &_repo); |
Matt Spinler | 734ed2b | 2022-01-21 09:31:46 -0600 | [diff] [blame] | 954 | if (!skipIaSignal) |
| 955 | { |
| 956 | pelEntry->emit_added(); |
| 957 | } |
Vijay Lobo | afb1b46 | 2021-07-21 23:29:13 -0500 | [diff] [blame] | 958 | _pelEntries.emplace(std::move(path), std::move(pelEntry)); |
| 959 | } |
| 960 | } |
| 961 | |
Ramesh Iyyar | f4203c4 | 2021-06-24 06:09:23 -0500 | [diff] [blame] | 962 | uint32_t Manager::getPELIdFromBMCLogId(uint32_t bmcLogId) |
| 963 | { |
| 964 | Repository::LogID id{Repository::LogID::Obmc(bmcLogId)}; |
| 965 | if (auto logId = _repo.getLogID(id); !logId.has_value()) |
| 966 | { |
| 967 | throw common_error::InvalidArgument(); |
| 968 | } |
| 969 | else |
| 970 | { |
| 971 | return logId->pelID.id; |
| 972 | } |
| 973 | } |
| 974 | |
Ramesh Iyyar | 530efbf | 2021-06-24 06:22:22 -0500 | [diff] [blame] | 975 | uint32_t Manager::getBMCLogIdFromPELId(uint32_t pelId) |
| 976 | { |
| 977 | Repository::LogID id{Repository::LogID::Pel(pelId)}; |
| 978 | if (auto logId = _repo.getLogID(id); !logId.has_value()) |
| 979 | { |
| 980 | throw common_error::InvalidArgument(); |
| 981 | } |
| 982 | else |
| 983 | { |
| 984 | return logId->obmcID.id; |
| 985 | } |
| 986 | } |
| 987 | |
Sumit Kumar | 3e27443 | 2021-09-14 06:37:56 -0500 | [diff] [blame] | 988 | void Manager::updateProgressSRC( |
| 989 | std::unique_ptr<openpower::pels::PEL>& pel) const |
| 990 | { |
| 991 | // Check for pel severity of type - 0x51 = critical error, system |
| 992 | // termination |
| 993 | if (pel->userHeader().severity() == 0x51) |
| 994 | { |
| 995 | auto src = pel->primarySRC(); |
| 996 | if (src) |
| 997 | { |
| 998 | std::vector<uint8_t> asciiSRC = (*src)->getSrcStruct(); |
| 999 | uint64_t srcRefCode = 0; |
| 1000 | |
| 1001 | // Read bytes from offset [40-47] e.g. BD8D1001 |
| 1002 | for (int i = 0; i < 8; i++) |
| 1003 | { |
Patrick Williams | 2544b41 | 2022-10-04 08:41:06 -0500 | [diff] [blame] | 1004 | srcRefCode |= (static_cast<uint64_t>(asciiSRC[40 + i]) |
| 1005 | << (8 * i)); |
Sumit Kumar | 3e27443 | 2021-09-14 06:37:56 -0500 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | try |
| 1009 | { |
| 1010 | _dataIface->createProgressSRC(srcRefCode, asciiSRC); |
| 1011 | } |
Matt Spinler | 87f3924 | 2023-05-01 11:36:18 -0500 | [diff] [blame] | 1012 | catch (const std::exception&) |
Sumit Kumar | 3e27443 | 2021-09-14 06:37:56 -0500 | [diff] [blame] | 1013 | { |
| 1014 | // Exception - may be no boot progress interface on dbus |
| 1015 | } |
| 1016 | } |
| 1017 | } |
| 1018 | } |
| 1019 | |
Matt Spinler | d8fb5ba | 2022-01-25 13:01:14 -0600 | [diff] [blame] | 1020 | void Manager::scheduleObmcLogDelete(uint32_t obmcLogID) |
| 1021 | { |
| 1022 | _obmcLogDeleteEventSource = std::make_unique<sdeventplus::source::Defer>( |
| 1023 | _event, std::bind(std::mem_fn(&Manager::deleteObmcLog), this, |
| 1024 | std::placeholders::_1, obmcLogID)); |
| 1025 | } |
| 1026 | |
| 1027 | void Manager::deleteObmcLog(sdeventplus::source::EventBase&, uint32_t obmcLogID) |
| 1028 | { |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 1029 | lg2::info("Removing event log with no PEL: {BMCID}", "BMCID", obmcLogID); |
Matt Spinler | d8fb5ba | 2022-01-25 13:01:14 -0600 | [diff] [blame] | 1030 | _logManager.erase(obmcLogID); |
| 1031 | _obmcLogDeleteEventSource.reset(); |
| 1032 | } |
| 1033 | |
Matt Spinler | 0dd22c8 | 2023-05-04 15:28:12 -0500 | [diff] [blame] | 1034 | bool Manager::clearPowerThermalDeconfigFlag(const std::string& locationCode, |
| 1035 | openpower::pels::PEL& pel) |
| 1036 | { |
| 1037 | // The requirements state that only power-thermal or |
| 1038 | // fan PELs need their deconfig flag cleared. |
| 1039 | static const std::vector<uint32_t> compIDs{bmcThermalCompID, bmcFansCompID}; |
| 1040 | |
| 1041 | if (std::find(compIDs.begin(), compIDs.end(), |
| 1042 | pel.privateHeader().header().componentID) == compIDs.end()) |
| 1043 | { |
| 1044 | return false; |
| 1045 | } |
| 1046 | |
| 1047 | auto src = pel.primarySRC(); |
| 1048 | const auto& callouts = (*src)->callouts(); |
| 1049 | if (!callouts) |
| 1050 | { |
| 1051 | return false; |
| 1052 | } |
| 1053 | |
| 1054 | for (const auto& callout : callouts->callouts()) |
| 1055 | { |
| 1056 | // Look for the passed in location code in a callout that |
| 1057 | // is either a normal HW callout or a symbolic FRU with |
| 1058 | // a trusted location code callout. |
| 1059 | if ((callout->locationCode() != locationCode) || |
| 1060 | !callout->fruIdentity()) |
| 1061 | { |
| 1062 | continue; |
| 1063 | } |
| 1064 | |
| 1065 | if ((callout->fruIdentity()->failingComponentType() != |
| 1066 | src::FRUIdentity::hardwareFRU) && |
| 1067 | (callout->fruIdentity()->failingComponentType() != |
| 1068 | src::FRUIdentity::symbolicFRUTrustedLocCode)) |
| 1069 | { |
| 1070 | continue; |
| 1071 | } |
| 1072 | |
Matt Spinler | fbdfc76 | 2023-06-30 15:15:44 -0500 | [diff] [blame] | 1073 | lg2::info( |
| 1074 | "Clearing deconfig flag in PEL {ID} with SRC {SRC} because {LOC} was replaced", |
| 1075 | "ID", lg2::hex, pel.id(), "SRC", (*src)->asciiString().substr(0, 8), |
| 1076 | "LOC", locationCode); |
Matt Spinler | 0dd22c8 | 2023-05-04 15:28:12 -0500 | [diff] [blame] | 1077 | (*src)->clearErrorStatusFlag(SRC::ErrorStatusFlags::deconfigured); |
| 1078 | return true; |
| 1079 | } |
| 1080 | return false; |
| 1081 | } |
| 1082 | |
| 1083 | void Manager::hardwarePresent(const std::string& locationCode) |
| 1084 | { |
| 1085 | Repository::PELUpdateFunc handlePowerThermalHardwarePresent = |
| 1086 | [locationCode](openpower::pels::PEL& pel) { |
| 1087 | return Manager::clearPowerThermalDeconfigFlag(locationCode, pel); |
| 1088 | }; |
| 1089 | |
| 1090 | // If the PEL was created by the BMC and has the deconfig flag set, |
| 1091 | // it's a candidate to have the deconfig flag cleared. |
| 1092 | for (const auto& [id, attributes] : _repo.getAttributesMap()) |
| 1093 | { |
| 1094 | if ((attributes.creator == static_cast<uint8_t>(CreatorID::openBMC)) && |
| 1095 | attributes.deconfig) |
| 1096 | { |
| 1097 | _repo.updatePEL(attributes.path, handlePowerThermalHardwarePresent); |
| 1098 | } |
| 1099 | } |
| 1100 | } |
| 1101 | |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 1102 | } // namespace pels |
| 1103 | } // namespace openpower |