1de54f486SWilly Tu /* 2de54f486SWilly Tu // Copyright (c) 2017 2018 Intel Corporation 3de54f486SWilly Tu // 4de54f486SWilly Tu // Licensed under the Apache License, Version 2.0 (the "License"); 5de54f486SWilly Tu // you may not use this file except in compliance with the License. 6de54f486SWilly Tu // You may obtain a copy of the License at 7de54f486SWilly Tu // 8de54f486SWilly Tu // http://www.apache.org/licenses/LICENSE-2.0 9de54f486SWilly Tu // 10de54f486SWilly Tu // Unless required by applicable law or agreed to in writing, software 11de54f486SWilly Tu // distributed under the License is distributed on an "AS IS" BASIS, 12de54f486SWilly Tu // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13de54f486SWilly Tu // See the License for the specific language governing permissions and 14de54f486SWilly Tu // limitations under the License. 15de54f486SWilly Tu */ 16de54f486SWilly Tu 17de54f486SWilly Tu #pragma once 18de54f486SWilly Tu #include <dbus-sdr/sdrutils.hpp> 19de54f486SWilly Tu 20fbc6c9d7SPatrick Williams #include <cstdint> 21fbc6c9d7SPatrick Williams 22de54f486SWilly Tu #pragma pack(push, 1) 23de54f486SWilly Tu 24de54f486SWilly Tu struct SensorThresholdResp 25de54f486SWilly Tu { 26de54f486SWilly Tu uint8_t readable; 27de54f486SWilly Tu uint8_t lowernc; 28de54f486SWilly Tu uint8_t lowercritical; 29de54f486SWilly Tu uint8_t lowernonrecoverable; 30de54f486SWilly Tu uint8_t uppernc; 31de54f486SWilly Tu uint8_t uppercritical; 32de54f486SWilly Tu uint8_t uppernonrecoverable; 33de54f486SWilly Tu }; 34de54f486SWilly Tu 35de54f486SWilly Tu #pragma pack(pop) 36de54f486SWilly Tu 37de54f486SWilly Tu enum class IPMIThresholdRespBits 38de54f486SWilly Tu { 39de54f486SWilly Tu lowerNonCritical, 40de54f486SWilly Tu lowerCritical, 41de54f486SWilly Tu lowerNonRecoverable, 42de54f486SWilly Tu upperNonCritical, 43de54f486SWilly Tu upperCritical, 44de54f486SWilly Tu upperNonRecoverable 45de54f486SWilly Tu }; 46de54f486SWilly Tu 47de54f486SWilly Tu enum class IPMISensorReadingByte2 : uint8_t 48de54f486SWilly Tu { 49de54f486SWilly Tu eventMessagesEnable = (1 << 7), 50de54f486SWilly Tu sensorScanningEnable = (1 << 6), 51de54f486SWilly Tu readingStateUnavailable = (1 << 5), 52de54f486SWilly Tu }; 53de54f486SWilly Tu 54de54f486SWilly Tu enum class IPMISensorReadingByte3 : uint8_t 55de54f486SWilly Tu { 56de54f486SWilly Tu upperNonRecoverable = (1 << 5), 57de54f486SWilly Tu upperCritical = (1 << 4), 58de54f486SWilly Tu upperNonCritical = (1 << 3), 59de54f486SWilly Tu lowerNonRecoverable = (1 << 2), 60de54f486SWilly Tu lowerCritical = (1 << 1), 61de54f486SWilly Tu lowerNonCritical = (1 << 0), 62de54f486SWilly Tu }; 63de54f486SWilly Tu 64de54f486SWilly Tu enum class IPMISensorEventEnableByte2 : uint8_t 65de54f486SWilly Tu { 66de54f486SWilly Tu eventMessagesEnable = (1 << 7), 67de54f486SWilly Tu sensorScanningEnable = (1 << 6), 68de54f486SWilly Tu }; 69de54f486SWilly Tu 70de54f486SWilly Tu enum class IPMISensorEventEnableThresholds : uint8_t 71de54f486SWilly Tu { 72de54f486SWilly Tu nonRecoverableThreshold = (1 << 6), 73de54f486SWilly Tu criticalThreshold = (1 << 5), 74de54f486SWilly Tu nonCriticalThreshold = (1 << 4), 75de54f486SWilly Tu upperNonRecoverableGoingHigh = (1 << 3), 76de54f486SWilly Tu upperNonRecoverableGoingLow = (1 << 2), 77de54f486SWilly Tu upperCriticalGoingHigh = (1 << 1), 78de54f486SWilly Tu upperCriticalGoingLow = (1 << 0), 79de54f486SWilly Tu upperNonCriticalGoingHigh = (1 << 7), 80de54f486SWilly Tu upperNonCriticalGoingLow = (1 << 6), 81de54f486SWilly Tu lowerNonRecoverableGoingHigh = (1 << 5), 82de54f486SWilly Tu lowerNonRecoverableGoingLow = (1 << 4), 83de54f486SWilly Tu lowerCriticalGoingHigh = (1 << 3), 84de54f486SWilly Tu lowerCriticalGoingLow = (1 << 2), 85de54f486SWilly Tu lowerNonCriticalGoingHigh = (1 << 1), 86de54f486SWilly Tu lowerNonCriticalGoingLow = (1 << 0), 87de54f486SWilly Tu }; 88de54f486SWilly Tu 89de54f486SWilly Tu enum class IPMIGetSensorEventEnableThresholds : uint8_t 90de54f486SWilly Tu { 91de54f486SWilly Tu lowerNonCriticalGoingLow = 0, 92de54f486SWilly Tu lowerNonCriticalGoingHigh = 1, 93de54f486SWilly Tu lowerCriticalGoingLow = 2, 94de54f486SWilly Tu lowerCriticalGoingHigh = 3, 95de54f486SWilly Tu lowerNonRecoverableGoingLow = 4, 96de54f486SWilly Tu lowerNonRecoverableGoingHigh = 5, 97de54f486SWilly Tu upperNonCriticalGoingLow = 6, 98de54f486SWilly Tu upperNonCriticalGoingHigh = 7, 99de54f486SWilly Tu upperCriticalGoingLow = 8, 100de54f486SWilly Tu upperCriticalGoingHigh = 9, 101de54f486SWilly Tu upperNonRecoverableGoingLow = 10, 102de54f486SWilly Tu upperNonRecoverableGoingHigh = 11, 103de54f486SWilly Tu }; 104de54f486SWilly Tu 105de54f486SWilly Tu namespace ipmi 106de54f486SWilly Tu { 107de54f486SWilly Tu 108*777cfaf2SJohnathan Mantey uint16_t getNumberOfSensors(); 109de54f486SWilly Tu 110*777cfaf2SJohnathan Mantey SensorSubTree& getSensorTree(); 111*777cfaf2SJohnathan Mantey 112*777cfaf2SJohnathan Mantey ipmi_ret_t getSensorConnection(ipmi::Context::ptr ctx, uint8_t sensnum, 113e39d4d84SHao Jiang std::string& connection, std::string& path, 114*777cfaf2SJohnathan Mantey std::vector<std::string>* interfaces = nullptr); 115de54f486SWilly Tu 116de54f486SWilly Tu struct IPMIThresholds 117de54f486SWilly Tu { 118de54f486SWilly Tu std::optional<uint8_t> warningLow; 119de54f486SWilly Tu std::optional<uint8_t> warningHigh; 120de54f486SWilly Tu std::optional<uint8_t> criticalLow; 121de54f486SWilly Tu std::optional<uint8_t> criticalHigh; 122de54f486SWilly Tu }; 123de54f486SWilly Tu 124*777cfaf2SJohnathan Mantey namespace sensor 125*777cfaf2SJohnathan Mantey { 126*777cfaf2SJohnathan Mantey /** 127*777cfaf2SJohnathan Mantey * @brief Retrieve the number of sensors that are not included in the list of 128*777cfaf2SJohnathan Mantey * sensors published via D-Bus 129*777cfaf2SJohnathan Mantey * 130*777cfaf2SJohnathan Mantey * @param[in]: ctx: the pointer to the D-Bus context 131*777cfaf2SJohnathan Mantey * @return: The number of additional sensors separate from those published 132*777cfaf2SJohnathan Mantey * dynamically on D-Bus 133*777cfaf2SJohnathan Mantey */ 134*777cfaf2SJohnathan Mantey size_t getOtherSensorsCount(ipmi::Context::ptr ctx); 135*777cfaf2SJohnathan Mantey 136*777cfaf2SJohnathan Mantey /** 137*777cfaf2SJohnathan Mantey * @brief Retrieve the record data for the sensors not published via D-Bus 138*777cfaf2SJohnathan Mantey * 139*777cfaf2SJohnathan Mantey * @param[in]: ctx: the pointer to the D-Bus context 140*777cfaf2SJohnathan Mantey * @param[in]: recordID: the integer index for the sensor to retrieve 141*777cfaf2SJohnathan Mantey * @param[out]: SDR data for the indexed sensor 142*777cfaf2SJohnathan Mantey * @return: 0: success 143*777cfaf2SJohnathan Mantey * negative number: error condition 144*777cfaf2SJohnathan Mantey */ 145*777cfaf2SJohnathan Mantey int getOtherSensorsDataRecord(ipmi::Context::ptr ctx, uint16_t recordID, 146*777cfaf2SJohnathan Mantey std::vector<uint8_t>& recordData); 147*777cfaf2SJohnathan Mantey } // namespace sensor 148*777cfaf2SJohnathan Mantey 149b1416efaSThang Tran namespace dcmi 150b1416efaSThang Tran { 151b1416efaSThang Tran 152b1416efaSThang Tran struct sensorInfo 153b1416efaSThang Tran { 154b1416efaSThang Tran std::string objectPath; 155b1416efaSThang Tran uint8_t type; 156b1416efaSThang Tran uint16_t recordId; 157b1416efaSThang Tran uint8_t entityId; 158b1416efaSThang Tran uint8_t entityInstance; 159b1416efaSThang Tran }; 160b1416efaSThang Tran 161b1416efaSThang Tran } // namespace dcmi 162b1416efaSThang Tran 163de54f486SWilly Tu } // namespace ipmi 164