13f7c5e40SJason M. Bills /* 23f7c5e40SJason M. Bills // Copyright (c) 2017 2018 Intel Corporation 33f7c5e40SJason M. Bills // 43f7c5e40SJason M. Bills // Licensed under the Apache License, Version 2.0 (the "License"); 53f7c5e40SJason M. Bills // you may not use this file except in compliance with the License. 63f7c5e40SJason M. Bills // You may obtain a copy of the License at 73f7c5e40SJason M. Bills // 83f7c5e40SJason M. Bills // http://www.apache.org/licenses/LICENSE-2.0 93f7c5e40SJason M. Bills // 103f7c5e40SJason M. Bills // Unless required by applicable law or agreed to in writing, software 113f7c5e40SJason M. Bills // distributed under the License is distributed on an "AS IS" BASIS, 123f7c5e40SJason M. Bills // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133f7c5e40SJason M. Bills // See the License for the specific language governing permissions and 143f7c5e40SJason M. Bills // limitations under the License. 153f7c5e40SJason M. Bills */ 163f7c5e40SJason M. Bills 173f7c5e40SJason M. Bills #pragma once 183f7c5e40SJason M. Bills #include <phosphor-ipmi-host/sensorhandler.hpp> 193f7c5e40SJason M. Bills 20*fcd2d3a9SJames Feist #include <cstdint> 21*fcd2d3a9SJames Feist 223f7c5e40SJason M. Bills static constexpr uint8_t ipmiSdrVersion = 0x51; 233f7c5e40SJason M. Bills 24c04e2e70SJason M. Bills namespace intel_oem::ipmi::sel 25c04e2e70SJason M. Bills { 26c04e2e70SJason M. Bills static constexpr uint8_t selOperationSupport = 0x02; 27c04e2e70SJason M. Bills static constexpr uint8_t systemEvent = 0x02; 28c04e2e70SJason M. Bills static constexpr size_t systemEventSize = 3; 29c04e2e70SJason M. Bills static constexpr uint8_t oemTsEventFirst = 0xC0; 30c04e2e70SJason M. Bills static constexpr uint8_t oemTsEventLast = 0xDF; 31c04e2e70SJason M. Bills static constexpr size_t oemTsEventSize = 9; 32c04e2e70SJason M. Bills static constexpr uint8_t oemEventFirst = 0xE0; 33c04e2e70SJason M. Bills static constexpr uint8_t oemEventLast = 0xFF; 34c04e2e70SJason M. Bills static constexpr size_t oemEventSize = 13; 35c04e2e70SJason M. Bills static constexpr uint8_t eventMsgRev = 0x04; 36c04e2e70SJason M. Bills } // namespace intel_oem::ipmi::sel 37c04e2e70SJason M. Bills 383f7c5e40SJason M. Bills #pragma pack(push, 1) 393f7c5e40SJason M. Bills struct GetSDRReq 403f7c5e40SJason M. Bills { 413f7c5e40SJason M. Bills uint16_t reservationID; 423f7c5e40SJason M. Bills uint16_t recordID; 433f7c5e40SJason M. Bills uint8_t offset; 443f7c5e40SJason M. Bills uint8_t bytesToRead; 453f7c5e40SJason M. Bills }; 463f7c5e40SJason M. Bills #pragma pack(pop) 473f7c5e40SJason M. Bills 483f7c5e40SJason M. Bills enum class SdrRepositoryInfoOps : uint8_t 493f7c5e40SJason M. Bills { 503f7c5e40SJason M. Bills allocCommandSupported = 0x1, 513f7c5e40SJason M. Bills reserveSDRRepositoryCommandSupported = 0x2, 523f7c5e40SJason M. Bills partialAddSDRSupported = 0x4, 533f7c5e40SJason M. Bills deleteSDRSupported = 0x8, 543f7c5e40SJason M. Bills reserved = 0x10, 553f7c5e40SJason M. Bills modalLSB = 0x20, 563f7c5e40SJason M. Bills modalMSB = 0x40, 573f7c5e40SJason M. Bills overflow = 0x80 583f7c5e40SJason M. Bills }; 593f7c5e40SJason M. Bills 60e2d1aee3SJason M. Bills enum class GetFRUAreaAccessType : uint8_t 61e2d1aee3SJason M. Bills { 62e2d1aee3SJason M. Bills byte = 0x0, 63e2d1aee3SJason M. Bills words = 0x1 64e2d1aee3SJason M. Bills }; 65e2d1aee3SJason M. Bills 663f7c5e40SJason M. Bills enum class SensorUnits : uint8_t 673f7c5e40SJason M. Bills { 683f7c5e40SJason M. Bills unspecified = 0x0, 693f7c5e40SJason M. Bills degreesC = 0x1, 703f7c5e40SJason M. Bills volts = 0x4, 713f7c5e40SJason M. Bills amps = 0x5, 723f7c5e40SJason M. Bills watts = 0x6, 733f7c5e40SJason M. Bills rpm = 0x12, 743f7c5e40SJason M. Bills }; 753f7c5e40SJason M. Bills 763f7c5e40SJason M. Bills enum class IPMINetfnStorageCmds : ipmi_cmd_t 773f7c5e40SJason M. Bills { 783f7c5e40SJason M. Bills ipmiCmdGetRepositoryInfo = 0x20, 793f7c5e40SJason M. Bills ipmiCmdGetSDRAllocationInfo = 0x21, 803f7c5e40SJason M. Bills ipmiCmdReserveSDR = 0x22, 813f7c5e40SJason M. Bills ipmiCmdGetSDR = 0x23, 823f7c5e40SJason M. Bills }; 833f7c5e40SJason M. Bills 84e2d1aee3SJason M. Bills #pragma pack(push, 1) 85e2d1aee3SJason M. Bills struct FRUHeader 86e2d1aee3SJason M. Bills { 87e2d1aee3SJason M. Bills uint8_t commonHeaderFormat; 88e2d1aee3SJason M. Bills uint8_t internalOffset; 89e2d1aee3SJason M. Bills uint8_t chassisOffset; 90e2d1aee3SJason M. Bills uint8_t boardOffset; 91e2d1aee3SJason M. Bills uint8_t productOffset; 92e2d1aee3SJason M. Bills uint8_t multiRecordOffset; 93e2d1aee3SJason M. Bills uint8_t pad; 94e2d1aee3SJason M. Bills uint8_t checksum; 95e2d1aee3SJason M. Bills }; 96e2d1aee3SJason M. Bills #pragma pack(pop) 97e2d1aee3SJason M. Bills 9874c50c64SJames Feist #pragma pack(push, 1) 9974c50c64SJames Feist struct Type12Record 10074c50c64SJames Feist { 10174c50c64SJames Feist get_sdr::SensorDataRecordHeader header; 10274c50c64SJames Feist uint8_t slaveAddress; 10374c50c64SJames Feist uint8_t channelNumber; 10474c50c64SJames Feist uint8_t powerStateNotification; 10574c50c64SJames Feist uint8_t deviceCapabilities; 10674c50c64SJames Feist uint24_t reserved; 10774c50c64SJames Feist uint8_t entityID; 10874c50c64SJames Feist uint8_t entityInstance; 10974c50c64SJames Feist uint8_t oem; 11074c50c64SJames Feist uint8_t typeLengthCode; 11174c50c64SJames Feist char name[16]; 11274c50c64SJames Feist }; 11374c50c64SJames Feist #pragma pack(pop) 11474c50c64SJames Feist 115fee5e4c7SYong Li #pragma pack(push, 1) 116fee5e4c7SYong Li struct NMDiscoveryRecord 117fee5e4c7SYong Li { 118fee5e4c7SYong Li get_sdr::SensorDataRecordHeader header; 119fee5e4c7SYong Li uint8_t oemID0; 120fee5e4c7SYong Li uint8_t oemID1; 121fee5e4c7SYong Li uint8_t oemID2; 122fee5e4c7SYong Li uint8_t subType; 123fee5e4c7SYong Li uint8_t version; 124fee5e4c7SYong Li uint8_t slaveAddress; 125fee5e4c7SYong Li uint8_t channelNumber; 126fee5e4c7SYong Li uint8_t healthEventSensor; 127fee5e4c7SYong Li uint8_t exceptionEventSensor; 128fee5e4c7SYong Li uint8_t operationalCapSensor; 129fee5e4c7SYong Li uint8_t thresholdExceededSensor; 130fee5e4c7SYong Li }; 131fee5e4c7SYong Li #pragma pack(pop) 132fee5e4c7SYong Li 1333f7c5e40SJason M. Bills namespace ipmi 1343f7c5e40SJason M. Bills { 1353f7c5e40SJason M. Bills namespace storage 1363f7c5e40SJason M. Bills { 13774c50c64SJames Feist 138fee5e4c7SYong Li constexpr const size_t nmDiscoverySDRCount = 1; 13974c50c64SJames Feist constexpr const size_t type12Count = 2; 1402569025eSJames Feist ipmi_ret_t getFruSdrs(ipmi::Context::ptr ctx, size_t index, 1412569025eSJames Feist get_sdr::SensorDataFruRecord& resp); 1423f7c5e40SJason M. Bills 1432569025eSJames Feist ipmi_ret_t getFruSdrCount(ipmi::Context::ptr ctx, size_t& count); 14474c50c64SJames Feist 14574c50c64SJames Feist std::vector<uint8_t> getType12SDRs(uint16_t index, uint16_t recordId); 146fee5e4c7SYong Li std::vector<uint8_t> getNMDiscoverySDR(uint16_t index, uint16_t recordId); 1473f7c5e40SJason M. Bills } // namespace storage 1483f7c5e40SJason M. Bills } // namespace ipmi 149