blob: 3b2fda929a4d96a1dc4ccb1c6097c7052a356d76 [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{
Jason M. Billsc04e2e72018-11-28 15:15:56 -080025static constexpr uint8_t selOperationSupport = 0x02;
26static constexpr uint8_t systemEvent = 0x02;
27static constexpr size_t systemEventSize = 3;
28static constexpr uint8_t oemTsEventFirst = 0xC0;
29static constexpr uint8_t oemTsEventLast = 0xDF;
30static constexpr size_t oemTsEventSize = 9;
31static constexpr uint8_t oemEventFirst = 0xE0;
32static constexpr uint8_t oemEventLast = 0xFF;
33static constexpr size_t oemEventSize = 13;
34static constexpr uint8_t eventMsgRev = 0x04;
35} // namespace intel_oem::ipmi::sel
36
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070037#pragma pack(push, 1)
38struct GetSDRInfoResp
39{
40 uint8_t sdrVersion;
41 uint8_t recordCountLS;
42 uint8_t recordCountMS;
43 uint8_t freeSpace[2];
44 uint32_t mostRecentAddition;
45 uint32_t mostRecentErase;
46 uint8_t operationSupport;
47};
48
49struct GetSDRReq
50{
51 uint16_t reservationID;
52 uint16_t recordID;
53 uint8_t offset;
54 uint8_t bytesToRead;
55};
56#pragma pack(pop)
57
58enum class SdrRepositoryInfoOps : uint8_t
59{
60 allocCommandSupported = 0x1,
61 reserveSDRRepositoryCommandSupported = 0x2,
62 partialAddSDRSupported = 0x4,
63 deleteSDRSupported = 0x8,
64 reserved = 0x10,
65 modalLSB = 0x20,
66 modalMSB = 0x40,
67 overflow = 0x80
68};
69
70#pragma pack(push, 1)
71struct GetAllocInfoResp
72{
73 uint8_t allocUnitsLSB;
74 uint8_t allocUnitsMSB;
75 uint8_t allocUnitSizeLSB;
76 uint8_t allocUnitSizeMSB;
77 uint8_t allocUnitFreeLSB;
78 uint8_t allocUnitFreeMSB;
79 uint8_t allocUnitLargestFreeLSB;
80 uint8_t allocUnitLargestFreeMSB;
81 uint8_t maxRecordSize;
82};
Jason M. Billse2d1aee2018-10-03 15:57:18 -070083
84struct GetFRUAreaReq
85{
86 uint8_t fruDeviceID;
87 uint16_t fruInventoryOffset;
88 uint8_t countToRead;
89};
90
91struct GetFRUAreaResp
92{
93 uint8_t inventorySizeLSB;
94 uint8_t inventorySizeMSB;
95 uint8_t accessType;
96};
97
98struct WriteFRUDataReq
99{
100 uint8_t fruDeviceID;
101 uint16_t fruInventoryOffset;
102 uint8_t data[];
103};
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800104
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800105struct AddSELRequest
106{
107 uint16_t recordID;
108 uint8_t recordType;
109 union
110 {
111 struct
112 {
113 uint32_t timestamp;
114 uint16_t generatorID;
115 uint8_t eventMsgRevision;
116 uint8_t sensorType;
117 uint8_t sensorNum;
Jason M. Bills4ed6f2c2019-04-02 12:21:25 -0700118 uint8_t eventType;
Jason M. Billsc04e2e72018-11-28 15:15:56 -0800119 uint8_t eventData[intel_oem::ipmi::sel::systemEventSize];
120 } system;
121 struct
122 {
123 uint32_t timestamp;
124 uint8_t eventData[intel_oem::ipmi::sel::oemTsEventSize];
125 } oemTs;
126 struct
127 {
128 uint8_t eventData[intel_oem::ipmi::sel::oemEventSize];
129 } oem;
130 } record;
131};
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700132#pragma pack(pop)
133
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700134enum class GetFRUAreaAccessType : uint8_t
135{
136 byte = 0x0,
137 words = 0x1
138};
139
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700140enum class SensorUnits : uint8_t
141{
142 unspecified = 0x0,
143 degreesC = 0x1,
144 volts = 0x4,
145 amps = 0x5,
146 watts = 0x6,
147 rpm = 0x12,
148};
149
150enum class IPMINetfnStorageCmds : ipmi_cmd_t
151{
152 ipmiCmdGetFRUInvAreaInfo = 0x10,
153 ipmiCmdReadFRUData = 0x11,
154 ipmiCmdWriteFRUData = 0x12,
155 ipmiCmdGetRepositoryInfo = 0x20,
156 ipmiCmdGetSDRAllocationInfo = 0x21,
157 ipmiCmdReserveSDR = 0x22,
158 ipmiCmdGetSDR = 0x23,
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700159 ipmiCmdAddSEL = 0x44,
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700160};
161
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700162#pragma pack(push, 1)
163struct FRUHeader
164{
165 uint8_t commonHeaderFormat;
166 uint8_t internalOffset;
167 uint8_t chassisOffset;
168 uint8_t boardOffset;
169 uint8_t productOffset;
170 uint8_t multiRecordOffset;
171 uint8_t pad;
172 uint8_t checksum;
173};
174#pragma pack(pop)
175
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700176namespace ipmi
177{
178namespace storage
179{
180ipmi_ret_t getFruSdrs(size_t index, get_sdr::SensorDataFruRecord& resp);
181
182ipmi_ret_t getFruSdrCount(size_t& count);
183} // namespace storage
184} // namespace ipmi