14e8078c0SMatt Spinler #pragma once 24e8078c0SMatt Spinler 3a34ab72cSMatt Spinler #include "config.h" 4a34ab72cSMatt Spinler 5c8705e2bSMatt Spinler #include "data_interface.hpp" 6f682b40dSMatt Spinler #include "event_logger.hpp" 7f60ac27eSMatt Spinler #include "host_notifier.hpp" 8d96fa60dSMatt Spinler #include "journal.hpp" 94e8078c0SMatt Spinler #include "log_manager.hpp" 1089fa082aSMatt Spinler #include "paths.hpp" 1156ad2a0eSMatt Spinler #include "pel.hpp" 12367144cfSMatt Spinler #include "registry.hpp" 1389fa082aSMatt Spinler #include "repository.hpp" 144e8078c0SMatt Spinler 15afb1b46fSVijay Lobo #include <org/open_power/Logging/PEL/Entry/server.hpp> 16a34ab72cSMatt Spinler #include <org/open_power/Logging/PEL/server.hpp> 17a34ab72cSMatt Spinler #include <sdbusplus/server.hpp> 186b1a5c83SMatt Spinler #include <sdeventplus/event.hpp> 196b1a5c83SMatt Spinler #include <sdeventplus/source/event.hpp> 2044893cc9SMatt Spinler #include <xyz/openbmc_project/Logging/Create/server.hpp> 21a34ab72cSMatt Spinler 224e8078c0SMatt Spinler namespace openpower 234e8078c0SMatt Spinler { 244e8078c0SMatt Spinler namespace pels 254e8078c0SMatt Spinler { 264e8078c0SMatt Spinler 2745e83521SPatrick Williams using PELInterface = sdbusplus::server::object_t< 28a34ab72cSMatt Spinler sdbusplus::org::open_power::Logging::server::PEL>; 29a34ab72cSMatt Spinler 304e8078c0SMatt Spinler /** 314e8078c0SMatt Spinler * @brief PEL manager object 324e8078c0SMatt Spinler */ 33a34ab72cSMatt Spinler class Manager : public PELInterface 344e8078c0SMatt Spinler { 354e8078c0SMatt Spinler public: 364e8078c0SMatt Spinler Manager() = delete; 374e8078c0SMatt Spinler Manager(const Manager&) = default; 384e8078c0SMatt Spinler Manager& operator=(const Manager&) = default; 394e8078c0SMatt Spinler Manager(Manager&&) = default; 404e8078c0SMatt Spinler Manager& operator=(Manager&&) = default; 414e8078c0SMatt Spinler 424e8078c0SMatt Spinler /** 434e8078c0SMatt Spinler * @brief constructor 444e8078c0SMatt Spinler * 454e8078c0SMatt Spinler * @param[in] logManager - internal::Manager object 46f60ac27eSMatt Spinler * @param[in] dataIface - The data interface object 47f682b40dSMatt Spinler * @param[in] creatorFunc - The function that EventLogger will 48f682b40dSMatt Spinler * use for creating event logs 494e8078c0SMatt Spinler */ 50f60ac27eSMatt Spinler Manager(phosphor::logging::internal::Manager& logManager, 51f682b40dSMatt Spinler std::unique_ptr<DataInterfaceBase> dataIface, 52d96fa60dSMatt Spinler EventLogger::LogFunction creatorFunc, 53d96fa60dSMatt Spinler std::unique_ptr<JournalBase> journal) : 54a34ab72cSMatt Spinler PELInterface(logManager.getBus(), OBJ_LOGGING), 55104e9360SMatt Spinler _logManager(logManager), _eventLogger(std::move(creatorFunc)), 56f682b40dSMatt Spinler _repo(getPELRepoPath()), 570d804ef5SMatt Spinler _registry(getPELReadOnlyDataPath() / message::registryFileName), 58ff9cec25SMatt Spinler _event(sdeventplus::Event::get_default()), 59d96fa60dSMatt Spinler _dataIface(std::move(dataIface)), _journal(std::move(journal)) 604e8078c0SMatt Spinler { 61e7d271aeSAdriana Kobylak for (const auto& entry : _logManager.entries) 62e7d271aeSAdriana Kobylak { 63e7d271aeSAdriana Kobylak setEntryPath(entry.first); 64cbc93a49SVijay Lobo setServiceProviderNotifyFlag(entry.first); 65afb1b46fSVijay Lobo // Create PELEntry interface and setup properties with their values 66734ed2b5SMatt Spinler createPELEntry(entry.first, true); 67e7d271aeSAdriana Kobylak } 6828d6ae2fSMatt Spinler 69ff9cec25SMatt Spinler setupPELDeleteWatch(); 700dd22c83SMatt Spinler 710dd22c83SMatt Spinler _dataIface->subscribeToFruPresent( 720dd22c83SMatt Spinler "Manager", 730dd22c83SMatt Spinler std::bind(&Manager::hardwarePresent, this, std::placeholders::_1)); 744e8078c0SMatt Spinler } 754e8078c0SMatt Spinler 764e8078c0SMatt Spinler /** 77f60ac27eSMatt Spinler * @brief constructor that enables host notification 78f60ac27eSMatt Spinler * 79f60ac27eSMatt Spinler * @param[in] logManager - internal::Manager object 80f60ac27eSMatt Spinler * @param[in] dataIface - The data interface object 81f682b40dSMatt Spinler * @param[in] creatorFunc - The function that EventLogger will 82f682b40dSMatt Spinler * use for creating event logs 83f60ac27eSMatt Spinler * @param[in] hostIface - The hostInterface object 84f60ac27eSMatt Spinler */ 85f60ac27eSMatt Spinler Manager(phosphor::logging::internal::Manager& logManager, 86f60ac27eSMatt Spinler std::unique_ptr<DataInterfaceBase> dataIface, 87f682b40dSMatt Spinler EventLogger::LogFunction creatorFunc, 88d96fa60dSMatt Spinler std::unique_ptr<JournalBase> journal, 89f60ac27eSMatt Spinler std::unique_ptr<HostInterface> hostIface) : 90d96fa60dSMatt Spinler Manager(logManager, std::move(dataIface), std::move(creatorFunc), 91d96fa60dSMatt Spinler std::move(journal)) 92f60ac27eSMatt Spinler { 93f60ac27eSMatt Spinler _hostNotifier = std::make_unique<HostNotifier>( 94f60ac27eSMatt Spinler _repo, *(_dataIface.get()), std::move(hostIface)); 95f60ac27eSMatt Spinler } 96f60ac27eSMatt Spinler 97f60ac27eSMatt Spinler /** 98ff9cec25SMatt Spinler * @brief Destructor 99ff9cec25SMatt Spinler */ 100ff9cec25SMatt Spinler ~Manager(); 101ff9cec25SMatt Spinler 102ff9cec25SMatt Spinler /** 1034e8078c0SMatt Spinler * @brief Creates a PEL based on the OpenBMC event log contents. If 1044e8078c0SMatt Spinler * a PEL was passed in via the RAWPEL specifier in the 1054e8078c0SMatt Spinler * additionalData parameter, use that instead. 1064e8078c0SMatt Spinler * 1074e8078c0SMatt Spinler * @param[in] message - the event log message property 1084e8078c0SMatt Spinler * @param[in] obmcLogID - the corresponding OpenBMC event log id 1094e8078c0SMatt Spinler * @param[in] timestamp - the Timestamp property 1104e8078c0SMatt Spinler * @param[in] severity - the event log severity 1114e8078c0SMatt Spinler * @param[in] additionalData - the AdditionalData property 1124e8078c0SMatt Spinler * @param[in] associations - the Associations property 11356ad2a0eSMatt Spinler * @param[in] ffdc - A vector of FFDC file information 1144e8078c0SMatt Spinler */ 1154e8078c0SMatt Spinler void create(const std::string& message, uint32_t obmcLogID, 116367144cfSMatt Spinler uint64_t timestamp, phosphor::logging::Entry::Level severity, 1174e8078c0SMatt Spinler const std::vector<std::string>& additionalData, 11856ad2a0eSMatt Spinler const std::vector<std::string>& associations, 11956ad2a0eSMatt Spinler const phosphor::logging::FFDCEntries& ffdc = 12056ad2a0eSMatt Spinler phosphor::logging::FFDCEntries{}); 1214e8078c0SMatt Spinler 1224e8078c0SMatt Spinler /** 1234e8078c0SMatt Spinler * @brief Erase a PEL based on its OpenBMC event log ID 1244e8078c0SMatt Spinler * 1254e8078c0SMatt Spinler * @param[in] obmcLogID - the corresponding OpenBMC event log id 1264e8078c0SMatt Spinler */ 1274e8078c0SMatt Spinler void erase(uint32_t obmcLogID); 1284e8078c0SMatt Spinler 1294e8078c0SMatt Spinler /** @brief Says if an OpenBMC event log may not be manually deleted at this 1304e8078c0SMatt Spinler * time because its corresponding PEL cannot be. 1314e8078c0SMatt Spinler * 1324e8078c0SMatt Spinler * There are PEL retention policies that can prohibit the manual deletion 1334e8078c0SMatt Spinler * of PELs (and therefore OpenBMC event logs). 1344e8078c0SMatt Spinler * 1354e8078c0SMatt Spinler * @param[in] obmcLogID - the OpenBMC event log ID 1364e8078c0SMatt Spinler * @return bool - true if prohibited 1374e8078c0SMatt Spinler */ 1384e8078c0SMatt Spinler bool isDeleteProhibited(uint32_t obmcLogID); 1394e8078c0SMatt Spinler 140a34ab72cSMatt Spinler /** 141a34ab72cSMatt Spinler * @brief Return a file descriptor to the raw PEL data 142a34ab72cSMatt Spinler * 143a34ab72cSMatt Spinler * Throws InvalidArgument if the PEL ID isn't found, 144a34ab72cSMatt Spinler * and InternalFailure if anything else fails. 145a34ab72cSMatt Spinler * 146a34ab72cSMatt Spinler * @param[in] pelID - The PEL ID to get the data for 147a34ab72cSMatt Spinler * 148a34ab72cSMatt Spinler * @return unix_fd - File descriptor to the file that contains the PEL 149a34ab72cSMatt Spinler */ 150a34ab72cSMatt Spinler sdbusplus::message::unix_fd getPEL(uint32_t pelID) override; 151a34ab72cSMatt Spinler 152a34ab72cSMatt Spinler /** 153a34ab72cSMatt Spinler * @brief Returns data for the PEL corresponding to an OpenBMC 154a34ab72cSMatt Spinler * event log. 155a34ab72cSMatt Spinler * 156a34ab72cSMatt Spinler * @param[in] obmcLogID - The OpenBMC event log ID 157a34ab72cSMatt Spinler * 158a34ab72cSMatt Spinler * @return vector<uint8_t> - The raw PEL data 159a34ab72cSMatt Spinler */ 160a34ab72cSMatt Spinler std::vector<uint8_t> getPELFromOBMCID(uint32_t obmcLogID) override; 161a34ab72cSMatt Spinler 162a34ab72cSMatt Spinler /** 163a34ab72cSMatt Spinler * @brief The D-Bus method called when a host successfully processes 164a34ab72cSMatt Spinler * a PEL. 165a34ab72cSMatt Spinler * 166a34ab72cSMatt Spinler * This D-Bus method is called from the PLDM daemon when they get an 167a34ab72cSMatt Spinler * 'Ack PEL' PLDM message from the host, which indicates the host 168a34ab72cSMatt Spinler * firmware successfully sent it to the OS and this code doesn't need 169a34ab72cSMatt Spinler * to send it to the host again. 170a34ab72cSMatt Spinler * 171a34ab72cSMatt Spinler * @param[in] pelID - The PEL ID 172a34ab72cSMatt Spinler */ 173a34ab72cSMatt Spinler void hostAck(uint32_t pelID) override; 174a34ab72cSMatt Spinler 175a34ab72cSMatt Spinler /** 176a34ab72cSMatt Spinler * @brief D-Bus method called when the host rejects a PEL. 177a34ab72cSMatt Spinler * 178a34ab72cSMatt Spinler * This D-Bus method is called from the PLDM daemon when they get an 179a34ab72cSMatt Spinler * 'Ack PEL' PLDM message from the host with a payload that says 180a34ab72cSMatt Spinler * something when wrong. 181a34ab72cSMatt Spinler * 182a34ab72cSMatt Spinler * The choices are either: 183a34ab72cSMatt Spinler * * Host Full - The host's staging area is full - try again later 184a34ab72cSMatt Spinler * * Malrformed PEL - The host received an invalid PEL 185a34ab72cSMatt Spinler * 186a34ab72cSMatt Spinler * @param[in] pelID - The PEL ID 187a34ab72cSMatt Spinler * @param[in] reason - One of the above two reasons 188a34ab72cSMatt Spinler */ 189a34ab72cSMatt Spinler void hostReject(uint32_t pelID, RejectionReason reason) override; 190a34ab72cSMatt Spinler 19144893cc9SMatt Spinler /** 19244893cc9SMatt Spinler * @brief D-Bus method to create a PEL/OpenBMC event log and 19344893cc9SMatt Spinler * return the created OpenBMC and PEL log IDs. 19444893cc9SMatt Spinler * 19544893cc9SMatt Spinler * The same as the CreateWithFFDCFiles method on the 19644893cc9SMatt Spinler * xyz.openbmc_project.Logging.Create interface, except for 19744893cc9SMatt Spinler * the return values. 19844893cc9SMatt Spinler * 19944893cc9SMatt Spinler * @param[in] message - The event log message property 20044893cc9SMatt Spinler * @param[in] severity - The event log severity 20144893cc9SMatt Spinler * @param[in] additionalData - The AdditionalData property 20244893cc9SMatt Spinler * @param[in] ffdc - A vector of FFDC file information 20344893cc9SMatt Spinler */ 2049cc30076SMatt Spinler std::tuple<uint32_t, uint32_t> createPELWithFFDCFiles( 2059cc30076SMatt Spinler std::string message, phosphor::logging::Entry::Level severity, 2069cc30076SMatt Spinler std::map<std::string, std::string> additionalData, 2079cc30076SMatt Spinler std::vector<std::tuple<sdbusplus::xyz::openbmc_project::Logging:: 2089cc30076SMatt Spinler server::Create::FFDCFormat, 2099cc30076SMatt Spinler uint8_t, uint8_t, sdbusplus::message::unix_fd>> 21044893cc9SMatt Spinler fFDC) override; 2119cc30076SMatt Spinler 21219e72901SMatt Spinler /** 213aa85a072SMatt Spinler * @brief D-Bus method to return the PEL in JSON format 214aa85a072SMatt Spinler * 215aa85a072SMatt Spinler * @param[in] obmcLogID - The OpenBMC entry log ID 216aa85a072SMatt Spinler * 217aa85a072SMatt Spinler * @return std::string - The fully parsed PEL in JSON 218aa85a072SMatt Spinler */ 2198bd4ca4eSMatt Spinler std::string getPELJSON(uint32_t obmcLogID) override; 220aa85a072SMatt Spinler 221aa85a072SMatt Spinler /** 22219e72901SMatt Spinler * @brief Converts the ESEL field in an OpenBMC event log to a 22319e72901SMatt Spinler * vector of uint8_ts that just contains the PEL data. 22419e72901SMatt Spinler * 22519e72901SMatt Spinler * That data string looks like: "50 48 00 ab ..." 22619e72901SMatt Spinler * 22719e72901SMatt Spinler * Throws an exception on any failures. 22819e72901SMatt Spinler * 22919e72901SMatt Spinler * @param[in] esel - The ESEL string 23019e72901SMatt Spinler * 23119e72901SMatt Spinler * @return std::vector<uint8_t> - The contained PEL data 23219e72901SMatt Spinler */ 23319e72901SMatt Spinler static std::vector<uint8_t> eselToRawData(const std::string& esel); 23419e72901SMatt Spinler 235d354a398SVijay Lobo /** 236593a4c66SVijay Lobo * @brief Generate resolution string from the PEL 237593a4c66SVijay Lobo * 238593a4c66SVijay Lobo * @param[in] pel - The PEL to use 239593a4c66SVijay Lobo */ 240593a4c66SVijay Lobo std::string getResolution(const openpower::pels::PEL& pel) const; 241593a4c66SVijay Lobo 242593a4c66SVijay Lobo /** 243d354a398SVijay Lobo * @brief Generate event ID from the PEL 244d354a398SVijay Lobo * 245d354a398SVijay Lobo * @param[in] pel - The PEL to use 246d354a398SVijay Lobo */ 247d354a398SVijay Lobo std::string getEventId(const openpower::pels::PEL& pel) const; 248d354a398SVijay Lobo 249f4203c47SRamesh Iyyar /** @brief Implementation for GetPELIdFromBMCLogId 250f4203c47SRamesh Iyyar * 251f4203c47SRamesh Iyyar * Returns the PEL Id (aka Entry ID (EID)) based on the given 252f4203c47SRamesh Iyyar * BMC event log id. 253f4203c47SRamesh Iyyar * 254f4203c47SRamesh Iyyar * @param[in] bmcLogId - The BMC event log id of the PEL to retrieve 255f4203c47SRamesh Iyyar * the PEL id. 256f4203c47SRamesh Iyyar * 257f4203c47SRamesh Iyyar * @return uint32_t - The Id of the PEL. 258f4203c47SRamesh Iyyar * Throw "InvalidArgument" if not found. 259f4203c47SRamesh Iyyar */ 260f4203c47SRamesh Iyyar uint32_t getPELIdFromBMCLogId(uint32_t bmcLogId) override; 261f4203c47SRamesh Iyyar 262530efbfcSRamesh Iyyar /** @brief Implementation for GetBMCLogIdFromPELId 263530efbfcSRamesh Iyyar * 264530efbfcSRamesh Iyyar * Returns the BMC event log id based on the given PEL id 265530efbfcSRamesh Iyyar * (aka Entry ID (EID)). 266530efbfcSRamesh Iyyar * 267530efbfcSRamesh Iyyar * @param[in] pelId - The PEL id to retrieve the BMC event log id. 268530efbfcSRamesh Iyyar * 269530efbfcSRamesh Iyyar * @return uint32_t - The BMC event log id of the PEL. 270530efbfcSRamesh Iyyar * Throw "InvalidArgument" if not found. 271530efbfcSRamesh Iyyar */ 272530efbfcSRamesh Iyyar uint32_t getBMCLogIdFromPELId(uint32_t pelId) override; 273530efbfcSRamesh Iyyar 2743e274432SSumit Kumar /** 2753e274432SSumit Kumar * @brief Update boot progress SRC based on severity 0x51, critical error 2763e274432SSumit Kumar * 2773e274432SSumit Kumar * @param[in] pel - The PEL to use 2783e274432SSumit Kumar */ 2793e274432SSumit Kumar void updateProgressSRC(std::unique_ptr<openpower::pels::PEL>& pel) const; 2803e274432SSumit Kumar 2810003af14SMatt Spinler /** 2820003af14SMatt Spinler * @brief Converts unprintable characters from the passed 2830003af14SMatt Spinler * in string to spaces so they won't crash D-Bus when 2840003af14SMatt Spinler * used as a property value. 2850003af14SMatt Spinler * 2860003af14SMatt Spinler * @param[in] field - The field to fix 2870003af14SMatt Spinler * 2880003af14SMatt Spinler * @return std::string - The string without non printable characters. 2890003af14SMatt Spinler */ 2900003af14SMatt Spinler static std::string sanitizeFieldForDBus(std::string field); 2910003af14SMatt Spinler 2924e8078c0SMatt Spinler private: 2934e8078c0SMatt Spinler /** 2944e8078c0SMatt Spinler * @brief Adds a received raw PEL to the PEL repository 2954e8078c0SMatt Spinler * 2964e8078c0SMatt Spinler * @param[in] rawPelPath - The path to the file that contains the 2974e8078c0SMatt Spinler * raw PEL. 2984e8078c0SMatt Spinler * @param[in] obmcLogID - the corresponding OpenBMC event log id 2994e8078c0SMatt Spinler */ 3004e8078c0SMatt Spinler void addRawPEL(const std::string& rawPelPath, uint32_t obmcLogID); 3014e8078c0SMatt Spinler 3024e8078c0SMatt Spinler /** 3034e8078c0SMatt Spinler * @brief Creates a PEL based on the OpenBMC event log contents. 3044e8078c0SMatt Spinler * 3054e8078c0SMatt Spinler * @param[in] message - The event log message property 3064e8078c0SMatt Spinler * @param[in] obmcLogID - the corresponding OpenBMC event log id 3074e8078c0SMatt Spinler * @param[in] timestamp - The timestamp property 3084e8078c0SMatt Spinler * @param[in] severity - The event log severity 3094e8078c0SMatt Spinler * @param[in] additionalData - The AdditionalData property 3104e8078c0SMatt Spinler * @param[in] associations - The associations property 31156ad2a0eSMatt Spinler * @param[in] ffdc - A vector of FFDC file information 3124e8078c0SMatt Spinler */ 3134e8078c0SMatt Spinler void createPEL(const std::string& message, uint32_t obmcLogID, 314367144cfSMatt Spinler uint64_t timestamp, phosphor::logging::Entry::Level severity, 3154e8078c0SMatt Spinler const std::vector<std::string>& additionalData, 31656ad2a0eSMatt Spinler const std::vector<std::string>& associations, 31756ad2a0eSMatt Spinler const phosphor::logging::FFDCEntries& ffdc); 3184e8078c0SMatt Spinler 3194e8078c0SMatt Spinler /** 3206b1a5c83SMatt Spinler * @brief Schedules a close of the file descriptor to occur from 3216b1a5c83SMatt Spinler * the event loop. 3226b1a5c83SMatt Spinler * 3236b1a5c83SMatt Spinler * Uses sd_event_add_defer 3246b1a5c83SMatt Spinler * 3256b1a5c83SMatt Spinler * @param[in] fd - The file descriptor to close 3266b1a5c83SMatt Spinler */ 3276b1a5c83SMatt Spinler void scheduleFDClose(int fd); 3286b1a5c83SMatt Spinler 3296b1a5c83SMatt Spinler /** 3306b1a5c83SMatt Spinler * @brief Closes the file descriptor passed in. 3316b1a5c83SMatt Spinler * 3326b1a5c83SMatt Spinler * This is called from the event loop to close FDs returned 3336b1a5c83SMatt Spinler * from getPEL(). 3346b1a5c83SMatt Spinler * 3356b1a5c83SMatt Spinler * @param[in] fd - The file descriptor to close 3366b1a5c83SMatt Spinler * @param[in] source - The event source object used 3376b1a5c83SMatt Spinler */ 3386b1a5c83SMatt Spinler void closeFD(int fd, sdeventplus::source::EventBase& source); 3396b1a5c83SMatt Spinler 3406b1a5c83SMatt Spinler /** 34119e72901SMatt Spinler * @brief Adds a PEL to the repository given its data 34219e72901SMatt Spinler * 34319e72901SMatt Spinler * @param[in] pelData - The PEL to add as a vector of uint8_ts 34419e72901SMatt Spinler * @param[in] obmcLogID - the OpenBMC event log ID 34519e72901SMatt Spinler */ 34619e72901SMatt Spinler void addPEL(std::vector<uint8_t>& pelData, uint32_t obmcLogID); 34719e72901SMatt Spinler 34819e72901SMatt Spinler /** 34919e72901SMatt Spinler * @brief Adds the PEL stored in the ESEL field of the AdditionalData 35019e72901SMatt Spinler * property of an OpenBMC event log to the repository. 35119e72901SMatt Spinler * 35219e72901SMatt Spinler * @param[in] esel - The ESEL AdditionalData contents 35319e72901SMatt Spinler * @param[in] obmcLogID - The OpenBMC event log ID 35419e72901SMatt Spinler */ 35519e72901SMatt Spinler void addESELPEL(const std::string& esel, uint32_t obmcLogID); 35619e72901SMatt Spinler 35719e72901SMatt Spinler /** 35856ad2a0eSMatt Spinler * @brief Converts the D-Bus FFDC method argument into a data 35956ad2a0eSMatt Spinler * structure understood by the PEL code. 36056ad2a0eSMatt Spinler * 36156ad2a0eSMatt Spinler * @param[in] ffdc - A vector of FFDC file information 36256ad2a0eSMatt Spinler * 36356ad2a0eSMatt Spinler * @return PelFFDC - The PEL FFDC data structure 36456ad2a0eSMatt Spinler */ 36556ad2a0eSMatt Spinler PelFFDC convertToPelFFDC(const phosphor::logging::FFDCEntries& ffdc); 36656ad2a0eSMatt Spinler 36756ad2a0eSMatt Spinler /** 3687e727a39SMatt Spinler * @brief Schedules a PEL repository prune to occur from 3697e727a39SMatt Spinler * the event loop. 3707e727a39SMatt Spinler * 3717e727a39SMatt Spinler * Uses sd_event_add_defer 3727e727a39SMatt Spinler */ 3737e727a39SMatt Spinler void scheduleRepoPrune(); 3747e727a39SMatt Spinler 3757e727a39SMatt Spinler /** 3767e727a39SMatt Spinler * @brief Prunes old PELs out of the repository to save space. 3777e727a39SMatt Spinler * 3787e727a39SMatt Spinler * This is called from the event loop. 3797e727a39SMatt Spinler * 3807e727a39SMatt Spinler * @param[in] source - The event source object used 3817e727a39SMatt Spinler */ 3827e727a39SMatt Spinler void pruneRepo(sdeventplus::source::EventBase& source); 3837e727a39SMatt Spinler 3847e727a39SMatt Spinler /** 385ff9cec25SMatt Spinler * @brief Sets up an inotify watch to watch for deleted PEL 386ff9cec25SMatt Spinler * files. Calls pelFileDeleted() when that occurs. 387ff9cec25SMatt Spinler */ 388ff9cec25SMatt Spinler void setupPELDeleteWatch(); 389ff9cec25SMatt Spinler 390ff9cec25SMatt Spinler /** 391ff9cec25SMatt Spinler * @brief Called when the inotify watch put on the repository directory 392ff9cec25SMatt Spinler * detects a PEL file was deleted. 393ff9cec25SMatt Spinler * 394ff9cec25SMatt Spinler * Will tell the Repository class about the deleted PEL, and then tell 395ff9cec25SMatt Spinler * the log manager class to delete the corresponding OpenBMC event log. 396ff9cec25SMatt Spinler */ 397ff9cec25SMatt Spinler void pelFileDeleted(sdeventplus::source::IO& io, int fd, uint32_t revents); 398ff9cec25SMatt Spinler 399ff9cec25SMatt Spinler /** 40044fc3168SAndrew Geissler * @brief Check if the input PEL should cause a quiesce of the system 40144fc3168SAndrew Geissler * 40244fc3168SAndrew Geissler * If QuiesceOnHwError is enabled within phosphor-settings and the PEL 403b2abc04dSMatt Spinler * from the host has a severity which is not SeverityType::nonError or 404b2abc04dSMatt Spinler * recovered then execute the quiesce and boot block logic. 40544fc3168SAndrew Geissler * 40644fc3168SAndrew Geissler * @param[in] pel - The PEL to check 40744fc3168SAndrew Geissler */ 40844fc3168SAndrew Geissler void checkPelAndQuiesce(std::unique_ptr<openpower::pels::PEL>& pel); 40944fc3168SAndrew Geissler 41044fc3168SAndrew Geissler /** 411d354a398SVijay Lobo * @brief Update eventId D-bus property for this error log 412d354a398SVijay Lobo * 413d354a398SVijay Lobo * Update the eventId property of D-bus with SRC and hexwords from the 414d354a398SVijay Lobo * PEL created 415d354a398SVijay Lobo * 416d354a398SVijay Lobo * @param[in] pel - The PEL to use 417d354a398SVijay Lobo */ 418d354a398SVijay Lobo void updateEventId(std::unique_ptr<openpower::pels::PEL>& pel); 419d354a398SVijay Lobo 420d354a398SVijay Lobo /** 4213387eac9SMatt Spinler * @brief Finds and serializes the log entry for the ID passed in. 4223387eac9SMatt Spinler * @param[in] obmcLogID - The OpenBMC event log ID 4233387eac9SMatt Spinler */ 4243387eac9SMatt Spinler void serializeLogEntry(uint32_t obmcLogID); 4253387eac9SMatt Spinler 4263387eac9SMatt Spinler /** 427e7d271aeSAdriana Kobylak * @brief Sets the FilePath of the specified error log entry to the PEL file 428e7d271aeSAdriana Kobylak * path. 429e7d271aeSAdriana Kobylak * 430e7d271aeSAdriana Kobylak * @param[in] obmcLogID - The OpenBMC entry log ID 431e7d271aeSAdriana Kobylak */ 432e7d271aeSAdriana Kobylak void setEntryPath(uint32_t obmcLogID); 433e7d271aeSAdriana Kobylak 434e7d271aeSAdriana Kobylak /** 435cbc93a49SVijay Lobo * @brief Sets the serviceProviderNotify D-bus property of PEL. 436cbc93a49SVijay Lobo * 437cbc93a49SVijay Lobo * @param[in] obmcLogID - The OpenBMC entry log ID 438cbc93a49SVijay Lobo */ 439cbc93a49SVijay Lobo void setServiceProviderNotifyFlag(uint32_t obmcLogID); 440cbc93a49SVijay Lobo 441cbc93a49SVijay Lobo /** 442593a4c66SVijay Lobo * @brief Update resolution D-bus property for this error log 443593a4c66SVijay Lobo * 444593a4c66SVijay Lobo * Update the resolution property of D-bus with callouts extracted from PEL 445593a4c66SVijay Lobo * 446593a4c66SVijay Lobo * @param[in] pel - The PEL to use 44728d6ae2fSMatt Spinler * 44828d6ae2fSMatt Spinler * @return bool - false for Repositor::for_each(). 449593a4c66SVijay Lobo */ 45028d6ae2fSMatt Spinler bool updateResolution(const openpower::pels::PEL& pel); 451593a4c66SVijay Lobo 452593a4c66SVijay Lobo /** 4538b81ec0eSMatt Spinler * @brief Check if the D-Bus severity property for the event log 4548b81ec0eSMatt Spinler * needs to be updated based on the final PEL severity, 4558b81ec0eSMatt Spinler * and update the property accordingly. 4568b81ec0eSMatt Spinler * 4578b81ec0eSMatt Spinler * @param[in] pel - The PEL to operate on. 4588b81ec0eSMatt Spinler */ 4598b81ec0eSMatt Spinler void updateDBusSeverity(const openpower::pels::PEL& pel); 4608b81ec0eSMatt Spinler 4618b81ec0eSMatt Spinler /** 462afb1b46fSVijay Lobo * @brief Create PELEntry Interface with supported properties 463afb1b46fSVijay Lobo * 464afb1b46fSVijay Lobo * Create PELEntry Interface and update all the properties which are 465afb1b46fSVijay Lobo * supported 466afb1b46fSVijay Lobo * 467afb1b46fSVijay Lobo * @param[in] obmcLogID - The OpenBMC entry log ID 468734ed2b5SMatt Spinler * @param[in] skipIaSignal - If The InterfacesAdded signal should be 469734ed2b5SMatt Spinler * skipped after creating the interfaces. 470afb1b46fSVijay Lobo */ 471734ed2b5SMatt Spinler void createPELEntry(uint32_t obmcLogID, bool skipIaSignal = false); 472afb1b46fSVijay Lobo 473afb1b46fSVijay Lobo /** 474d8fb5baeSMatt Spinler * @brief Schedules the delete of the OpenBMC event log for when 475d8fb5baeSMatt Spinler * execution gets back to the event loop (uses sd_event_add_defer). 476d8fb5baeSMatt Spinler * 477d8fb5baeSMatt Spinler * @param[in] obmcLogID - The OpenBMC entry log ID 478d8fb5baeSMatt Spinler */ 479d8fb5baeSMatt Spinler void scheduleObmcLogDelete(uint32_t obmcLogID); 480d8fb5baeSMatt Spinler 481d8fb5baeSMatt Spinler /** 482d8fb5baeSMatt Spinler * @brief SD event callback to delete an OpenBMC event log 483d8fb5baeSMatt Spinler * 484d8fb5baeSMatt Spinler * @param[in] obmcLogID - The OpenBMC entry log ID 485d8fb5baeSMatt Spinler */ 486d8fb5baeSMatt Spinler void deleteObmcLog(sdeventplus::source::EventBase&, uint32_t obmcLogID); 487d8fb5baeSMatt Spinler 488d8fb5baeSMatt Spinler /** 4890dd22c83SMatt Spinler * @brief Clears the deconfig flag in the PEL if necessary. 4900dd22c83SMatt Spinler * 4910dd22c83SMatt Spinler * If the passed in location code is in a callout and it's a PEL with 4920dd22c83SMatt Spinler * the BMC power/thermal or fans component ID, clear the deconfig flag. 4930dd22c83SMatt Spinler * 4940dd22c83SMatt Spinler * @param[in] locationCode - The location code to look for 4950dd22c83SMatt Spinler * @param[inout] pel - The PEL to check and modify. 4960dd22c83SMatt Spinler * @return bool - true if the flag was cleared for this PEL 4970dd22c83SMatt Spinler */ 4980dd22c83SMatt Spinler static bool clearPowerThermalDeconfigFlag(const std::string& locationCode, 4990dd22c83SMatt Spinler openpower::pels::PEL& pel); 5000dd22c83SMatt Spinler 5010dd22c83SMatt Spinler /** 5020dd22c83SMatt Spinler * @brief Called by DataInterface when the presence of hotpluggable 5030dd22c83SMatt Spinler * hardware is detected. 5040dd22c83SMatt Spinler * 5050dd22c83SMatt Spinler * Clears the 'Deconfig' flag in any PEL that has the location code 5060dd22c83SMatt Spinler * of the hardware in a callout. 5070dd22c83SMatt Spinler * 5080dd22c83SMatt Spinler * @param[in] locationCode - The location code of the hardware. 5090dd22c83SMatt Spinler */ 5100dd22c83SMatt Spinler void hardwarePresent(const std::string& locationCode); 5110dd22c83SMatt Spinler 5120dd22c83SMatt Spinler /** 5134e8078c0SMatt Spinler * @brief Reference to phosphor-logging's Manager class 5144e8078c0SMatt Spinler */ 515367144cfSMatt Spinler phosphor::logging::internal::Manager& _logManager; 51689fa082aSMatt Spinler 51789fa082aSMatt Spinler /** 518f682b40dSMatt Spinler * @brief Handles creating event logs/PELs from within 519f682b40dSMatt Spinler * the PEL extension code 520f682b40dSMatt Spinler */ 521f682b40dSMatt Spinler EventLogger _eventLogger; 522f682b40dSMatt Spinler 523f682b40dSMatt Spinler /** 52489fa082aSMatt Spinler * @brief The PEL repository object 52589fa082aSMatt Spinler */ 52689fa082aSMatt Spinler Repository _repo; 527c8705e2bSMatt Spinler 528c8705e2bSMatt Spinler /** 529367144cfSMatt Spinler * @brief The PEL message registry object 530367144cfSMatt Spinler */ 531367144cfSMatt Spinler message::Registry _registry; 532367144cfSMatt Spinler 533367144cfSMatt Spinler /** 534ff9cec25SMatt Spinler * @brief The Event object this class uses 535ff9cec25SMatt Spinler */ 536ff9cec25SMatt Spinler sdeventplus::Event _event; 537ff9cec25SMatt Spinler 538ff9cec25SMatt Spinler /** 539c8705e2bSMatt Spinler * @brief The API the PEL sections use to gather data 540c8705e2bSMatt Spinler */ 541c8705e2bSMatt Spinler std::unique_ptr<DataInterfaceBase> _dataIface; 542f60ac27eSMatt Spinler 543f60ac27eSMatt Spinler /** 544d96fa60dSMatt Spinler * @brief Object used to read from the journal 545d96fa60dSMatt Spinler */ 546d96fa60dSMatt Spinler std::unique_ptr<JournalBase> _journal; 547d96fa60dSMatt Spinler 548d96fa60dSMatt Spinler /** 549afb1b46fSVijay Lobo * @brief The map used to keep track of PEL entry pointer associated with 550afb1b46fSVijay Lobo * event log. 551afb1b46fSVijay Lobo */ 552afb1b46fSVijay Lobo std::map<std::string, 553afb1b46fSVijay Lobo std::unique_ptr< 554*6ddbf69eSWilly Tu sdbusplus::server::org::open_power::logging::pel::Entry>> 555afb1b46fSVijay Lobo _pelEntries; 556afb1b46fSVijay Lobo 557afb1b46fSVijay Lobo /** 558f60ac27eSMatt Spinler * @brief The HostNotifier object used for telling the 559f60ac27eSMatt Spinler * host about new PELs 560f60ac27eSMatt Spinler */ 561f60ac27eSMatt Spinler std::unique_ptr<HostNotifier> _hostNotifier; 5626b1a5c83SMatt Spinler 5636b1a5c83SMatt Spinler /** 5646b1a5c83SMatt Spinler * @brief The event source for closing a PEL file descriptor after 5656b1a5c83SMatt Spinler * it has been returned from the getPEL D-Bus method. 5666b1a5c83SMatt Spinler */ 5676b1a5c83SMatt Spinler std::unique_ptr<sdeventplus::source::Defer> _fdCloserEventSource; 5687e727a39SMatt Spinler 5697e727a39SMatt Spinler /** 5707e727a39SMatt Spinler * @brief The even source for removing old PELs when the repo is 5717e727a39SMatt Spinler * running out of space to make room for new ones. 5727e727a39SMatt Spinler */ 5737e727a39SMatt Spinler std::unique_ptr<sdeventplus::source::Defer> _repoPrunerEventSource; 574ff9cec25SMatt Spinler 575ff9cec25SMatt Spinler /** 576d8fb5baeSMatt Spinler * @brief The event source for deleting an OpenBMC event log. 577d8fb5baeSMatt Spinler * Used when its corresponding PEL is invalid. 578d8fb5baeSMatt Spinler */ 579d8fb5baeSMatt Spinler std::unique_ptr<sdeventplus::source::Defer> _obmcLogDeleteEventSource; 580d8fb5baeSMatt Spinler 581d8fb5baeSMatt Spinler /** 582ff9cec25SMatt Spinler * @brief The even source for watching for deleted PEL files. 583ff9cec25SMatt Spinler */ 584ff9cec25SMatt Spinler std::unique_ptr<sdeventplus::source::IO> _pelFileDeleteEventSource; 585ff9cec25SMatt Spinler 586ff9cec25SMatt Spinler /** 587ff9cec25SMatt Spinler * @brief The file descriptor returned by inotify_init1() used 588ff9cec25SMatt Spinler * for watching for deleted PEL files. 589ff9cec25SMatt Spinler */ 590ff9cec25SMatt Spinler int _pelFileDeleteFD = -1; 591ff9cec25SMatt Spinler 592ff9cec25SMatt Spinler /** 593ff9cec25SMatt Spinler * @brief The file descriptor returned by inotify_add_watch(). 594ff9cec25SMatt Spinler */ 595ff9cec25SMatt Spinler int _pelFileDeleteWatchFD = -1; 5964e8078c0SMatt Spinler }; 5974e8078c0SMatt Spinler 5984e8078c0SMatt Spinler } // namespace pels 5994e8078c0SMatt Spinler } // namespace openpower 600