1b61b107fSTom Joseph #pragma once 270dbc587SMatthew Barth 3822eaf6dSWilliam A. Kennington III #include <ipmid/api.h> 402261c0cSPatrick Venture #include <stdint.h> 570dbc587SMatthew Barth 6b61b107fSTom Joseph #include <map> 702261c0cSPatrick Venture #include <string> 870dbc587SMatthew Barth 9*81c34dfeSAdriana Kobylak static constexpr auto propertiesIntf = "org.freedesktop.DBus.Properties"; 10*81c34dfeSAdriana Kobylak static constexpr auto bmcUpdaterServiceName = 11*81c34dfeSAdriana Kobylak "xyz.openbmc_project.Software.BMC.Updater"; 12*81c34dfeSAdriana Kobylak static constexpr auto softwarePath = "/xyz/openbmc_project/software"; 13*81c34dfeSAdriana Kobylak static constexpr auto factoryResetIntf = 14*81c34dfeSAdriana Kobylak "xyz.openbmc_project.Common.FactoryReset"; 15*81c34dfeSAdriana Kobylak static constexpr auto stateChassisPath = "/xyz/openbmc_project/state/chassis0"; 16*81c34dfeSAdriana Kobylak static constexpr auto stateChassisIntf = "xyz.openbmc_project.State.Chassis"; 17*81c34dfeSAdriana Kobylak static constexpr auto stateBmcPath = "/xyz/openbmc_project/state/bmc0"; 18*81c34dfeSAdriana Kobylak static constexpr auto stateBmcIntf = "xyz.openbmc_project.State.BMC"; 19*81c34dfeSAdriana Kobylak 2070dbc587SMatthew Barth // IPMI commands for net functions. 2170dbc587SMatthew Barth enum ipmi_netfn_oem_cmds 2270dbc587SMatthew Barth { 2370dbc587SMatthew Barth IPMI_CMD_PREP_FW_UPDATE = 0x10, 24*81c34dfeSAdriana Kobylak IPMI_CMD_BMC_FACTORY_RESET = 0x11, 2570dbc587SMatthew Barth IPMI_CMD_PESEL = 0xF0, 2607655065SVishwanatha Subbanna IPMI_CMD_OCC_RESET = 0x0E, 2770dbc587SMatthew Barth }; 2870dbc587SMatthew Barth 29246bc0d6STom Joseph /** @brief Read eSEL data into a string 30246bc0d6STom Joseph * 31246bc0d6STom Joseph * @param[in] filename - filename of file containing eSEL 32246bc0d6STom Joseph * 33246bc0d6STom Joseph * @return On success return the eSEL data 34246bc0d6STom Joseph */ 35246bc0d6STom Joseph std::string readESEL(const char* filename); 3670dbc587SMatthew Barth 37246bc0d6STom Joseph /** @brief Create OCC metrics log entry 38246bc0d6STom Joseph * 39246bc0d6STom Joseph * @param[in] eSELData - eSEL data containing OCC metrics data 40246bc0d6STom Joseph */ 41246bc0d6STom Joseph void createLogEntry(const std::string& eSELData); 4270dbc587SMatthew Barth 4370dbc587SMatthew Barth ipmi_ret_t ipmi_ibm_oem_partial_esel(ipmi_netfn_t netfn, ipmi_cmd_t cmd, 4402261c0cSPatrick Venture ipmi_request_t request, 4502261c0cSPatrick Venture ipmi_response_t response, 4602261c0cSPatrick Venture ipmi_data_len_t data_len, 4702261c0cSPatrick Venture ipmi_context_t context); 4870dbc587SMatthew Barth 4902261c0cSPatrick Venture struct esel_request_t 5002261c0cSPatrick Venture { 5170dbc587SMatthew Barth uint16_t resid; 5270dbc587SMatthew Barth uint16_t selrecord; 5370dbc587SMatthew Barth uint16_t offset; 5470dbc587SMatthew Barth uint8_t progress; 5570dbc587SMatthew Barth } __attribute__((packed)); 5670dbc587SMatthew Barth 57b61b107fSTom Joseph /** @struct SELEventRecord 58b61b107fSTom Joseph * 59b61b107fSTom Joseph * IPMI SEL event record format. 60b61b107fSTom Joseph */ 61b61b107fSTom Joseph struct SELEventRecord 62b61b107fSTom Joseph { 63b61b107fSTom Joseph uint16_t recordID; //!< Record ID. 64b61b107fSTom Joseph uint8_t recordType; //!< Record Type. 65b61b107fSTom Joseph uint32_t timeStamp; //!< Timestamp. 66b61b107fSTom Joseph uint16_t generatorID; //!< Generator ID. 67b61b107fSTom Joseph uint8_t eventMsgRevision; //!< Event Message Revision. 68b61b107fSTom Joseph uint8_t sensorType; //!< Sensor Type. 69b61b107fSTom Joseph uint8_t sensorNum; //!< Sensor Number. 70b61b107fSTom Joseph uint8_t eventType; //!< Event Dir | Event Type. 71b61b107fSTom Joseph uint8_t eventData1; //!< Event Data 1. 72b61b107fSTom Joseph uint8_t eventData2; //!< Event Data 2. 73b61b107fSTom Joseph uint8_t eventData3; //!< Event Data 3. 74b61b107fSTom Joseph } __attribute__((packed)); 75b61b107fSTom Joseph 76b61b107fSTom Joseph using Id = uint8_t; 77b61b107fSTom Joseph using Type = uint8_t; 78b61b107fSTom Joseph using ReadingType = uint8_t; 79b61b107fSTom Joseph using Offset = uint8_t; 80b61b107fSTom Joseph using Path = std::string; 81b61b107fSTom Joseph 82b61b107fSTom Joseph struct Data 83b61b107fSTom Joseph { 84b61b107fSTom Joseph Id sensorID; 85b61b107fSTom Joseph Type sensorType; 86b61b107fSTom Joseph ReadingType eventReadingType; 87b61b107fSTom Joseph Offset eventOffset; 88b61b107fSTom Joseph }; 89b61b107fSTom Joseph 90b61b107fSTom Joseph using ObjectIDMap = std::map<Path, Data>; 91