1 #pragma once
2 
3 #include <ipmid/api.h>
4 #include <stdint.h>
5 
6 #include <map>
7 #include <string>
8 
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 
20 // IPMI commands for net functions.
21 enum ipmi_netfn_oem_cmds
22 {
23     IPMI_CMD_PREP_FW_UPDATE = 0x10,
24     IPMI_CMD_BMC_FACTORY_RESET = 0x11,
25     IPMI_CMD_PESEL = 0xF0,
26     IPMI_CMD_OCC_RESET = 0x0E,
27 };
28 
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);
36 
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);
42 
43 ipmi_ret_t ipmi_ibm_oem_partial_esel(
44     ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t request,
45     ipmi_response_t response, ipmi_data_len_t data_len, ipmi_context_t context);
46 
47 struct esel_request_t
48 {
49     uint16_t resid;
50     uint16_t selrecord;
51     uint16_t offset;
52     uint8_t progress;
53 } __attribute__((packed));
54 
55 /** @struct SELEventRecord
56  *
57  *  IPMI SEL event record format.
58  */
59 struct SELEventRecord
60 {
61     uint16_t recordID;        //!< Record ID.
62     uint8_t recordType;       //!< Record Type.
63     uint32_t timeStamp;       //!< Timestamp.
64     uint16_t generatorID;     //!< Generator ID.
65     uint8_t eventMsgRevision; //!< Event Message Revision.
66     uint8_t sensorType;       //!< Sensor Type.
67     uint8_t sensorNum;        //!< Sensor Number.
68     uint8_t eventType;        //!< Event Dir | Event Type.
69     uint8_t eventData1;       //!< Event Data 1.
70     uint8_t eventData2;       //!< Event Data 2.
71     uint8_t eventData3;       //!< Event Data 3.
72 } __attribute__((packed));
73 
74 using Id = uint8_t;
75 using Type = uint8_t;
76 using ReadingType = uint8_t;
77 using Offset = uint8_t;
78 using Path = std::string;
79 
80 struct Data
81 {
82     Id sensorID;
83     Type sensorType;
84     ReadingType eventReadingType;
85     Offset eventOffset;
86 };
87 
88 using ObjectIDMap = std::map<Path, Data>;
89