blob: 063f2a8f1c18d46c95023d82b0dd325baff8f5d8 [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
23#pragma pack(push, 1)
24struct GetSDRInfoResp
25{
26 uint8_t sdrVersion;
27 uint8_t recordCountLS;
28 uint8_t recordCountMS;
29 uint8_t freeSpace[2];
30 uint32_t mostRecentAddition;
31 uint32_t mostRecentErase;
32 uint8_t operationSupport;
33};
34
35struct GetSDRReq
36{
37 uint16_t reservationID;
38 uint16_t recordID;
39 uint8_t offset;
40 uint8_t bytesToRead;
41};
42#pragma pack(pop)
43
44enum class SdrRepositoryInfoOps : uint8_t
45{
46 allocCommandSupported = 0x1,
47 reserveSDRRepositoryCommandSupported = 0x2,
48 partialAddSDRSupported = 0x4,
49 deleteSDRSupported = 0x8,
50 reserved = 0x10,
51 modalLSB = 0x20,
52 modalMSB = 0x40,
53 overflow = 0x80
54};
55
56#pragma pack(push, 1)
57struct GetAllocInfoResp
58{
59 uint8_t allocUnitsLSB;
60 uint8_t allocUnitsMSB;
61 uint8_t allocUnitSizeLSB;
62 uint8_t allocUnitSizeMSB;
63 uint8_t allocUnitFreeLSB;
64 uint8_t allocUnitFreeMSB;
65 uint8_t allocUnitLargestFreeLSB;
66 uint8_t allocUnitLargestFreeMSB;
67 uint8_t maxRecordSize;
68};
Jason M. Billse2d1aee2018-10-03 15:57:18 -070069
70struct GetFRUAreaReq
71{
72 uint8_t fruDeviceID;
73 uint16_t fruInventoryOffset;
74 uint8_t countToRead;
75};
76
77struct GetFRUAreaResp
78{
79 uint8_t inventorySizeLSB;
80 uint8_t inventorySizeMSB;
81 uint8_t accessType;
82};
83
84struct WriteFRUDataReq
85{
86 uint8_t fruDeviceID;
87 uint16_t fruInventoryOffset;
88 uint8_t data[];
89};
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070090#pragma pack(pop)
91
Jason M. Billse2d1aee2018-10-03 15:57:18 -070092enum class GetFRUAreaAccessType : uint8_t
93{
94 byte = 0x0,
95 words = 0x1
96};
97
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070098enum class SensorUnits : uint8_t
99{
100 unspecified = 0x0,
101 degreesC = 0x1,
102 volts = 0x4,
103 amps = 0x5,
104 watts = 0x6,
105 rpm = 0x12,
106};
107
108enum class IPMINetfnStorageCmds : ipmi_cmd_t
109{
110 ipmiCmdGetFRUInvAreaInfo = 0x10,
111 ipmiCmdReadFRUData = 0x11,
112 ipmiCmdWriteFRUData = 0x12,
113 ipmiCmdGetRepositoryInfo = 0x20,
114 ipmiCmdGetSDRAllocationInfo = 0x21,
115 ipmiCmdReserveSDR = 0x22,
116 ipmiCmdGetSDR = 0x23,
117 ipmiCmdGetSELInfo = 0x40,
118 ipmiCmdReserveSEL = 0x42,
119 ipmiCmdGetSELEntry = 0x43,
120 ipmiCmdAddSEL = 0x44,
121 ipmiCmdDeleteSEL = 0x46,
122 ipmiCmdClearSEL = 0x47,
123 ipmiCmdGetSELTime = 0x48,
124 ipmiCmdSetSELTime = 0x49,
125};
126
Jason M. Billse2d1aee2018-10-03 15:57:18 -0700127#pragma pack(push, 1)
128struct FRUHeader
129{
130 uint8_t commonHeaderFormat;
131 uint8_t internalOffset;
132 uint8_t chassisOffset;
133 uint8_t boardOffset;
134 uint8_t productOffset;
135 uint8_t multiRecordOffset;
136 uint8_t pad;
137 uint8_t checksum;
138};
139#pragma pack(pop)
140
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700141namespace ipmi
142{
143namespace storage
144{
145ipmi_ret_t getFruSdrs(size_t index, get_sdr::SensorDataFruRecord& resp);
146
147ipmi_ret_t getFruSdrCount(size_t& count);
148} // namespace storage
149} // namespace ipmi