blob: 78a83934fc050f01352e4ae285ec6547c35edf8b [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"
Vijay Khemka139aa4f2019-08-16 09:57:41 -070028#define BIT(value, index) ((value >> index) & 1)
Vijay Khemka11b9c3b2019-08-21 15:21:42 -070029
Vijay Khemkae7d23d02019-03-08 13:13:40 -080030static constexpr uint8_t ipmiSdrVersion = 0x51;
31
32#pragma pack(push, 1)
33
34struct GetSDRReq
35{
36 uint16_t reservationID;
37 uint16_t recordID;
38 uint8_t offset;
39 uint8_t bytesToRead;
40};
41
Vijay Khemka17cf1342020-11-02 14:44:42 -080042struct GetFRUAreaResp
43{
44 uint8_t inventorySizeLSB;
45 uint8_t inventorySizeMSB;
46 uint8_t accessType;
47};
48
Vijay Khemkae7d23d02019-03-08 13:13:40 -080049struct GetFRUAreaReq
50{
51 uint8_t fruDeviceID;
52 uint16_t fruInventoryOffset;
53 uint8_t countToRead;
54};
55
56struct WriteFRUDataReq
57{
58 uint8_t fruDeviceID;
59 uint16_t fruInventoryOffset;
60 uint8_t data[];
61};
62
63#pragma pack(pop)
64
65enum class GetFRUAreaAccessType : uint8_t
66{
67 byte = 0x0,
68 words = 0x1
69};
70
71enum class IPMINetfnStorageCmds : ipmi_cmd_t
72{
73 ipmiCmdGetFRUInvAreaInfo = 0x10,
74 ipmiCmdReadFRUData = 0x11,
75 ipmiCmdWriteFRUData = 0x12,
76 ipmiCmdGetRepositoryInfo = 0x20,
77 ipmiCmdGetSDRAllocationInfo = 0x21,
78 ipmiCmdReserveSDR = 0x22,
79 ipmiCmdGetSDR = 0x23,
80 ipmiCmdGetSELInfo = 0x40,
81 ipmiCmdReserveSEL = 0x42,
82 ipmiCmdGetSELEntry = 0x43,
83 ipmiCmdAddSEL = 0x44,
84 ipmiCmdDeleteSEL = 0x46,
85 ipmiCmdClearSEL = 0x47,
86 ipmiCmdGetSELTime = 0x48,
87 ipmiCmdSetSELTime = 0x49,
88};
89
90#pragma pack(push, 1)
91struct FRUHeader
92{
93 uint8_t commonHeaderFormat;
94 uint8_t internalOffset;
95 uint8_t chassisOffset;
96 uint8_t boardOffset;
97 uint8_t productOffset;
98 uint8_t multiRecordOffset;
99 uint8_t pad;
100 uint8_t checksum;
101};
102#pragma pack(pop)
Vijay Khemka11b9c3b2019-08-21 15:21:42 -0700103
104namespace fb_oem::ipmi::sel
105{
106
107static constexpr auto selVersion = 0x51;
108static constexpr auto invalidTimeStamp = 0xFFFFFFFF;
109/* Spec indicates that more than 64kB is free */
110static constexpr auto freeSpace = 0xFFFF;
111static constexpr uint8_t selOperationSupport = 0x02;
112
113static constexpr auto firstEntry = 0x0000;
114static constexpr auto lastEntry = 0xFFFF;
115static constexpr auto entireRecord = 0xFF;
116static constexpr auto selRecordSize = 16;
117
Vijay Khemkaf36f3452019-08-09 13:24:45 -0700118static constexpr auto stdErr = "Standard";
119static constexpr auto oemTSErr = "OEM timestamped";
Vijay Khemka34a875f2019-08-09 15:08:15 -0700120static constexpr auto fbUniSELErr = "Facebook Unified SEL";
Vijay Khemkaf36f3452019-08-09 13:24:45 -0700121static constexpr auto oemNTSErr = "OEM non-timestamped";
122static constexpr auto unknownErr = "Unknown";
123
124static constexpr uint8_t stdErrType = 0x02;
125static constexpr uint8_t oemTSErrTypeMin = 0xC0;
126static constexpr uint8_t oemTSErrTypeMax = 0xDF;
127static constexpr uint8_t oemNTSErrTypeMin = 0xE0;
Vijay Khemka34a875f2019-08-09 15:08:15 -0700128static constexpr uint8_t fbUniErrType = 0xFB;
Vijay Khemkaf36f3452019-08-09 13:24:45 -0700129static constexpr uint8_t oemNTSErrTypeMax = 0xFF;
130
131static constexpr uint8_t unifiedPcieErr = 0;
132static constexpr uint8_t unifiedMemErr = 1;
133
134/* event sensor name in processing SEL */
Vijay Khemka139aa4f2019-08-16 09:57:41 -0700135static constexpr uint8_t memoryEccError = 0x63;
136static constexpr uint8_t memoryErrLogDIS = 0x87;
Vijay Khemkaf36f3452019-08-09 13:24:45 -0700137
Vijay Khemka11b9c3b2019-08-21 15:21:42 -0700138/** @struct GetSELInfoData
139 *
140 * IPMI response payload data for Get SEL Info request
141 */
142struct GetSELInfoData
143{
144 uint8_t selVersion;
145 uint16_t entries;
146 uint16_t freeSpace;
147 uint32_t addTimeStamp;
148 uint32_t eraseTimeStamp;
149 uint8_t operationSupport;
150};
151
152/** @struct GetSELEntryRequest
153 *
154 * IPMI payload for Get SEL Entry command request.
155 */
156struct GetSELEntryRequest
157{
158 uint16_t reservID; //!< Reservation ID.
159 uint16_t recordID; //!< SEL Record ID.
160 uint8_t offset; //!< Offset into record.
161 uint8_t readLen; //!< Bytes to read.
162} __attribute__((packed));
163
164/** @struct GetSELEntryResponse
165 *
166 * IPMI payload for Get SEL Entry command response.
167 */
168struct GetSELEntryResponse
169{
170 uint16_t nextRecordID; //!< Next RecordID.
171 uint8_t recordData[16]; //!< Record Data.
172} __attribute__((packed));
173
Vijay Khemkaf36f3452019-08-09 13:24:45 -0700174/** @struct AddSELEntryRequest
175 *
176 * IPMI payload for ADD SEL Entry command request.
177 */
178struct StdSELEntry
179{
180 uint16_t recordID; //!< Record ID.
181 uint8_t recordType; //!< Record Type.
182 uint32_t timeStamp; //!< Timestamp.
183 uint16_t generatorID; //!< Generator ID.
184 uint8_t eventMsgRevision; //!< Event Message Revision.
185 uint8_t sensorType; //!< Sensor Type.
186 uint8_t sensorNum; //!< Sensor Number.
187 uint8_t eventType; //!< Event Dir | Event Type.
188 uint8_t eventData1; //!< Event Data 1.
189 uint8_t eventData2; //!< Event Data 2.
190 uint8_t eventData3; //!< Event Data 3.
191} __attribute__((packed));
192
193struct TsOemSELEntry
194{
195 uint16_t recordID; //!< Record ID.
196 uint8_t recordType; //!< Record Type.
197 uint32_t timeStamp; //!< Timestamp.
198 uint8_t mfrId[3]; //!< Manufacturer Id.
199 uint8_t oemData[6]; //!< OEM Data.
200} __attribute__((packed));
201
202struct NtsOemSELEntry
203{
204 uint16_t recordID; //!< Record ID.
205 uint8_t recordType; //!< Record Type.
206 uint8_t oemData[13]; //!< OEM Data.
207} __attribute__((packed));
208
Vijay Khemkac1921c62019-08-09 13:11:31 -0700209static constexpr auto initiateErase = 0xAA;
210static constexpr auto getEraseStatus = 0x00;
211static constexpr auto eraseComplete = 0x01;
212
Vijay Khemka11b9c3b2019-08-21 15:21:42 -0700213} // namespace fb_oem::ipmi::sel