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