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 | { |
Jason M. Bills | c04e2e7 | 2018-11-28 15:15:56 -0800 | [diff] [blame] | 25 | static constexpr uint8_t selOperationSupport = 0x02; |
| 26 | static constexpr uint8_t systemEvent = 0x02; |
| 27 | static constexpr size_t systemEventSize = 3; |
| 28 | static constexpr uint8_t oemTsEventFirst = 0xC0; |
| 29 | static constexpr uint8_t oemTsEventLast = 0xDF; |
| 30 | static constexpr size_t oemTsEventSize = 9; |
| 31 | static constexpr uint8_t oemEventFirst = 0xE0; |
| 32 | static constexpr uint8_t oemEventLast = 0xFF; |
| 33 | static constexpr size_t oemEventSize = 13; |
| 34 | static constexpr uint8_t eventMsgRev = 0x04; |
| 35 | } // namespace intel_oem::ipmi::sel |
| 36 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 37 | #pragma pack(push, 1) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 38 | struct GetSDRReq |
| 39 | { |
| 40 | uint16_t reservationID; |
| 41 | uint16_t recordID; |
| 42 | uint8_t offset; |
| 43 | uint8_t bytesToRead; |
| 44 | }; |
| 45 | #pragma pack(pop) |
| 46 | |
| 47 | enum class SdrRepositoryInfoOps : uint8_t |
| 48 | { |
| 49 | allocCommandSupported = 0x1, |
| 50 | reserveSDRRepositoryCommandSupported = 0x2, |
| 51 | partialAddSDRSupported = 0x4, |
| 52 | deleteSDRSupported = 0x8, |
| 53 | reserved = 0x10, |
| 54 | modalLSB = 0x20, |
| 55 | modalMSB = 0x40, |
| 56 | overflow = 0x80 |
| 57 | }; |
| 58 | |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 59 | enum class GetFRUAreaAccessType : uint8_t |
| 60 | { |
| 61 | byte = 0x0, |
| 62 | words = 0x1 |
| 63 | }; |
| 64 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 65 | enum class SensorUnits : uint8_t |
| 66 | { |
| 67 | unspecified = 0x0, |
| 68 | degreesC = 0x1, |
| 69 | volts = 0x4, |
| 70 | amps = 0x5, |
| 71 | watts = 0x6, |
| 72 | rpm = 0x12, |
| 73 | }; |
| 74 | |
| 75 | enum class IPMINetfnStorageCmds : ipmi_cmd_t |
| 76 | { |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 77 | ipmiCmdGetRepositoryInfo = 0x20, |
| 78 | ipmiCmdGetSDRAllocationInfo = 0x21, |
| 79 | ipmiCmdReserveSDR = 0x22, |
| 80 | ipmiCmdGetSDR = 0x23, |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
Jason M. Bills | e2d1aee | 2018-10-03 15:57:18 -0700 | [diff] [blame] | 83 | #pragma pack(push, 1) |
| 84 | struct FRUHeader |
| 85 | { |
| 86 | uint8_t commonHeaderFormat; |
| 87 | uint8_t internalOffset; |
| 88 | uint8_t chassisOffset; |
| 89 | uint8_t boardOffset; |
| 90 | uint8_t productOffset; |
| 91 | uint8_t multiRecordOffset; |
| 92 | uint8_t pad; |
| 93 | uint8_t checksum; |
| 94 | }; |
| 95 | #pragma pack(pop) |
| 96 | |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 97 | #pragma pack(push, 1) |
| 98 | struct Type12Record |
| 99 | { |
| 100 | get_sdr::SensorDataRecordHeader header; |
| 101 | uint8_t slaveAddress; |
| 102 | uint8_t channelNumber; |
| 103 | uint8_t powerStateNotification; |
| 104 | uint8_t deviceCapabilities; |
| 105 | uint24_t reserved; |
| 106 | uint8_t entityID; |
| 107 | uint8_t entityInstance; |
| 108 | uint8_t oem; |
| 109 | uint8_t typeLengthCode; |
| 110 | char name[16]; |
| 111 | }; |
| 112 | #pragma pack(pop) |
| 113 | |
Yong Li | fee5e4c | 2020-01-17 19:36:29 +0800 | [diff] [blame] | 114 | #pragma pack(push, 1) |
| 115 | struct NMDiscoveryRecord |
| 116 | { |
| 117 | get_sdr::SensorDataRecordHeader header; |
| 118 | uint8_t oemID0; |
| 119 | uint8_t oemID1; |
| 120 | uint8_t oemID2; |
| 121 | uint8_t subType; |
| 122 | uint8_t version; |
| 123 | uint8_t slaveAddress; |
| 124 | uint8_t channelNumber; |
| 125 | uint8_t healthEventSensor; |
| 126 | uint8_t exceptionEventSensor; |
| 127 | uint8_t operationalCapSensor; |
| 128 | uint8_t thresholdExceededSensor; |
| 129 | }; |
| 130 | #pragma pack(pop) |
| 131 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 132 | namespace ipmi |
| 133 | { |
| 134 | namespace storage |
| 135 | { |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 136 | |
Yong Li | fee5e4c | 2020-01-17 19:36:29 +0800 | [diff] [blame] | 137 | constexpr const size_t nmDiscoverySDRCount = 1; |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 138 | constexpr const size_t type12Count = 2; |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 139 | ipmi_ret_t getFruSdrs(ipmi::Context::ptr ctx, size_t index, |
| 140 | get_sdr::SensorDataFruRecord& resp); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 141 | |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 142 | ipmi_ret_t getFruSdrCount(ipmi::Context::ptr ctx, size_t& count); |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 143 | |
| 144 | std::vector<uint8_t> getType12SDRs(uint16_t index, uint16_t recordId); |
Yong Li | fee5e4c | 2020-01-17 19:36:29 +0800 | [diff] [blame] | 145 | std::vector<uint8_t> getNMDiscoverySDR(uint16_t index, uint16_t recordId); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 146 | } // namespace storage |
| 147 | } // namespace ipmi |