Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 21 | static constexpr uint8_t ipmiSdrVersion = 0x51; |
| 22 | |
Jason M. Bills | c04e2e7 | 2018-11-28 15:15:56 -0800 | [diff] [blame] | 23 | namespace 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. |
| 27 | static constexpr const char* selMessageId = "b370836ccf2f4850ac5bee185b77893a"; |
| 28 | static constexpr uint8_t selOperationSupport = 0x02; |
| 29 | static constexpr uint8_t systemEvent = 0x02; |
| 30 | static constexpr size_t systemEventSize = 3; |
| 31 | static constexpr uint8_t oemTsEventFirst = 0xC0; |
| 32 | static constexpr uint8_t oemTsEventLast = 0xDF; |
| 33 | static constexpr size_t oemTsEventSize = 9; |
| 34 | static constexpr uint8_t oemEventFirst = 0xE0; |
| 35 | static constexpr uint8_t oemEventLast = 0xFF; |
| 36 | static constexpr size_t oemEventSize = 13; |
| 37 | static constexpr uint8_t eventMsgRev = 0x04; |
| 38 | } // namespace intel_oem::ipmi::sel |
| 39 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 40 | #pragma pack(push, 1) |
| 41 | struct 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 | |
| 52 | struct GetSDRReq |
| 53 | { |
| 54 | uint16_t reservationID; |
| 55 | uint16_t recordID; |
| 56 | uint8_t offset; |
| 57 | uint8_t bytesToRead; |
| 58 | }; |
| 59 | #pragma pack(pop) |
| 60 | |
| 61 | enum 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) |
| 74 | struct 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. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 86 | |
| 87 | struct GetFRUAreaReq |
| 88 | { |
| 89 | uint8_t fruDeviceID; |
| 90 | uint16_t fruInventoryOffset; |
| 91 | uint8_t countToRead; |
| 92 | }; |
| 93 | |
| 94 | struct GetFRUAreaResp |
| 95 | { |
| 96 | uint8_t inventorySizeLSB; |
| 97 | uint8_t inventorySizeMSB; |
| 98 | uint8_t accessType; |
| 99 | }; |
| 100 | |
| 101 | struct WriteFRUDataReq |
| 102 | { |
| 103 | uint8_t fruDeviceID; |
| 104 | uint16_t fruInventoryOffset; |
| 105 | uint8_t data[]; |
| 106 | }; |
Jason M. Bills | c04e2e7 | 2018-11-28 15:15:56 -0800 | [diff] [blame] | 107 | |
| 108 | struct 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; |
Jason M. Bills | 4ed6f2c | 2019-04-02 12:21:25 -0700 | [diff] [blame] | 122 | uint8_t eventType; |
Jason M. Bills | c04e2e7 | 2018-11-28 15:15:56 -0800 | [diff] [blame] | 123 | uint8_t eventData[intel_oem::ipmi::sel::systemEventSize]; |
| 124 | } system; |
| 125 | struct |
| 126 | { |
| 127 | uint32_t timestamp; |
| 128 | uint8_t eventData[intel_oem::ipmi::sel::oemTsEventSize]; |
| 129 | } oemTs; |
| 130 | struct |
| 131 | { |
| 132 | uint8_t eventData[intel_oem::ipmi::sel::oemEventSize]; |
| 133 | } oem; |
| 134 | } record; |
| 135 | }; |
| 136 | |
| 137 | struct AddSELRequest |
| 138 | { |
| 139 | uint16_t recordID; |
| 140 | uint8_t recordType; |
| 141 | union |
| 142 | { |
| 143 | struct |
| 144 | { |
| 145 | uint32_t timestamp; |
| 146 | uint16_t generatorID; |
| 147 | uint8_t eventMsgRevision; |
| 148 | uint8_t sensorType; |
| 149 | uint8_t sensorNum; |
Jason M. Bills | 4ed6f2c | 2019-04-02 12:21:25 -0700 | [diff] [blame] | 150 | uint8_t eventType; |
Jason M. Bills | c04e2e7 | 2018-11-28 15:15:56 -0800 | [diff] [blame] | 151 | uint8_t eventData[intel_oem::ipmi::sel::systemEventSize]; |
| 152 | } system; |
| 153 | struct |
| 154 | { |
| 155 | uint32_t timestamp; |
| 156 | uint8_t eventData[intel_oem::ipmi::sel::oemTsEventSize]; |
| 157 | } oemTs; |
| 158 | struct |
| 159 | { |
| 160 | uint8_t eventData[intel_oem::ipmi::sel::oemEventSize]; |
| 161 | } oem; |
| 162 | } record; |
| 163 | }; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 164 | #pragma pack(pop) |
| 165 | |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 166 | enum class GetFRUAreaAccessType : uint8_t |
| 167 | { |
| 168 | byte = 0x0, |
| 169 | words = 0x1 |
| 170 | }; |
| 171 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 172 | enum class SensorUnits : uint8_t |
| 173 | { |
| 174 | unspecified = 0x0, |
| 175 | degreesC = 0x1, |
| 176 | volts = 0x4, |
| 177 | amps = 0x5, |
| 178 | watts = 0x6, |
| 179 | rpm = 0x12, |
| 180 | }; |
| 181 | |
| 182 | enum class IPMINetfnStorageCmds : ipmi_cmd_t |
| 183 | { |
| 184 | ipmiCmdGetFRUInvAreaInfo = 0x10, |
| 185 | ipmiCmdReadFRUData = 0x11, |
| 186 | ipmiCmdWriteFRUData = 0x12, |
| 187 | ipmiCmdGetRepositoryInfo = 0x20, |
| 188 | ipmiCmdGetSDRAllocationInfo = 0x21, |
| 189 | ipmiCmdReserveSDR = 0x22, |
| 190 | ipmiCmdGetSDR = 0x23, |
| 191 | ipmiCmdGetSELInfo = 0x40, |
| 192 | ipmiCmdReserveSEL = 0x42, |
| 193 | ipmiCmdGetSELEntry = 0x43, |
| 194 | ipmiCmdAddSEL = 0x44, |
| 195 | ipmiCmdDeleteSEL = 0x46, |
| 196 | ipmiCmdClearSEL = 0x47, |
| 197 | ipmiCmdGetSELTime = 0x48, |
| 198 | ipmiCmdSetSELTime = 0x49, |
| 199 | }; |
| 200 | |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 201 | #pragma pack(push, 1) |
| 202 | struct FRUHeader |
| 203 | { |
| 204 | uint8_t commonHeaderFormat; |
| 205 | uint8_t internalOffset; |
| 206 | uint8_t chassisOffset; |
| 207 | uint8_t boardOffset; |
| 208 | uint8_t productOffset; |
| 209 | uint8_t multiRecordOffset; |
| 210 | uint8_t pad; |
| 211 | uint8_t checksum; |
| 212 | }; |
| 213 | #pragma pack(pop) |
| 214 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 215 | namespace ipmi |
| 216 | { |
| 217 | namespace storage |
| 218 | { |
| 219 | ipmi_ret_t getFruSdrs(size_t index, get_sdr::SensorDataFruRecord& resp); |
| 220 | |
| 221 | ipmi_ret_t getFruSdrCount(size_t& count); |
| 222 | } // namespace storage |
| 223 | } // namespace ipmi |