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 | |
Patrick Venture | 31b35d5 | 2019-10-20 13:25:16 -0700 | [diff] [blame] | 17 | #include "sensorcommands.hpp" |
| 18 | |
| 19 | #include "commandutils.hpp" |
| 20 | #include "ipmi_to_redfish_hooks.hpp" |
| 21 | #include "sdrutils.hpp" |
| 22 | #include "sensorutils.hpp" |
| 23 | #include "storagecommands.hpp" |
| 24 | |
Patrick Venture | f777e1b | 2019-09-25 17:45:44 -0700 | [diff] [blame] | 25 | #include <algorithm> |
Patrick Venture | 44ec88e | 2019-09-25 17:48:29 -0700 | [diff] [blame] | 26 | #include <array> |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 27 | #include <boost/algorithm/string.hpp> |
| 28 | #include <boost/container/flat_map.hpp> |
| 29 | #include <chrono> |
| 30 | #include <cmath> |
Patrick Venture | 5c2d26e | 2019-09-25 17:43:53 -0700 | [diff] [blame] | 31 | #include <cstring> |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 32 | #include <iostream> |
James Feist | 2a265d5 | 2019-04-08 11:16:27 -0700 | [diff] [blame] | 33 | #include <ipmid/api.hpp> |
Vernon Mauery | 5480ef6 | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 34 | #include <ipmid/utils.hpp> |
Patrick Venture | b10ec8b | 2019-09-25 16:39:14 -0700 | [diff] [blame] | 35 | #include <map> |
Patrick Venture | fd2a938 | 2019-09-25 17:47:25 -0700 | [diff] [blame] | 36 | #include <memory> |
Patrick Venture | c4e9de6 | 2019-09-25 17:40:54 -0700 | [diff] [blame] | 37 | #include <optional> |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 38 | #include <phosphor-logging/log.hpp> |
| 39 | #include <sdbusplus/bus.hpp> |
Patrick Venture | e615402 | 2019-09-25 17:50:25 -0700 | [diff] [blame] | 40 | #include <stdexcept> |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 41 | #include <string> |
Patrick Venture | 38f46f2 | 2019-09-25 17:41:26 -0700 | [diff] [blame] | 42 | #include <utility> |
Patrick Venture | eb02a5c | 2019-09-25 17:44:43 -0700 | [diff] [blame] | 43 | #include <variant> |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 44 | |
| 45 | namespace ipmi |
| 46 | { |
| 47 | using ManagedObjectType = |
| 48 | std::map<sdbusplus::message::object_path, |
| 49 | std::map<std::string, std::map<std::string, DbusVariant>>>; |
| 50 | |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 51 | static constexpr int sensorMapUpdatePeriod = 10; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 52 | |
| 53 | constexpr size_t maxSDRTotalSize = |
| 54 | 76; // Largest SDR Record Size (type 01) + SDR Overheader Size |
| 55 | constexpr static const uint32_t noTimestamp = 0xFFFFFFFF; |
| 56 | |
| 57 | static uint16_t sdrReservationID; |
| 58 | static uint32_t sdrLastAdd = noTimestamp; |
| 59 | static uint32_t sdrLastRemove = noTimestamp; |
| 60 | |
Richard Marian Thomaiyar | 01fbcb5 | 2018-11-19 22:04:34 +0530 | [diff] [blame] | 61 | SensorSubTree sensorTree; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 62 | static boost::container::flat_map<std::string, ManagedObjectType> SensorCache; |
| 63 | |
Jason M. Bills | 17add59 | 2018-11-12 14:30:12 -0800 | [diff] [blame] | 64 | // Specify the comparison required to sort and find char* map objects |
| 65 | struct CmpStr |
| 66 | { |
| 67 | bool operator()(const char *a, const char *b) const |
| 68 | { |
| 69 | return std::strcmp(a, b) < 0; |
| 70 | } |
| 71 | }; |
| 72 | const static boost::container::flat_map<const char *, SensorUnits, CmpStr> |
| 73 | sensorUnits{{{"temperature", SensorUnits::degreesC}, |
| 74 | {"voltage", SensorUnits::volts}, |
| 75 | {"current", SensorUnits::amps}, |
| 76 | {"fan_tach", SensorUnits::rpm}, |
| 77 | {"power", SensorUnits::watts}}}; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 78 | |
| 79 | void registerSensorFunctions() __attribute__((constructor)); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 80 | |
| 81 | static sdbusplus::bus::match::match sensorAdded( |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 82 | *getSdBus(), |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 83 | "type='signal',member='InterfacesAdded',arg0path='/xyz/openbmc_project/" |
| 84 | "sensors/'", |
| 85 | [](sdbusplus::message::message &m) { |
| 86 | sensorTree.clear(); |
| 87 | sdrLastAdd = std::chrono::duration_cast<std::chrono::seconds>( |
| 88 | std::chrono::system_clock::now().time_since_epoch()) |
| 89 | .count(); |
| 90 | }); |
| 91 | |
| 92 | static sdbusplus::bus::match::match sensorRemoved( |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 93 | *getSdBus(), |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 94 | "type='signal',member='InterfacesRemoved',arg0path='/xyz/openbmc_project/" |
| 95 | "sensors/'", |
| 96 | [](sdbusplus::message::message &m) { |
| 97 | sensorTree.clear(); |
| 98 | sdrLastRemove = std::chrono::duration_cast<std::chrono::seconds>( |
| 99 | std::chrono::system_clock::now().time_since_epoch()) |
| 100 | .count(); |
| 101 | }); |
| 102 | |
James Feist | 392786a | 2019-03-19 13:36:10 -0700 | [diff] [blame] | 103 | // this keeps track of deassertions for sensor event status command. A |
| 104 | // deasertion can only happen if an assertion was seen first. |
| 105 | static boost::container::flat_map< |
| 106 | std::string, boost::container::flat_map<std::string, std::optional<bool>>> |
| 107 | thresholdDeassertMap; |
| 108 | |
| 109 | static sdbusplus::bus::match::match thresholdChanged( |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 110 | *getSdBus(), |
James Feist | 392786a | 2019-03-19 13:36:10 -0700 | [diff] [blame] | 111 | "type='signal',member='PropertiesChanged',interface='org.freedesktop.DBus." |
| 112 | "Properties',arg0namespace='xyz.openbmc_project.Sensor.Threshold'", |
| 113 | [](sdbusplus::message::message &m) { |
| 114 | boost::container::flat_map<std::string, std::variant<bool, double>> |
| 115 | values; |
| 116 | m.read(std::string(), values); |
| 117 | |
| 118 | auto findAssert = |
| 119 | std::find_if(values.begin(), values.end(), [](const auto &pair) { |
| 120 | return pair.first.find("Alarm") != std::string::npos; |
| 121 | }); |
| 122 | if (findAssert != values.end()) |
| 123 | { |
| 124 | auto ptr = std::get_if<bool>(&(findAssert->second)); |
| 125 | if (ptr == nullptr) |
| 126 | { |
| 127 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 128 | "thresholdChanged: Assert non bool"); |
| 129 | return; |
| 130 | } |
| 131 | if (*ptr) |
| 132 | { |
| 133 | phosphor::logging::log<phosphor::logging::level::INFO>( |
| 134 | "thresholdChanged: Assert", |
| 135 | phosphor::logging::entry("SENSOR=%s", m.get_path())); |
| 136 | thresholdDeassertMap[m.get_path()][findAssert->first] = *ptr; |
| 137 | } |
| 138 | else |
| 139 | { |
| 140 | auto &value = |
| 141 | thresholdDeassertMap[m.get_path()][findAssert->first]; |
| 142 | if (value) |
| 143 | { |
| 144 | phosphor::logging::log<phosphor::logging::level::INFO>( |
| 145 | "thresholdChanged: deassert", |
| 146 | phosphor::logging::entry("SENSOR=%s", m.get_path())); |
| 147 | value = *ptr; |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | }); |
| 152 | |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 153 | static void getSensorMaxMin(const SensorMap &sensorMap, double &max, |
| 154 | double &min) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 155 | { |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 156 | max = 127; |
| 157 | min = -128; |
| 158 | |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 159 | auto sensorObject = sensorMap.find("xyz.openbmc_project.Sensor.Value"); |
| 160 | auto critical = |
| 161 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical"); |
| 162 | auto warning = |
| 163 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning"); |
| 164 | |
| 165 | if (sensorObject != sensorMap.end()) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 166 | { |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 167 | auto maxMap = sensorObject->second.find("MaxValue"); |
| 168 | auto minMap = sensorObject->second.find("MinValue"); |
| 169 | |
| 170 | if (maxMap != sensorObject->second.end()) |
| 171 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 172 | max = std::visit(VariantToDoubleVisitor(), maxMap->second); |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 173 | } |
| 174 | if (minMap != sensorObject->second.end()) |
| 175 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 176 | min = std::visit(VariantToDoubleVisitor(), minMap->second); |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 177 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 178 | } |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 179 | if (critical != sensorMap.end()) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 180 | { |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 181 | auto lower = critical->second.find("CriticalLow"); |
| 182 | auto upper = critical->second.find("CriticalHigh"); |
| 183 | if (lower != critical->second.end()) |
| 184 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 185 | double value = std::visit(VariantToDoubleVisitor(), lower->second); |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 186 | min = std::min(value, min); |
| 187 | } |
| 188 | if (upper != critical->second.end()) |
| 189 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 190 | double value = std::visit(VariantToDoubleVisitor(), upper->second); |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 191 | max = std::max(value, max); |
| 192 | } |
| 193 | } |
| 194 | if (warning != sensorMap.end()) |
| 195 | { |
| 196 | |
| 197 | auto lower = warning->second.find("WarningLow"); |
| 198 | auto upper = warning->second.find("WarningHigh"); |
| 199 | if (lower != warning->second.end()) |
| 200 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 201 | double value = std::visit(VariantToDoubleVisitor(), lower->second); |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 202 | min = std::min(value, min); |
| 203 | } |
| 204 | if (upper != warning->second.end()) |
| 205 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 206 | double value = std::visit(VariantToDoubleVisitor(), upper->second); |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 207 | max = std::max(value, max); |
| 208 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 212 | static bool getSensorMap(boost::asio::yield_context yield, |
| 213 | std::string sensorConnection, std::string sensorPath, |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 214 | SensorMap &sensorMap) |
| 215 | { |
| 216 | static boost::container::flat_map< |
| 217 | std::string, std::chrono::time_point<std::chrono::steady_clock>> |
| 218 | updateTimeMap; |
| 219 | |
| 220 | auto updateFind = updateTimeMap.find(sensorConnection); |
| 221 | auto lastUpdate = std::chrono::time_point<std::chrono::steady_clock>(); |
| 222 | if (updateFind != updateTimeMap.end()) |
| 223 | { |
| 224 | lastUpdate = updateFind->second; |
| 225 | } |
| 226 | |
| 227 | auto now = std::chrono::steady_clock::now(); |
| 228 | |
| 229 | if (std::chrono::duration_cast<std::chrono::seconds>(now - lastUpdate) |
| 230 | .count() > sensorMapUpdatePeriod) |
| 231 | { |
| 232 | updateTimeMap[sensorConnection] = now; |
| 233 | |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 234 | std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus(); |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 235 | boost::system::error_code ec; |
| 236 | auto managedObjects = dbus->yield_method_call<ManagedObjectType>( |
| 237 | yield, ec, sensorConnection.c_str(), "/", |
| 238 | "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); |
| 239 | if (ec) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 240 | { |
| 241 | phosphor::logging::log<phosphor::logging::level::ERR>( |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 242 | "GetMangagedObjects for getSensorMap failed", |
| 243 | phosphor::logging::entry("ERROR=%s", ec.message().c_str())); |
| 244 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 245 | return false; |
| 246 | } |
| 247 | |
| 248 | SensorCache[sensorConnection] = managedObjects; |
| 249 | } |
| 250 | auto connection = SensorCache.find(sensorConnection); |
| 251 | if (connection == SensorCache.end()) |
| 252 | { |
| 253 | return false; |
| 254 | } |
| 255 | auto path = connection->second.find(sensorPath); |
| 256 | if (path == connection->second.end()) |
| 257 | { |
| 258 | return false; |
| 259 | } |
| 260 | sensorMap = path->second; |
| 261 | |
| 262 | return true; |
| 263 | } |
| 264 | |
| 265 | /* sensor commands */ |
| 266 | ipmi_ret_t ipmiSensorWildcardHandler(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 267 | ipmi_request_t request, |
| 268 | ipmi_response_t response, |
| 269 | ipmi_data_len_t dataLen, |
| 270 | ipmi_context_t context) |
| 271 | { |
| 272 | *dataLen = 0; |
| 273 | printCommand(+netfn, +cmd); |
| 274 | return IPMI_CC_INVALID; |
| 275 | } |
| 276 | |
James Feist | 7aaf3fe | 2019-06-25 11:52:11 -0700 | [diff] [blame] | 277 | namespace meHealth |
| 278 | { |
| 279 | constexpr const char *busname = "xyz.openbmc_project.NodeManagerProxy"; |
| 280 | constexpr const char *path = "/xyz/openbmc_project/status/me"; |
| 281 | constexpr const char *interface = "xyz.openbmc_project.SetHealth"; |
| 282 | constexpr const char *method = "SetHealth"; |
| 283 | constexpr const char *critical = "critical"; |
| 284 | constexpr const char *warning = "warning"; |
| 285 | constexpr const char *ok = "ok"; |
| 286 | } // namespace meHealth |
| 287 | |
| 288 | static void setMeStatus(uint8_t eventData2, uint8_t eventData3, bool disable) |
| 289 | { |
| 290 | constexpr const std::array<uint8_t, 10> critical = { |
| 291 | 0x1, 0x2, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xD, 0xE}; |
| 292 | constexpr const std::array<uint8_t, 5> warning = {0x3, 0xA, 0x13, 0x19, |
| 293 | 0x1A}; |
| 294 | |
| 295 | std::string state; |
| 296 | if (std::find(critical.begin(), critical.end(), eventData2) != |
| 297 | critical.end()) |
| 298 | { |
| 299 | state = meHealth::critical; |
| 300 | } |
| 301 | // special case 0x3 as we only care about a few states |
| 302 | else if (eventData2 == 0x3) |
| 303 | { |
| 304 | if (eventData3 <= 0x2) |
| 305 | { |
| 306 | state = meHealth::warning; |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | return; |
| 311 | } |
| 312 | } |
| 313 | else if (std::find(warning.begin(), warning.end(), eventData2) != |
| 314 | warning.end()) |
| 315 | { |
| 316 | state = meHealth::warning; |
| 317 | } |
| 318 | else |
| 319 | { |
| 320 | return; |
| 321 | } |
| 322 | if (disable) |
| 323 | { |
| 324 | state = meHealth::ok; |
| 325 | } |
| 326 | |
| 327 | std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus(); |
| 328 | auto setHealth = |
| 329 | dbus->new_method_call(meHealth::busname, meHealth::path, |
| 330 | meHealth::interface, meHealth::method); |
| 331 | setHealth.append(std::to_string(static_cast<size_t>(eventData2)), state); |
| 332 | try |
| 333 | { |
| 334 | dbus->call(setHealth); |
| 335 | } |
| 336 | catch (sdbusplus::exception_t &) |
| 337 | { |
| 338 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 339 | "Failed to set ME Health"); |
| 340 | } |
| 341 | } |
| 342 | |
Jason M. Bills | ae6bdb1 | 2019-04-02 12:00:04 -0700 | [diff] [blame] | 343 | ipmi::RspType<> ipmiSenPlatformEvent(ipmi::message::Payload &p) |
| 344 | { |
James Feist | 7aaf3fe | 2019-06-25 11:52:11 -0700 | [diff] [blame] | 345 | constexpr const uint8_t meId = 0x2C; |
| 346 | constexpr const uint8_t meSensorNum = 0x17; |
| 347 | constexpr const uint8_t disabled = 0x80; |
| 348 | |
Jason M. Bills | ae6bdb1 | 2019-04-02 12:00:04 -0700 | [diff] [blame] | 349 | uint8_t generatorID = 0; |
| 350 | uint8_t evmRev = 0; |
| 351 | uint8_t sensorType = 0; |
| 352 | uint8_t sensorNum = 0; |
| 353 | uint8_t eventType = 0; |
| 354 | uint8_t eventData1 = 0; |
| 355 | std::optional<uint8_t> eventData2 = 0; |
| 356 | std::optional<uint8_t> eventData3 = 0; |
| 357 | |
| 358 | // todo: This check is supposed to be based on the incoming channel. |
| 359 | // e.g. system channel will provide upto 8 bytes including generator |
| 360 | // ID, but ipmb channel will provide only up to 7 bytes without the |
| 361 | // generator ID. |
| 362 | // Support for this check is coming in future patches, so for now just base |
| 363 | // it on if the first byte is the EvMRev (0x04). |
| 364 | if (p.size() && p.data()[0] == 0x04) |
| 365 | { |
| 366 | p.unpack(evmRev, sensorType, sensorNum, eventType, eventData1, |
| 367 | eventData2, eventData3); |
| 368 | // todo: the generator ID for this channel is supposed to come from the |
| 369 | // IPMB requesters slave address. Support for this is coming in future |
| 370 | // patches, so for now just assume it is coming from the ME (0x2C). |
| 371 | generatorID = 0x2C; |
| 372 | } |
| 373 | else |
| 374 | { |
| 375 | p.unpack(generatorID, evmRev, sensorType, sensorNum, eventType, |
| 376 | eventData1, eventData2, eventData3); |
| 377 | } |
| 378 | if (!p.fullyUnpacked()) |
| 379 | { |
| 380 | return ipmi::responseReqDataLenInvalid(); |
| 381 | } |
| 382 | |
Jason M. Bills | 6dd8f04 | 2019-04-11 10:39:02 -0700 | [diff] [blame] | 383 | // Send this request to the Redfish hooks to log it as a Redfish message |
| 384 | // instead. There is no need to add it to the SEL, so just return success. |
| 385 | intel_oem::ipmi::sel::checkRedfishHooks( |
| 386 | generatorID, evmRev, sensorType, sensorNum, eventType, eventData1, |
| 387 | eventData2.value_or(0xFF), eventData3.value_or(0xFF)); |
Jason M. Bills | ae6bdb1 | 2019-04-02 12:00:04 -0700 | [diff] [blame] | 388 | |
James Feist | 7aaf3fe | 2019-06-25 11:52:11 -0700 | [diff] [blame] | 389 | if (generatorID == meId && sensorNum == meSensorNum && eventData2 && |
| 390 | eventData3) |
| 391 | { |
| 392 | setMeStatus(*eventData2, *eventData3, (eventType & disabled)); |
| 393 | } |
| 394 | |
Jason M. Bills | ae6bdb1 | 2019-04-02 12:00:04 -0700 | [diff] [blame] | 395 | return ipmi::responseSuccess(); |
| 396 | } |
| 397 | |
James Feist | 0cd014a | 2019-04-08 15:04:33 -0700 | [diff] [blame] | 398 | ipmi::RspType<uint8_t, uint8_t, uint8_t, std::optional<uint8_t>> |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 399 | ipmiSenGetSensorReading(boost::asio::yield_context yield, uint8_t sensnum) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 400 | { |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 401 | std::string connection; |
| 402 | std::string path; |
| 403 | |
| 404 | auto status = getSensorConnection(sensnum, connection, path); |
| 405 | if (status) |
| 406 | { |
James Feist | 0cd014a | 2019-04-08 15:04:33 -0700 | [diff] [blame] | 407 | return ipmi::response(status); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | SensorMap sensorMap; |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 411 | if (!getSensorMap(yield, connection, path, sensorMap)) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 412 | { |
James Feist | 0cd014a | 2019-04-08 15:04:33 -0700 | [diff] [blame] | 413 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 414 | } |
| 415 | auto sensorObject = sensorMap.find("xyz.openbmc_project.Sensor.Value"); |
| 416 | |
| 417 | if (sensorObject == sensorMap.end() || |
| 418 | sensorObject->second.find("Value") == sensorObject->second.end()) |
| 419 | { |
James Feist | 0cd014a | 2019-04-08 15:04:33 -0700 | [diff] [blame] | 420 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 421 | } |
James Feist | 0cd014a | 2019-04-08 15:04:33 -0700 | [diff] [blame] | 422 | auto &valueVariant = sensorObject->second["Value"]; |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 423 | double reading = std::visit(VariantToDoubleVisitor(), valueVariant); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 424 | |
Yong Li | 1f2eb5e | 2019-05-23 14:07:17 +0800 | [diff] [blame] | 425 | double max = 0; |
| 426 | double min = 0; |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 427 | getSensorMaxMin(sensorMap, max, min); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 428 | |
| 429 | int16_t mValue = 0; |
| 430 | int16_t bValue = 0; |
| 431 | int8_t rExp = 0; |
| 432 | int8_t bExp = 0; |
| 433 | bool bSigned = false; |
| 434 | |
| 435 | if (!getSensorAttributes(max, min, mValue, rExp, bValue, bExp, bSigned)) |
| 436 | { |
James Feist | 0cd014a | 2019-04-08 15:04:33 -0700 | [diff] [blame] | 437 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 438 | } |
| 439 | |
James Feist | 0cd014a | 2019-04-08 15:04:33 -0700 | [diff] [blame] | 440 | uint8_t value = |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 441 | scaleIPMIValueFromDouble(reading, mValue, rExp, bValue, bExp, bSigned); |
James Feist | 0cd014a | 2019-04-08 15:04:33 -0700 | [diff] [blame] | 442 | uint8_t operation = |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 443 | static_cast<uint8_t>(IPMISensorReadingByte2::sensorScanningEnable); |
James Feist | 0cd014a | 2019-04-08 15:04:33 -0700 | [diff] [blame] | 444 | operation |= |
James Feist | 81a95c1 | 2019-03-01 15:08:28 -0800 | [diff] [blame] | 445 | static_cast<uint8_t>(IPMISensorReadingByte2::eventMessagesEnable); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 446 | |
James Feist | 0cd014a | 2019-04-08 15:04:33 -0700 | [diff] [blame] | 447 | uint8_t thresholds = 0; |
| 448 | |
| 449 | auto warningObject = |
| 450 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning"); |
| 451 | if (warningObject != sensorMap.end()) |
| 452 | { |
| 453 | auto alarmHigh = warningObject->second.find("WarningAlarmHigh"); |
| 454 | auto alarmLow = warningObject->second.find("WarningAlarmLow"); |
| 455 | if (alarmHigh != warningObject->second.end()) |
| 456 | { |
| 457 | if (std::get<bool>(alarmHigh->second)) |
| 458 | { |
| 459 | thresholds |= static_cast<uint8_t>( |
| 460 | IPMISensorReadingByte3::upperNonCritical); |
| 461 | } |
| 462 | } |
| 463 | if (alarmLow != warningObject->second.end()) |
| 464 | { |
| 465 | if (std::get<bool>(alarmLow->second)) |
| 466 | { |
| 467 | thresholds |= static_cast<uint8_t>( |
| 468 | IPMISensorReadingByte3::lowerNonCritical); |
| 469 | } |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | auto criticalObject = |
| 474 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical"); |
| 475 | if (criticalObject != sensorMap.end()) |
| 476 | { |
| 477 | auto alarmHigh = criticalObject->second.find("CriticalAlarmHigh"); |
| 478 | auto alarmLow = criticalObject->second.find("CriticalAlarmLow"); |
| 479 | if (alarmHigh != criticalObject->second.end()) |
| 480 | { |
| 481 | if (std::get<bool>(alarmHigh->second)) |
| 482 | { |
| 483 | thresholds |= |
| 484 | static_cast<uint8_t>(IPMISensorReadingByte3::upperCritical); |
| 485 | } |
| 486 | } |
| 487 | if (alarmLow != criticalObject->second.end()) |
| 488 | { |
| 489 | if (std::get<bool>(alarmLow->second)) |
| 490 | { |
| 491 | thresholds |= |
| 492 | static_cast<uint8_t>(IPMISensorReadingByte3::lowerCritical); |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | // no discrete as of today so optional byte is never returned |
| 498 | return ipmi::responseSuccess(value, operation, thresholds, std::nullopt); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 499 | } |
| 500 | |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 501 | /** @brief implements the Set Sensor threshold command |
| 502 | * @param sensorNumber - sensor number |
| 503 | * @param lowerNonCriticalThreshMask |
| 504 | * @param lowerCriticalThreshMask |
| 505 | * @param lowerNonRecovThreshMask |
| 506 | * @param upperNonCriticalThreshMask |
| 507 | * @param upperCriticalThreshMask |
| 508 | * @param upperNonRecovThreshMask |
| 509 | * @param reserved |
| 510 | * @param lowerNonCritical - lower non-critical threshold |
| 511 | * @param lowerCritical - Lower critical threshold |
| 512 | * @param lowerNonRecoverable - Lower non recovarable threshold |
| 513 | * @param upperNonCritical - Upper non-critical threshold |
| 514 | * @param upperCritical - Upper critical |
| 515 | * @param upperNonRecoverable - Upper Non-recoverable |
| 516 | * |
| 517 | * @returns IPMI completion code |
| 518 | */ |
| 519 | ipmi::RspType<> ipmiSenSetSensorThresholds( |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 520 | boost::asio::yield_context yield, uint8_t sensorNum, |
| 521 | bool lowerNonCriticalThreshMask, bool lowerCriticalThreshMask, |
| 522 | bool lowerNonRecovThreshMask, bool upperNonCriticalThreshMask, |
| 523 | bool upperCriticalThreshMask, bool upperNonRecovThreshMask, |
| 524 | uint2_t reserved, uint8_t lowerNonCritical, uint8_t lowerCritical, |
| 525 | uint8_t lowerNonRecoverable, uint8_t upperNonCritical, |
| 526 | uint8_t upperCritical, uint8_t upperNonRecoverable) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 527 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 528 | constexpr uint8_t thresholdMask = 0xFF; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 529 | |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 530 | if (reserved) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 531 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 532 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | // lower nc and upper nc not suppported on any sensor |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 536 | if (lowerNonRecovThreshMask || upperNonRecovThreshMask) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 537 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 538 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 539 | } |
| 540 | |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 541 | // if none of the threshold mask are set, nothing to do |
| 542 | if (!(lowerNonCriticalThreshMask | lowerCriticalThreshMask | |
| 543 | lowerNonRecovThreshMask | upperNonCriticalThreshMask | |
| 544 | upperCriticalThreshMask | upperNonRecovThreshMask)) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 545 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 546 | return ipmi::responseSuccess(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 547 | } |
| 548 | |
| 549 | std::string connection; |
| 550 | std::string path; |
| 551 | |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 552 | ipmi::Cc status = getSensorConnection(sensorNum, connection, path); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 553 | if (status) |
| 554 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 555 | return ipmi::response(status); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 556 | } |
| 557 | SensorMap sensorMap; |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 558 | if (!getSensorMap(yield, connection, path, sensorMap)) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 559 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 560 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 561 | } |
| 562 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 563 | double max = 0; |
| 564 | double min = 0; |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 565 | getSensorMaxMin(sensorMap, max, min); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 566 | |
| 567 | int16_t mValue = 0; |
| 568 | int16_t bValue = 0; |
| 569 | int8_t rExp = 0; |
| 570 | int8_t bExp = 0; |
| 571 | bool bSigned = false; |
| 572 | |
| 573 | if (!getSensorAttributes(max, min, mValue, rExp, bValue, bExp, bSigned)) |
| 574 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 575 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 576 | } |
| 577 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 578 | // store a vector of property name, value to set, and interface |
| 579 | std::vector<std::tuple<std::string, uint8_t, std::string>> thresholdsToSet; |
| 580 | |
| 581 | // define the indexes of the tuple |
| 582 | constexpr uint8_t propertyName = 0; |
| 583 | constexpr uint8_t thresholdValue = 1; |
| 584 | constexpr uint8_t interface = 2; |
| 585 | // verifiy all needed fields are present |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 586 | if (lowerCriticalThreshMask || upperCriticalThreshMask) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 587 | { |
| 588 | auto findThreshold = |
| 589 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical"); |
| 590 | if (findThreshold == sensorMap.end()) |
| 591 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 592 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 593 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 594 | if (lowerCriticalThreshMask) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 595 | { |
| 596 | auto findLower = findThreshold->second.find("CriticalLow"); |
| 597 | if (findLower == findThreshold->second.end()) |
| 598 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 599 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 600 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 601 | thresholdsToSet.emplace_back("CriticalLow", lowerCritical, |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 602 | findThreshold->first); |
| 603 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 604 | if (upperCriticalThreshMask) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 605 | { |
| 606 | auto findUpper = findThreshold->second.find("CriticalHigh"); |
| 607 | if (findUpper == findThreshold->second.end()) |
| 608 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 609 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 610 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 611 | thresholdsToSet.emplace_back("CriticalHigh", upperCritical, |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 612 | findThreshold->first); |
| 613 | } |
| 614 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 615 | if (lowerNonCriticalThreshMask || upperNonCriticalThreshMask) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 616 | { |
| 617 | auto findThreshold = |
| 618 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning"); |
| 619 | if (findThreshold == sensorMap.end()) |
| 620 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 621 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 622 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 623 | if (lowerNonCriticalThreshMask) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 624 | { |
| 625 | auto findLower = findThreshold->second.find("WarningLow"); |
| 626 | if (findLower == findThreshold->second.end()) |
| 627 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 628 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 629 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 630 | thresholdsToSet.emplace_back("WarningLow", lowerNonCritical, |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 631 | findThreshold->first); |
| 632 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 633 | if (upperNonCriticalThreshMask) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 634 | { |
| 635 | auto findUpper = findThreshold->second.find("WarningHigh"); |
| 636 | if (findUpper == findThreshold->second.end()) |
| 637 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 638 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 639 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 640 | thresholdsToSet.emplace_back("WarningHigh", upperNonCritical, |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 641 | findThreshold->first); |
| 642 | } |
| 643 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 644 | for (const auto &property : thresholdsToSet) |
| 645 | { |
| 646 | // from section 36.3 in the IPMI Spec, assume all linear |
| 647 | double valueToSet = ((mValue * std::get<thresholdValue>(property)) + |
Josh Lehan | 86236a2 | 2019-11-18 17:53:33 -0800 | [diff] [blame] | 648 | (bValue * std::pow(10.0, bExp))) * |
| 649 | std::pow(10.0, rExp); |
Vernon Mauery | 15419dd | 2019-05-24 09:40:30 -0700 | [diff] [blame] | 650 | setDbusProperty( |
| 651 | *getSdBus(), connection, path, std::get<interface>(property), |
| 652 | std::get<propertyName>(property), ipmi::Value(valueToSet)); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 653 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 654 | return ipmi::responseSuccess(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 655 | } |
| 656 | |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 657 | IPMIThresholds getIPMIThresholds(const SensorMap &sensorMap) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 658 | { |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 659 | IPMIThresholds resp; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 660 | auto warningInterface = |
| 661 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning"); |
| 662 | auto criticalInterface = |
| 663 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical"); |
| 664 | |
| 665 | if ((warningInterface != sensorMap.end()) || |
| 666 | (criticalInterface != sensorMap.end())) |
| 667 | { |
| 668 | auto sensorPair = sensorMap.find("xyz.openbmc_project.Sensor.Value"); |
| 669 | |
| 670 | if (sensorPair == sensorMap.end()) |
| 671 | { |
| 672 | // should not have been able to find a sensor not implementing |
| 673 | // the sensor object |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 674 | throw std::runtime_error("Invalid sensor map"); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 675 | } |
| 676 | |
Chen,Yugang | 606dd9f | 2019-07-01 10:37:30 +0800 | [diff] [blame] | 677 | double max = 0; |
| 678 | double min = 0; |
James Feist | aecaef7 | 2019-04-26 10:30:32 -0700 | [diff] [blame] | 679 | getSensorMaxMin(sensorMap, max, min); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 680 | |
| 681 | int16_t mValue = 0; |
| 682 | int16_t bValue = 0; |
| 683 | int8_t rExp = 0; |
| 684 | int8_t bExp = 0; |
| 685 | bool bSigned = false; |
| 686 | |
| 687 | if (!getSensorAttributes(max, min, mValue, rExp, bValue, bExp, bSigned)) |
| 688 | { |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 689 | throw std::runtime_error("Invalid sensor atrributes"); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 690 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 691 | if (warningInterface != sensorMap.end()) |
| 692 | { |
| 693 | auto &warningMap = warningInterface->second; |
| 694 | |
| 695 | auto warningHigh = warningMap.find("WarningHigh"); |
| 696 | auto warningLow = warningMap.find("WarningLow"); |
| 697 | |
| 698 | if (warningHigh != warningMap.end()) |
| 699 | { |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 700 | |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 701 | double value = |
| 702 | std::visit(VariantToDoubleVisitor(), warningHigh->second); |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 703 | resp.warningHigh = scaleIPMIValueFromDouble( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 704 | value, mValue, rExp, bValue, bExp, bSigned); |
| 705 | } |
| 706 | if (warningLow != warningMap.end()) |
| 707 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 708 | double value = |
| 709 | std::visit(VariantToDoubleVisitor(), warningLow->second); |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 710 | resp.warningLow = scaleIPMIValueFromDouble( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 711 | value, mValue, rExp, bValue, bExp, bSigned); |
| 712 | } |
| 713 | } |
| 714 | if (criticalInterface != sensorMap.end()) |
| 715 | { |
| 716 | auto &criticalMap = criticalInterface->second; |
| 717 | |
| 718 | auto criticalHigh = criticalMap.find("CriticalHigh"); |
| 719 | auto criticalLow = criticalMap.find("CriticalLow"); |
| 720 | |
| 721 | if (criticalHigh != criticalMap.end()) |
| 722 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 723 | double value = |
| 724 | std::visit(VariantToDoubleVisitor(), criticalHigh->second); |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 725 | resp.criticalHigh = scaleIPMIValueFromDouble( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 726 | value, mValue, rExp, bValue, bExp, bSigned); |
| 727 | } |
| 728 | if (criticalLow != criticalMap.end()) |
| 729 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 730 | double value = |
| 731 | std::visit(VariantToDoubleVisitor(), criticalLow->second); |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 732 | resp.criticalLow = scaleIPMIValueFromDouble( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 733 | value, mValue, rExp, bValue, bExp, bSigned); |
| 734 | } |
| 735 | } |
| 736 | } |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 737 | return resp; |
| 738 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 739 | |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 740 | ipmi::RspType<uint8_t, // readable |
| 741 | uint8_t, // lowerNCrit |
| 742 | uint8_t, // lowerCrit |
| 743 | uint8_t, // lowerNrecoverable |
| 744 | uint8_t, // upperNC |
| 745 | uint8_t, // upperCrit |
| 746 | uint8_t> // upperNRecoverable |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 747 | ipmiSenGetSensorThresholds(boost::asio::yield_context yield, |
| 748 | uint8_t sensorNumber) |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 749 | { |
| 750 | std::string connection; |
| 751 | std::string path; |
| 752 | |
| 753 | auto status = getSensorConnection(sensorNumber, connection, path); |
| 754 | if (status) |
| 755 | { |
| 756 | return ipmi::response(status); |
| 757 | } |
| 758 | |
| 759 | SensorMap sensorMap; |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 760 | if (!getSensorMap(yield, connection, path, sensorMap)) |
James Feist | 902c4c5 | 2019-04-16 14:51:31 -0700 | [diff] [blame] | 761 | { |
| 762 | return ipmi::responseResponseError(); |
| 763 | } |
| 764 | |
| 765 | IPMIThresholds thresholdData; |
| 766 | try |
| 767 | { |
| 768 | thresholdData = getIPMIThresholds(sensorMap); |
| 769 | } |
| 770 | catch (std::exception &) |
| 771 | { |
| 772 | return ipmi::responseResponseError(); |
| 773 | } |
| 774 | |
| 775 | uint8_t readable = 0; |
| 776 | uint8_t lowerNC = 0; |
| 777 | uint8_t lowerCritical = 0; |
| 778 | uint8_t lowerNonRecoverable = 0; |
| 779 | uint8_t upperNC = 0; |
| 780 | uint8_t upperCritical = 0; |
| 781 | uint8_t upperNonRecoverable = 0; |
| 782 | |
| 783 | if (thresholdData.warningHigh) |
| 784 | { |
| 785 | readable |= |
| 786 | 1 << static_cast<uint8_t>(IPMIThresholdRespBits::upperNonCritical); |
| 787 | upperNC = *thresholdData.warningHigh; |
| 788 | } |
| 789 | if (thresholdData.warningLow) |
| 790 | { |
| 791 | readable |= |
| 792 | 1 << static_cast<uint8_t>(IPMIThresholdRespBits::lowerNonCritical); |
| 793 | lowerNC = *thresholdData.warningLow; |
| 794 | } |
| 795 | |
| 796 | if (thresholdData.criticalHigh) |
| 797 | { |
| 798 | readable |= |
| 799 | 1 << static_cast<uint8_t>(IPMIThresholdRespBits::upperCritical); |
| 800 | upperCritical = *thresholdData.criticalHigh; |
| 801 | } |
| 802 | if (thresholdData.criticalLow) |
| 803 | { |
| 804 | readable |= |
| 805 | 1 << static_cast<uint8_t>(IPMIThresholdRespBits::lowerCritical); |
| 806 | lowerCritical = *thresholdData.criticalLow; |
| 807 | } |
| 808 | |
| 809 | return ipmi::responseSuccess(readable, lowerNC, lowerCritical, |
| 810 | lowerNonRecoverable, upperNC, upperCritical, |
| 811 | upperNonRecoverable); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 812 | } |
| 813 | |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 814 | /** @brief implements the get Sensor event enable command |
| 815 | * @param sensorNumber - sensor number |
| 816 | * |
| 817 | * @returns IPMI completion code plus response data |
| 818 | * - enabled - Sensor Event messages |
| 819 | * - assertionEnabledLsb - Assertion event messages |
| 820 | * - assertionEnabledMsb - Assertion event messages |
| 821 | * - deassertionEnabledLsb - Deassertion event messages |
| 822 | * - deassertionEnabledMsb - Deassertion event messages |
| 823 | */ |
| 824 | |
| 825 | ipmi::RspType<uint8_t, // enabled |
| 826 | uint8_t, // assertionEnabledLsb |
| 827 | uint8_t, // assertionEnabledMsb |
| 828 | uint8_t, // deassertionEnabledLsb |
| 829 | uint8_t> // deassertionEnabledMsb |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 830 | ipmiSenGetSensorEventEnable(boost::asio::yield_context yield, |
| 831 | uint8_t sensorNum) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 832 | { |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 833 | std::string connection; |
| 834 | std::string path; |
| 835 | |
Patrick Venture | a41714c | 2019-09-25 16:59:41 -0700 | [diff] [blame] | 836 | uint8_t enabled = 0; |
| 837 | uint8_t assertionEnabledLsb = 0; |
| 838 | uint8_t assertionEnabledMsb = 0; |
| 839 | uint8_t deassertionEnabledLsb = 0; |
| 840 | uint8_t deassertionEnabledMsb = 0; |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 841 | |
| 842 | auto status = getSensorConnection(sensorNum, connection, path); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 843 | if (status) |
| 844 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 845 | return ipmi::response(status); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | SensorMap sensorMap; |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 849 | if (!getSensorMap(yield, connection, path, sensorMap)) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 850 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 851 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 852 | } |
| 853 | |
| 854 | auto warningInterface = |
| 855 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning"); |
| 856 | auto criticalInterface = |
| 857 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical"); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 858 | if ((warningInterface != sensorMap.end()) || |
| 859 | (criticalInterface != sensorMap.end())) |
| 860 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 861 | enabled = static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 862 | IPMISensorEventEnableByte2::sensorScanningEnable); |
| 863 | if (warningInterface != sensorMap.end()) |
| 864 | { |
| 865 | auto &warningMap = warningInterface->second; |
| 866 | |
| 867 | auto warningHigh = warningMap.find("WarningHigh"); |
| 868 | auto warningLow = warningMap.find("WarningLow"); |
| 869 | if (warningHigh != warningMap.end()) |
| 870 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 871 | assertionEnabledLsb |= static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 872 | IPMISensorEventEnableThresholds::upperNonCriticalGoingHigh); |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 873 | deassertionEnabledLsb |= static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 874 | IPMISensorEventEnableThresholds::upperNonCriticalGoingLow); |
| 875 | } |
| 876 | if (warningLow != warningMap.end()) |
| 877 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 878 | assertionEnabledLsb |= static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 879 | IPMISensorEventEnableThresholds::lowerNonCriticalGoingLow); |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 880 | deassertionEnabledLsb |= static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 881 | IPMISensorEventEnableThresholds::lowerNonCriticalGoingHigh); |
| 882 | } |
| 883 | } |
| 884 | if (criticalInterface != sensorMap.end()) |
| 885 | { |
| 886 | auto &criticalMap = criticalInterface->second; |
| 887 | |
| 888 | auto criticalHigh = criticalMap.find("CriticalHigh"); |
| 889 | auto criticalLow = criticalMap.find("CriticalLow"); |
| 890 | |
| 891 | if (criticalHigh != criticalMap.end()) |
| 892 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 893 | assertionEnabledMsb |= static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 894 | IPMISensorEventEnableThresholds::upperCriticalGoingHigh); |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 895 | deassertionEnabledMsb |= static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 896 | IPMISensorEventEnableThresholds::upperCriticalGoingLow); |
| 897 | } |
| 898 | if (criticalLow != criticalMap.end()) |
| 899 | { |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 900 | assertionEnabledLsb |= static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 901 | IPMISensorEventEnableThresholds::lowerCriticalGoingLow); |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 902 | deassertionEnabledLsb |= static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 903 | IPMISensorEventEnableThresholds::lowerCriticalGoingHigh); |
| 904 | } |
| 905 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 906 | } |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 907 | |
| 908 | return ipmi::responseSuccess(enabled, assertionEnabledLsb, |
| 909 | assertionEnabledMsb, deassertionEnabledLsb, |
| 910 | deassertionEnabledMsb); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 911 | } |
| 912 | |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 913 | /** @brief implements the get Sensor event status command |
| 914 | * @param sensorNumber - sensor number, FFh = reserved |
| 915 | * |
| 916 | * @returns IPMI completion code plus response data |
| 917 | * - sensorEventStatus - Sensor Event messages state |
| 918 | * - assertions - Assertion event messages |
| 919 | * - deassertions - Deassertion event messages |
| 920 | */ |
| 921 | ipmi::RspType<uint8_t, // sensorEventStatus |
| 922 | std::bitset<16>, // assertions |
| 923 | std::bitset<16> // deassertion |
| 924 | > |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 925 | ipmiSenGetSensorEventStatus(boost::asio::yield_context yield, |
| 926 | uint8_t sensorNum) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 927 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 928 | if (sensorNum == 0xFF) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 929 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 930 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 931 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 932 | |
| 933 | std::string connection; |
| 934 | std::string path; |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 935 | auto status = getSensorConnection(sensorNum, connection, path); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 936 | if (status) |
| 937 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 938 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 939 | "ipmiSenGetSensorEventStatus: Sensor connection Error", |
| 940 | phosphor::logging::entry("SENSOR=%d", sensorNum)); |
| 941 | return ipmi::response(status); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | SensorMap sensorMap; |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 945 | if (!getSensorMap(yield, connection, path, sensorMap)) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 946 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 947 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 948 | "ipmiSenGetSensorEventStatus: Sensor Mapping Error", |
| 949 | phosphor::logging::entry("SENSOR=%s", path.c_str())); |
| 950 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 951 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 952 | auto warningInterface = |
| 953 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Warning"); |
| 954 | auto criticalInterface = |
| 955 | sensorMap.find("xyz.openbmc_project.Sensor.Threshold.Critical"); |
| 956 | |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 957 | uint8_t sensorEventStatus = |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 958 | static_cast<uint8_t>(IPMISensorEventEnableByte2::sensorScanningEnable); |
| 959 | |
James Feist | 392786a | 2019-03-19 13:36:10 -0700 | [diff] [blame] | 960 | std::optional<bool> criticalDeassertHigh = |
| 961 | thresholdDeassertMap[path]["CriticalAlarmHigh"]; |
| 962 | std::optional<bool> criticalDeassertLow = |
| 963 | thresholdDeassertMap[path]["CriticalAlarmLow"]; |
| 964 | std::optional<bool> warningDeassertHigh = |
| 965 | thresholdDeassertMap[path]["WarningAlarmHigh"]; |
| 966 | std::optional<bool> warningDeassertLow = |
| 967 | thresholdDeassertMap[path]["WarningAlarmLow"]; |
| 968 | |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 969 | std::bitset<16> assertions = 0; |
| 970 | std::bitset<16> deassertions = 0; |
| 971 | |
James Feist | 392786a | 2019-03-19 13:36:10 -0700 | [diff] [blame] | 972 | if (criticalDeassertHigh && !*criticalDeassertHigh) |
| 973 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 974 | deassertions.set(static_cast<size_t>( |
| 975 | IPMIGetSensorEventEnableThresholds::upperCriticalGoingHigh)); |
James Feist | 392786a | 2019-03-19 13:36:10 -0700 | [diff] [blame] | 976 | } |
| 977 | if (criticalDeassertLow && !*criticalDeassertLow) |
| 978 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 979 | deassertions.set(static_cast<size_t>( |
| 980 | IPMIGetSensorEventEnableThresholds::upperCriticalGoingLow)); |
James Feist | 392786a | 2019-03-19 13:36:10 -0700 | [diff] [blame] | 981 | } |
| 982 | if (warningDeassertHigh && !*warningDeassertHigh) |
| 983 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 984 | deassertions.set(static_cast<size_t>( |
| 985 | IPMIGetSensorEventEnableThresholds::upperNonCriticalGoingHigh)); |
James Feist | 392786a | 2019-03-19 13:36:10 -0700 | [diff] [blame] | 986 | } |
| 987 | if (warningDeassertLow && !*warningDeassertLow) |
| 988 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 989 | deassertions.set(static_cast<size_t>( |
| 990 | IPMIGetSensorEventEnableThresholds::lowerNonCriticalGoingHigh)); |
James Feist | 392786a | 2019-03-19 13:36:10 -0700 | [diff] [blame] | 991 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 992 | if ((warningInterface != sensorMap.end()) || |
| 993 | (criticalInterface != sensorMap.end())) |
| 994 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 995 | sensorEventStatus = static_cast<size_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 996 | IPMISensorEventEnableByte2::eventMessagesEnable); |
| 997 | if (warningInterface != sensorMap.end()) |
| 998 | { |
| 999 | auto &warningMap = warningInterface->second; |
| 1000 | |
| 1001 | auto warningHigh = warningMap.find("WarningAlarmHigh"); |
| 1002 | auto warningLow = warningMap.find("WarningAlarmLow"); |
| 1003 | auto warningHighAlarm = false; |
| 1004 | auto warningLowAlarm = false; |
| 1005 | |
| 1006 | if (warningHigh != warningMap.end()) |
| 1007 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 1008 | warningHighAlarm = std::get<bool>(warningHigh->second); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1009 | } |
| 1010 | if (warningLow != warningMap.end()) |
| 1011 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 1012 | warningLowAlarm = std::get<bool>(warningLow->second); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1013 | } |
| 1014 | if (warningHighAlarm) |
| 1015 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 1016 | assertions.set( |
| 1017 | static_cast<size_t>(IPMIGetSensorEventEnableThresholds:: |
| 1018 | upperNonCriticalGoingHigh)); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1019 | } |
| 1020 | if (warningLowAlarm) |
| 1021 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 1022 | assertions.set( |
| 1023 | static_cast<size_t>(IPMIGetSensorEventEnableThresholds:: |
| 1024 | lowerNonCriticalGoingLow)); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1025 | } |
| 1026 | } |
| 1027 | if (criticalInterface != sensorMap.end()) |
| 1028 | { |
| 1029 | auto &criticalMap = criticalInterface->second; |
| 1030 | |
| 1031 | auto criticalHigh = criticalMap.find("CriticalAlarmHigh"); |
| 1032 | auto criticalLow = criticalMap.find("CriticalAlarmLow"); |
| 1033 | auto criticalHighAlarm = false; |
| 1034 | auto criticalLowAlarm = false; |
| 1035 | |
| 1036 | if (criticalHigh != criticalMap.end()) |
| 1037 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 1038 | criticalHighAlarm = std::get<bool>(criticalHigh->second); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1039 | } |
| 1040 | if (criticalLow != criticalMap.end()) |
| 1041 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 1042 | criticalLowAlarm = std::get<bool>(criticalLow->second); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1043 | } |
| 1044 | if (criticalHighAlarm) |
| 1045 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 1046 | assertions.set( |
| 1047 | static_cast<size_t>(IPMIGetSensorEventEnableThresholds:: |
| 1048 | upperCriticalGoingHigh)); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1049 | } |
| 1050 | if (criticalLowAlarm) |
| 1051 | { |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 1052 | assertions.set(static_cast<size_t>( |
| 1053 | IPMIGetSensorEventEnableThresholds::lowerCriticalGoingLow)); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1054 | } |
| 1055 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1056 | } |
| 1057 | |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 1058 | return ipmi::responseSuccess(sensorEventStatus, assertions, deassertions); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1059 | } |
| 1060 | |
| 1061 | /* end sensor commands */ |
| 1062 | |
| 1063 | /* storage commands */ |
| 1064 | |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1065 | ipmi::RspType<uint8_t, // sdr version |
| 1066 | uint16_t, // record count |
| 1067 | uint16_t, // free space |
| 1068 | uint32_t, // most recent addition |
| 1069 | uint32_t, // most recent erase |
| 1070 | uint8_t // operationSupport |
| 1071 | > |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 1072 | ipmiStorageGetSDRRepositoryInfo(ipmi::Context::ptr ctx) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1073 | { |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1074 | constexpr const uint16_t unspecifiedFreeSpace = 0xFFFF; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1075 | if (sensorTree.empty() && !getSensorSubtree(sensorTree)) |
| 1076 | { |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1077 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1078 | } |
| 1079 | |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1080 | size_t fruCount = 0; |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 1081 | ipmi::Cc ret = ipmi::storage::getFruSdrCount(ctx, fruCount); |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1082 | if (ret != ipmi::ccSuccess) |
| 1083 | { |
| 1084 | return ipmi::response(ret); |
| 1085 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1086 | |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1087 | uint16_t recordCount = |
| 1088 | sensorTree.size() + fruCount + ipmi::storage::type12Count; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1089 | |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1090 | uint8_t operationSupport = static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1091 | SdrRepositoryInfoOps::overflow); // write not supported |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1092 | |
| 1093 | operationSupport |= |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1094 | static_cast<uint8_t>(SdrRepositoryInfoOps::allocCommandSupported); |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1095 | operationSupport |= static_cast<uint8_t>( |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1096 | SdrRepositoryInfoOps::reserveSDRRepositoryCommandSupported); |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1097 | return ipmi::responseSuccess(ipmiSdrVersion, recordCount, |
| 1098 | unspecifiedFreeSpace, sdrLastAdd, |
| 1099 | sdrLastRemove, operationSupport); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1100 | } |
| 1101 | |
jayaprakash Mutyala | 6ae0818 | 2019-05-13 18:56:11 +0000 | [diff] [blame] | 1102 | /** @brief implements the get SDR allocation info command |
| 1103 | * |
| 1104 | * @returns IPMI completion code plus response data |
| 1105 | * - allocUnits - Number of possible allocation units |
| 1106 | * - allocUnitSize - Allocation unit size in bytes. |
| 1107 | * - allocUnitFree - Number of free allocation units |
| 1108 | * - allocUnitLargestFree - Largest free block in allocation units |
| 1109 | * - maxRecordSize - Maximum record size in allocation units. |
| 1110 | */ |
| 1111 | ipmi::RspType<uint16_t, // allocUnits |
| 1112 | uint16_t, // allocUnitSize |
| 1113 | uint16_t, // allocUnitFree |
| 1114 | uint16_t, // allocUnitLargestFree |
| 1115 | uint8_t // maxRecordSize |
| 1116 | > |
| 1117 | ipmiStorageGetSDRAllocationInfo() |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1118 | { |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1119 | // 0000h unspecified number of alloc units |
jayaprakash Mutyala | 6ae0818 | 2019-05-13 18:56:11 +0000 | [diff] [blame] | 1120 | constexpr uint16_t allocUnits = 0; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1121 | |
jayaprakash Mutyala | 6ae0818 | 2019-05-13 18:56:11 +0000 | [diff] [blame] | 1122 | constexpr uint16_t allocUnitFree = 0; |
| 1123 | constexpr uint16_t allocUnitLargestFree = 0; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1124 | // only allow one block at a time |
jayaprakash Mutyala | 6ae0818 | 2019-05-13 18:56:11 +0000 | [diff] [blame] | 1125 | constexpr uint8_t maxRecordSize = 1; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1126 | |
jayaprakash Mutyala | 6ae0818 | 2019-05-13 18:56:11 +0000 | [diff] [blame] | 1127 | return ipmi::responseSuccess(allocUnits, maxSDRTotalSize, allocUnitFree, |
| 1128 | allocUnitLargestFree, maxRecordSize); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1129 | } |
| 1130 | |
jayaprakash Mutyala | 6ae0818 | 2019-05-13 18:56:11 +0000 | [diff] [blame] | 1131 | /** @brief implements the reserve SDR command |
| 1132 | * @returns IPMI completion code plus response data |
| 1133 | * - sdrReservationID |
| 1134 | */ |
| 1135 | ipmi::RspType<uint16_t> ipmiStorageReserveSDR() |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1136 | { |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1137 | sdrReservationID++; |
James Feist | a80cb90 | 2019-02-14 13:05:25 -0800 | [diff] [blame] | 1138 | if (sdrReservationID == 0) |
| 1139 | { |
| 1140 | sdrReservationID++; |
| 1141 | } |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1142 | |
jayaprakash Mutyala | 6ae0818 | 2019-05-13 18:56:11 +0000 | [diff] [blame] | 1143 | return ipmi::responseSuccess(sdrReservationID); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1144 | } |
| 1145 | |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1146 | ipmi::RspType<uint16_t, // next record ID |
| 1147 | std::vector<uint8_t> // payload |
| 1148 | > |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 1149 | ipmiStorageGetSDR(ipmi::Context::ptr ctx, uint16_t reservationID, |
| 1150 | uint16_t recordID, uint8_t offset, uint8_t bytesToRead) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1151 | { |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1152 | constexpr uint16_t lastRecordIndex = 0xFFFF; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1153 | |
| 1154 | // reservation required for partial reads with non zero offset into |
| 1155 | // record |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1156 | if ((sdrReservationID == 0 || reservationID != sdrReservationID) && offset) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1157 | { |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1158 | return ipmi::responseInvalidReservationId(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1159 | } |
| 1160 | |
| 1161 | if (sensorTree.empty() && !getSensorSubtree(sensorTree)) |
| 1162 | { |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1163 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1164 | } |
| 1165 | |
| 1166 | size_t fruCount = 0; |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 1167 | ipmi::Cc ret = ipmi::storage::getFruSdrCount(ctx, fruCount); |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1168 | if (ret != ipmi::ccSuccess) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1169 | { |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1170 | return ipmi::response(ret); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1171 | } |
| 1172 | |
Yong Li | fee5e4c | 2020-01-17 19:36:29 +0800 | [diff] [blame] | 1173 | size_t lastRecord = sensorTree.size() + fruCount + |
| 1174 | ipmi::storage::type12Count + |
| 1175 | ipmi::storage::nmDiscoverySDRCount - 1; |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1176 | if (recordID == lastRecordIndex) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1177 | { |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1178 | recordID = lastRecord; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1179 | } |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1180 | if (recordID > lastRecord) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1181 | { |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1182 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1183 | } |
| 1184 | |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1185 | uint16_t nextRecordId = lastRecord > recordID ? recordID + 1 : 0XFFFF; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1186 | |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1187 | if (recordID >= sensorTree.size()) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1188 | { |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1189 | std::vector<uint8_t> recordData; |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1190 | size_t fruIndex = recordID - sensorTree.size(); |
Yong Li | fee5e4c | 2020-01-17 19:36:29 +0800 | [diff] [blame] | 1191 | size_t type12End = fruCount + ipmi::storage::type12Count; |
| 1192 | |
| 1193 | if (fruIndex >= type12End) |
| 1194 | { |
| 1195 | // NM discovery SDR |
| 1196 | size_t nmDiscoveryIndex = fruIndex - type12End; |
| 1197 | if (nmDiscoveryIndex >= ipmi::storage::nmDiscoverySDRCount || |
| 1198 | offset > sizeof(NMDiscoveryRecord)) |
| 1199 | { |
| 1200 | return ipmi::responseInvalidFieldRequest(); |
| 1201 | } |
| 1202 | |
| 1203 | std::vector<uint8_t> record = |
| 1204 | ipmi::storage::getNMDiscoverySDR(nmDiscoveryIndex, recordID); |
| 1205 | if (record.size() < (offset + bytesToRead)) |
| 1206 | { |
| 1207 | bytesToRead = record.size() - offset; |
| 1208 | } |
| 1209 | recordData.insert(recordData.end(), record.begin() + offset, |
| 1210 | record.begin() + offset + bytesToRead); |
| 1211 | } |
| 1212 | else if (fruIndex >= fruCount) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1213 | { |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1214 | // handle type 12 hardcoded records |
| 1215 | size_t type12Index = fruIndex - fruCount; |
| 1216 | if (type12Index >= ipmi::storage::type12Count || |
| 1217 | offset > sizeof(Type12Record)) |
| 1218 | { |
| 1219 | return ipmi::responseInvalidFieldRequest(); |
| 1220 | } |
| 1221 | std::vector<uint8_t> record = |
| 1222 | ipmi::storage::getType12SDRs(type12Index, recordID); |
| 1223 | if (record.size() < (offset + bytesToRead)) |
| 1224 | { |
| 1225 | bytesToRead = record.size() - offset; |
| 1226 | } |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1227 | |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1228 | recordData.insert(recordData.end(), record.begin() + offset, |
| 1229 | record.begin() + offset + bytesToRead); |
| 1230 | } |
| 1231 | else |
| 1232 | { |
| 1233 | // handle fru records |
| 1234 | get_sdr::SensorDataFruRecord data; |
| 1235 | if (offset > sizeof(data)) |
| 1236 | { |
| 1237 | return ipmi::responseInvalidFieldRequest(); |
| 1238 | } |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 1239 | ret = ipmi::storage::getFruSdrs(ctx, fruIndex, data); |
James Feist | 74c50c6 | 2019-08-14 14:18:41 -0700 | [diff] [blame] | 1240 | if (ret != IPMI_CC_OK) |
| 1241 | { |
| 1242 | return ipmi::response(ret); |
| 1243 | } |
| 1244 | data.header.record_id_msb = recordID << 8; |
| 1245 | data.header.record_id_lsb = recordID & 0xFF; |
| 1246 | if (sizeof(data) < (offset + bytesToRead)) |
| 1247 | { |
| 1248 | bytesToRead = sizeof(data) - offset; |
| 1249 | } |
| 1250 | |
| 1251 | uint8_t *respStart = reinterpret_cast<uint8_t *>(&data) + offset; |
| 1252 | recordData.insert(recordData.end(), respStart, |
| 1253 | respStart + bytesToRead); |
| 1254 | } |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1255 | |
| 1256 | return ipmi::responseSuccess(nextRecordId, recordData); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1257 | } |
| 1258 | |
| 1259 | std::string connection; |
| 1260 | std::string path; |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1261 | uint16_t sensorIndex = recordID; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1262 | for (const auto &sensor : sensorTree) |
| 1263 | { |
| 1264 | if (sensorIndex-- == 0) |
| 1265 | { |
| 1266 | if (!sensor.second.size()) |
| 1267 | { |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1268 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1269 | } |
| 1270 | connection = sensor.second.begin()->first; |
| 1271 | path = sensor.first; |
| 1272 | break; |
| 1273 | } |
| 1274 | } |
| 1275 | |
| 1276 | SensorMap sensorMap; |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 1277 | if (!getSensorMap(ctx->yield, connection, path, sensorMap)) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1278 | { |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1279 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1280 | } |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1281 | uint8_t sensornumber = (recordID & 0xFF); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1282 | get_sdr::SensorDataFullRecord record = {0}; |
| 1283 | |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1284 | record.header.record_id_msb = recordID << 8; |
| 1285 | record.header.record_id_lsb = recordID & 0xFF; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1286 | record.header.sdr_version = ipmiSdrVersion; |
| 1287 | record.header.record_type = get_sdr::SENSOR_DATA_FULL_RECORD; |
| 1288 | record.header.record_length = sizeof(get_sdr::SensorDataFullRecord) - |
| 1289 | sizeof(get_sdr::SensorDataRecordHeader); |
| 1290 | record.key.owner_id = 0x20; |
| 1291 | record.key.owner_lun = 0x0; |
| 1292 | record.key.sensor_number = sensornumber; |
| 1293 | |
James Feist | 7086a88 | 2019-03-13 10:46:00 -0700 | [diff] [blame] | 1294 | record.body.sensor_capabilities = 0x68; // auto rearm - todo hysteresis |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1295 | record.body.sensor_type = getSensorTypeFromPath(path); |
| 1296 | std::string type = getSensorTypeStringFromPath(path); |
| 1297 | auto typeCstr = type.c_str(); |
| 1298 | auto findUnits = sensorUnits.find(typeCstr); |
| 1299 | if (findUnits != sensorUnits.end()) |
| 1300 | { |
| 1301 | record.body.sensor_units_2_base = |
| 1302 | static_cast<uint8_t>(findUnits->second); |
| 1303 | } // else default 0x0 unspecified |
| 1304 | |
| 1305 | record.body.event_reading_type = getSensorEventTypeFromPath(path); |
| 1306 | |
| 1307 | auto sensorObject = sensorMap.find("xyz.openbmc_project.Sensor.Value"); |
| 1308 | if (sensorObject == sensorMap.end()) |
| 1309 | { |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1310 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1311 | } |
| 1312 | |
Patrick Venture | 262276f | 2019-10-18 13:27:59 -0700 | [diff] [blame] | 1313 | uint8_t entityId = 0; |
| 1314 | uint8_t entityInstance = 0x01; |
| 1315 | |
| 1316 | // follow the association chain to get the parent board's entityid and |
| 1317 | // entityInstance |
| 1318 | updateIpmiFromAssociation(path, sensorMap, entityId, entityInstance); |
| 1319 | |
| 1320 | record.body.entity_id = entityId; |
| 1321 | record.body.entity_instance = entityInstance; |
| 1322 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1323 | auto maxObject = sensorObject->second.find("MaxValue"); |
| 1324 | auto minObject = sensorObject->second.find("MinValue"); |
Josh Lehan | ca9dcbd | 2019-11-18 15:59:59 -0800 | [diff] [blame] | 1325 | |
| 1326 | // If min and/or max are left unpopulated, |
| 1327 | // then default to what a signed byte would be, namely (-128,127) range. |
| 1328 | auto max = static_cast<double>(std::numeric_limits<int8_t>::max()); |
| 1329 | auto min = static_cast<double>(std::numeric_limits<int8_t>::lowest()); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1330 | if (maxObject != sensorObject->second.end()) |
| 1331 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 1332 | max = std::visit(VariantToDoubleVisitor(), maxObject->second); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1333 | } |
| 1334 | |
| 1335 | if (minObject != sensorObject->second.end()) |
| 1336 | { |
Vernon Mauery | 8166c8d | 2019-05-23 11:22:30 -0700 | [diff] [blame] | 1337 | min = std::visit(VariantToDoubleVisitor(), minObject->second); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1338 | } |
| 1339 | |
Yong Li | 1f2eb5e | 2019-05-23 14:07:17 +0800 | [diff] [blame] | 1340 | int16_t mValue = 0; |
| 1341 | int8_t rExp = 0; |
| 1342 | int16_t bValue = 0; |
| 1343 | int8_t bExp = 0; |
| 1344 | bool bSigned = false; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1345 | |
| 1346 | if (!getSensorAttributes(max, min, mValue, rExp, bValue, bExp, bSigned)) |
| 1347 | { |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1348 | return ipmi::responseResponseError(); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1349 | } |
| 1350 | |
Josh Lehan | 7cc9e47 | 2019-11-18 16:09:26 -0800 | [diff] [blame] | 1351 | // The record.body is a struct SensorDataFullRecordBody |
| 1352 | // from sensorhandler.hpp in phosphor-ipmi-host. |
| 1353 | // The meaning of these bits appears to come from |
| 1354 | // table 43.1 of the IPMI spec. |
| 1355 | // The above 5 sensor attributes are stuffed in as follows: |
| 1356 | // Byte 21 = AA000000 = analog interpretation, 10 signed, 00 unsigned |
| 1357 | // Byte 22-24 are for other purposes |
| 1358 | // Byte 25 = MMMMMMMM = LSB of M |
| 1359 | // Byte 26 = MMTTTTTT = MSB of M (signed), and Tolerance |
| 1360 | // Byte 27 = BBBBBBBB = LSB of B |
| 1361 | // Byte 28 = BBAAAAAA = MSB of B (signed), and LSB of Accuracy |
| 1362 | // Byte 29 = AAAAEE00 = MSB of Accuracy, exponent of Accuracy |
| 1363 | // Byte 30 = RRRRBBBB = rExp (signed), bExp (signed) |
| 1364 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1365 | // apply M, B, and exponents, M and B are 10 bit values, exponents are 4 |
| 1366 | record.body.m_lsb = mValue & 0xFF; |
| 1367 | |
Josh Lehan | 7cc9e47 | 2019-11-18 16:09:26 -0800 | [diff] [blame] | 1368 | uint8_t mBitSign = (mValue < 0) ? 1 : 0; |
| 1369 | uint8_t mBitNine = (mValue & 0x0100) >> 8; |
| 1370 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1371 | // move the smallest bit of the MSB into place (bit 9) |
| 1372 | // the MSbs are bits 7:8 in m_msb_and_tolerance |
Josh Lehan | 7cc9e47 | 2019-11-18 16:09:26 -0800 | [diff] [blame] | 1373 | record.body.m_msb_and_tolerance = (mBitSign << 7) | (mBitNine << 6); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1374 | |
| 1375 | record.body.b_lsb = bValue & 0xFF; |
| 1376 | |
Josh Lehan | 7cc9e47 | 2019-11-18 16:09:26 -0800 | [diff] [blame] | 1377 | uint8_t bBitSign = (bValue < 0) ? 1 : 0; |
| 1378 | uint8_t bBitNine = (bValue & 0x0100) >> 8; |
| 1379 | |
| 1380 | // move the smallest bit of the MSB into place (bit 9) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1381 | // the MSbs are bits 7:8 in b_msb_and_accuracy_lsb |
Josh Lehan | 7cc9e47 | 2019-11-18 16:09:26 -0800 | [diff] [blame] | 1382 | record.body.b_msb_and_accuracy_lsb = (bBitSign << 7) | (bBitNine << 6); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1383 | |
Josh Lehan | 7cc9e47 | 2019-11-18 16:09:26 -0800 | [diff] [blame] | 1384 | uint8_t rExpSign = (rExp < 0) ? 1 : 0; |
| 1385 | uint8_t rExpBits = rExp & 0x07; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1386 | |
Josh Lehan | 7cc9e47 | 2019-11-18 16:09:26 -0800 | [diff] [blame] | 1387 | uint8_t bExpSign = (bExp < 0) ? 1 : 0; |
| 1388 | uint8_t bExpBits = bExp & 0x07; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1389 | |
Josh Lehan | 7cc9e47 | 2019-11-18 16:09:26 -0800 | [diff] [blame] | 1390 | // move rExp and bExp into place |
| 1391 | record.body.r_b_exponents = |
| 1392 | (rExpSign << 7) | (rExpBits << 4) | (bExpSign << 3) | bExpBits; |
| 1393 | |
| 1394 | // Set the analog reading byte interpretation accordingly |
| 1395 | record.body.sensor_units_1 = (bSigned ? 1 : 0) << 7; |
| 1396 | |
| 1397 | // TODO(): Perhaps care about Tolerance, Accuracy, and so on |
| 1398 | // These seem redundant, but derivable from the above 5 attributes |
| 1399 | // Original comment said "todo fill out rest of units" |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1400 | |
| 1401 | // populate sensor name from path |
| 1402 | std::string name; |
| 1403 | size_t nameStart = path.rfind("/"); |
| 1404 | if (nameStart != std::string::npos) |
| 1405 | { |
| 1406 | name = path.substr(nameStart + 1, std::string::npos - nameStart); |
| 1407 | } |
| 1408 | |
| 1409 | std::replace(name.begin(), name.end(), '_', ' '); |
| 1410 | if (name.size() > FULL_RECORD_ID_STR_MAX_LENGTH) |
| 1411 | { |
James Feist | 979a232 | 2019-05-15 09:06:54 -0700 | [diff] [blame] | 1412 | // try to not truncate by replacing common words |
| 1413 | constexpr std::array<std::pair<const char *, const char *>, 2> |
| 1414 | replaceWords = {std::make_pair("Output", "Out"), |
| 1415 | std::make_pair("Input", "In")}; |
| 1416 | for (const auto &[find, replace] : replaceWords) |
| 1417 | { |
| 1418 | boost::replace_all(name, find, replace); |
| 1419 | } |
| 1420 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1421 | name.resize(FULL_RECORD_ID_STR_MAX_LENGTH); |
| 1422 | } |
| 1423 | record.body.id_string_info = name.size(); |
| 1424 | std::strncpy(record.body.id_string, name.c_str(), |
| 1425 | sizeof(record.body.id_string)); |
| 1426 | |
James Feist | c4b15bc | 2019-04-16 15:41:39 -0700 | [diff] [blame] | 1427 | IPMIThresholds thresholdData; |
| 1428 | try |
| 1429 | { |
| 1430 | thresholdData = getIPMIThresholds(sensorMap); |
| 1431 | } |
| 1432 | catch (std::exception &) |
| 1433 | { |
| 1434 | return ipmi::responseResponseError(); |
| 1435 | } |
| 1436 | |
| 1437 | if (thresholdData.criticalHigh) |
| 1438 | { |
| 1439 | record.body.upper_critical_threshold = *thresholdData.criticalHigh; |
| 1440 | record.body.supported_deassertions[1] |= static_cast<uint8_t>( |
| 1441 | IPMISensorEventEnableThresholds::upperCriticalGoingHigh); |
| 1442 | record.body.supported_assertions[1] |= static_cast<uint8_t>( |
| 1443 | IPMISensorEventEnableThresholds::upperCriticalGoingHigh); |
| 1444 | record.body.discrete_reading_setting_mask[0] |= |
| 1445 | static_cast<uint8_t>(IPMISensorReadingByte3::upperCritical); |
| 1446 | } |
| 1447 | if (thresholdData.warningHigh) |
| 1448 | { |
| 1449 | record.body.upper_noncritical_threshold = *thresholdData.warningHigh; |
| 1450 | record.body.supported_deassertions[0] |= static_cast<uint8_t>( |
| 1451 | IPMISensorEventEnableThresholds::upperNonCriticalGoingHigh); |
| 1452 | record.body.supported_assertions[0] |= static_cast<uint8_t>( |
| 1453 | IPMISensorEventEnableThresholds::upperNonCriticalGoingHigh); |
| 1454 | record.body.discrete_reading_setting_mask[0] |= |
| 1455 | static_cast<uint8_t>(IPMISensorReadingByte3::upperNonCritical); |
| 1456 | } |
| 1457 | if (thresholdData.criticalLow) |
| 1458 | { |
| 1459 | record.body.lower_critical_threshold = *thresholdData.criticalLow; |
| 1460 | record.body.supported_deassertions[0] |= static_cast<uint8_t>( |
| 1461 | IPMISensorEventEnableThresholds::lowerCriticalGoingLow); |
| 1462 | record.body.supported_assertions[0] |= static_cast<uint8_t>( |
| 1463 | IPMISensorEventEnableThresholds::lowerCriticalGoingLow); |
| 1464 | record.body.discrete_reading_setting_mask[0] |= |
| 1465 | static_cast<uint8_t>(IPMISensorReadingByte3::lowerCritical); |
| 1466 | } |
| 1467 | if (thresholdData.warningLow) |
| 1468 | { |
| 1469 | record.body.lower_noncritical_threshold = *thresholdData.warningLow; |
| 1470 | record.body.supported_deassertions[0] |= static_cast<uint8_t>( |
| 1471 | IPMISensorEventEnableThresholds::lowerNonCriticalGoingLow); |
| 1472 | record.body.supported_assertions[0] |= static_cast<uint8_t>( |
| 1473 | IPMISensorEventEnableThresholds::lowerNonCriticalGoingLow); |
| 1474 | record.body.discrete_reading_setting_mask[0] |= |
| 1475 | static_cast<uint8_t>(IPMISensorReadingByte3::lowerNonCritical); |
| 1476 | } |
| 1477 | |
| 1478 | // everything that is readable is setable |
| 1479 | record.body.discrete_reading_setting_mask[1] = |
| 1480 | record.body.discrete_reading_setting_mask[0]; |
| 1481 | |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1482 | if (sizeof(get_sdr::SensorDataFullRecord) < (offset + bytesToRead)) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1483 | { |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1484 | bytesToRead = sizeof(get_sdr::SensorDataFullRecord) - offset; |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1485 | } |
| 1486 | |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1487 | uint8_t *respStart = reinterpret_cast<uint8_t *>(&record) + offset; |
| 1488 | std::vector<uint8_t> recordData(respStart, respStart + bytesToRead); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1489 | |
James Feist | b49a98a | 2019-04-16 13:48:09 -0700 | [diff] [blame] | 1490 | return ipmi::responseSuccess(nextRecordId, recordData); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1491 | } |
| 1492 | /* end storage commands */ |
| 1493 | |
| 1494 | void registerSensorFunctions() |
| 1495 | { |
| 1496 | // get firmware version information |
| 1497 | ipmiPrintAndRegister(NETFUN_SENSOR, IPMI_CMD_WILDCARD, nullptr, |
| 1498 | ipmiSensorWildcardHandler, PRIVILEGE_USER); |
| 1499 | |
| 1500 | // <Get Sensor Type> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1501 | ipmiPrintAndRegister(NETFUN_SENSOR, ipmi::sensor_event::cmdGetSensorType, |
| 1502 | nullptr, ipmiSensorWildcardHandler, PRIVILEGE_USER); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1503 | |
| 1504 | // <Set Sensor Reading and Event Status> |
| 1505 | ipmiPrintAndRegister( |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1506 | NETFUN_SENSOR, ipmi::sensor_event::cmdSetSensorReadingAndEvtSts, |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1507 | nullptr, ipmiSensorWildcardHandler, PRIVILEGE_OPERATOR); |
| 1508 | |
Jason M. Bills | ae6bdb1 | 2019-04-02 12:00:04 -0700 | [diff] [blame] | 1509 | // <Platform Event> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1510 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnSensor, |
| 1511 | ipmi::sensor_event::cmdPlatformEvent, |
| 1512 | ipmi::Privilege::Operator, ipmiSenPlatformEvent); |
Jason M. Bills | ae6bdb1 | 2019-04-02 12:00:04 -0700 | [diff] [blame] | 1513 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1514 | // <Get Sensor Reading> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1515 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnSensor, |
| 1516 | ipmi::sensor_event::cmdGetSensorReading, |
| 1517 | ipmi::Privilege::User, ipmiSenGetSensorReading); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1518 | |
| 1519 | // <Get Sensor Threshold> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1520 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnSensor, |
| 1521 | ipmi::sensor_event::cmdGetSensorThreshold, |
| 1522 | ipmi::Privilege::User, ipmiSenGetSensorThresholds); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1523 | |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 1524 | // <Set Sensor Threshold> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1525 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnSensor, |
| 1526 | ipmi::sensor_event::cmdSetSensorThreshold, |
| 1527 | ipmi::Privilege::Operator, |
| 1528 | ipmiSenSetSensorThresholds); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1529 | |
| 1530 | // <Get Sensor Event Enable> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1531 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnSensor, |
| 1532 | ipmi::sensor_event::cmdGetSensorEventEnable, |
jayaprakash Mutyala | 39fa93f | 2019-05-13 12:16:30 +0000 | [diff] [blame] | 1533 | ipmi::Privilege::User, ipmiSenGetSensorEventEnable); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1534 | |
| 1535 | // <Get Sensor Event Status> |
jayaprakash Mutyala | ccf88f6 | 2019-05-13 16:57:16 +0000 | [diff] [blame] | 1536 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnSensor, |
| 1537 | ipmi::sensor_event::cmdGetSensorEventStatus, |
| 1538 | ipmi::Privilege::User, ipmiSenGetSensorEventStatus); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1539 | |
| 1540 | // register all storage commands for both Sensor and Storage command |
| 1541 | // versions |
| 1542 | |
| 1543 | // <Get SDR Repository Info> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1544 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnStorage, |
| 1545 | ipmi::storage::cmdGetSdrRepositoryInfo, |
| 1546 | ipmi::Privilege::User, |
| 1547 | ipmiStorageGetSDRRepositoryInfo); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1548 | |
| 1549 | // <Get SDR Allocation Info> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1550 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnStorage, |
| 1551 | ipmi::storage::cmdGetSdrRepositoryAllocInfo, |
| 1552 | ipmi::Privilege::User, |
| 1553 | ipmiStorageGetSDRAllocationInfo); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1554 | |
| 1555 | // <Reserve SDR Repo> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1556 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnSensor, |
| 1557 | ipmi::sensor_event::cmdReserveDeviceSdrRepository, |
jayaprakash Mutyala | 6ae0818 | 2019-05-13 18:56:11 +0000 | [diff] [blame] | 1558 | ipmi::Privilege::User, ipmiStorageReserveSDR); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1559 | |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1560 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnStorage, |
| 1561 | ipmi::storage::cmdReserveSdrRepository, |
| 1562 | ipmi::Privilege::User, ipmiStorageReserveSDR); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1563 | |
| 1564 | // <Get Sdr> |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1565 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnSensor, |
| 1566 | ipmi::sensor_event::cmdGetDeviceSdr, |
| 1567 | ipmi::Privilege::User, ipmiStorageGetSDR); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1568 | |
Vernon Mauery | 98bbf69 | 2019-09-16 11:14:59 -0700 | [diff] [blame] | 1569 | ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnStorage, |
| 1570 | ipmi::storage::cmdGetSdr, ipmi::Privilege::User, |
| 1571 | ipmiStorageGetSDR); |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 1572 | } |
| 1573 | } // namespace ipmi |