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 | |
| 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 | }; |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame^] | 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 | }; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 90 | #pragma pack(pop) |
| 91 | |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame^] | 92 | enum class GetFRUAreaAccessType : uint8_t |
| 93 | { |
| 94 | byte = 0x0, |
| 95 | words = 0x1 |
| 96 | }; |
| 97 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 98 | enum class SensorTypeCodes : uint8_t |
| 99 | { |
| 100 | reserved = 0x0, |
| 101 | temperature = 0x1, |
| 102 | voltage = 0x2, |
| 103 | current = 0x3, |
| 104 | fan = 0x4, |
| 105 | other = 0xB, |
| 106 | }; |
| 107 | |
| 108 | enum class SensorUnits : uint8_t |
| 109 | { |
| 110 | unspecified = 0x0, |
| 111 | degreesC = 0x1, |
| 112 | volts = 0x4, |
| 113 | amps = 0x5, |
| 114 | watts = 0x6, |
| 115 | rpm = 0x12, |
| 116 | }; |
| 117 | |
| 118 | enum class IPMINetfnStorageCmds : ipmi_cmd_t |
| 119 | { |
| 120 | ipmiCmdGetFRUInvAreaInfo = 0x10, |
| 121 | ipmiCmdReadFRUData = 0x11, |
| 122 | ipmiCmdWriteFRUData = 0x12, |
| 123 | ipmiCmdGetRepositoryInfo = 0x20, |
| 124 | ipmiCmdGetSDRAllocationInfo = 0x21, |
| 125 | ipmiCmdReserveSDR = 0x22, |
| 126 | ipmiCmdGetSDR = 0x23, |
| 127 | ipmiCmdGetSELInfo = 0x40, |
| 128 | ipmiCmdReserveSEL = 0x42, |
| 129 | ipmiCmdGetSELEntry = 0x43, |
| 130 | ipmiCmdAddSEL = 0x44, |
| 131 | ipmiCmdDeleteSEL = 0x46, |
| 132 | ipmiCmdClearSEL = 0x47, |
| 133 | ipmiCmdGetSELTime = 0x48, |
| 134 | ipmiCmdSetSELTime = 0x49, |
| 135 | }; |
| 136 | |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame^] | 137 | #pragma pack(push, 1) |
| 138 | struct FRUHeader |
| 139 | { |
| 140 | uint8_t commonHeaderFormat; |
| 141 | uint8_t internalOffset; |
| 142 | uint8_t chassisOffset; |
| 143 | uint8_t boardOffset; |
| 144 | uint8_t productOffset; |
| 145 | uint8_t multiRecordOffset; |
| 146 | uint8_t pad; |
| 147 | uint8_t checksum; |
| 148 | }; |
| 149 | #pragma pack(pop) |
| 150 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 151 | namespace ipmi |
| 152 | { |
| 153 | namespace storage |
| 154 | { |
| 155 | ipmi_ret_t getFruSdrs(size_t index, get_sdr::SensorDataFruRecord& resp); |
| 156 | |
| 157 | ipmi_ret_t getFruSdrCount(size_t& count); |
| 158 | } // namespace storage |
| 159 | } // namespace ipmi |