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 23 #pragma pack(push, 1) 24 struct 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 35 struct GetSDRReq 36 { 37 uint16_t reservationID; 38 uint16_t recordID; 39 uint8_t offset; 40 uint8_t bytesToRead; 41 }; 42 #pragma pack(pop) 43 44 enum 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) 57 struct 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 }; 69 70 struct GetFRUAreaReq 71 { 72 uint8_t fruDeviceID; 73 uint16_t fruInventoryOffset; 74 uint8_t countToRead; 75 }; 76 77 struct GetFRUAreaResp 78 { 79 uint8_t inventorySizeLSB; 80 uint8_t inventorySizeMSB; 81 uint8_t accessType; 82 }; 83 84 struct WriteFRUDataReq 85 { 86 uint8_t fruDeviceID; 87 uint16_t fruInventoryOffset; 88 uint8_t data[]; 89 }; 90 #pragma pack(pop) 91 92 enum class GetFRUAreaAccessType : uint8_t 93 { 94 byte = 0x0, 95 words = 0x1 96 }; 97 98 enum 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 108 enum 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 127 #pragma pack(push, 1) 128 struct 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 141 namespace ipmi 142 { 143 namespace storage 144 { 145 ipmi_ret_t getFruSdrs(size_t index, get_sdr::SensorDataFruRecord& resp); 146 147 ipmi_ret_t getFruSdrCount(size_t& count); 148 } // namespace storage 149 } // namespace ipmi 150