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 */ Manager(phosphor::logging::internal::Manager & logManager,std::unique_ptr<DataInterfaceBase> dataIface,EventLogger::LogFunction creatorFunc,std::unique_ptr<JournalBase> journal)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) : 54075c7923SPatrick Williams PELInterface(logManager.getBus(), OBJ_LOGGING), _logManager(logManager), 55075c7923SPatrick Williams _eventLogger(std::move(creatorFunc)), _repo(getPELRepoPath()), 560d804ef5SMatt Spinler _registry(getPELReadOnlyDataPath() / message::registryFileName), 57ff9cec25SMatt Spinler _event(sdeventplus::Event::get_default()), 58d96fa60dSMatt Spinler _dataIface(std::move(dataIface)), _journal(std::move(journal)) 594e8078c0SMatt Spinler { 60e7d271aeSAdriana Kobylak for (const auto& entry : _logManager.entries) 61e7d271aeSAdriana Kobylak { 62e7d271aeSAdriana Kobylak setEntryPath(entry.first); 63cbc93a49SVijay Lobo setServiceProviderNotifyFlag(entry.first); 64afb1b46fSVijay Lobo // Create PELEntry interface and setup properties with their values 65734ed2b5SMatt Spinler createPELEntry(entry.first, true); 66e7d271aeSAdriana Kobylak } 6728d6ae2fSMatt Spinler 68ff9cec25SMatt Spinler setupPELDeleteWatch(); 690dd22c83SMatt Spinler 700dd22c83SMatt Spinler _dataIface->subscribeToFruPresent( 710dd22c83SMatt Spinler "Manager", 720dd22c83SMatt Spinler std::bind(&Manager::hardwarePresent, this, std::placeholders::_1)); 734e8078c0SMatt Spinler } 744e8078c0SMatt Spinler 754e8078c0SMatt Spinler /** 76f60ac27eSMatt Spinler * @brief constructor that enables host notification 77f60ac27eSMatt Spinler * 78f60ac27eSMatt Spinler * @param[in] logManager - internal::Manager object 79f60ac27eSMatt Spinler * @param[in] dataIface - The data interface object 80f682b40dSMatt Spinler * @param[in] creatorFunc - The function that EventLogger will 81f682b40dSMatt Spinler * use for creating event logs 82f60ac27eSMatt Spinler * @param[in] hostIface - The hostInterface object 83f60ac27eSMatt Spinler */ Manager(phosphor::logging::internal::Manager & logManager,std::unique_ptr<DataInterfaceBase> dataIface,EventLogger::LogFunction creatorFunc,std::unique_ptr<JournalBase> journal,std::unique_ptr<HostInterface> hostIface)84f60ac27eSMatt Spinler Manager(phosphor::logging::internal::Manager& logManager, 85f60ac27eSMatt Spinler std::unique_ptr<DataInterfaceBase> dataIface, 86f682b40dSMatt Spinler EventLogger::LogFunction creatorFunc, 87d96fa60dSMatt Spinler std::unique_ptr<JournalBase> journal, 88f60ac27eSMatt Spinler std::unique_ptr<HostInterface> hostIface) : 89d96fa60dSMatt Spinler Manager(logManager, std::move(dataIface), std::move(creatorFunc), 90d96fa60dSMatt Spinler std::move(journal)) 91f60ac27eSMatt Spinler { 92f60ac27eSMatt Spinler _hostNotifier = std::make_unique<HostNotifier>( 93f60ac27eSMatt Spinler _repo, *(_dataIface.get()), std::move(hostIface)); 94f60ac27eSMatt Spinler } 95f60ac27eSMatt Spinler 96f60ac27eSMatt Spinler /** 97ff9cec25SMatt Spinler * @brief Destructor 98ff9cec25SMatt Spinler */ 99ff9cec25SMatt Spinler ~Manager(); 100ff9cec25SMatt Spinler 101ff9cec25SMatt Spinler /** 1024e8078c0SMatt Spinler * @brief Creates a PEL based on the OpenBMC event log contents. If 1034e8078c0SMatt Spinler * a PEL was passed in via the RAWPEL specifier in the 1044e8078c0SMatt Spinler * additionalData parameter, use that instead. 1054e8078c0SMatt Spinler * 1064e8078c0SMatt Spinler * @param[in] message - the event log message property 1074e8078c0SMatt Spinler * @param[in] obmcLogID - the corresponding OpenBMC event log id 1084e8078c0SMatt Spinler * @param[in] timestamp - the Timestamp property 1094e8078c0SMatt Spinler * @param[in] severity - the event log severity 1104e8078c0SMatt Spinler * @param[in] additionalData - the AdditionalData property 1114e8078c0SMatt Spinler * @param[in] associations - the Associations property 11256ad2a0eSMatt Spinler * @param[in] ffdc - A vector of FFDC file information 1134e8078c0SMatt Spinler */ 1144e8078c0SMatt Spinler void create(const std::string& message, uint32_t obmcLogID, 115367144cfSMatt Spinler uint64_t timestamp, phosphor::logging::Entry::Level severity, 116*e5940634SPatrick Williams const std::map<std::string, std::string>& additionalData, 11756ad2a0eSMatt Spinler const std::vector<std::string>& associations, 11856ad2a0eSMatt Spinler const phosphor::logging::FFDCEntries& ffdc = 11956ad2a0eSMatt Spinler phosphor::logging::FFDCEntries{}); 1204e8078c0SMatt Spinler 1214e8078c0SMatt Spinler /** 1224e8078c0SMatt Spinler * @brief Erase a PEL based on its OpenBMC event log ID 1234e8078c0SMatt Spinler * 1244e8078c0SMatt Spinler * @param[in] obmcLogID - the corresponding OpenBMC event log id 1254e8078c0SMatt Spinler */ 1264e8078c0SMatt Spinler void erase(uint32_t obmcLogID); 1274e8078c0SMatt Spinler 128d763db35Sharsh-agarwal1 /** 129d763db35Sharsh-agarwal1 * @brief Get the list of event log ids that have an associated 130d763db35Sharsh-agarwal1 * hardware isolation entry. 131d763db35Sharsh-agarwal1 * 132d763db35Sharsh-agarwal1 * @param[in] idsWithHwIsoEntry - List to store the list of log ids 133d763db35Sharsh-agarwal1 */ 134d763db35Sharsh-agarwal1 void getLogIDWithHwIsolation(std::vector<uint32_t>& idsWithHwIsoEntry); 135d763db35Sharsh-agarwal1 1364e8078c0SMatt Spinler /** @brief Says if an OpenBMC event log may not be manually deleted at this 1374e8078c0SMatt Spinler * time because its corresponding PEL cannot be. 1384e8078c0SMatt Spinler * 1394e8078c0SMatt Spinler * There are PEL retention policies that can prohibit the manual deletion 1404e8078c0SMatt Spinler * of PELs (and therefore OpenBMC event logs). 1414e8078c0SMatt Spinler * 1424e8078c0SMatt Spinler * @param[in] obmcLogID - the OpenBMC event log ID 1434e8078c0SMatt Spinler * @return bool - true if prohibited 1444e8078c0SMatt Spinler */ 1454e8078c0SMatt Spinler bool isDeleteProhibited(uint32_t obmcLogID); 1464e8078c0SMatt Spinler 147a34ab72cSMatt Spinler /** 148a34ab72cSMatt Spinler * @brief Return a file descriptor to the raw PEL data 149a34ab72cSMatt Spinler * 150a34ab72cSMatt Spinler * Throws InvalidArgument if the PEL ID isn't found, 151a34ab72cSMatt Spinler * and InternalFailure if anything else fails. 152a34ab72cSMatt Spinler * 153a34ab72cSMatt Spinler * @param[in] pelID - The PEL ID to get the data for 154a34ab72cSMatt Spinler * 155a34ab72cSMatt Spinler * @return unix_fd - File descriptor to the file that contains the PEL 156a34ab72cSMatt Spinler */ 157a34ab72cSMatt Spinler sdbusplus::message::unix_fd getPEL(uint32_t pelID) override; 158a34ab72cSMatt Spinler 159a34ab72cSMatt Spinler /** 160a34ab72cSMatt Spinler * @brief Returns data for the PEL corresponding to an OpenBMC 161a34ab72cSMatt Spinler * event log. 162a34ab72cSMatt Spinler * 163a34ab72cSMatt Spinler * @param[in] obmcLogID - The OpenBMC event log ID 164a34ab72cSMatt Spinler * 165a34ab72cSMatt Spinler * @return vector<uint8_t> - The raw PEL data 166a34ab72cSMatt Spinler */ 167a34ab72cSMatt Spinler std::vector<uint8_t> getPELFromOBMCID(uint32_t obmcLogID) override; 168a34ab72cSMatt Spinler 169a34ab72cSMatt Spinler /** 170a34ab72cSMatt Spinler * @brief The D-Bus method called when a host successfully processes 171a34ab72cSMatt Spinler * a PEL. 172a34ab72cSMatt Spinler * 173a34ab72cSMatt Spinler * This D-Bus method is called from the PLDM daemon when they get an 174a34ab72cSMatt Spinler * 'Ack PEL' PLDM message from the host, which indicates the host 175a34ab72cSMatt Spinler * firmware successfully sent it to the OS and this code doesn't need 176a34ab72cSMatt Spinler * to send it to the host again. 177a34ab72cSMatt Spinler * 178a34ab72cSMatt Spinler * @param[in] pelID - The PEL ID 179a34ab72cSMatt Spinler */ 180a34ab72cSMatt Spinler void hostAck(uint32_t pelID) override; 181a34ab72cSMatt Spinler 182a34ab72cSMatt Spinler /** 183a34ab72cSMatt Spinler * @brief D-Bus method called when the host rejects a PEL. 184a34ab72cSMatt Spinler * 185a34ab72cSMatt Spinler * This D-Bus method is called from the PLDM daemon when they get an 186a34ab72cSMatt Spinler * 'Ack PEL' PLDM message from the host with a payload that says 187a34ab72cSMatt Spinler * something when wrong. 188a34ab72cSMatt Spinler * 189a34ab72cSMatt Spinler * The choices are either: 190a34ab72cSMatt Spinler * * Host Full - The host's staging area is full - try again later 191a34ab72cSMatt Spinler * * Malrformed PEL - The host received an invalid PEL 192a34ab72cSMatt Spinler * 193a34ab72cSMatt Spinler * @param[in] pelID - The PEL ID 194a34ab72cSMatt Spinler * @param[in] reason - One of the above two reasons 195a34ab72cSMatt Spinler */ 196a34ab72cSMatt Spinler void hostReject(uint32_t pelID, RejectionReason reason) override; 197a34ab72cSMatt Spinler 19844893cc9SMatt Spinler /** 19944893cc9SMatt Spinler * @brief D-Bus method to create a PEL/OpenBMC event log and 20044893cc9SMatt Spinler * return the created OpenBMC and PEL log IDs. 20144893cc9SMatt Spinler * 20244893cc9SMatt Spinler * The same as the CreateWithFFDCFiles method on the 20344893cc9SMatt Spinler * xyz.openbmc_project.Logging.Create interface, except for 20444893cc9SMatt Spinler * the return values. 20544893cc9SMatt Spinler * 20644893cc9SMatt Spinler * @param[in] message - The event log message property 20744893cc9SMatt Spinler * @param[in] severity - The event log severity 20844893cc9SMatt Spinler * @param[in] additionalData - The AdditionalData property 20944893cc9SMatt Spinler * @param[in] ffdc - A vector of FFDC file information 21044893cc9SMatt Spinler */ 2119cc30076SMatt Spinler std::tuple<uint32_t, uint32_t> createPELWithFFDCFiles( 2129cc30076SMatt Spinler std::string message, phosphor::logging::Entry::Level severity, 2139cc30076SMatt Spinler std::map<std::string, std::string> additionalData, 2149cc30076SMatt Spinler std::vector<std::tuple<sdbusplus::xyz::openbmc_project::Logging:: 2159cc30076SMatt Spinler server::Create::FFDCFormat, 2169cc30076SMatt Spinler uint8_t, uint8_t, sdbusplus::message::unix_fd>> 21744893cc9SMatt Spinler fFDC) override; 2189cc30076SMatt Spinler 21919e72901SMatt Spinler /** 220aa85a072SMatt Spinler * @brief D-Bus method to return the PEL in JSON format 221aa85a072SMatt Spinler * 222aa85a072SMatt Spinler * @param[in] obmcLogID - The OpenBMC entry log ID 223aa85a072SMatt Spinler * 224aa85a072SMatt Spinler * @return std::string - The fully parsed PEL in JSON 225aa85a072SMatt Spinler */ 2268bd4ca4eSMatt Spinler std::string getPELJSON(uint32_t obmcLogID) override; 227aa85a072SMatt Spinler 228aa85a072SMatt Spinler /** 22919e72901SMatt Spinler * @brief Converts the ESEL field in an OpenBMC event log to a 23019e72901SMatt Spinler * vector of uint8_ts that just contains the PEL data. 23119e72901SMatt Spinler * 23219e72901SMatt Spinler * That data string looks like: "50 48 00 ab ..." 23319e72901SMatt Spinler * 23419e72901SMatt Spinler * Throws an exception on any failures. 23519e72901SMatt Spinler * 23619e72901SMatt Spinler * @param[in] esel - The ESEL string 23719e72901SMatt Spinler * 23819e72901SMatt Spinler * @return std::vector<uint8_t> - The contained PEL data 23919e72901SMatt Spinler */ 24019e72901SMatt Spinler static std::vector<uint8_t> eselToRawData(const std::string& esel); 24119e72901SMatt Spinler 242d354a398SVijay Lobo /** 243593a4c66SVijay Lobo * @brief Generate resolution string from the PEL 244593a4c66SVijay Lobo * 245593a4c66SVijay Lobo * @param[in] pel - The PEL to use 246593a4c66SVijay Lobo */ 247593a4c66SVijay Lobo std::string getResolution(const openpower::pels::PEL& pel) const; 248593a4c66SVijay Lobo 249593a4c66SVijay Lobo /** 250d354a398SVijay Lobo * @brief Generate event ID from the PEL 251d354a398SVijay Lobo * 252d354a398SVijay Lobo * @param[in] pel - The PEL to use 253d354a398SVijay Lobo */ 254d354a398SVijay Lobo std::string getEventId(const openpower::pels::PEL& pel) const; 255d354a398SVijay Lobo 256f4203c47SRamesh Iyyar /** @brief Implementation for GetPELIdFromBMCLogId 257f4203c47SRamesh Iyyar * 258f4203c47SRamesh Iyyar * Returns the PEL Id (aka Entry ID (EID)) based on the given 259f4203c47SRamesh Iyyar * BMC event log id. 260f4203c47SRamesh Iyyar * 261f4203c47SRamesh Iyyar * @param[in] bmcLogId - The BMC event log id of the PEL to retrieve 262f4203c47SRamesh Iyyar * the PEL id. 263f4203c47SRamesh Iyyar * 264f4203c47SRamesh Iyyar * @return uint32_t - The Id of the PEL. 265f4203c47SRamesh Iyyar * Throw "InvalidArgument" if not found. 266f4203c47SRamesh Iyyar */ 267f4203c47SRamesh Iyyar uint32_t getPELIdFromBMCLogId(uint32_t bmcLogId) override; 268f4203c47SRamesh Iyyar 269530efbfcSRamesh Iyyar /** @brief Implementation for GetBMCLogIdFromPELId 270530efbfcSRamesh Iyyar * 271530efbfcSRamesh Iyyar * Returns the BMC event log id based on the given PEL id 272530efbfcSRamesh Iyyar * (aka Entry ID (EID)). 273530efbfcSRamesh Iyyar * 274530efbfcSRamesh Iyyar * @param[in] pelId - The PEL id to retrieve the BMC event log id. 275530efbfcSRamesh Iyyar * 276530efbfcSRamesh Iyyar * @return uint32_t - The BMC event log id of the PEL. 277530efbfcSRamesh Iyyar * Throw "InvalidArgument" if not found. 278530efbfcSRamesh Iyyar */ 279530efbfcSRamesh Iyyar uint32_t getBMCLogIdFromPELId(uint32_t pelId) override; 280530efbfcSRamesh Iyyar 2813e274432SSumit Kumar /** 2823e274432SSumit Kumar * @brief Update boot progress SRC based on severity 0x51, critical error 2833e274432SSumit Kumar * 2843e274432SSumit Kumar * @param[in] pel - The PEL to use 2853e274432SSumit Kumar */ 2863e274432SSumit Kumar void updateProgressSRC(std::unique_ptr<openpower::pels::PEL>& pel) const; 2873e274432SSumit Kumar 2880003af14SMatt Spinler /** 2890003af14SMatt Spinler * @brief Converts unprintable characters from the passed 2900003af14SMatt Spinler * in string to spaces so they won't crash D-Bus when 2910003af14SMatt Spinler * used as a property value. 2920003af14SMatt Spinler * 2930003af14SMatt Spinler * @param[in] field - The field to fix 2940003af14SMatt Spinler * 2950003af14SMatt Spinler * @return std::string - The string without non printable characters. 2960003af14SMatt Spinler */ 2970003af14SMatt Spinler static std::string sanitizeFieldForDBus(std::string field); 2980003af14SMatt Spinler 2994e8078c0SMatt Spinler private: 3004e8078c0SMatt Spinler /** 3014e8078c0SMatt Spinler * @brief Adds a received raw PEL to the PEL repository 3024e8078c0SMatt Spinler * 3034e8078c0SMatt Spinler * @param[in] rawPelPath - The path to the file that contains the 3044e8078c0SMatt Spinler * raw PEL. 3054e8078c0SMatt Spinler * @param[in] obmcLogID - the corresponding OpenBMC event log id 3064e8078c0SMatt Spinler */ 3074e8078c0SMatt Spinler void addRawPEL(const std::string& rawPelPath, uint32_t obmcLogID); 3084e8078c0SMatt Spinler 3094e8078c0SMatt Spinler /** 3104e8078c0SMatt Spinler * @brief Creates a PEL based on the OpenBMC event log contents. 3114e8078c0SMatt Spinler * 3124e8078c0SMatt Spinler * @param[in] message - The event log message property 3134e8078c0SMatt Spinler * @param[in] obmcLogID - the corresponding OpenBMC event log id 3144e8078c0SMatt Spinler * @param[in] timestamp - The timestamp property 3154e8078c0SMatt Spinler * @param[in] severity - The event log severity 3164e8078c0SMatt Spinler * @param[in] additionalData - The AdditionalData property 3174e8078c0SMatt Spinler * @param[in] associations - The associations property 31856ad2a0eSMatt Spinler * @param[in] ffdc - A vector of FFDC file information 3194e8078c0SMatt Spinler */ 3204e8078c0SMatt Spinler void createPEL(const std::string& message, uint32_t obmcLogID, 321367144cfSMatt Spinler uint64_t timestamp, phosphor::logging::Entry::Level severity, 322*e5940634SPatrick Williams const std::map<std::string, std::string>& additionalData, 32356ad2a0eSMatt Spinler const std::vector<std::string>& associations, 32456ad2a0eSMatt Spinler const phosphor::logging::FFDCEntries& ffdc); 3254e8078c0SMatt Spinler 3264e8078c0SMatt Spinler /** 3276b1a5c83SMatt Spinler * @brief Schedules a close of the file descriptor to occur from 3286b1a5c83SMatt Spinler * the event loop. 3296b1a5c83SMatt Spinler * 3306b1a5c83SMatt Spinler * Uses sd_event_add_defer 3316b1a5c83SMatt Spinler * 3326b1a5c83SMatt Spinler * @param[in] fd - The file descriptor to close 3336b1a5c83SMatt Spinler */ 3346b1a5c83SMatt Spinler void scheduleFDClose(int fd); 3356b1a5c83SMatt Spinler 3366b1a5c83SMatt Spinler /** 3376b1a5c83SMatt Spinler * @brief Closes the file descriptor passed in. 3386b1a5c83SMatt Spinler * 3396b1a5c83SMatt Spinler * This is called from the event loop to close FDs returned 3406b1a5c83SMatt Spinler * from getPEL(). 3416b1a5c83SMatt Spinler * 3426b1a5c83SMatt Spinler * @param[in] fd - The file descriptor to close 3436b1a5c83SMatt Spinler * @param[in] source - The event source object used 3446b1a5c83SMatt Spinler */ 3456b1a5c83SMatt Spinler void closeFD(int fd, sdeventplus::source::EventBase& source); 3466b1a5c83SMatt Spinler 3476b1a5c83SMatt Spinler /** 34819e72901SMatt Spinler * @brief Adds a PEL to the repository given its data 34919e72901SMatt Spinler * 35019e72901SMatt Spinler * @param[in] pelData - The PEL to add as a vector of uint8_ts 35119e72901SMatt Spinler * @param[in] obmcLogID - the OpenBMC event log ID 35219e72901SMatt Spinler */ 35319e72901SMatt Spinler void addPEL(std::vector<uint8_t>& pelData, uint32_t obmcLogID); 35419e72901SMatt Spinler 35519e72901SMatt Spinler /** 35619e72901SMatt Spinler * @brief Adds the PEL stored in the ESEL field of the AdditionalData 35719e72901SMatt Spinler * property of an OpenBMC event log to the repository. 35819e72901SMatt Spinler * 35919e72901SMatt Spinler * @param[in] esel - The ESEL AdditionalData contents 36019e72901SMatt Spinler * @param[in] obmcLogID - The OpenBMC event log ID 36119e72901SMatt Spinler */ 36219e72901SMatt Spinler void addESELPEL(const std::string& esel, uint32_t obmcLogID); 36319e72901SMatt Spinler 36419e72901SMatt Spinler /** 36556ad2a0eSMatt Spinler * @brief Converts the D-Bus FFDC method argument into a data 36656ad2a0eSMatt Spinler * structure understood by the PEL code. 36756ad2a0eSMatt Spinler * 36856ad2a0eSMatt Spinler * @param[in] ffdc - A vector of FFDC file information 36956ad2a0eSMatt Spinler * 37056ad2a0eSMatt Spinler * @return PelFFDC - The PEL FFDC data structure 37156ad2a0eSMatt Spinler */ 37256ad2a0eSMatt Spinler PelFFDC convertToPelFFDC(const phosphor::logging::FFDCEntries& ffdc); 37356ad2a0eSMatt Spinler 37456ad2a0eSMatt Spinler /** 3757e727a39SMatt Spinler * @brief Schedules a PEL repository prune to occur from 3767e727a39SMatt Spinler * the event loop. 3777e727a39SMatt Spinler * 3787e727a39SMatt Spinler * Uses sd_event_add_defer 3797e727a39SMatt Spinler */ 3807e727a39SMatt Spinler void scheduleRepoPrune(); 3817e727a39SMatt Spinler 3827e727a39SMatt Spinler /** 3837e727a39SMatt Spinler * @brief Prunes old PELs out of the repository to save space. 3847e727a39SMatt Spinler * 3857e727a39SMatt Spinler * This is called from the event loop. 3867e727a39SMatt Spinler * 3877e727a39SMatt Spinler * @param[in] source - The event source object used 3887e727a39SMatt Spinler */ 3897e727a39SMatt Spinler void pruneRepo(sdeventplus::source::EventBase& source); 3907e727a39SMatt Spinler 3917e727a39SMatt Spinler /** 392ff9cec25SMatt Spinler * @brief Sets up an inotify watch to watch for deleted PEL 393ff9cec25SMatt Spinler * files. Calls pelFileDeleted() when that occurs. 394ff9cec25SMatt Spinler */ 395ff9cec25SMatt Spinler void setupPELDeleteWatch(); 396ff9cec25SMatt Spinler 397ff9cec25SMatt Spinler /** 398ff9cec25SMatt Spinler * @brief Called when the inotify watch put on the repository directory 399ff9cec25SMatt Spinler * detects a PEL file was deleted. 400ff9cec25SMatt Spinler * 401ff9cec25SMatt Spinler * Will tell the Repository class about the deleted PEL, and then tell 402ff9cec25SMatt Spinler * the log manager class to delete the corresponding OpenBMC event log. 403ff9cec25SMatt Spinler */ 404ff9cec25SMatt Spinler void pelFileDeleted(sdeventplus::source::IO& io, int fd, uint32_t revents); 405ff9cec25SMatt Spinler 406ff9cec25SMatt Spinler /** 40744fc3168SAndrew Geissler * @brief Check if the input PEL should cause a quiesce of the system 40844fc3168SAndrew Geissler * 40944fc3168SAndrew Geissler * If QuiesceOnHwError is enabled within phosphor-settings and the PEL 410b2abc04dSMatt Spinler * from the host has a severity which is not SeverityType::nonError or 411b2abc04dSMatt Spinler * recovered then execute the quiesce and boot block logic. 41244fc3168SAndrew Geissler * 41344fc3168SAndrew Geissler * @param[in] pel - The PEL to check 41444fc3168SAndrew Geissler */ 41544fc3168SAndrew Geissler void checkPelAndQuiesce(std::unique_ptr<openpower::pels::PEL>& pel); 41644fc3168SAndrew Geissler 41744fc3168SAndrew Geissler /** 418d354a398SVijay Lobo * @brief Update eventId D-bus property for this error log 419d354a398SVijay Lobo * 420d354a398SVijay Lobo * Update the eventId property of D-bus with SRC and hexwords from the 421d354a398SVijay Lobo * PEL created 422d354a398SVijay Lobo * 423d354a398SVijay Lobo * @param[in] pel - The PEL to use 424d354a398SVijay Lobo */ 425d354a398SVijay Lobo void updateEventId(std::unique_ptr<openpower::pels::PEL>& pel); 426d354a398SVijay Lobo 427d354a398SVijay Lobo /** 4283387eac9SMatt Spinler * @brief Finds and serializes the log entry for the ID passed in. 4293387eac9SMatt Spinler * @param[in] obmcLogID - The OpenBMC event log ID 4303387eac9SMatt Spinler */ 4313387eac9SMatt Spinler void serializeLogEntry(uint32_t obmcLogID); 4323387eac9SMatt Spinler 4333387eac9SMatt Spinler /** 434e7d271aeSAdriana Kobylak * @brief Sets the FilePath of the specified error log entry to the PEL file 435e7d271aeSAdriana Kobylak * path. 436e7d271aeSAdriana Kobylak * 437e7d271aeSAdriana Kobylak * @param[in] obmcLogID - The OpenBMC entry log ID 438e7d271aeSAdriana Kobylak */ 439e7d271aeSAdriana Kobylak void setEntryPath(uint32_t obmcLogID); 440e7d271aeSAdriana Kobylak 441e7d271aeSAdriana Kobylak /** 442cbc93a49SVijay Lobo * @brief Sets the serviceProviderNotify D-bus property of PEL. 443cbc93a49SVijay Lobo * 444cbc93a49SVijay Lobo * @param[in] obmcLogID - The OpenBMC entry log ID 445cbc93a49SVijay Lobo */ 446cbc93a49SVijay Lobo void setServiceProviderNotifyFlag(uint32_t obmcLogID); 447cbc93a49SVijay Lobo 448cbc93a49SVijay Lobo /** 449593a4c66SVijay Lobo * @brief Update resolution D-bus property for this error log 450593a4c66SVijay Lobo * 451593a4c66SVijay Lobo * Update the resolution property of D-bus with callouts extracted from PEL 452593a4c66SVijay Lobo * 453593a4c66SVijay Lobo * @param[in] pel - The PEL to use 45428d6ae2fSMatt Spinler * 45528d6ae2fSMatt Spinler * @return bool - false for Repositor::for_each(). 456593a4c66SVijay Lobo */ 45728d6ae2fSMatt Spinler bool updateResolution(const openpower::pels::PEL& pel); 458593a4c66SVijay Lobo 459593a4c66SVijay Lobo /** 4608b81ec0eSMatt Spinler * @brief Check if the D-Bus severity property for the event log 4618b81ec0eSMatt Spinler * needs to be updated based on the final PEL severity, 4628b81ec0eSMatt Spinler * and update the property accordingly. 4638b81ec0eSMatt Spinler * 4648b81ec0eSMatt Spinler * @param[in] pel - The PEL to operate on. 4658b81ec0eSMatt Spinler */ 4668b81ec0eSMatt Spinler void updateDBusSeverity(const openpower::pels::PEL& pel); 4678b81ec0eSMatt Spinler 4688b81ec0eSMatt Spinler /** 469afb1b46fSVijay Lobo * @brief Create PELEntry Interface with supported properties 470afb1b46fSVijay Lobo * 471afb1b46fSVijay Lobo * Create PELEntry Interface and update all the properties which are 472afb1b46fSVijay Lobo * supported 473afb1b46fSVijay Lobo * 474afb1b46fSVijay Lobo * @param[in] obmcLogID - The OpenBMC entry log ID 475734ed2b5SMatt Spinler * @param[in] skipIaSignal - If The InterfacesAdded signal should be 476734ed2b5SMatt Spinler * skipped after creating the interfaces. 477afb1b46fSVijay Lobo */ 478734ed2b5SMatt Spinler void createPELEntry(uint32_t obmcLogID, bool skipIaSignal = false); 479afb1b46fSVijay Lobo 480afb1b46fSVijay Lobo /** 481d8fb5baeSMatt Spinler * @brief Schedules the delete of the OpenBMC event log for when 482d8fb5baeSMatt Spinler * execution gets back to the event loop (uses sd_event_add_defer). 483d8fb5baeSMatt Spinler * 484d8fb5baeSMatt Spinler * @param[in] obmcLogID - The OpenBMC entry log ID 485d8fb5baeSMatt Spinler */ 486d8fb5baeSMatt Spinler void scheduleObmcLogDelete(uint32_t obmcLogID); 487d8fb5baeSMatt Spinler 488d8fb5baeSMatt Spinler /** 489d8fb5baeSMatt Spinler * @brief SD event callback to delete an OpenBMC event log 490d8fb5baeSMatt Spinler * 491d8fb5baeSMatt Spinler * @param[in] obmcLogID - The OpenBMC entry log ID 492d8fb5baeSMatt Spinler */ 493d8fb5baeSMatt Spinler void deleteObmcLog(sdeventplus::source::EventBase&, uint32_t obmcLogID); 494d8fb5baeSMatt Spinler 495d8fb5baeSMatt Spinler /** 4960dd22c83SMatt Spinler * @brief Clears the deconfig flag in the PEL if necessary. 4970dd22c83SMatt Spinler * 4980dd22c83SMatt Spinler * If the passed in location code is in a callout and it's a PEL with 4990dd22c83SMatt Spinler * the BMC power/thermal or fans component ID, clear the deconfig flag. 5000dd22c83SMatt Spinler * 5010dd22c83SMatt Spinler * @param[in] locationCode - The location code to look for 5020dd22c83SMatt Spinler * @param[inout] pel - The PEL to check and modify. 5030dd22c83SMatt Spinler * @return bool - true if the flag was cleared for this PEL 5040dd22c83SMatt Spinler */ 5050dd22c83SMatt Spinler static bool clearPowerThermalDeconfigFlag(const std::string& locationCode, 5060dd22c83SMatt Spinler openpower::pels::PEL& pel); 5070dd22c83SMatt Spinler 5080dd22c83SMatt Spinler /** 5090dd22c83SMatt Spinler * @brief Called by DataInterface when the presence of hotpluggable 5100dd22c83SMatt Spinler * hardware is detected. 5110dd22c83SMatt Spinler * 5120dd22c83SMatt Spinler * Clears the 'Deconfig' flag in any PEL that has the location code 5130dd22c83SMatt Spinler * of the hardware in a callout. 5140dd22c83SMatt Spinler * 5150dd22c83SMatt Spinler * @param[in] locationCode - The location code of the hardware. 5160dd22c83SMatt Spinler */ 5170dd22c83SMatt Spinler void hardwarePresent(const std::string& locationCode); 5180dd22c83SMatt Spinler 5190dd22c83SMatt Spinler /** 5204e8078c0SMatt Spinler * @brief Reference to phosphor-logging's Manager class 5214e8078c0SMatt Spinler */ 522367144cfSMatt Spinler phosphor::logging::internal::Manager& _logManager; 52389fa082aSMatt Spinler 52489fa082aSMatt Spinler /** 525f682b40dSMatt Spinler * @brief Handles creating event logs/PELs from within 526f682b40dSMatt Spinler * the PEL extension code 527f682b40dSMatt Spinler */ 528f682b40dSMatt Spinler EventLogger _eventLogger; 529f682b40dSMatt Spinler 530f682b40dSMatt Spinler /** 53189fa082aSMatt Spinler * @brief The PEL repository object 53289fa082aSMatt Spinler */ 53389fa082aSMatt Spinler Repository _repo; 534c8705e2bSMatt Spinler 535c8705e2bSMatt Spinler /** 536367144cfSMatt Spinler * @brief The PEL message registry object 537367144cfSMatt Spinler */ 538367144cfSMatt Spinler message::Registry _registry; 539367144cfSMatt Spinler 540367144cfSMatt Spinler /** 541ff9cec25SMatt Spinler * @brief The Event object this class uses 542ff9cec25SMatt Spinler */ 543ff9cec25SMatt Spinler sdeventplus::Event _event; 544ff9cec25SMatt Spinler 545ff9cec25SMatt Spinler /** 546c8705e2bSMatt Spinler * @brief The API the PEL sections use to gather data 547c8705e2bSMatt Spinler */ 548c8705e2bSMatt Spinler std::unique_ptr<DataInterfaceBase> _dataIface; 549f60ac27eSMatt Spinler 550f60ac27eSMatt Spinler /** 551d96fa60dSMatt Spinler * @brief Object used to read from the journal 552d96fa60dSMatt Spinler */ 553d96fa60dSMatt Spinler std::unique_ptr<JournalBase> _journal; 554d96fa60dSMatt Spinler 555d96fa60dSMatt Spinler /** 556afb1b46fSVijay Lobo * @brief The map used to keep track of PEL entry pointer associated with 557afb1b46fSVijay Lobo * event log. 558afb1b46fSVijay Lobo */ 559afb1b46fSVijay Lobo std::map<std::string, 560afb1b46fSVijay Lobo std::unique_ptr< 5616ddbf69eSWilly Tu sdbusplus::server::org::open_power::logging::pel::Entry>> 562afb1b46fSVijay Lobo _pelEntries; 563afb1b46fSVijay Lobo 564afb1b46fSVijay Lobo /** 565f60ac27eSMatt Spinler * @brief The HostNotifier object used for telling the 566f60ac27eSMatt Spinler * host about new PELs 567f60ac27eSMatt Spinler */ 568f60ac27eSMatt Spinler std::unique_ptr<HostNotifier> _hostNotifier; 5696b1a5c83SMatt Spinler 5706b1a5c83SMatt Spinler /** 5716b1a5c83SMatt Spinler * @brief The event source for closing a PEL file descriptor after 5726b1a5c83SMatt Spinler * it has been returned from the getPEL D-Bus method. 5736b1a5c83SMatt Spinler */ 5746b1a5c83SMatt Spinler std::unique_ptr<sdeventplus::source::Defer> _fdCloserEventSource; 5757e727a39SMatt Spinler 5767e727a39SMatt Spinler /** 5777e727a39SMatt Spinler * @brief The even source for removing old PELs when the repo is 5787e727a39SMatt Spinler * running out of space to make room for new ones. 5797e727a39SMatt Spinler */ 5807e727a39SMatt Spinler std::unique_ptr<sdeventplus::source::Defer> _repoPrunerEventSource; 581ff9cec25SMatt Spinler 582ff9cec25SMatt Spinler /** 583d8fb5baeSMatt Spinler * @brief The event source for deleting an OpenBMC event log. 584d8fb5baeSMatt Spinler * Used when its corresponding PEL is invalid. 585d8fb5baeSMatt Spinler */ 586d8fb5baeSMatt Spinler std::unique_ptr<sdeventplus::source::Defer> _obmcLogDeleteEventSource; 587d8fb5baeSMatt Spinler 588d8fb5baeSMatt Spinler /** 589ff9cec25SMatt Spinler * @brief The even source for watching for deleted PEL files. 590ff9cec25SMatt Spinler */ 591ff9cec25SMatt Spinler std::unique_ptr<sdeventplus::source::IO> _pelFileDeleteEventSource; 592ff9cec25SMatt Spinler 593ff9cec25SMatt Spinler /** 594ff9cec25SMatt Spinler * @brief The file descriptor returned by inotify_init1() used 595ff9cec25SMatt Spinler * for watching for deleted PEL files. 596ff9cec25SMatt Spinler */ 597ff9cec25SMatt Spinler int _pelFileDeleteFD = -1; 598ff9cec25SMatt Spinler 599ff9cec25SMatt Spinler /** 600ff9cec25SMatt Spinler * @brief The file descriptor returned by inotify_add_watch(). 601ff9cec25SMatt Spinler */ 602ff9cec25SMatt Spinler int _pelFileDeleteWatchFD = -1; 6034e8078c0SMatt Spinler }; 6044e8078c0SMatt Spinler 6054e8078c0SMatt Spinler } // namespace pels 6064e8078c0SMatt Spinler } // namespace openpower 607