| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 1 | #pragma once | 
|  | 2 |  | 
| Brandon Kim | 9cf8562 | 2019-06-19 12:05:08 -0700 | [diff] [blame] | 3 | #include "config.h" | 
|  | 4 |  | 
| Patrick Venture | 46470a3 | 2018-09-07 19:26:25 -0700 | [diff] [blame] | 5 | #include "sensorhandler.hpp" | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 6 |  | 
| Vernon Mauery | e08fbff | 2019-04-03 09:19:34 -0700 | [diff] [blame] | 7 | #include <ipmid/api.hpp> | 
| Vernon Mauery | 3325024 | 2019-03-12 16:49:26 -0700 | [diff] [blame] | 8 | #include <ipmid/types.hpp> | 
| Vernon Mauery | 6a98fe7 | 2019-03-11 15:57:48 -0700 | [diff] [blame] | 9 | #include <ipmid/utils.hpp> | 
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 10 | #include <phosphor-logging/elog-errors.hpp> | 
| George Liu | 9b745a8 | 2024-07-19 09:09:36 +0800 | [diff] [blame] | 11 | #include <phosphor-logging/lg2.hpp> | 
| William A. Kennington III | 4c00802 | 2018-10-12 17:18:14 -0700 | [diff] [blame] | 12 | #include <sdbusplus/message/types.hpp> | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 13 |  | 
| Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 14 | #include <cmath> | 
|  | 15 |  | 
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 16 | #ifdef FEATURE_SENSORS_CACHE | 
| Lei YU | a55e9ea | 2021-09-18 15:15:17 +0800 | [diff] [blame] | 17 |  | 
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 18 | extern ipmi::sensor::SensorCacheMap sensorCacheMap; | 
| Lei YU | a55e9ea | 2021-09-18 15:15:17 +0800 | [diff] [blame] | 19 |  | 
|  | 20 | // The signal's message type is 0x04 from DBus spec: | 
|  | 21 | // https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages | 
|  | 22 | static constexpr auto msgTypeSignal = 0x04; | 
|  | 23 |  | 
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 24 | #endif | 
|  | 25 |  | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 26 | namespace ipmi | 
|  | 27 | { | 
|  | 28 | namespace sensor | 
|  | 29 | { | 
|  | 30 |  | 
|  | 31 | using Assertion = uint16_t; | 
|  | 32 | using Deassertion = uint16_t; | 
|  | 33 | using AssertionSet = std::pair<Assertion, Deassertion>; | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 34 | using Service = std::string; | 
|  | 35 | using Path = std::string; | 
|  | 36 | using Interface = std::string; | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 37 | using ServicePath = std::pair<Path, Service>; | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 38 | using Interfaces = std::vector<Interface>; | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 39 | using MapperResponseType = std::map<Path, std::map<Service, Interfaces>>; | 
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 40 | using PropertyMap = ipmi::PropertyMap; | 
|  | 41 |  | 
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 42 | using namespace phosphor::logging; | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 43 |  | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 44 | /** @brief Make assertion set from input data | 
|  | 45 | *  @param[in] cmdData - Input sensor data | 
|  | 46 | *  @return pair of assertion and deassertion set | 
|  | 47 | */ | 
|  | 48 | AssertionSet getAssertionSet(const SetSensorReadingReq& cmdData); | 
|  | 49 |  | 
|  | 50 | /** @brief send the message to DBus | 
|  | 51 | *  @param[in] msg - message to send | 
|  | 52 | *  @return failure status in IPMI error code | 
|  | 53 | */ | 
| Dhruvaraj Subhashchandran | 2a444d0 | 2017-08-07 01:45:14 -0500 | [diff] [blame] | 54 | ipmi_ret_t updateToDbus(IpmiUpdateData& msg); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 55 |  | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 56 | namespace get | 
|  | 57 | { | 
|  | 58 |  | 
| Tom Joseph | b0adbcd | 2018-01-24 11:51:29 +0530 | [diff] [blame] | 59 | /** @brief Populate sensor name from the D-Bus property associated with the | 
|  | 60 | *         sensor. In the example entry from the yaml, the name of the D-bus | 
|  | 61 | *         property "AttemptsLeft" is the sensor name. | 
|  | 62 | * | 
|  | 63 | *         0x07: | 
|  | 64 | *            sensorType: 195 | 
|  | 65 | *            path: /xyz/openbmc_project/state/host0 | 
|  | 66 | *            sensorReadingType: 0x6F | 
|  | 67 | *            serviceInterface: org.freedesktop.DBus.Properties | 
|  | 68 | *            readingType: readingAssertion | 
|  | 69 | *            sensorNamePattern: nameProperty | 
|  | 70 | *            interfaces: | 
|  | 71 | *              xyz.openbmc_project.Control.Boot.RebootAttempts: | 
|  | 72 | *                AttemptsLeft: | 
|  | 73 | *                    Offsets: | 
|  | 74 | *                        0xFF: | 
|  | 75 | *                          type: uint32_t | 
|  | 76 | * | 
|  | 77 | * | 
|  | 78 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 79 | * | 
|  | 80 | *  @return On success return the sensor name for the sensor. | 
|  | 81 | */ | 
|  | 82 | inline SensorName nameProperty(const Info& sensorInfo) | 
|  | 83 | { | 
|  | 84 | return sensorInfo.propertyInterfaces.begin()->second.begin()->first; | 
|  | 85 | } | 
|  | 86 |  | 
|  | 87 | /** @brief Populate sensor name from the D-Bus object associated with the | 
|  | 88 | *         sensor. If the object path is /system/chassis/motherboard/dimm0 then | 
|  | 89 | *         the leaf dimm0 is considered as the sensor name. | 
|  | 90 | * | 
|  | 91 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 92 | * | 
|  | 93 | *  @return On success return the sensor name for the sensor. | 
|  | 94 | */ | 
|  | 95 | inline SensorName nameLeaf(const Info& sensorInfo) | 
|  | 96 | { | 
|  | 97 | return sensorInfo.sensorPath.substr( | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 98 | sensorInfo.sensorPath.find_last_of('/') + 1, | 
|  | 99 | sensorInfo.sensorPath.length()); | 
| Tom Joseph | b0adbcd | 2018-01-24 11:51:29 +0530 | [diff] [blame] | 100 | } | 
|  | 101 |  | 
|  | 102 | /** @brief Populate sensor name from the D-Bus object associated with the | 
| Lotus Xu | 2101a44 | 2020-12-24 16:01:56 +0800 | [diff] [blame] | 103 | *         sensor and the property. | 
|  | 104 | *         If the object path is /xyz/openbmc_project/inventory/Fan0 and | 
|  | 105 | *         the property is Present, the leaf Fan0 and the Property is | 
|  | 106 | *         joined to Fan0_Present as the sensor name. | 
|  | 107 | * | 
|  | 108 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 109 | * | 
|  | 110 | *  @return On success return the sensor name for the sensor. | 
|  | 111 | */ | 
|  | 112 | inline SensorName nameLeafProperty(const Info& sensorInfo) | 
|  | 113 | { | 
|  | 114 | return nameLeaf(sensorInfo) + "_" + nameProperty(sensorInfo); | 
|  | 115 | } | 
|  | 116 |  | 
|  | 117 | /** @brief Populate sensor name from the D-Bus object associated with the | 
| Tom Joseph | b0adbcd | 2018-01-24 11:51:29 +0530 | [diff] [blame] | 118 | *         sensor. If the object path is /system/chassis/motherboard/cpu0/core0 | 
|  | 119 | *         then the sensor name is cpu0_core0. The leaf and the parent is put | 
|  | 120 | *         together to get the sensor name. | 
|  | 121 | * | 
|  | 122 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 123 | * | 
|  | 124 | *  @return On success return the sensor name for the sensor. | 
|  | 125 | */ | 
|  | 126 | SensorName nameParentLeaf(const Info& sensorInfo); | 
|  | 127 |  | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 128 | /** | 
|  | 129 | *  @brief Helper function to map the dbus info to sensor's assertion status | 
|  | 130 | *         for the get sensor reading command. | 
|  | 131 | * | 
|  | 132 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 133 | *  @param[in] path - Dbus object path. | 
|  | 134 | *  @param[in] interface - Dbus interface. | 
|  | 135 | * | 
|  | 136 | *  @return Response for get sensor reading command. | 
|  | 137 | */ | 
|  | 138 | GetSensorResponse mapDbusToAssertion(const Info& sensorInfo, | 
|  | 139 | const InstancePath& path, | 
|  | 140 | const DbusInterface& interface); | 
|  | 141 |  | 
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 142 | #ifndef FEATURE_SENSORS_CACHE | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 143 | /** | 
|  | 144 | *  @brief Map the Dbus info to sensor's assertion status in the Get sensor | 
|  | 145 | *         reading command response. | 
|  | 146 | * | 
|  | 147 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 148 | * | 
|  | 149 | *  @return Response for get sensor reading command. | 
|  | 150 | */ | 
|  | 151 | GetSensorResponse assertion(const Info& sensorInfo); | 
|  | 152 |  | 
| Tom Joseph | e4014fc | 2017-09-06 23:57:36 +0530 | [diff] [blame] | 153 | /** | 
|  | 154 | *  @brief Maps the Dbus info to the reading field in the Get sensor reading | 
|  | 155 | *         command response. | 
|  | 156 | * | 
|  | 157 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 158 | * | 
|  | 159 | *  @return Response for get sensor reading command. | 
|  | 160 | */ | 
|  | 161 | GetSensorResponse eventdata2(const Info& sensorInfo); | 
|  | 162 |  | 
| Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 163 | /** | 
|  | 164 | *  @brief readingAssertion is a case where the entire assertion state field | 
|  | 165 | *         serves as the sensor value. | 
|  | 166 | * | 
|  | 167 | *  @tparam T - type of the dbus property related to sensor. | 
|  | 168 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 169 | * | 
|  | 170 | *  @return Response for get sensor reading command. | 
|  | 171 | */ | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 172 | template <typename T> | 
| Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 173 | GetSensorResponse readingAssertion(const Info& sensorInfo) | 
|  | 174 | { | 
| Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 175 | sdbusplus::bus_t bus{ipmid_get_sd_bus_connection()}; | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 176 | GetSensorResponse response{}; | 
| Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 177 |  | 
| Jeremy Kerr | 3dc3558 | 2020-05-17 15:47:07 +0800 | [diff] [blame] | 178 | enableScanning(&response); | 
|  | 179 |  | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 180 | auto service = ipmi::getService(bus, sensorInfo.sensorInterface, | 
| Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 181 | sensorInfo.sensorPath); | 
|  | 182 |  | 
|  | 183 | auto propValue = ipmi::getDbusProperty( | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 184 | bus, service, sensorInfo.sensorPath, | 
|  | 185 | sensorInfo.propertyInterfaces.begin()->first, | 
|  | 186 | sensorInfo.propertyInterfaces.begin()->second.begin()->first); | 
| Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 187 |  | 
| Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 188 | setAssertionBytes(static_cast<uint16_t>(std::get<T>(propValue)), &response); | 
| Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 189 |  | 
|  | 190 | return response; | 
|  | 191 | } | 
|  | 192 |  | 
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 193 | /** @brief Map the Dbus info to the reading field in the Get sensor reading | 
|  | 194 | *         command response | 
|  | 195 | * | 
|  | 196 | *  @tparam T - type of the dbus property related to sensor. | 
|  | 197 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 198 | * | 
|  | 199 | *  @return Response for get sensor reading command. | 
|  | 200 | */ | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 201 | template <typename T> | 
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 202 | GetSensorResponse readingData(const Info& sensorInfo) | 
|  | 203 | { | 
| Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 204 | sdbusplus::bus_t bus{ipmid_get_sd_bus_connection()}; | 
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 205 |  | 
| Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 206 | GetSensorResponse response{}; | 
|  | 207 |  | 
|  | 208 | enableScanning(&response); | 
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 209 |  | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 210 | auto service = ipmi::getService(bus, sensorInfo.sensorInterface, | 
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 211 | sensorInfo.sensorPath); | 
|  | 212 |  | 
| Brandon Kim | 9cf8562 | 2019-06-19 12:05:08 -0700 | [diff] [blame] | 213 | #ifdef UPDATE_FUNCTIONAL_ON_FAIL | 
|  | 214 | // Check the OperationalStatus interface for functional property | 
|  | 215 | if (sensorInfo.propertyInterfaces.begin()->first == | 
|  | 216 | "xyz.openbmc_project.Sensor.Value") | 
|  | 217 | { | 
|  | 218 | bool functional = true; | 
|  | 219 | try | 
|  | 220 | { | 
|  | 221 | auto funcValue = ipmi::getDbusProperty( | 
|  | 222 | bus, service, sensorInfo.sensorPath, | 
|  | 223 | "xyz.openbmc_project.State.Decorator.OperationalStatus", | 
|  | 224 | "Functional"); | 
|  | 225 | functional = std::get<bool>(funcValue); | 
|  | 226 | } | 
|  | 227 | catch (...) | 
|  | 228 | { | 
|  | 229 | // No-op if Functional property could not be found since this | 
|  | 230 | // check is only valid for Sensor.Value read for hwmonio | 
|  | 231 | } | 
|  | 232 | if (!functional) | 
|  | 233 | { | 
|  | 234 | throw SensorFunctionalError(); | 
|  | 235 | } | 
|  | 236 | } | 
|  | 237 | #endif | 
|  | 238 |  | 
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 239 | auto propValue = ipmi::getDbusProperty( | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 240 | bus, service, sensorInfo.sensorPath, | 
|  | 241 | sensorInfo.propertyInterfaces.begin()->first, | 
|  | 242 | sensorInfo.propertyInterfaces.begin()->second.begin()->first); | 
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 243 |  | 
| Vernon Mauery | f442e11 | 2019-04-09 11:44:36 -0700 | [diff] [blame] | 244 | double value = std::get<T>(propValue) * | 
| Patrick Venture | 586d35b | 2018-09-07 19:56:18 -0700 | [diff] [blame] | 245 | std::pow(10, sensorInfo.scale - sensorInfo.exponentR); | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 246 | int32_t rawData = | 
|  | 247 | (value - sensorInfo.scaledOffset) / sensorInfo.coefficientM; | 
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 248 |  | 
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 249 | constexpr uint8_t sensorUnitsSignedBits = 2 << 6; | 
|  | 250 | constexpr uint8_t signedDataFormat = 0x80; | 
|  | 251 | // if sensorUnits1 [7:6] = 10b, sensor is signed | 
| Willy Tu | 9154caa | 2021-12-02 02:28:54 -0800 | [diff] [blame] | 252 | int32_t minClamp; | 
|  | 253 | int32_t maxClamp; | 
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 254 | if ((sensorInfo.sensorUnits1 & sensorUnitsSignedBits) == signedDataFormat) | 
|  | 255 | { | 
| Willy Tu | 9154caa | 2021-12-02 02:28:54 -0800 | [diff] [blame] | 256 | minClamp = std::numeric_limits<int8_t>::lowest(); | 
|  | 257 | maxClamp = std::numeric_limits<int8_t>::max(); | 
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 258 | } | 
|  | 259 | else | 
|  | 260 | { | 
| Willy Tu | 9154caa | 2021-12-02 02:28:54 -0800 | [diff] [blame] | 261 | minClamp = std::numeric_limits<uint8_t>::lowest(); | 
|  | 262 | maxClamp = std::numeric_limits<uint8_t>::max(); | 
| Tony Lee | c532425 | 2019-10-31 17:24:16 +0800 | [diff] [blame] | 263 | } | 
| Willy Tu | 9154caa | 2021-12-02 02:28:54 -0800 | [diff] [blame] | 264 | setReading(static_cast<uint8_t>(std::clamp(rawData, minClamp, maxClamp)), | 
|  | 265 | &response); | 
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 266 |  | 
| Konstantin Aladyshev | f93b29c | 2021-05-05 14:49:14 +0300 | [diff] [blame] | 267 | if (!std::isfinite(value)) | 
|  | 268 | { | 
|  | 269 | response.readingOrStateUnavailable = 1; | 
|  | 270 | } | 
|  | 271 |  | 
| Konstantin Aladyshev | 778f659 | 2021-11-02 11:28:25 +0300 | [diff] [blame] | 272 | bool critAlarmHigh; | 
|  | 273 | try | 
|  | 274 | { | 
|  | 275 | critAlarmHigh = std::get<bool>(ipmi::getDbusProperty( | 
|  | 276 | bus, service, sensorInfo.sensorPath, | 
|  | 277 | "xyz.openbmc_project.Sensor.Threshold.Critical", | 
|  | 278 | "CriticalAlarmHigh")); | 
|  | 279 | } | 
|  | 280 | catch (const std::exception& e) | 
|  | 281 | { | 
|  | 282 | critAlarmHigh = false; | 
|  | 283 | } | 
|  | 284 | bool critAlarmLow; | 
|  | 285 | try | 
|  | 286 | { | 
|  | 287 | critAlarmLow = std::get<bool>(ipmi::getDbusProperty( | 
|  | 288 | bus, service, sensorInfo.sensorPath, | 
|  | 289 | "xyz.openbmc_project.Sensor.Threshold.Critical", | 
|  | 290 | "CriticalAlarmLow")); | 
|  | 291 | } | 
|  | 292 | catch (const std::exception& e) | 
|  | 293 | { | 
|  | 294 | critAlarmLow = false; | 
|  | 295 | } | 
|  | 296 | bool warningAlarmHigh; | 
|  | 297 | try | 
|  | 298 | { | 
|  | 299 | warningAlarmHigh = std::get<bool>(ipmi::getDbusProperty( | 
|  | 300 | bus, service, sensorInfo.sensorPath, | 
|  | 301 | "xyz.openbmc_project.Sensor.Threshold.Warning", | 
|  | 302 | "WarningAlarmHigh")); | 
|  | 303 | } | 
|  | 304 | catch (const std::exception& e) | 
|  | 305 | { | 
|  | 306 | warningAlarmHigh = false; | 
|  | 307 | } | 
|  | 308 | bool warningAlarmLow; | 
|  | 309 | try | 
|  | 310 | { | 
|  | 311 | warningAlarmLow = std::get<bool>(ipmi::getDbusProperty( | 
|  | 312 | bus, service, sensorInfo.sensorPath, | 
| Tim Lee | d09db49 | 2022-05-30 10:22:34 +0800 | [diff] [blame] | 313 | "xyz.openbmc_project.Sensor.Threshold.Warning", "WarningAlarmLow")); | 
| Konstantin Aladyshev | 778f659 | 2021-11-02 11:28:25 +0300 | [diff] [blame] | 314 | } | 
|  | 315 | catch (const std::exception& e) | 
|  | 316 | { | 
|  | 317 | warningAlarmLow = false; | 
|  | 318 | } | 
|  | 319 | response.thresholdLevelsStates = | 
| George Liu | 33d90e1 | 2022-05-16 12:54:20 +0800 | [diff] [blame] | 320 | (static_cast<uint8_t>(critAlarmHigh) << 3) | | 
|  | 321 | (static_cast<uint8_t>(critAlarmLow) << 2) | | 
|  | 322 | (static_cast<uint8_t>(warningAlarmHigh) << 1) | | 
|  | 323 | (static_cast<uint8_t>(warningAlarmLow)); | 
| Konstantin Aladyshev | 778f659 | 2021-11-02 11:28:25 +0300 | [diff] [blame] | 324 |  | 
| Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 325 | return response; | 
|  | 326 | } | 
|  | 327 |  | 
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 328 | #else | 
|  | 329 |  | 
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 330 | /** | 
|  | 331 | *  @brief Map the Dbus info to sensor's assertion status in the Get sensor | 
|  | 332 | *         reading command response. | 
|  | 333 | * | 
|  | 334 | *  @param[in] id - The sensor id | 
|  | 335 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 336 | *  @param[in] msg - Dbus message from match callback. | 
|  | 337 | * | 
|  | 338 | *  @return Response for get sensor reading command. | 
|  | 339 | */ | 
|  | 340 | std::optional<GetSensorResponse> assertion(uint8_t id, const Info& sensorInfo, | 
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 341 | const PropertyMap& properties); | 
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 342 |  | 
|  | 343 | /** | 
|  | 344 | *  @brief Maps the Dbus info to the reading field in the Get sensor reading | 
|  | 345 | *         command response. | 
|  | 346 | * | 
|  | 347 | *  @param[in] id - The sensor id | 
|  | 348 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 349 | *  @param[in] msg - Dbus message from match callback. | 
|  | 350 | * | 
|  | 351 | *  @return Response for get sensor reading command. | 
|  | 352 | */ | 
|  | 353 | std::optional<GetSensorResponse> eventdata2(uint8_t id, const Info& sensorInfo, | 
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 354 | const PropertyMap& properties); | 
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 355 |  | 
|  | 356 | /** | 
|  | 357 | *  @brief readingAssertion is a case where the entire assertion state field | 
|  | 358 | *         serves as the sensor value. | 
|  | 359 | * | 
|  | 360 | *  @tparam T - type of the dbus property related to sensor. | 
|  | 361 | *  @param[in] id - The sensor id | 
|  | 362 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 363 | *  @param[in] msg - Dbus message from match callback. | 
|  | 364 | * | 
|  | 365 | *  @return Response for get sensor reading command. | 
|  | 366 | */ | 
|  | 367 | template <typename T> | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 368 | std::optional<GetSensorResponse> readingAssertion( | 
|  | 369 | uint8_t id, const Info& sensorInfo, const PropertyMap& properties) | 
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 370 | { | 
| Lei YU | 7d72034 | 2021-09-18 18:39:09 +0800 | [diff] [blame] | 371 | GetSensorResponse response{}; | 
| Lei YU | 7d72034 | 2021-09-18 18:39:09 +0800 | [diff] [blame] | 372 | enableScanning(&response); | 
|  | 373 |  | 
| Lei YU | 7d72034 | 2021-09-18 18:39:09 +0800 | [diff] [blame] | 374 | auto iter = properties.find( | 
|  | 375 | sensorInfo.propertyInterfaces.begin()->second.begin()->first); | 
|  | 376 | if (iter == properties.end()) | 
|  | 377 | { | 
|  | 378 | return {}; | 
|  | 379 | } | 
|  | 380 |  | 
|  | 381 | setAssertionBytes(static_cast<uint16_t>(std::get<T>(iter->second)), | 
|  | 382 | &response); | 
|  | 383 |  | 
|  | 384 | if (!sensorCacheMap[id].has_value()) | 
|  | 385 | { | 
|  | 386 | sensorCacheMap[id] = SensorData{}; | 
|  | 387 | } | 
|  | 388 | sensorCacheMap[id]->response = response; | 
|  | 389 | return response; | 
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 390 | } | 
|  | 391 |  | 
|  | 392 | /** @brief Get sensor reading from the dbus message from match | 
|  | 393 | * | 
|  | 394 | *  @tparam T - type of the dbus property related to sensor. | 
|  | 395 | *  @param[in] id - The sensor id | 
|  | 396 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 397 | *  @param[in] msg - Dbus message from match callback. | 
|  | 398 | * | 
|  | 399 | *  @return Response for get sensor reading command. | 
|  | 400 | */ | 
|  | 401 | template <typename T> | 
|  | 402 | std::optional<GetSensorResponse> readingData(uint8_t id, const Info& sensorInfo, | 
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 403 | const PropertyMap& properties) | 
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 404 | { | 
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 405 | auto iter = properties.find("Functional"); | 
|  | 406 | if (iter != properties.end()) | 
| Lei YU | a55e9ea | 2021-09-18 15:15:17 +0800 | [diff] [blame] | 407 | { | 
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 408 | sensorCacheMap[id]->functional = std::get<bool>(iter->second); | 
| Lei YU | a55e9ea | 2021-09-18 15:15:17 +0800 | [diff] [blame] | 409 | } | 
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 410 | iter = properties.find("Available"); | 
|  | 411 | if (iter != properties.end()) | 
|  | 412 | { | 
|  | 413 | sensorCacheMap[id]->available = std::get<bool>(iter->second); | 
|  | 414 | } | 
|  | 415 | #ifdef UPDATE_FUNCTIONAL_ON_FAIL | 
|  | 416 | if (sensorCacheMap[id]) | 
|  | 417 | { | 
|  | 418 | if (!sensorCacheMap[id]->functional) | 
|  | 419 | { | 
|  | 420 | throw SensorFunctionalError(); | 
|  | 421 | } | 
|  | 422 | } | 
|  | 423 | #endif | 
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 424 |  | 
|  | 425 | GetSensorResponse response{}; | 
|  | 426 |  | 
|  | 427 | enableScanning(&response); | 
|  | 428 |  | 
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 429 | iter = properties.find( | 
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 430 | sensorInfo.propertyInterfaces.begin()->second.begin()->first); | 
|  | 431 | if (iter == properties.end()) | 
|  | 432 | { | 
|  | 433 | return {}; | 
|  | 434 | } | 
|  | 435 |  | 
|  | 436 | double value = std::get<T>(iter->second) * | 
|  | 437 | std::pow(10, sensorInfo.scale - sensorInfo.exponentR); | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 438 | int32_t rawData = | 
|  | 439 | (value - sensorInfo.scaledOffset) / sensorInfo.coefficientM; | 
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 440 |  | 
|  | 441 | constexpr uint8_t sensorUnitsSignedBits = 2 << 6; | 
|  | 442 | constexpr uint8_t signedDataFormat = 0x80; | 
|  | 443 | // if sensorUnits1 [7:6] = 10b, sensor is signed | 
|  | 444 | if ((sensorInfo.sensorUnits1 & sensorUnitsSignedBits) == signedDataFormat) | 
|  | 445 | { | 
|  | 446 | if (rawData > std::numeric_limits<int8_t>::max() || | 
|  | 447 | rawData < std::numeric_limits<int8_t>::lowest()) | 
|  | 448 | { | 
| George Liu | 9b745a8 | 2024-07-19 09:09:36 +0800 | [diff] [blame] | 449 | lg2::error("Value out of range"); | 
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 450 | throw std::out_of_range("Value out of range"); | 
|  | 451 | } | 
|  | 452 | setReading(static_cast<int8_t>(rawData), &response); | 
|  | 453 | } | 
|  | 454 | else | 
|  | 455 | { | 
|  | 456 | if (rawData > std::numeric_limits<uint8_t>::max() || | 
|  | 457 | rawData < std::numeric_limits<uint8_t>::lowest()) | 
|  | 458 | { | 
| George Liu | 9b745a8 | 2024-07-19 09:09:36 +0800 | [diff] [blame] | 459 | lg2::error("Value out of range"); | 
| Lei YU | 9714050 | 2021-09-17 13:49:43 +0800 | [diff] [blame] | 460 | throw std::out_of_range("Value out of range"); | 
|  | 461 | } | 
|  | 462 | setReading(static_cast<uint8_t>(rawData), &response); | 
|  | 463 | } | 
|  | 464 |  | 
|  | 465 | if (!std::isfinite(value)) | 
|  | 466 | { | 
|  | 467 | response.readingOrStateUnavailable = 1; | 
|  | 468 | } | 
|  | 469 |  | 
|  | 470 | if (!sensorCacheMap[id].has_value()) | 
|  | 471 | { | 
|  | 472 | sensorCacheMap[id] = SensorData{}; | 
|  | 473 | } | 
|  | 474 | sensorCacheMap[id]->response = response; | 
|  | 475 |  | 
|  | 476 | return response; | 
| Lei YU | 8c2c048 | 2021-09-16 17:28:28 +0800 | [diff] [blame] | 477 | } | 
|  | 478 |  | 
|  | 479 | #endif // FEATURE_SENSORS_CACHE | 
|  | 480 |  | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 481 | } // namespace get | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 482 |  | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 483 | namespace set | 
|  | 484 | { | 
|  | 485 |  | 
|  | 486 | /** @brief Make a DBus message for a Dbus call | 
|  | 487 | *  @param[in] updateInterface - Interface name | 
|  | 488 | *  @param[in] sensorPath - Path of the sensor | 
|  | 489 | *  @param[in] command - command to be executed | 
|  | 490 | *  @param[in] sensorInterface - DBus interface of sensor | 
|  | 491 | *  @return a dbus message | 
|  | 492 | */ | 
|  | 493 | IpmiUpdateData makeDbusMsg(const std::string& updateInterface, | 
|  | 494 | const std::string& sensorPath, | 
|  | 495 | const std::string& command, | 
|  | 496 | const std::string& sensorInterface); | 
|  | 497 |  | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 498 | /** @brief Update d-bus based on assertion type sensor data | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 499 | *  @param[in] cmdData - input sensor data | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 500 | *  @param[in] sensorInfo - sensor d-bus info | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 501 | *  @return a IPMI error code | 
|  | 502 | */ | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 503 | ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, | 
|  | 504 | const Info& sensorInfo); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 505 |  | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 506 | /** @brief Update d-bus based on a reading assertion | 
|  | 507 | *  @tparam T - type of d-bus property mapping this sensor | 
|  | 508 | *  @param[in] cmdData - input sensor data | 
|  | 509 | *  @param[in] sensorInfo - sensor d-bus info | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 510 | *  @return a IPMI error code | 
|  | 511 | */ | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 512 | template <typename T> | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 513 | ipmi_ret_t readingAssertion(const SetSensorReadingReq& cmdData, | 
|  | 514 | const Info& sensorInfo) | 
|  | 515 | { | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 516 | auto msg = | 
|  | 517 | makeDbusMsg("org.freedesktop.DBus.Properties", sensorInfo.sensorPath, | 
|  | 518 | "Set", sensorInfo.sensorInterface); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 519 |  | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 520 | const auto& interface = sensorInfo.propertyInterfaces.begin(); | 
|  | 521 | msg.append(interface->first); | 
|  | 522 | for (const auto& property : interface->second) | 
|  | 523 | { | 
|  | 524 | msg.append(property.first); | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 525 | std::variant<T> value = static_cast<T>( | 
|  | 526 | (cmdData.assertOffset8_14 << 8) | cmdData.assertOffset0_7); | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 527 | msg.append(value); | 
|  | 528 | } | 
|  | 529 | return updateToDbus(msg); | 
|  | 530 | } | 
|  | 531 |  | 
| Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 532 | /** @brief Update d-bus based on a discrete reading | 
|  | 533 | *  @param[in] cmdData - input sensor data | 
|  | 534 | *  @param[in] sensorInfo - sensor d-bus info | 
|  | 535 | *  @return an IPMI error code | 
|  | 536 | */ | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 537 | template <typename T> | 
| Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 538 | ipmi_ret_t readingData(const SetSensorReadingReq& cmdData, | 
|  | 539 | const Info& sensorInfo) | 
|  | 540 | { | 
| Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 541 | T raw_value = (sensorInfo.coefficientM * cmdData.reading) + | 
|  | 542 | sensorInfo.scaledOffset; | 
| Tom Joseph | 2210215 | 2018-03-02 18:46:39 +0530 | [diff] [blame] | 543 |  | 
| Patrick Venture | 586d35b | 2018-09-07 19:56:18 -0700 | [diff] [blame] | 544 | raw_value *= std::pow(10, sensorInfo.exponentR - sensorInfo.scale); | 
| Tom Joseph | 2210215 | 2018-03-02 18:46:39 +0530 | [diff] [blame] | 545 |  | 
| Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 546 | auto msg = | 
|  | 547 | makeDbusMsg("org.freedesktop.DBus.Properties", sensorInfo.sensorPath, | 
|  | 548 | "Set", sensorInfo.sensorInterface); | 
| Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 549 |  | 
|  | 550 | const auto& interface = sensorInfo.propertyInterfaces.begin(); | 
|  | 551 | msg.append(interface->first); | 
|  | 552 |  | 
| Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 553 | for (const auto& property : interface->second) | 
|  | 554 | { | 
|  | 555 | msg.append(property.first); | 
| Vernon Mauery | 16b8693 | 2019-05-01 08:36:11 -0700 | [diff] [blame] | 556 | std::variant<T> value = raw_value; | 
| Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 557 | msg.append(value); | 
|  | 558 | } | 
|  | 559 | return updateToDbus(msg); | 
|  | 560 | } | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 561 |  | 
|  | 562 | /** @brief Update d-bus based on eventdata type sensor data | 
|  | 563 | *  @param[in] cmdData - input sensor data | 
|  | 564 | *  @param[in] sensorInfo - sensor d-bus info | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 565 | *  @return a IPMI error code | 
|  | 566 | */ | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 567 | ipmi_ret_t eventdata(const SetSensorReadingReq& cmdData, const Info& sensorInfo, | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 568 | uint8_t data); | 
|  | 569 |  | 
|  | 570 | /** @brief Update d-bus based on eventdata1 type sensor data | 
|  | 571 | *  @param[in] cmdData - input sensor data | 
|  | 572 | *  @param[in] sensorInfo - sensor d-bus info | 
|  | 573 | *  @return a IPMI error code | 
|  | 574 | */ | 
|  | 575 | inline ipmi_ret_t eventdata1(const SetSensorReadingReq& cmdData, | 
|  | 576 | const Info& sensorInfo) | 
|  | 577 | { | 
|  | 578 | return eventdata(cmdData, sensorInfo, cmdData.eventData1); | 
|  | 579 | } | 
|  | 580 |  | 
|  | 581 | /** @brief Update d-bus based on eventdata2 type sensor data | 
|  | 582 | *  @param[in] cmdData - input sensor data | 
|  | 583 | *  @param[in] sensorInfo - sensor d-bus info | 
|  | 584 | *  @return a IPMI error code | 
|  | 585 | */ | 
|  | 586 | inline ipmi_ret_t eventdata2(const SetSensorReadingReq& cmdData, | 
|  | 587 | const Info& sensorInfo) | 
|  | 588 | { | 
|  | 589 | return eventdata(cmdData, sensorInfo, cmdData.eventData2); | 
|  | 590 | } | 
|  | 591 |  | 
|  | 592 | /** @brief Update d-bus based on eventdata3 type sensor data | 
|  | 593 | *  @param[in] cmdData - input sensor data | 
|  | 594 | *  @param[in] sensorInfo - sensor d-bus info | 
|  | 595 | *  @return a IPMI error code | 
|  | 596 | */ | 
|  | 597 | inline ipmi_ret_t eventdata3(const SetSensorReadingReq& cmdData, | 
|  | 598 | const Info& sensorInfo) | 
|  | 599 | { | 
|  | 600 | return eventdata(cmdData, sensorInfo, cmdData.eventData3); | 
|  | 601 | } | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 602 |  | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 603 | } // namespace set | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 604 |  | 
|  | 605 | namespace notify | 
|  | 606 | { | 
|  | 607 |  | 
|  | 608 | /** @brief Make a DBus message for a Dbus call | 
|  | 609 | *  @param[in] updateInterface - Interface name | 
|  | 610 | *  @param[in] sensorPath - Path of the sensor | 
|  | 611 | *  @param[in] command - command to be executed | 
|  | 612 | *  @param[in] sensorInterface - DBus interface of sensor | 
|  | 613 | *  @return a dbus message | 
|  | 614 | */ | 
|  | 615 | IpmiUpdateData makeDbusMsg(const std::string& updateInterface, | 
|  | 616 | const std::string& sensorPath, | 
|  | 617 | const std::string& command, | 
|  | 618 | const std::string& sensorInterface); | 
|  | 619 |  | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 620 | /** @brief Update d-bus based on assertion type sensor data | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 621 | *  @param[in] interfaceMap - sensor interface | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 622 | *  @param[in] cmdData - input sensor data | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 623 | *  @param[in] sensorInfo - sensor d-bus info | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 624 | *  @return a IPMI error code | 
|  | 625 | */ | 
| Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 626 | ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, | 
|  | 627 | const Info& sensorInfo); | 
| Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 628 |  | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 629 | } // namespace notify | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 630 |  | 
|  | 631 | namespace inventory | 
|  | 632 | { | 
|  | 633 |  | 
|  | 634 | namespace get | 
|  | 635 | { | 
|  | 636 |  | 
| Lei YU | ff8c9b4 | 2021-10-15 14:20:57 +0800 | [diff] [blame] | 637 | #ifndef FEATURE_SENSORS_CACHE | 
|  | 638 |  | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 639 | /** | 
|  | 640 | *  @brief Map the Dbus info to sensor's assertion status in the Get sensor | 
|  | 641 | *         reading command response. | 
|  | 642 | * | 
|  | 643 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 644 | * | 
|  | 645 | *  @return Response for get sensor reading command. | 
|  | 646 | */ | 
|  | 647 | GetSensorResponse assertion(const Info& sensorInfo); | 
|  | 648 |  | 
| Lei YU | ff8c9b4 | 2021-10-15 14:20:57 +0800 | [diff] [blame] | 649 | #else | 
|  | 650 |  | 
|  | 651 | /** | 
|  | 652 | *  @brief Map the Dbus info to sensor's assertion status in the Get sensor | 
|  | 653 | *         reading command response. | 
|  | 654 | * | 
|  | 655 | *  @param[in] id - The sensor id | 
|  | 656 | *  @param[in] sensorInfo - Dbus info related to sensor. | 
|  | 657 | *  @param[in] msg - Dbus message from match callback. | 
|  | 658 | * | 
|  | 659 | *  @return Response for get sensor reading command. | 
|  | 660 | */ | 
|  | 661 | std::optional<GetSensorResponse> assertion(uint8_t id, const Info& sensorInfo, | 
| Lei YU | 8e8152c | 2021-12-06 20:11:08 +0800 | [diff] [blame] | 662 | const PropertyMap& properties); | 
| Lei YU | ff8c9b4 | 2021-10-15 14:20:57 +0800 | [diff] [blame] | 663 |  | 
|  | 664 | #endif | 
|  | 665 |  | 
| Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 666 | } // namespace get | 
|  | 667 |  | 
|  | 668 | } // namespace inventory | 
| Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 669 | } // namespace sensor | 
|  | 670 | } // namespace ipmi |