blob: 164ebe68c6cea3a7c561542eef3d79cde7694570 [file] [log] [blame]
Tom Joseph6b7a1432017-05-19 10:43:36 +05301#pragma once
2
3#include <cstdint>
4#include <sdbusplus/server.hpp>
5#include "types.hpp"
6
7namespace ipmi
8{
9
10namespace sel
11{
12
13static constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper";
14static constexpr auto mapperObjPath = "/xyz/openbmc_project/object_mapper";
15static constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
16
17static constexpr auto logBasePath = "/xyz/openbmc_project/logging/entry";
18static constexpr auto logEntryIntf = "xyz.openbmc_project.Logging.Entry";
19static constexpr auto logDeleteIntf = "xyz.openbmc_project.Object.Delete";
20
21static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
22
Tom Joseph232f5292017-07-07 20:14:02 +053023using ObjectPaths = std::vector<std::string>;
Tom Joseph6b7a1432017-05-19 10:43:36 +053024using PropertyType = sdbusplus::message::variant<bool, uint32_t, uint64_t,
25 std::string, std::vector<std::string>>;
26
Tom Joseph6f7deaa2017-06-30 19:03:54 +053027static constexpr auto selVersion = 0x51;
28static constexpr auto invalidTimeStamp = 0xFFFFFFFF;
29static constexpr auto operationSupport = 0x0A;
30
31/** @struct GetSELInfoResponse
32 *
33 * IPMI payload for Get SEL Info command response.
34 */
35struct GetSELInfoResponse
36{
37 uint8_t selVersion; //!< SEL revision.
38 uint16_t entries; //!< Number of log entries in SEL.
39 uint16_t freeSpace; //!< Free Space in bytes.
40 uint32_t addTimeStamp; //!< Most recent addition timestamp.
41 uint32_t eraseTimeStamp; //!< Most recent erase timestamp.
42 uint8_t operationSupport; //!< Operation support.
43} __attribute__((packed));
44
Tom Josepha4953392017-06-30 19:09:47 +053045static constexpr auto firstEntry = 0x0000;
46static constexpr auto lastEntry = 0xFFFF;
47static constexpr auto entireRecord = 0xFF;
48static constexpr auto selRecordSize = 16;
49
50/** @struct GetSELEntryRequest
51 *
52 * IPMI payload for Get SEL Entry command request.
53 */
54struct GetSELEntryRequest
55{
56 uint16_t reservationID; //!< Reservation ID.
57 uint16_t selRecordID; //!< SEL Record ID.
58 uint8_t offset; //!< Offset into record.
59 uint8_t readLength; //!< Bytes to read.
60} __attribute__((packed));
61
Tom Joseph6b7a1432017-05-19 10:43:36 +053062/** @struct GetSELEntryResponse
63 *
64 * IPMI payload for Get SEL Entry command response.
65 */
66struct GetSELEntryResponse
67{
68 uint16_t nextRecordID; //!< Next RecordID.
69 uint16_t recordID; //!< Record ID.
70 uint8_t recordType; //!< Record Type.
71 uint32_t timeStamp; //!< Timestamp.
72 uint16_t generatorID; //!< Generator ID.
73 uint8_t eventMsgRevision; //!< Event Message Revision.
74 uint8_t sensorType; //!< Sensor Type.
75 uint8_t sensorNum; //!< Sensor Number.
76 uint8_t eventType; //!< Event Dir | Event Type.
77 uint8_t eventData1; //!< Event Data 1.
78 uint8_t eventData2; //!< Event Data 2.
79 uint8_t eventData3; //!< Event Data 3.
80} __attribute__((packed));
81
Tom Joseph8f4a2aa2017-06-30 19:12:49 +053082/** @struct DeleteSELEntryRequest
83 *
84 * IPMI payload for Delete SEL Entry command request.
85 */
86struct DeleteSELEntryRequest
87{
88 uint16_t reservationID; //!< Reservation ID.
89 uint16_t selRecordID; //!< SEL Record ID.
90} __attribute__((packed));
91
Tom Joseph2f05bb52017-06-30 19:14:49 +053092static constexpr auto initiateErase = 0xAA;
93static constexpr auto getEraseStatus = 0x00;
94static constexpr auto eraseComplete = 0x01;
95
96/** @struct ClearSELRequest
97 *
98 * IPMI payload for Clear SEL command request.
99 */
100struct ClearSELRequest
101{
102 uint16_t reservationID; //!< Reservation ID.
103 uint8_t charC; //!< Char 'C'(0x43h).
104 uint8_t charL; //!< Char 'L'(0x4Ch).
105 uint8_t charR; //!< Char 'R'(0x52h).
106 uint8_t eraseOperation; //!< Erase operation.
107} __attribute__((packed));
108
Tom Joseph6edc8a02017-06-30 18:52:56 +0530109/** @brief Convert logging entry to SEL
110 *
111 * @param[in] objPath - DBUS object path of the logging entry.
112 *
113 * @return On success return the response of Get SEL entry command.
114 */
115GetSELEntryResponse convertLogEntrytoSEL(const std::string& objPath);
116
Tom Joseph399fd922017-06-30 18:40:30 +0530117/** @brief Get the timestamp of the log entry
118 *
119 * @param[in] objPath - DBUS object path of the logging entry.
120 *
121 * @return On success return the timestamp of the log entry as number of
122 * seconds from epoch.
123 */
124std::chrono::seconds getEntryTimeStamp(const std::string& objPath);
Tom Joseph6edc8a02017-06-30 18:52:56 +0530125
Tom Joseph232f5292017-07-07 20:14:02 +0530126/** @brief Read the logging entry object paths
127 *
128 * This API would read the logging dbus logging entry object paths and sorting
129 * the filename in the numeric order. The paths is cleared before populating
130 * the object paths.
131 *
132 * @param[in,out] paths - sorted list of logging entry object paths.
133 *
134 * @note This function is invoked when the Get SEL Info command or the Delete
135 * SEL entry command is invoked. The Get SEL Entry command is preceded
136 * typically by Get SEL Info command, so readLoggingObjectPaths is not
137 * invoked before each Get SEL entry command.
138 */
139void readLoggingObjectPaths(ObjectPaths& paths);
140
Tom Joseph6b7a1432017-05-19 10:43:36 +0530141namespace internal
142{
143
144/** @brief Convert logging entry to SEL event record
145 *
146 * @param[in] objPath - DBUS object path of the logging entry.
147 * @param[in] iter - Iterator to the sensor data corresponding to the logging
148 * entry
149 *
150 * @return On success return the SEL event record, throw an exception in case
151 * of failure.
152 */
153GetSELEntryResponse prepareSELEntry(
154 const std::string& objPath,
155 ipmi::sensor::InvObjectIDMap::const_iterator iter);
156
Tom Joseph399fd922017-06-30 18:40:30 +0530157}
Tom Joseph6b7a1432017-05-19 10:43:36 +0530158
159} // namespace sel
160
161} // namespace ipmi