Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1 | /* |
| 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 Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 18 | #include "sdrutils.hpp" |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 19 | |
Vijay Khemka | 11b9c3b | 2019-08-21 15:21:42 -0700 | [diff] [blame] | 20 | #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 Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 29 | static constexpr uint8_t ipmiSdrVersion = 0x51; |
| 30 | |
| 31 | #pragma pack(push, 1) |
| 32 | |
| 33 | struct GetSDRReq |
| 34 | { |
| 35 | uint16_t reservationID; |
| 36 | uint16_t recordID; |
| 37 | uint8_t offset; |
| 38 | uint8_t bytesToRead; |
| 39 | }; |
| 40 | |
| 41 | struct GetFRUAreaReq |
| 42 | { |
| 43 | uint8_t fruDeviceID; |
| 44 | uint16_t fruInventoryOffset; |
| 45 | uint8_t countToRead; |
| 46 | }; |
| 47 | |
| 48 | struct WriteFRUDataReq |
| 49 | { |
| 50 | uint8_t fruDeviceID; |
| 51 | uint16_t fruInventoryOffset; |
| 52 | uint8_t data[]; |
| 53 | }; |
| 54 | |
| 55 | #pragma pack(pop) |
| 56 | |
| 57 | enum class GetFRUAreaAccessType : uint8_t |
| 58 | { |
| 59 | byte = 0x0, |
| 60 | words = 0x1 |
| 61 | }; |
| 62 | |
| 63 | enum 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) |
| 83 | struct 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 Khemka | 11b9c3b | 2019-08-21 15:21:42 -0700 | [diff] [blame] | 95 | |
| 96 | namespace fb_oem::ipmi::sel |
| 97 | { |
| 98 | |
| 99 | static constexpr auto selVersion = 0x51; |
| 100 | static constexpr auto invalidTimeStamp = 0xFFFFFFFF; |
| 101 | /* Spec indicates that more than 64kB is free */ |
| 102 | static constexpr auto freeSpace = 0xFFFF; |
| 103 | static constexpr uint8_t selOperationSupport = 0x02; |
| 104 | |
| 105 | static constexpr auto firstEntry = 0x0000; |
| 106 | static constexpr auto lastEntry = 0xFFFF; |
| 107 | static constexpr auto entireRecord = 0xFF; |
| 108 | static constexpr auto selRecordSize = 16; |
| 109 | |
Vijay Khemka | f36f345 | 2019-08-09 13:24:45 -0700 | [diff] [blame] | 110 | static constexpr auto stdErr = "Standard"; |
| 111 | static constexpr auto oemTSErr = "OEM timestamped"; |
Vijay Khemka | 34a875f | 2019-08-09 15:08:15 -0700 | [diff] [blame] | 112 | static constexpr auto fbUniSELErr = "Facebook Unified SEL"; |
Vijay Khemka | f36f345 | 2019-08-09 13:24:45 -0700 | [diff] [blame] | 113 | static constexpr auto oemNTSErr = "OEM non-timestamped"; |
| 114 | static constexpr auto unknownErr = "Unknown"; |
| 115 | |
| 116 | static constexpr uint8_t stdErrType = 0x02; |
| 117 | static constexpr uint8_t oemTSErrTypeMin = 0xC0; |
| 118 | static constexpr uint8_t oemTSErrTypeMax = 0xDF; |
| 119 | static constexpr uint8_t oemNTSErrTypeMin = 0xE0; |
Vijay Khemka | 34a875f | 2019-08-09 15:08:15 -0700 | [diff] [blame] | 120 | static constexpr uint8_t fbUniErrType = 0xFB; |
Vijay Khemka | f36f345 | 2019-08-09 13:24:45 -0700 | [diff] [blame] | 121 | static constexpr uint8_t oemNTSErrTypeMax = 0xFF; |
| 122 | |
| 123 | static constexpr uint8_t unifiedPcieErr = 0; |
| 124 | static constexpr uint8_t unifiedMemErr = 1; |
| 125 | |
| 126 | /* event sensor name in processing SEL */ |
| 127 | static constexpr uint8_t memoryEccError = 0X63; |
| 128 | static constexpr uint8_t memoryErrLogDIS = 0X87; |
| 129 | |
| 130 | static boost::container::flat_map<uint8_t, std::string> sensorNameTable = { |
| 131 | {0xE9, "SYSTEM_EVENT"}, |
| 132 | {0x7D, "THERM_THRESH_EVT"}, |
| 133 | {0xAA, "BUTTON"}, |
| 134 | {0xAB, "POWER_STATE"}, |
| 135 | {0xEA, "CRITICAL_IRQ"}, |
| 136 | {0x2B, "POST_ERROR"}, |
| 137 | {0x40, "MACHINE_CHK_ERR"}, |
| 138 | {0x41, "PCIE_ERR"}, |
| 139 | {0x43, "IIO_ERR"}, |
| 140 | {0X63, "MEMORY_ECC_ERR"}, |
| 141 | {0X87, "MEMORY_ERR_LOG_DIS"}, |
| 142 | {0X51, "PROCHOT_EXT"}, |
| 143 | {0X56, "PWR_ERR"}, |
| 144 | {0xE6, "CATERR_A"}, |
| 145 | {0xEB, "CATERR_B"}, |
| 146 | {0xB3, "CPU_DIMM_HOT"}, |
| 147 | {0x90, "SOFTWARE_NMI"}, |
| 148 | {0x1C, "CPU0_THERM_STATUS"}, |
| 149 | {0x1D, "CPU1_THERM_STATUS"}, |
| 150 | {0x16, "ME_POWER_STATE"}, |
| 151 | {0x17, "SPS_FW_HEALTH"}, |
| 152 | {0x18, "NM_EXCEPTION_A"}, |
| 153 | {0x08, "PCH_THERM_THRESHOLD"}, |
| 154 | {0x19, "NM_HEALTH"}, |
| 155 | {0x1A, "NM_CAPABILITIES"}, |
| 156 | {0x1B, "NM_THRESHOLD"}, |
| 157 | {0x3B, "PWR_THRESH_EVT"}, |
| 158 | {0xE7, "MSMI"}, |
| 159 | {0xC5, "HPR_WARNING"}}; |
| 160 | |
Vijay Khemka | 11b9c3b | 2019-08-21 15:21:42 -0700 | [diff] [blame] | 161 | /** @struct GetSELInfoData |
| 162 | * |
| 163 | * IPMI response payload data for Get SEL Info request |
| 164 | */ |
| 165 | struct GetSELInfoData |
| 166 | { |
| 167 | uint8_t selVersion; |
| 168 | uint16_t entries; |
| 169 | uint16_t freeSpace; |
| 170 | uint32_t addTimeStamp; |
| 171 | uint32_t eraseTimeStamp; |
| 172 | uint8_t operationSupport; |
| 173 | }; |
| 174 | |
| 175 | /** @struct GetSELEntryRequest |
| 176 | * |
| 177 | * IPMI payload for Get SEL Entry command request. |
| 178 | */ |
| 179 | struct GetSELEntryRequest |
| 180 | { |
| 181 | uint16_t reservID; //!< Reservation ID. |
| 182 | uint16_t recordID; //!< SEL Record ID. |
| 183 | uint8_t offset; //!< Offset into record. |
| 184 | uint8_t readLen; //!< Bytes to read. |
| 185 | } __attribute__((packed)); |
| 186 | |
| 187 | /** @struct GetSELEntryResponse |
| 188 | * |
| 189 | * IPMI payload for Get SEL Entry command response. |
| 190 | */ |
| 191 | struct GetSELEntryResponse |
| 192 | { |
| 193 | uint16_t nextRecordID; //!< Next RecordID. |
| 194 | uint8_t recordData[16]; //!< Record Data. |
| 195 | } __attribute__((packed)); |
| 196 | |
Vijay Khemka | f36f345 | 2019-08-09 13:24:45 -0700 | [diff] [blame] | 197 | /** @struct AddSELEntryRequest |
| 198 | * |
| 199 | * IPMI payload for ADD SEL Entry command request. |
| 200 | */ |
| 201 | struct StdSELEntry |
| 202 | { |
| 203 | uint16_t recordID; //!< Record ID. |
| 204 | uint8_t recordType; //!< Record Type. |
| 205 | uint32_t timeStamp; //!< Timestamp. |
| 206 | uint16_t generatorID; //!< Generator ID. |
| 207 | uint8_t eventMsgRevision; //!< Event Message Revision. |
| 208 | uint8_t sensorType; //!< Sensor Type. |
| 209 | uint8_t sensorNum; //!< Sensor Number. |
| 210 | uint8_t eventType; //!< Event Dir | Event Type. |
| 211 | uint8_t eventData1; //!< Event Data 1. |
| 212 | uint8_t eventData2; //!< Event Data 2. |
| 213 | uint8_t eventData3; //!< Event Data 3. |
| 214 | } __attribute__((packed)); |
| 215 | |
| 216 | struct TsOemSELEntry |
| 217 | { |
| 218 | uint16_t recordID; //!< Record ID. |
| 219 | uint8_t recordType; //!< Record Type. |
| 220 | uint32_t timeStamp; //!< Timestamp. |
| 221 | uint8_t mfrId[3]; //!< Manufacturer Id. |
| 222 | uint8_t oemData[6]; //!< OEM Data. |
| 223 | } __attribute__((packed)); |
| 224 | |
| 225 | struct NtsOemSELEntry |
| 226 | { |
| 227 | uint16_t recordID; //!< Record ID. |
| 228 | uint8_t recordType; //!< Record Type. |
| 229 | uint8_t oemData[13]; //!< OEM Data. |
| 230 | } __attribute__((packed)); |
| 231 | |
Vijay Khemka | c1921c6 | 2019-08-09 13:11:31 -0700 | [diff] [blame] | 232 | static constexpr auto initiateErase = 0xAA; |
| 233 | static constexpr auto getEraseStatus = 0x00; |
| 234 | static constexpr auto eraseComplete = 0x01; |
| 235 | |
Vijay Khemka | 11b9c3b | 2019-08-21 15:21:42 -0700 | [diff] [blame] | 236 | } // namespace fb_oem::ipmi::sel |