blob: 57ed24fc85ae44cf0822c91885480c39c945252e [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 Joseph306878b2017-07-10 19:30:54 +053024using PropertyName = std::string;
25using Resolved = bool;
26using Id = uint32_t;
27using Timestamp = uint64_t;
28using Message = std::string;
29using AdditionalData = std::vector<std::string>;
30using PropertyType = sdbusplus::message::variant<Resolved, Id, Timestamp,
31 Message, AdditionalData>;
Tom Joseph6b7a1432017-05-19 10:43:36 +053032
Tom Joseph6f7deaa2017-06-30 19:03:54 +053033static constexpr auto selVersion = 0x51;
34static constexpr auto invalidTimeStamp = 0xFFFFFFFF;
35static constexpr auto operationSupport = 0x0A;
36
37/** @struct GetSELInfoResponse
38 *
39 * IPMI payload for Get SEL Info command response.
40 */
41struct GetSELInfoResponse
42{
43 uint8_t selVersion; //!< SEL revision.
44 uint16_t entries; //!< Number of log entries in SEL.
45 uint16_t freeSpace; //!< Free Space in bytes.
46 uint32_t addTimeStamp; //!< Most recent addition timestamp.
47 uint32_t eraseTimeStamp; //!< Most recent erase timestamp.
48 uint8_t operationSupport; //!< Operation support.
49} __attribute__((packed));
50
Tom Josepha4953392017-06-30 19:09:47 +053051static constexpr auto firstEntry = 0x0000;
52static constexpr auto lastEntry = 0xFFFF;
53static constexpr auto entireRecord = 0xFF;
54static constexpr auto selRecordSize = 16;
55
56/** @struct GetSELEntryRequest
57 *
58 * IPMI payload for Get SEL Entry command request.
59 */
60struct GetSELEntryRequest
61{
62 uint16_t reservationID; //!< Reservation ID.
63 uint16_t selRecordID; //!< SEL Record ID.
64 uint8_t offset; //!< Offset into record.
65 uint8_t readLength; //!< Bytes to read.
66} __attribute__((packed));
67
Tom Joseph6b7a1432017-05-19 10:43:36 +053068/** @struct GetSELEntryResponse
69 *
70 * IPMI payload for Get SEL Entry command response.
71 */
72struct GetSELEntryResponse
73{
74 uint16_t nextRecordID; //!< Next RecordID.
75 uint16_t recordID; //!< Record ID.
76 uint8_t recordType; //!< Record Type.
77 uint32_t timeStamp; //!< Timestamp.
78 uint16_t generatorID; //!< Generator ID.
79 uint8_t eventMsgRevision; //!< Event Message Revision.
80 uint8_t sensorType; //!< Sensor Type.
81 uint8_t sensorNum; //!< Sensor Number.
82 uint8_t eventType; //!< Event Dir | Event Type.
83 uint8_t eventData1; //!< Event Data 1.
84 uint8_t eventData2; //!< Event Data 2.
85 uint8_t eventData3; //!< Event Data 3.
86} __attribute__((packed));
87
Tom Joseph8f4a2aa2017-06-30 19:12:49 +053088/** @struct DeleteSELEntryRequest
89 *
90 * IPMI payload for Delete SEL Entry command request.
91 */
92struct DeleteSELEntryRequest
93{
94 uint16_t reservationID; //!< Reservation ID.
95 uint16_t selRecordID; //!< SEL Record ID.
96} __attribute__((packed));
97
Tom Joseph2f05bb52017-06-30 19:14:49 +053098static constexpr auto initiateErase = 0xAA;
99static constexpr auto getEraseStatus = 0x00;
100static constexpr auto eraseComplete = 0x01;
101
102/** @struct ClearSELRequest
103 *
104 * IPMI payload for Clear SEL command request.
105 */
106struct ClearSELRequest
107{
108 uint16_t reservationID; //!< Reservation ID.
109 uint8_t charC; //!< Char 'C'(0x43h).
110 uint8_t charL; //!< Char 'L'(0x4Ch).
111 uint8_t charR; //!< Char 'R'(0x52h).
112 uint8_t eraseOperation; //!< Erase operation.
113} __attribute__((packed));
114
Tom Joseph6edc8a02017-06-30 18:52:56 +0530115/** @brief Convert logging entry to SEL
116 *
117 * @param[in] objPath - DBUS object path of the logging entry.
118 *
119 * @return On success return the response of Get SEL entry command.
120 */
121GetSELEntryResponse convertLogEntrytoSEL(const std::string& objPath);
122
Tom Joseph399fd922017-06-30 18:40:30 +0530123/** @brief Get the timestamp of the log entry
124 *
125 * @param[in] objPath - DBUS object path of the logging entry.
126 *
127 * @return On success return the timestamp of the log entry as number of
128 * seconds from epoch.
129 */
130std::chrono::seconds getEntryTimeStamp(const std::string& objPath);
Tom Joseph6edc8a02017-06-30 18:52:56 +0530131
Tom Joseph232f5292017-07-07 20:14:02 +0530132/** @brief Read the logging entry object paths
133 *
134 * This API would read the logging dbus logging entry object paths and sorting
135 * the filename in the numeric order. The paths is cleared before populating
136 * the object paths.
137 *
138 * @param[in,out] paths - sorted list of logging entry object paths.
139 *
140 * @note This function is invoked when the Get SEL Info command or the Delete
141 * SEL entry command is invoked. The Get SEL Entry command is preceded
142 * typically by Get SEL Info command, so readLoggingObjectPaths is not
143 * invoked before each Get SEL entry command.
144 */
145void readLoggingObjectPaths(ObjectPaths& paths);
146
Tom Joseph6b7a1432017-05-19 10:43:36 +0530147namespace internal
148{
149
150/** @brief Convert logging entry to SEL event record
151 *
152 * @param[in] objPath - DBUS object path of the logging entry.
153 * @param[in] iter - Iterator to the sensor data corresponding to the logging
154 * entry
155 *
156 * @return On success return the SEL event record, throw an exception in case
157 * of failure.
158 */
159GetSELEntryResponse prepareSELEntry(
160 const std::string& objPath,
161 ipmi::sensor::InvObjectIDMap::const_iterator iter);
162
Tom Joseph399fd922017-06-30 18:40:30 +0530163}
Tom Joseph6b7a1432017-05-19 10:43:36 +0530164
165} // namespace sel
166
167} // namespace ipmi