blob: 946161be80b0d6f276bf9567258ad333e0114da8 [file] [log] [blame]
Jason M. Bills3f7c5e42018-10-03 14:00:41 -07001/*
2// Copyright (c) 2017 2018 Intel Corporation
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
18#include <cstdint>
19#include <phosphor-ipmi-host/sensorhandler.hpp>
20
21static constexpr uint8_t ipmiSdrVersion = 0x51;
22
Jason M. Billsc04e2e72018-11-28 15:15:56 -080023namespace intel_oem::ipmi::sel
24{
25// ID string generated using journalctl to include in the MESSAGE_ID field for
26// SEL entries. Helps with filtering SEL entries in the journal.
27static constexpr const char* selMessageId = "b370836ccf2f4850ac5bee185b77893a";
28static constexpr uint8_t selOperationSupport = 0x02;
29static constexpr uint8_t systemEvent = 0x02;
30static constexpr size_t systemEventSize = 3;
31static constexpr uint8_t oemTsEventFirst = 0xC0;
32static constexpr uint8_t oemTsEventLast = 0xDF;
33static constexpr size_t oemTsEventSize = 9;
34static constexpr uint8_t oemEventFirst = 0xE0;
35static constexpr uint8_t oemEventLast = 0xFF;
36static constexpr size_t oemEventSize = 13;
37static constexpr uint8_t eventMsgRev = 0x04;
38} // namespace intel_oem::ipmi::sel
39
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070040#pragma pack(push, 1)
41struct GetSDRInfoResp
42{
43 uint8_t sdrVersion;
44 uint8_t recordCountLS;
45 uint8_t recordCountMS;
46 uint8_t freeSpace[2];
47 uint32_t mostRecentAddition;
48 uint32_t mostRecentErase;
49 uint8_t operationSupport;
50};
51
52struct GetSDRReq
53{
54 uint16_t reservationID;
55 uint16_t recordID;
56 uint8_t offset;
57 uint8_t bytesToRead;
58};
59#pragma pack(pop)
60
61enum class SdrRepositoryInfoOps : uint8_t
62{
63 allocCommandSupported = 0x1,
64 reserveSDRRepositoryCommandSupported = 0x2,
65 partialAddSDRSupported = 0x4,
66 deleteSDRSupported = 0x8,
67 reserved = 0x10,
68 modalLSB = 0x20,
69 modalMSB = 0x40,
70 overflow = 0x80
71};
72
73#pragma pack(push, 1)
74struct GetAllocInfoResp
75{
76 uint8_t allocUnitsLSB;
77 uint8_t allocUnitsMSB;
78 uint8_t allocUnitSizeLSB;
79 uint8_t allocUnitSizeMSB;
80 uint8_t allocUnitFreeLSB;
81 uint8_t allocUnitFreeMSB;
82 uint8_t allocUnitLargestFreeLSB;
83 uint8_t allocUnitLargestFreeMSB;
84 uint8_t maxRecordSize;
85};
Jason M. Billse2d1aee2018-10-03 15:57:18 -070086
87struct GetFRUAreaReq
88{
89 uint8_t fruDeviceID;
90 uint16_t fruInventoryOffset;
91 uint8_t countToRead;
92};
93
94struct GetFRUAreaResp
95{
96 uint8_t inventorySizeLSB;
97 uint8_t inventorySizeMSB;
98 uint8_t accessType;
99};
100
101struct WriteFRUDataReq
102{
103 uint8_t fruDeviceID;
104 uint16_t fruInventoryOffset;
105 uint8_t data[];
106};
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800107
108struct GetSELEntryResponse
109{
110 uint16_t nextRecordID;
111 uint16_t recordID;
112 uint8_t recordType;
113 union
114 {
115 struct
116 {
117 uint32_t timestamp;
118 uint16_t generatorID;
119 uint8_t eventMsgRevision;
120 uint8_t sensorType;
121 uint8_t sensorNum;
122 uint8_t eventType : 7;
123 uint8_t eventDir : 1;
124 uint8_t eventData[intel_oem::ipmi::sel::systemEventSize];
125 } system;
126 struct
127 {
128 uint32_t timestamp;
129 uint8_t eventData[intel_oem::ipmi::sel::oemTsEventSize];
130 } oemTs;
131 struct
132 {
133 uint8_t eventData[intel_oem::ipmi::sel::oemEventSize];
134 } oem;
135 } record;
136};
137
138struct AddSELRequest
139{
140 uint16_t recordID;
141 uint8_t recordType;
142 union
143 {
144 struct
145 {
146 uint32_t timestamp;
147 uint16_t generatorID;
148 uint8_t eventMsgRevision;
149 uint8_t sensorType;
150 uint8_t sensorNum;
151 uint8_t eventType : 7;
152 uint8_t eventDir : 1;
153 uint8_t eventData[intel_oem::ipmi::sel::systemEventSize];
154 } system;
155 struct
156 {
157 uint32_t timestamp;
158 uint8_t eventData[intel_oem::ipmi::sel::oemTsEventSize];
159 } oemTs;
160 struct
161 {
162 uint8_t eventData[intel_oem::ipmi::sel::oemEventSize];
163 } oem;
164 } record;
165};
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700166#pragma pack(pop)
167
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700168enum class GetFRUAreaAccessType : uint8_t
169{
170 byte = 0x0,
171 words = 0x1
172};
173
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700174enum class SensorUnits : uint8_t
175{
176 unspecified = 0x0,
177 degreesC = 0x1,
178 volts = 0x4,
179 amps = 0x5,
180 watts = 0x6,
181 rpm = 0x12,
182};
183
184enum class IPMINetfnStorageCmds : ipmi_cmd_t
185{
186 ipmiCmdGetFRUInvAreaInfo = 0x10,
187 ipmiCmdReadFRUData = 0x11,
188 ipmiCmdWriteFRUData = 0x12,
189 ipmiCmdGetRepositoryInfo = 0x20,
190 ipmiCmdGetSDRAllocationInfo = 0x21,
191 ipmiCmdReserveSDR = 0x22,
192 ipmiCmdGetSDR = 0x23,
193 ipmiCmdGetSELInfo = 0x40,
194 ipmiCmdReserveSEL = 0x42,
195 ipmiCmdGetSELEntry = 0x43,
196 ipmiCmdAddSEL = 0x44,
197 ipmiCmdDeleteSEL = 0x46,
198 ipmiCmdClearSEL = 0x47,
199 ipmiCmdGetSELTime = 0x48,
200 ipmiCmdSetSELTime = 0x49,
201};
202
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700203#pragma pack(push, 1)
204struct FRUHeader
205{
206 uint8_t commonHeaderFormat;
207 uint8_t internalOffset;
208 uint8_t chassisOffset;
209 uint8_t boardOffset;
210 uint8_t productOffset;
211 uint8_t multiRecordOffset;
212 uint8_t pad;
213 uint8_t checksum;
214};
215#pragma pack(pop)
216
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700217namespace ipmi
218{
219namespace storage
220{
221ipmi_ret_t getFruSdrs(size_t index, get_sdr::SensorDataFruRecord& resp);
222
223ipmi_ret_t getFruSdrCount(size_t& count);
224} // namespace storage
225} // namespace ipmi