Tom Joseph | b61b107 | 2019-01-28 12:32:52 +0530 | [diff] [blame] | 1 | #pragma once |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 2 | |
William A. Kennington III | 822eaf6 | 2019-02-12 15:20:06 -0800 | [diff] [blame] | 3 | #include <ipmid/api.h> |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 4 | #include <stdint.h> |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 5 | |
Tom Joseph | b61b107 | 2019-01-28 12:32:52 +0530 | [diff] [blame] | 6 | #include <map> |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 7 | #include <string> |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 8 | |
Adriana Kobylak | 81c34df | 2018-11-01 11:44:16 -0500 | [diff] [blame] | 9 | static constexpr auto propertiesIntf = "org.freedesktop.DBus.Properties"; |
| 10 | static constexpr auto bmcUpdaterServiceName = |
| 11 | "xyz.openbmc_project.Software.BMC.Updater"; |
| 12 | static constexpr auto softwarePath = "/xyz/openbmc_project/software"; |
| 13 | static constexpr auto factoryResetIntf = |
| 14 | "xyz.openbmc_project.Common.FactoryReset"; |
| 15 | static constexpr auto stateChassisPath = "/xyz/openbmc_project/state/chassis0"; |
| 16 | static constexpr auto stateChassisIntf = "xyz.openbmc_project.State.Chassis"; |
| 17 | static constexpr auto stateBmcPath = "/xyz/openbmc_project/state/bmc0"; |
| 18 | static constexpr auto stateBmcIntf = "xyz.openbmc_project.State.BMC"; |
| 19 | |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 20 | // IPMI commands for net functions. |
| 21 | enum ipmi_netfn_oem_cmds |
| 22 | { |
Adriana Kobylak | 187bfce | 2016-03-04 11:55:43 -0600 | [diff] [blame] | 23 | IPMI_CMD_PREP_FW_UPDATE = 0x10, |
Adriana Kobylak | 81c34df | 2018-11-01 11:44:16 -0500 | [diff] [blame] | 24 | IPMI_CMD_BMC_FACTORY_RESET = 0x11, |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 25 | IPMI_CMD_PESEL = 0xF0, |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 26 | IPMI_CMD_OCC_RESET = 0x0E, |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 27 | }; |
| 28 | |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 29 | /** @brief Read eSEL data into a string |
| 30 | * |
| 31 | * @param[in] filename - filename of file containing eSEL |
| 32 | * |
| 33 | * @return On success return the eSEL data |
| 34 | */ |
| 35 | std::string readESEL(const char* filename); |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 36 | |
Tom Joseph | 246bc0d | 2017-10-17 16:08:38 +0530 | [diff] [blame] | 37 | /** @brief Create OCC metrics log entry |
| 38 | * |
| 39 | * @param[in] eSELData - eSEL data containing OCC metrics data |
| 40 | */ |
| 41 | void createLogEntry(const std::string& eSELData); |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 42 | |
Patrick Williams | 24fa5a9 | 2015-10-30 14:53:57 -0500 | [diff] [blame] | 43 | ipmi_ret_t ipmi_ibm_oem_partial_esel(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 44 | ipmi_request_t request, |
| 45 | ipmi_response_t response, |
| 46 | ipmi_data_len_t data_len, |
| 47 | ipmi_context_t context); |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 48 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 49 | struct esel_request_t |
| 50 | { |
| 51 | uint16_t resid; |
| 52 | uint16_t selrecord; |
| 53 | uint16_t offset; |
| 54 | uint8_t progress; |
| 55 | } __attribute__((packed)); |
Chris Austen | 4d98c1e | 2015-10-13 14:33:50 -0500 | [diff] [blame] | 56 | |
Tom Joseph | b61b107 | 2019-01-28 12:32:52 +0530 | [diff] [blame] | 57 | /** @struct SELEventRecord |
| 58 | * |
| 59 | * IPMI SEL event record format. |
| 60 | */ |
| 61 | struct SELEventRecord |
| 62 | { |
| 63 | uint16_t recordID; //!< Record ID. |
| 64 | uint8_t recordType; //!< Record Type. |
| 65 | uint32_t timeStamp; //!< Timestamp. |
| 66 | uint16_t generatorID; //!< Generator ID. |
| 67 | uint8_t eventMsgRevision; //!< Event Message Revision. |
| 68 | uint8_t sensorType; //!< Sensor Type. |
| 69 | uint8_t sensorNum; //!< Sensor Number. |
| 70 | uint8_t eventType; //!< Event Dir | Event Type. |
| 71 | uint8_t eventData1; //!< Event Data 1. |
| 72 | uint8_t eventData2; //!< Event Data 2. |
| 73 | uint8_t eventData3; //!< Event Data 3. |
| 74 | } __attribute__((packed)); |
| 75 | |
| 76 | using Id = uint8_t; |
| 77 | using Type = uint8_t; |
| 78 | using ReadingType = uint8_t; |
| 79 | using Offset = uint8_t; |
| 80 | using Path = std::string; |
| 81 | |
| 82 | struct Data |
| 83 | { |
| 84 | Id sensorID; |
| 85 | Type sensorType; |
| 86 | ReadingType eventReadingType; |
| 87 | Offset eventOffset; |
| 88 | }; |
| 89 | |
| 90 | using ObjectIDMap = std::map<Path, Data>; |