blob: 5307c2dd9ef08153bcd815600ea8c37d48f73228 [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
110/** @struct GetSELInfoData
111 *
112 * IPMI response payload data for Get SEL Info request
113 */
114struct GetSELInfoData
115{
116 uint8_t selVersion;
117 uint16_t entries;
118 uint16_t freeSpace;
119 uint32_t addTimeStamp;
120 uint32_t eraseTimeStamp;
121 uint8_t operationSupport;
122};
123
124/** @struct GetSELEntryRequest
125 *
126 * IPMI payload for Get SEL Entry command request.
127 */
128struct GetSELEntryRequest
129{
130 uint16_t reservID; //!< Reservation ID.
131 uint16_t recordID; //!< SEL Record ID.
132 uint8_t offset; //!< Offset into record.
133 uint8_t readLen; //!< Bytes to read.
134} __attribute__((packed));
135
136/** @struct GetSELEntryResponse
137 *
138 * IPMI payload for Get SEL Entry command response.
139 */
140struct GetSELEntryResponse
141{
142 uint16_t nextRecordID; //!< Next RecordID.
143 uint8_t recordData[16]; //!< Record Data.
144} __attribute__((packed));
145
Vijay Khemkac1921c62019-08-09 13:11:31 -0700146static constexpr auto initiateErase = 0xAA;
147static constexpr auto getEraseStatus = 0x00;
148static constexpr auto eraseComplete = 0x01;
149
Vijay Khemka11b9c3b2019-08-21 15:21:42 -0700150} // namespace fb_oem::ipmi::sel