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 |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 18 | #include <phosphor-ipmi-host/sensorhandler.hpp> |
| 19 | |
James Feist | fcd2d3a | 2020-05-28 10:38:15 -0700 | [diff] [blame] | 20 | #include <cstdint> |
| 21 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 22 | static constexpr uint8_t ipmiSdrVersion = 0x51; |
| 23 | |
Jason M. Bills | c04e2e7 | 2018-11-28 15:15:56 -0800 | [diff] [blame] | 24 | namespace intel_oem::ipmi::sel |
| 25 | { |
Jason M. Bills | c04e2e7 | 2018-11-28 15:15:56 -0800 | [diff] [blame] | 26 | static constexpr uint8_t selOperationSupport = 0x02; |
| 27 | static constexpr uint8_t systemEvent = 0x02; |
| 28 | static constexpr size_t systemEventSize = 3; |
| 29 | static constexpr uint8_t oemTsEventFirst = 0xC0; |
| 30 | static constexpr uint8_t oemTsEventLast = 0xDF; |
| 31 | static constexpr size_t oemTsEventSize = 9; |
| 32 | static constexpr uint8_t oemEventFirst = 0xE0; |
| 33 | static constexpr uint8_t oemEventLast = 0xFF; |
| 34 | static constexpr size_t oemEventSize = 13; |
| 35 | static constexpr uint8_t eventMsgRev = 0x04; |
| 36 | } // namespace intel_oem::ipmi::sel |
| 37 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 38 | #pragma pack(push, 1) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 39 | struct GetSDRReq |
| 40 | { |
| 41 | uint16_t reservationID; |
| 42 | uint16_t recordID; |
| 43 | uint8_t offset; |
| 44 | uint8_t bytesToRead; |
| 45 | }; |
| 46 | #pragma pack(pop) |
| 47 | |
| 48 | enum class SdrRepositoryInfoOps : uint8_t |
| 49 | { |
| 50 | allocCommandSupported = 0x1, |
| 51 | reserveSDRRepositoryCommandSupported = 0x2, |
| 52 | partialAddSDRSupported = 0x4, |
| 53 | deleteSDRSupported = 0x8, |
| 54 | reserved = 0x10, |
| 55 | modalLSB = 0x20, |
| 56 | modalMSB = 0x40, |
| 57 | overflow = 0x80 |
| 58 | }; |
| 59 | |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 60 | enum class GetFRUAreaAccessType : uint8_t |
| 61 | { |
| 62 | byte = 0x0, |
| 63 | words = 0x1 |
| 64 | }; |
| 65 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 66 | enum class SensorUnits : uint8_t |
| 67 | { |
| 68 | unspecified = 0x0, |
| 69 | degreesC = 0x1, |
| 70 | volts = 0x4, |
| 71 | amps = 0x5, |
| 72 | watts = 0x6, |
| 73 | rpm = 0x12, |
| 74 | }; |
| 75 | |
| 76 | enum class IPMINetfnStorageCmds : ipmi_cmd_t |
| 77 | { |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 78 | ipmiCmdGetRepositoryInfo = 0x20, |
| 79 | ipmiCmdGetSDRAllocationInfo = 0x21, |
| 80 | ipmiCmdReserveSDR = 0x22, |
| 81 | ipmiCmdGetSDR = 0x23, |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 84 | #pragma pack(push, 1) |
| 85 | struct FRUHeader |
| 86 | { |
| 87 | uint8_t commonHeaderFormat; |
| 88 | uint8_t internalOffset; |
| 89 | uint8_t chassisOffset; |
| 90 | uint8_t boardOffset; |
| 91 | uint8_t productOffset; |
| 92 | uint8_t multiRecordOffset; |
| 93 | uint8_t pad; |
| 94 | uint8_t checksum; |
| 95 | }; |
| 96 | #pragma pack(pop) |
| 97 | |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 98 | #pragma pack(push, 1) |
| 99 | struct Type12Record |
| 100 | { |
| 101 | get_sdr::SensorDataRecordHeader header; |
Matt Simmering | 80d4d5f | 2023-02-15 15:18:51 -0800 | [diff] [blame] | 102 | uint8_t targetAddress; |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 103 | uint8_t channelNumber; |
| 104 | uint8_t powerStateNotification; |
| 105 | uint8_t deviceCapabilities; |
Johnathan Mantey | f4d5e05 | 2021-09-22 12:58:08 -0700 | [diff] [blame] | 106 | // define reserved bytes explicitly. The uint24_t is silently expanded to |
| 107 | // uint32_t, which ruins the byte alignment required by this structure. |
| 108 | uint8_t reserved[3]; |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 109 | uint8_t entityID; |
| 110 | uint8_t entityInstance; |
| 111 | uint8_t oem; |
| 112 | uint8_t typeLengthCode; |
| 113 | char name[16]; |
Johnathan Mantey | f4d5e05 | 2021-09-22 12:58:08 -0700 | [diff] [blame] | 114 | |
| 115 | Type12Record(uint16_t recordID, uint8_t address, uint8_t chNumber, |
| 116 | uint8_t pwrStateNotification, uint8_t capabilities, |
| 117 | uint8_t eid, uint8_t entityInst, uint8_t mfrDefined, |
| 118 | const std::string& sensorname) : |
Matt Simmering | 80d4d5f | 2023-02-15 15:18:51 -0800 | [diff] [blame] | 119 | targetAddress(address), |
Johnathan Mantey | f4d5e05 | 2021-09-22 12:58:08 -0700 | [diff] [blame] | 120 | channelNumber(chNumber), powerStateNotification(pwrStateNotification), |
| 121 | deviceCapabilities(capabilities), reserved{}, entityID(eid), |
| 122 | entityInstance(entityInst), oem(mfrDefined) |
| 123 | { |
| 124 | get_sdr::header::set_record_id(recordID, &header); |
| 125 | header.sdr_version = ipmiSdrVersion; |
| 126 | header.record_type = 0x12; |
| 127 | size_t nameLen = std::min(sensorname.size(), sizeof(name)); |
| 128 | header.record_length = sizeof(Type12Record) - |
| 129 | sizeof(get_sdr::SensorDataRecordHeader) - |
| 130 | sizeof(name) + nameLen; |
| 131 | typeLengthCode = 0xc0 | nameLen; |
| 132 | std::copy(sensorname.begin(), sensorname.begin() + nameLen, name); |
| 133 | } |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 134 | }; |
| 135 | #pragma pack(pop) |
| 136 | |
Yong Li | fee5e4c | 2020-01-17 19:36:29 +0800 | [diff] [blame] | 137 | #pragma pack(push, 1) |
| 138 | struct NMDiscoveryRecord |
| 139 | { |
| 140 | get_sdr::SensorDataRecordHeader header; |
| 141 | uint8_t oemID0; |
| 142 | uint8_t oemID1; |
| 143 | uint8_t oemID2; |
| 144 | uint8_t subType; |
| 145 | uint8_t version; |
Matt Simmering | 80d4d5f | 2023-02-15 15:18:51 -0800 | [diff] [blame] | 146 | uint8_t targetAddress; |
Yong Li | fee5e4c | 2020-01-17 19:36:29 +0800 | [diff] [blame] | 147 | uint8_t channelNumber; |
| 148 | uint8_t healthEventSensor; |
| 149 | uint8_t exceptionEventSensor; |
| 150 | uint8_t operationalCapSensor; |
| 151 | uint8_t thresholdExceededSensor; |
| 152 | }; |
| 153 | #pragma pack(pop) |
| 154 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 155 | namespace ipmi |
| 156 | { |
| 157 | namespace storage |
| 158 | { |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 159 | |
Yong Li | fee5e4c | 2020-01-17 19:36:29 +0800 | [diff] [blame] | 160 | constexpr const size_t nmDiscoverySDRCount = 1; |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 161 | constexpr const size_t type12Count = 2; |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 162 | ipmi_ret_t getFruSdrs(ipmi::Context::ptr ctx, size_t index, |
| 163 | get_sdr::SensorDataFruRecord& resp); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 164 | |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 165 | ipmi_ret_t getFruSdrCount(ipmi::Context::ptr ctx, size_t& count); |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 166 | |
| 167 | std::vector<uint8_t> getType12SDRs(uint16_t index, uint16_t recordId); |
Yong Li | fee5e4c | 2020-01-17 19:36:29 +0800 | [diff] [blame] | 168 | std::vector<uint8_t> getNMDiscoverySDR(uint16_t index, uint16_t recordId); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 169 | } // namespace storage |
| 170 | } // namespace ipmi |