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 981c34dfeSAdriana Kobylak static constexpr auto propertiesIntf = "org.freedesktop.DBus.Properties"; 1081c34dfeSAdriana Kobylak static constexpr auto bmcUpdaterServiceName = 1181c34dfeSAdriana Kobylak "xyz.openbmc_project.Software.BMC.Updater"; 1281c34dfeSAdriana Kobylak static constexpr auto softwarePath = "/xyz/openbmc_project/software"; 1381c34dfeSAdriana Kobylak static constexpr auto factoryResetIntf = 1481c34dfeSAdriana Kobylak "xyz.openbmc_project.Common.FactoryReset"; 1581c34dfeSAdriana Kobylak static constexpr auto stateChassisPath = "/xyz/openbmc_project/state/chassis0"; 1681c34dfeSAdriana Kobylak static constexpr auto stateChassisIntf = "xyz.openbmc_project.State.Chassis"; 1781c34dfeSAdriana Kobylak static constexpr auto stateBmcPath = "/xyz/openbmc_project/state/bmc0"; 1881c34dfeSAdriana Kobylak static constexpr auto stateBmcIntf = "xyz.openbmc_project.State.BMC"; 1981c34dfeSAdriana 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, 2481c34dfeSAdriana 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 43*d9c74acdSPatrick Williams ipmi_ret_t ipmi_ibm_oem_partial_esel( 44*d9c74acdSPatrick Williams ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t request, 45*d9c74acdSPatrick Williams ipmi_response_t response, ipmi_data_len_t data_len, ipmi_context_t context); 4670dbc587SMatthew Barth 4702261c0cSPatrick Venture struct esel_request_t 4802261c0cSPatrick Venture { 4970dbc587SMatthew Barth uint16_t resid; 5070dbc587SMatthew Barth uint16_t selrecord; 5170dbc587SMatthew Barth uint16_t offset; 5270dbc587SMatthew Barth uint8_t progress; 5370dbc587SMatthew Barth } __attribute__((packed)); 5470dbc587SMatthew Barth 55b61b107fSTom Joseph /** @struct SELEventRecord 56b61b107fSTom Joseph * 57b61b107fSTom Joseph * IPMI SEL event record format. 58b61b107fSTom Joseph */ 59b61b107fSTom Joseph struct SELEventRecord 60b61b107fSTom Joseph { 61b61b107fSTom Joseph uint16_t recordID; //!< Record ID. 62b61b107fSTom Joseph uint8_t recordType; //!< Record Type. 63b61b107fSTom Joseph uint32_t timeStamp; //!< Timestamp. 64b61b107fSTom Joseph uint16_t generatorID; //!< Generator ID. 65b61b107fSTom Joseph uint8_t eventMsgRevision; //!< Event Message Revision. 66b61b107fSTom Joseph uint8_t sensorType; //!< Sensor Type. 67b61b107fSTom Joseph uint8_t sensorNum; //!< Sensor Number. 68b61b107fSTom Joseph uint8_t eventType; //!< Event Dir | Event Type. 69b61b107fSTom Joseph uint8_t eventData1; //!< Event Data 1. 70b61b107fSTom Joseph uint8_t eventData2; //!< Event Data 2. 71b61b107fSTom Joseph uint8_t eventData3; //!< Event Data 3. 72b61b107fSTom Joseph } __attribute__((packed)); 73b61b107fSTom Joseph 74b61b107fSTom Joseph using Id = uint8_t; 75b61b107fSTom Joseph using Type = uint8_t; 76b61b107fSTom Joseph using ReadingType = uint8_t; 77b61b107fSTom Joseph using Offset = uint8_t; 78b61b107fSTom Joseph using Path = std::string; 79b61b107fSTom Joseph 80b61b107fSTom Joseph struct Data 81b61b107fSTom Joseph { 82b61b107fSTom Joseph Id sensorID; 83b61b107fSTom Joseph Type sensorType; 84b61b107fSTom Joseph ReadingType eventReadingType; 85b61b107fSTom Joseph Offset eventOffset; 86b61b107fSTom Joseph }; 87b61b107fSTom Joseph 88b61b107fSTom Joseph using ObjectIDMap = std::map<Path, Data>; 89