blob: 9c5f563e5e6bb01a986a8306227efe675792371e [file] [log] [blame]
Tom Josephb61b1072019-01-28 12:32:52 +05301#pragma once
Chris Austen4d98c1e2015-10-13 14:33:50 -05002
William A. Kennington III822eaf62019-02-12 15:20:06 -08003#include <ipmid/api.h>
Patrick Venture02261c02018-10-31 15:16:23 -07004#include <stdint.h>
Chris Austen4d98c1e2015-10-13 14:33:50 -05005
Tom Josephb61b1072019-01-28 12:32:52 +05306#include <map>
Patrick Venture02261c02018-10-31 15:16:23 -07007#include <string>
Chris Austen4d98c1e2015-10-13 14:33:50 -05008
Adriana Kobylak81c34df2018-11-01 11:44:16 -05009static constexpr auto propertiesIntf = "org.freedesktop.DBus.Properties";
10static constexpr auto bmcUpdaterServiceName =
11 "xyz.openbmc_project.Software.BMC.Updater";
12static constexpr auto softwarePath = "/xyz/openbmc_project/software";
13static constexpr auto factoryResetIntf =
14 "xyz.openbmc_project.Common.FactoryReset";
15static constexpr auto stateChassisPath = "/xyz/openbmc_project/state/chassis0";
16static constexpr auto stateChassisIntf = "xyz.openbmc_project.State.Chassis";
17static constexpr auto stateBmcPath = "/xyz/openbmc_project/state/bmc0";
18static constexpr auto stateBmcIntf = "xyz.openbmc_project.State.BMC";
19
Chris Austen4d98c1e2015-10-13 14:33:50 -050020// IPMI commands for net functions.
21enum ipmi_netfn_oem_cmds
22{
Adriana Kobylak187bfce2016-03-04 11:55:43 -060023 IPMI_CMD_PREP_FW_UPDATE = 0x10,
Adriana Kobylak81c34df2018-11-01 11:44:16 -050024 IPMI_CMD_BMC_FACTORY_RESET = 0x11,
Chris Austen4d98c1e2015-10-13 14:33:50 -050025 IPMI_CMD_PESEL = 0xF0,
Vishwanatha Subbanna07655062017-07-14 20:31:57 +053026 IPMI_CMD_OCC_RESET = 0x0E,
Chris Austen4d98c1e2015-10-13 14:33:50 -050027};
28
Tom Joseph246bc0d2017-10-17 16:08:38 +053029/** @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 */
35std::string readESEL(const char* filename);
Chris Austen4d98c1e2015-10-13 14:33:50 -050036
Tom Joseph246bc0d2017-10-17 16:08:38 +053037/** @brief Create OCC metrics log entry
38 *
39 * @param[in] eSELData - eSEL data containing OCC metrics data
40 */
41void createLogEntry(const std::string& eSELData);
Chris Austen4d98c1e2015-10-13 14:33:50 -050042
Patrick Williams24fa5a92015-10-30 14:53:57 -050043ipmi_ret_t ipmi_ibm_oem_partial_esel(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
Patrick Venture02261c02018-10-31 15:16:23 -070044 ipmi_request_t request,
45 ipmi_response_t response,
46 ipmi_data_len_t data_len,
47 ipmi_context_t context);
Chris Austen4d98c1e2015-10-13 14:33:50 -050048
Patrick Venture02261c02018-10-31 15:16:23 -070049struct esel_request_t
50{
51 uint16_t resid;
52 uint16_t selrecord;
53 uint16_t offset;
54 uint8_t progress;
55} __attribute__((packed));
Chris Austen4d98c1e2015-10-13 14:33:50 -050056
Tom Josephb61b1072019-01-28 12:32:52 +053057/** @struct SELEventRecord
58 *
59 * IPMI SEL event record format.
60 */
61struct 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
76using Id = uint8_t;
77using Type = uint8_t;
78using ReadingType = uint8_t;
79using Offset = uint8_t;
80using Path = std::string;
81
82struct Data
83{
84 Id sensorID;
85 Type sensorType;
86 ReadingType eventReadingType;
87 Offset eventOffset;
88};
89
90using ObjectIDMap = std::map<Path, Data>;