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 | |
Patrick Venture | 586d35b | 2018-09-07 19:56:18 -0700 | [diff] [blame] | 7 | #include <cmath> |
Vernon Mauery | e08fbff | 2019-04-03 09:19:34 -0700 | [diff] [blame] | 8 | #include <ipmid/api.hpp> |
Vernon Mauery | 3325024 | 2019-03-12 16:49:26 -0700 | [diff] [blame] | 9 | #include <ipmid/types.hpp> |
Vernon Mauery | 6a98fe7 | 2019-03-11 15:57:48 -0700 | [diff] [blame] | 10 | #include <ipmid/utils.hpp> |
William A. Kennington III | 4c00802 | 2018-10-12 17:18:14 -0700 | [diff] [blame] | 11 | #include <sdbusplus/message/types.hpp> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 12 | |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 13 | namespace ipmi |
| 14 | { |
| 15 | namespace sensor |
| 16 | { |
| 17 | |
| 18 | using Assertion = uint16_t; |
| 19 | using Deassertion = uint16_t; |
| 20 | using AssertionSet = std::pair<Assertion, Deassertion>; |
| 21 | |
| 22 | using Service = std::string; |
| 23 | using Path = std::string; |
| 24 | using Interface = std::string; |
| 25 | |
| 26 | using ServicePath = std::pair<Path, Service>; |
| 27 | |
| 28 | using Interfaces = std::vector<Interface>; |
| 29 | |
| 30 | using MapperResponseType = std::map<Path, std::map<Service, Interfaces>>; |
| 31 | |
| 32 | /** @brief get the D-Bus service and service path |
| 33 | * @param[in] bus - The Dbus bus object |
| 34 | * @param[in] interface - interface to the service |
| 35 | * @param[in] path - interested path in the list of objects |
| 36 | * @return pair of service path and service |
| 37 | */ |
| 38 | ServicePath getServiceAndPath(sdbusplus::bus::bus& bus, |
| 39 | const std::string& interface, |
| 40 | const std::string& path = std::string()); |
| 41 | |
| 42 | /** @brief Make assertion set from input data |
| 43 | * @param[in] cmdData - Input sensor data |
| 44 | * @return pair of assertion and deassertion set |
| 45 | */ |
| 46 | AssertionSet getAssertionSet(const SetSensorReadingReq& cmdData); |
| 47 | |
| 48 | /** @brief send the message to DBus |
| 49 | * @param[in] msg - message to send |
| 50 | * @return failure status in IPMI error code |
| 51 | */ |
Dhruvaraj Subhashchandran | 2a444d0 | 2017-08-07 01:45:14 -0500 | [diff] [blame] | 52 | ipmi_ret_t updateToDbus(IpmiUpdateData& msg); |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 53 | |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 54 | namespace get |
| 55 | { |
| 56 | |
Tom Joseph | b0adbcd | 2018-01-24 11:51:29 +0530 | [diff] [blame] | 57 | /** @brief Populate sensor name from the D-Bus property associated with the |
| 58 | * sensor. In the example entry from the yaml, the name of the D-bus |
| 59 | * property "AttemptsLeft" is the sensor name. |
| 60 | * |
| 61 | * 0x07: |
| 62 | * sensorType: 195 |
| 63 | * path: /xyz/openbmc_project/state/host0 |
| 64 | * sensorReadingType: 0x6F |
| 65 | * serviceInterface: org.freedesktop.DBus.Properties |
| 66 | * readingType: readingAssertion |
| 67 | * sensorNamePattern: nameProperty |
| 68 | * interfaces: |
| 69 | * xyz.openbmc_project.Control.Boot.RebootAttempts: |
| 70 | * AttemptsLeft: |
| 71 | * Offsets: |
| 72 | * 0xFF: |
| 73 | * type: uint32_t |
| 74 | * |
| 75 | * |
| 76 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 77 | * |
| 78 | * @return On success return the sensor name for the sensor. |
| 79 | */ |
| 80 | inline SensorName nameProperty(const Info& sensorInfo) |
| 81 | { |
| 82 | return sensorInfo.propertyInterfaces.begin()->second.begin()->first; |
| 83 | } |
| 84 | |
| 85 | /** @brief Populate sensor name from the D-Bus object associated with the |
| 86 | * sensor. If the object path is /system/chassis/motherboard/dimm0 then |
| 87 | * the leaf dimm0 is considered as the sensor name. |
| 88 | * |
| 89 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 90 | * |
| 91 | * @return On success return the sensor name for the sensor. |
| 92 | */ |
| 93 | inline SensorName nameLeaf(const Info& sensorInfo) |
| 94 | { |
| 95 | return sensorInfo.sensorPath.substr( |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 96 | sensorInfo.sensorPath.find_last_of('/') + 1, |
| 97 | sensorInfo.sensorPath.length()); |
Tom Joseph | b0adbcd | 2018-01-24 11:51:29 +0530 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | /** @brief Populate sensor name from the D-Bus object associated with the |
| 101 | * sensor. If the object path is /system/chassis/motherboard/cpu0/core0 |
| 102 | * then the sensor name is cpu0_core0. The leaf and the parent is put |
| 103 | * together to get the sensor name. |
| 104 | * |
| 105 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 106 | * |
| 107 | * @return On success return the sensor name for the sensor. |
| 108 | */ |
| 109 | SensorName nameParentLeaf(const Info& sensorInfo); |
| 110 | |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 111 | /** |
| 112 | * @brief Helper function to map the dbus info to sensor's assertion status |
| 113 | * for the get sensor reading command. |
| 114 | * |
| 115 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 116 | * @param[in] path - Dbus object path. |
| 117 | * @param[in] interface - Dbus interface. |
| 118 | * |
| 119 | * @return Response for get sensor reading command. |
| 120 | */ |
| 121 | GetSensorResponse mapDbusToAssertion(const Info& sensorInfo, |
| 122 | const InstancePath& path, |
| 123 | const DbusInterface& interface); |
| 124 | |
| 125 | /** |
| 126 | * @brief Map the Dbus info to sensor's assertion status in the Get sensor |
| 127 | * reading command response. |
| 128 | * |
| 129 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 130 | * |
| 131 | * @return Response for get sensor reading command. |
| 132 | */ |
| 133 | GetSensorResponse assertion(const Info& sensorInfo); |
| 134 | |
Tom Joseph | e4014fc | 2017-09-06 23:57:36 +0530 | [diff] [blame] | 135 | /** |
| 136 | * @brief Maps the Dbus info to the reading field in the Get sensor reading |
| 137 | * command response. |
| 138 | * |
| 139 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 140 | * |
| 141 | * @return Response for get sensor reading command. |
| 142 | */ |
| 143 | GetSensorResponse eventdata2(const Info& sensorInfo); |
| 144 | |
Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 145 | /** |
| 146 | * @brief readingAssertion is a case where the entire assertion state field |
| 147 | * serves as the sensor value. |
| 148 | * |
| 149 | * @tparam T - type of the dbus property related to sensor. |
| 150 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 151 | * |
| 152 | * @return Response for get sensor reading command. |
| 153 | */ |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 154 | template <typename T> |
Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 155 | GetSensorResponse readingAssertion(const Info& sensorInfo) |
| 156 | { |
| 157 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 158 | GetSensorResponse response{}; |
Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 159 | |
Jeremy Kerr | 3dc3558 | 2020-05-17 15:47:07 +0800 | [diff] [blame] | 160 | enableScanning(&response); |
| 161 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 162 | auto service = ipmi::getService(bus, sensorInfo.sensorInterface, |
Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 163 | sensorInfo.sensorPath); |
| 164 | |
| 165 | auto propValue = ipmi::getDbusProperty( |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 166 | bus, service, sensorInfo.sensorPath, |
| 167 | sensorInfo.propertyInterfaces.begin()->first, |
| 168 | sensorInfo.propertyInterfaces.begin()->second.begin()->first); |
Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 169 | |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 170 | setAssertionBytes(static_cast<uint16_t>(std::get<T>(propValue)), &response); |
Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 171 | |
| 172 | return response; |
| 173 | } |
| 174 | |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 175 | /** @brief Map the Dbus info to the reading field in the Get sensor reading |
| 176 | * command response |
| 177 | * |
| 178 | * @tparam T - type of the dbus property related to sensor. |
| 179 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 180 | * |
| 181 | * @return Response for get sensor reading command. |
| 182 | */ |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 183 | template <typename T> |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 184 | GetSensorResponse readingData(const Info& sensorInfo) |
| 185 | { |
| 186 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 187 | |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 188 | GetSensorResponse response{}; |
| 189 | |
| 190 | enableScanning(&response); |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 191 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 192 | auto service = ipmi::getService(bus, sensorInfo.sensorInterface, |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 193 | sensorInfo.sensorPath); |
| 194 | |
Brandon Kim | 9cf8562 | 2019-06-19 12:05:08 -0700 | [diff] [blame] | 195 | #ifdef UPDATE_FUNCTIONAL_ON_FAIL |
| 196 | // Check the OperationalStatus interface for functional property |
| 197 | if (sensorInfo.propertyInterfaces.begin()->first == |
| 198 | "xyz.openbmc_project.Sensor.Value") |
| 199 | { |
| 200 | bool functional = true; |
| 201 | try |
| 202 | { |
| 203 | auto funcValue = ipmi::getDbusProperty( |
| 204 | bus, service, sensorInfo.sensorPath, |
| 205 | "xyz.openbmc_project.State.Decorator.OperationalStatus", |
| 206 | "Functional"); |
| 207 | functional = std::get<bool>(funcValue); |
| 208 | } |
| 209 | catch (...) |
| 210 | { |
| 211 | // No-op if Functional property could not be found since this |
| 212 | // check is only valid for Sensor.Value read for hwmonio |
| 213 | } |
| 214 | if (!functional) |
| 215 | { |
| 216 | throw SensorFunctionalError(); |
| 217 | } |
| 218 | } |
| 219 | #endif |
| 220 | |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 221 | auto propValue = ipmi::getDbusProperty( |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 222 | bus, service, sensorInfo.sensorPath, |
| 223 | sensorInfo.propertyInterfaces.begin()->first, |
| 224 | sensorInfo.propertyInterfaces.begin()->second.begin()->first); |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 225 | |
Vernon Mauery | f442e11 | 2019-04-09 11:44:36 -0700 | [diff] [blame] | 226 | double value = std::get<T>(propValue) * |
Patrick Venture | 586d35b | 2018-09-07 19:56:18 -0700 | [diff] [blame] | 227 | std::pow(10, sensorInfo.scale - sensorInfo.exponentR); |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 228 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 229 | auto rawData = static_cast<uint8_t>((value - sensorInfo.scaledOffset) / |
| 230 | sensorInfo.coefficientM); |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 231 | setReading(rawData, &response); |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 232 | |
| 233 | return response; |
| 234 | } |
| 235 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 236 | } // namespace get |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 237 | |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 238 | namespace set |
| 239 | { |
| 240 | |
| 241 | /** @brief Make a DBus message for a Dbus call |
| 242 | * @param[in] updateInterface - Interface name |
| 243 | * @param[in] sensorPath - Path of the sensor |
| 244 | * @param[in] command - command to be executed |
| 245 | * @param[in] sensorInterface - DBus interface of sensor |
| 246 | * @return a dbus message |
| 247 | */ |
| 248 | IpmiUpdateData makeDbusMsg(const std::string& updateInterface, |
| 249 | const std::string& sensorPath, |
| 250 | const std::string& command, |
| 251 | const std::string& sensorInterface); |
| 252 | |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 253 | /** @brief Update d-bus based on assertion type sensor data |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 254 | * @param[in] cmdData - input sensor data |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 255 | * @param[in] sensorInfo - sensor d-bus info |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 256 | * @return a IPMI error code |
| 257 | */ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 258 | ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, |
| 259 | const Info& sensorInfo); |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 260 | |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 261 | /** @brief Update d-bus based on a reading assertion |
| 262 | * @tparam T - type of d-bus property mapping this sensor |
| 263 | * @param[in] cmdData - input sensor data |
| 264 | * @param[in] sensorInfo - sensor d-bus info |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 265 | * @return a IPMI error code |
| 266 | */ |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 267 | template <typename T> |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 268 | ipmi_ret_t readingAssertion(const SetSensorReadingReq& cmdData, |
| 269 | const Info& sensorInfo) |
| 270 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 271 | auto msg = |
| 272 | makeDbusMsg("org.freedesktop.DBus.Properties", sensorInfo.sensorPath, |
| 273 | "Set", sensorInfo.sensorInterface); |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 274 | |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 275 | const auto& interface = sensorInfo.propertyInterfaces.begin(); |
| 276 | msg.append(interface->first); |
| 277 | for (const auto& property : interface->second) |
| 278 | { |
| 279 | msg.append(property.first); |
Andrew Geissler | 6467ed2 | 2020-05-16 16:03:53 -0500 | [diff] [blame] | 280 | std::variant<T> value = static_cast<T>((cmdData.assertOffset8_14 << 8) | |
| 281 | cmdData.assertOffset0_7); |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 282 | msg.append(value); |
| 283 | } |
| 284 | return updateToDbus(msg); |
| 285 | } |
| 286 | |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 287 | /** @brief Update d-bus based on a discrete reading |
| 288 | * @param[in] cmdData - input sensor data |
| 289 | * @param[in] sensorInfo - sensor d-bus info |
| 290 | * @return an IPMI error code |
| 291 | */ |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 292 | template <typename T> |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 293 | ipmi_ret_t readingData(const SetSensorReadingReq& cmdData, |
| 294 | const Info& sensorInfo) |
| 295 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 296 | T raw_value = |
| 297 | (sensorInfo.coefficientM * cmdData.reading) + sensorInfo.scaledOffset; |
Tom Joseph | 2210215 | 2018-03-02 18:46:39 +0530 | [diff] [blame] | 298 | |
Patrick Venture | 586d35b | 2018-09-07 19:56:18 -0700 | [diff] [blame] | 299 | raw_value *= std::pow(10, sensorInfo.exponentR - sensorInfo.scale); |
Tom Joseph | 2210215 | 2018-03-02 18:46:39 +0530 | [diff] [blame] | 300 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 301 | auto msg = |
| 302 | makeDbusMsg("org.freedesktop.DBus.Properties", sensorInfo.sensorPath, |
| 303 | "Set", sensorInfo.sensorInterface); |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 304 | |
| 305 | const auto& interface = sensorInfo.propertyInterfaces.begin(); |
| 306 | msg.append(interface->first); |
| 307 | |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 308 | for (const auto& property : interface->second) |
| 309 | { |
| 310 | msg.append(property.first); |
Vernon Mauery | 16b8693 | 2019-05-01 08:36:11 -0700 | [diff] [blame] | 311 | std::variant<T> value = raw_value; |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 312 | msg.append(value); |
| 313 | } |
| 314 | return updateToDbus(msg); |
| 315 | } |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 316 | |
| 317 | /** @brief Update d-bus based on eventdata type sensor data |
| 318 | * @param[in] cmdData - input sensor data |
| 319 | * @param[in] sensorInfo - sensor d-bus info |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 320 | * @return a IPMI error code |
| 321 | */ |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 322 | ipmi_ret_t eventdata(const SetSensorReadingReq& cmdData, const Info& sensorInfo, |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 323 | uint8_t data); |
| 324 | |
| 325 | /** @brief Update d-bus based on eventdata1 type sensor data |
| 326 | * @param[in] cmdData - input sensor data |
| 327 | * @param[in] sensorInfo - sensor d-bus info |
| 328 | * @return a IPMI error code |
| 329 | */ |
| 330 | inline ipmi_ret_t eventdata1(const SetSensorReadingReq& cmdData, |
| 331 | const Info& sensorInfo) |
| 332 | { |
| 333 | return eventdata(cmdData, sensorInfo, cmdData.eventData1); |
| 334 | } |
| 335 | |
| 336 | /** @brief Update d-bus based on eventdata2 type sensor data |
| 337 | * @param[in] cmdData - input sensor data |
| 338 | * @param[in] sensorInfo - sensor d-bus info |
| 339 | * @return a IPMI error code |
| 340 | */ |
| 341 | inline ipmi_ret_t eventdata2(const SetSensorReadingReq& cmdData, |
| 342 | const Info& sensorInfo) |
| 343 | { |
| 344 | return eventdata(cmdData, sensorInfo, cmdData.eventData2); |
| 345 | } |
| 346 | |
| 347 | /** @brief Update d-bus based on eventdata3 type sensor data |
| 348 | * @param[in] cmdData - input sensor data |
| 349 | * @param[in] sensorInfo - sensor d-bus info |
| 350 | * @return a IPMI error code |
| 351 | */ |
| 352 | inline ipmi_ret_t eventdata3(const SetSensorReadingReq& cmdData, |
| 353 | const Info& sensorInfo) |
| 354 | { |
| 355 | return eventdata(cmdData, sensorInfo, cmdData.eventData3); |
| 356 | } |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 357 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 358 | } // namespace set |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 359 | |
| 360 | namespace notify |
| 361 | { |
| 362 | |
| 363 | /** @brief Make a DBus message for a Dbus call |
| 364 | * @param[in] updateInterface - Interface name |
| 365 | * @param[in] sensorPath - Path of the sensor |
| 366 | * @param[in] command - command to be executed |
| 367 | * @param[in] sensorInterface - DBus interface of sensor |
| 368 | * @return a dbus message |
| 369 | */ |
| 370 | IpmiUpdateData makeDbusMsg(const std::string& updateInterface, |
| 371 | const std::string& sensorPath, |
| 372 | const std::string& command, |
| 373 | const std::string& sensorInterface); |
| 374 | |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 375 | /** @brief Update d-bus based on assertion type sensor data |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 376 | * @param[in] interfaceMap - sensor interface |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 377 | * @param[in] cmdData - input sensor data |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 378 | * @param[in] sensorInfo - sensor d-bus info |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 379 | * @return a IPMI error code |
| 380 | */ |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 381 | ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, |
| 382 | const Info& sensorInfo); |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 383 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 384 | } // namespace notify |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 385 | |
| 386 | namespace inventory |
| 387 | { |
| 388 | |
| 389 | namespace get |
| 390 | { |
| 391 | |
| 392 | /** |
| 393 | * @brief Map the Dbus info to sensor's assertion status in the Get sensor |
| 394 | * reading command response. |
| 395 | * |
| 396 | * @param[in] sensorInfo - Dbus info related to sensor. |
| 397 | * |
| 398 | * @return Response for get sensor reading command. |
| 399 | */ |
| 400 | GetSensorResponse assertion(const Info& sensorInfo); |
| 401 | |
| 402 | } // namespace get |
| 403 | |
| 404 | } // namespace inventory |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 405 | } // namespace sensor |
| 406 | } // namespace ipmi |