blob: e51e9ca587f720af699dd9a064fb950102e23c30 [file] [log] [blame]
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001/*
2 * Copyright (c) 2018-present Facebook. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
Vijay Khemka1b6fae32019-03-25 17:43:01 -070018#include "sdrutils.hpp"
Vijay Khemkae7d23d02019-03-08 13:13:40 -080019
Vijay Khemka11b9c3b2019-08-21 15:21:42 -070020#define SEL_JSON_DATA_FILE "/var/log/fbSelRaw.json"
21#define KEY_SEL_COUNT "SelCount"
22#define KEY_SEL_ENTRY_RAW "SelEntry"
23#define KEY_ADD_TIME "AddTimeStamp"
24#define KEY_ERASE_TIME "EraseTimeStamp"
25#define KEY_FREE_SPACE "FreeSpace"
26#define KEY_OPER_SUPP "OperationalSupport"
27#define KEY_SEL_VER "SELVersion"
28
Vijay Khemkae7d23d02019-03-08 13:13:40 -080029static constexpr uint8_t ipmiSdrVersion = 0x51;
30
31#pragma pack(push, 1)
32
33struct GetSDRReq
34{
35 uint16_t reservationID;
36 uint16_t recordID;
37 uint8_t offset;
38 uint8_t bytesToRead;
39};
40
41struct GetFRUAreaReq
42{
43 uint8_t fruDeviceID;
44 uint16_t fruInventoryOffset;
45 uint8_t countToRead;
46};
47
48struct WriteFRUDataReq
49{
50 uint8_t fruDeviceID;
51 uint16_t fruInventoryOffset;
52 uint8_t data[];
53};
54
55#pragma pack(pop)
56
57enum class GetFRUAreaAccessType : uint8_t
58{
59 byte = 0x0,
60 words = 0x1
61};
62
63enum class IPMINetfnStorageCmds : ipmi_cmd_t
64{
65 ipmiCmdGetFRUInvAreaInfo = 0x10,
66 ipmiCmdReadFRUData = 0x11,
67 ipmiCmdWriteFRUData = 0x12,
68 ipmiCmdGetRepositoryInfo = 0x20,
69 ipmiCmdGetSDRAllocationInfo = 0x21,
70 ipmiCmdReserveSDR = 0x22,
71 ipmiCmdGetSDR = 0x23,
72 ipmiCmdGetSELInfo = 0x40,
73 ipmiCmdReserveSEL = 0x42,
74 ipmiCmdGetSELEntry = 0x43,
75 ipmiCmdAddSEL = 0x44,
76 ipmiCmdDeleteSEL = 0x46,
77 ipmiCmdClearSEL = 0x47,
78 ipmiCmdGetSELTime = 0x48,
79 ipmiCmdSetSELTime = 0x49,
80};
81
82#pragma pack(push, 1)
83struct FRUHeader
84{
85 uint8_t commonHeaderFormat;
86 uint8_t internalOffset;
87 uint8_t chassisOffset;
88 uint8_t boardOffset;
89 uint8_t productOffset;
90 uint8_t multiRecordOffset;
91 uint8_t pad;
92 uint8_t checksum;
93};
94#pragma pack(pop)
Vijay Khemka11b9c3b2019-08-21 15:21:42 -070095
96namespace fb_oem::ipmi::sel
97{
98
99static constexpr auto selVersion = 0x51;
100static constexpr auto invalidTimeStamp = 0xFFFFFFFF;
101/* Spec indicates that more than 64kB is free */
102static constexpr auto freeSpace = 0xFFFF;
103static constexpr uint8_t selOperationSupport = 0x02;
104
105static constexpr auto firstEntry = 0x0000;
106static constexpr auto lastEntry = 0xFFFF;
107static constexpr auto entireRecord = 0xFF;
108static constexpr auto selRecordSize = 16;
109
Vijay Khemkaf36f3452019-08-09 13:24:45 -0700110static constexpr auto stdErr = "Standard";
111static constexpr auto oemTSErr = "OEM timestamped";
112static constexpr auto oemNTSErr = "OEM non-timestamped";
113static constexpr auto unknownErr = "Unknown";
114
115static constexpr uint8_t stdErrType = 0x02;
116static constexpr uint8_t oemTSErrTypeMin = 0xC0;
117static constexpr uint8_t oemTSErrTypeMax = 0xDF;
118static constexpr uint8_t oemNTSErrTypeMin = 0xE0;
119static constexpr uint8_t oemNTSErrTypeMax = 0xFF;
120
121static constexpr uint8_t unifiedPcieErr = 0;
122static constexpr uint8_t unifiedMemErr = 1;
123
124/* event sensor name in processing SEL */
125static constexpr uint8_t memoryEccError = 0X63;
126static constexpr uint8_t memoryErrLogDIS = 0X87;
127
128static boost::container::flat_map<uint8_t, std::string> sensorNameTable = {
129 {0xE9, "SYSTEM_EVENT"},
130 {0x7D, "THERM_THRESH_EVT"},
131 {0xAA, "BUTTON"},
132 {0xAB, "POWER_STATE"},
133 {0xEA, "CRITICAL_IRQ"},
134 {0x2B, "POST_ERROR"},
135 {0x40, "MACHINE_CHK_ERR"},
136 {0x41, "PCIE_ERR"},
137 {0x43, "IIO_ERR"},
138 {0X63, "MEMORY_ECC_ERR"},
139 {0X87, "MEMORY_ERR_LOG_DIS"},
140 {0X51, "PROCHOT_EXT"},
141 {0X56, "PWR_ERR"},
142 {0xE6, "CATERR_A"},
143 {0xEB, "CATERR_B"},
144 {0xB3, "CPU_DIMM_HOT"},
145 {0x90, "SOFTWARE_NMI"},
146 {0x1C, "CPU0_THERM_STATUS"},
147 {0x1D, "CPU1_THERM_STATUS"},
148 {0x16, "ME_POWER_STATE"},
149 {0x17, "SPS_FW_HEALTH"},
150 {0x18, "NM_EXCEPTION_A"},
151 {0x08, "PCH_THERM_THRESHOLD"},
152 {0x19, "NM_HEALTH"},
153 {0x1A, "NM_CAPABILITIES"},
154 {0x1B, "NM_THRESHOLD"},
155 {0x3B, "PWR_THRESH_EVT"},
156 {0xE7, "MSMI"},
157 {0xC5, "HPR_WARNING"}};
158
Vijay Khemka11b9c3b2019-08-21 15:21:42 -0700159/** @struct GetSELInfoData
160 *
161 * IPMI response payload data for Get SEL Info request
162 */
163struct GetSELInfoData
164{
165 uint8_t selVersion;
166 uint16_t entries;
167 uint16_t freeSpace;
168 uint32_t addTimeStamp;
169 uint32_t eraseTimeStamp;
170 uint8_t operationSupport;
171};
172
173/** @struct GetSELEntryRequest
174 *
175 * IPMI payload for Get SEL Entry command request.
176 */
177struct GetSELEntryRequest
178{
179 uint16_t reservID; //!< Reservation ID.
180 uint16_t recordID; //!< SEL Record ID.
181 uint8_t offset; //!< Offset into record.
182 uint8_t readLen; //!< Bytes to read.
183} __attribute__((packed));
184
185/** @struct GetSELEntryResponse
186 *
187 * IPMI payload for Get SEL Entry command response.
188 */
189struct GetSELEntryResponse
190{
191 uint16_t nextRecordID; //!< Next RecordID.
192 uint8_t recordData[16]; //!< Record Data.
193} __attribute__((packed));
194
Vijay Khemkaf36f3452019-08-09 13:24:45 -0700195/** @struct AddSELEntryRequest
196 *
197 * IPMI payload for ADD SEL Entry command request.
198 */
199struct StdSELEntry
200{
201 uint16_t recordID; //!< Record ID.
202 uint8_t recordType; //!< Record Type.
203 uint32_t timeStamp; //!< Timestamp.
204 uint16_t generatorID; //!< Generator ID.
205 uint8_t eventMsgRevision; //!< Event Message Revision.
206 uint8_t sensorType; //!< Sensor Type.
207 uint8_t sensorNum; //!< Sensor Number.
208 uint8_t eventType; //!< Event Dir | Event Type.
209 uint8_t eventData1; //!< Event Data 1.
210 uint8_t eventData2; //!< Event Data 2.
211 uint8_t eventData3; //!< Event Data 3.
212} __attribute__((packed));
213
214struct TsOemSELEntry
215{
216 uint16_t recordID; //!< Record ID.
217 uint8_t recordType; //!< Record Type.
218 uint32_t timeStamp; //!< Timestamp.
219 uint8_t mfrId[3]; //!< Manufacturer Id.
220 uint8_t oemData[6]; //!< OEM Data.
221} __attribute__((packed));
222
223struct NtsOemSELEntry
224{
225 uint16_t recordID; //!< Record ID.
226 uint8_t recordType; //!< Record Type.
227 uint8_t oemData[13]; //!< OEM Data.
228} __attribute__((packed));
229
Vijay Khemkac1921c62019-08-09 13:11:31 -0700230static constexpr auto initiateErase = 0xAA;
231static constexpr auto getEraseStatus = 0x00;
232static constexpr auto eraseComplete = 0x01;
233
Vijay Khemka11b9c3b2019-08-21 15:21:42 -0700234} // namespace fb_oem::ipmi::sel