blob: dcff17abcf86195a78fb62ae73d2603b8f258dd4 [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;
cchoux74519032024-02-04 20:35:29 +0800133static constexpr uint8_t unifiedIioErr = 3;
134static constexpr uint8_t unifiedPostEvt = 8;
135static constexpr uint8_t unifiedPcieEvt = 9;
136static constexpr uint8_t unifiedMemEvt = 10;
137static constexpr uint8_t unifiedBootGuard = 12;
138static constexpr uint8_t unifiedPprEvt = 13;
Vijay Khemkaf36f3452019-08-09 13:24:45 -0700139
140/* event sensor name in processing SEL */
Vijay Khemka139aa4f2019-08-16 09:57:41 -0700141static constexpr uint8_t memoryEccError = 0x63;
142static constexpr uint8_t memoryErrLogDIS = 0x87;
Vijay Khemkaf36f3452019-08-09 13:24:45 -0700143
Vijay Khemka11b9c3b2019-08-21 15:21:42 -0700144/** @struct GetSELInfoData
145 *
146 * IPMI response payload data for Get SEL Info request
147 */
148struct GetSELInfoData
149{
150 uint8_t selVersion;
151 uint16_t entries;
152 uint16_t freeSpace;
153 uint32_t addTimeStamp;
154 uint32_t eraseTimeStamp;
155 uint8_t operationSupport;
156};
157
158/** @struct GetSELEntryRequest
159 *
160 * IPMI payload for Get SEL Entry command request.
161 */
162struct GetSELEntryRequest
163{
164 uint16_t reservID; //!< Reservation ID.
165 uint16_t recordID; //!< SEL Record ID.
166 uint8_t offset; //!< Offset into record.
167 uint8_t readLen; //!< Bytes to read.
168} __attribute__((packed));
169
170/** @struct GetSELEntryResponse
171 *
172 * IPMI payload for Get SEL Entry command response.
173 */
174struct GetSELEntryResponse
175{
176 uint16_t nextRecordID; //!< Next RecordID.
177 uint8_t recordData[16]; //!< Record Data.
178} __attribute__((packed));
179
Vijay Khemkaf36f3452019-08-09 13:24:45 -0700180/** @struct AddSELEntryRequest
181 *
182 * IPMI payload for ADD SEL Entry command request.
183 */
184struct StdSELEntry
185{
186 uint16_t recordID; //!< Record ID.
187 uint8_t recordType; //!< Record Type.
188 uint32_t timeStamp; //!< Timestamp.
189 uint16_t generatorID; //!< Generator ID.
190 uint8_t eventMsgRevision; //!< Event Message Revision.
191 uint8_t sensorType; //!< Sensor Type.
192 uint8_t sensorNum; //!< Sensor Number.
193 uint8_t eventType; //!< Event Dir | Event Type.
194 uint8_t eventData1; //!< Event Data 1.
195 uint8_t eventData2; //!< Event Data 2.
196 uint8_t eventData3; //!< Event Data 3.
197} __attribute__((packed));
198
199struct TsOemSELEntry
200{
201 uint16_t recordID; //!< Record ID.
202 uint8_t recordType; //!< Record Type.
203 uint32_t timeStamp; //!< Timestamp.
204 uint8_t mfrId[3]; //!< Manufacturer Id.
205 uint8_t oemData[6]; //!< OEM Data.
206} __attribute__((packed));
207
208struct NtsOemSELEntry
209{
210 uint16_t recordID; //!< Record ID.
211 uint8_t recordType; //!< Record Type.
212 uint8_t oemData[13]; //!< OEM Data.
213} __attribute__((packed));
214
Vijay Khemkac1921c62019-08-09 13:11:31 -0700215static constexpr auto initiateErase = 0xAA;
216static constexpr auto getEraseStatus = 0x00;
217static constexpr auto eraseComplete = 0x01;
218
Vijay Khemka11b9c3b2019-08-21 15:21:42 -0700219} // namespace fb_oem::ipmi::sel