Patrick Venture | 3a5071a | 2018-09-12 13:27:42 -0700 | [diff] [blame] | 1 | #include "storagehandler.hpp" |
| 2 | |
| 3 | #include "fruread.hpp" |
| 4 | #include "read_fru_data.hpp" |
| 5 | #include "selutility.hpp" |
| 6 | #include "sensorhandler.hpp" |
| 7 | #include "storageaddsel.hpp" |
Patrick Venture | 3a5071a | 2018-09-12 13:27:42 -0700 | [diff] [blame] | 8 | |
Lei YU | 52d9124 | 2017-10-17 22:52:28 +0800 | [diff] [blame] | 9 | #include <arpa/inet.h> |
Patrick Venture | 3a5071a | 2018-09-12 13:27:42 -0700 | [diff] [blame] | 10 | #include <mapper.h> |
| 11 | #include <systemd/sd-bus.h> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 12 | |
| 13 | #include <algorithm> |
Lei YU | 52d9124 | 2017-10-17 22:52:28 +0800 | [diff] [blame] | 14 | #include <chrono> |
| 15 | #include <cstdio> |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 16 | #include <cstring> |
Vernon Mauery | bdda800 | 2019-02-26 10:18:51 -0800 | [diff] [blame] | 17 | #include <filesystem> |
Vernon Mauery | e08fbff | 2019-04-03 09:19:34 -0700 | [diff] [blame] | 18 | #include <ipmid/api.hpp> |
Vernon Mauery | 6a98fe7 | 2019-03-11 15:57:48 -0700 | [diff] [blame] | 19 | #include <ipmid/utils.hpp> |
Patrick Venture | 3a5071a | 2018-09-12 13:27:42 -0700 | [diff] [blame] | 20 | #include <phosphor-logging/elog-errors.hpp> |
| 21 | #include <phosphor-logging/log.hpp> |
| 22 | #include <sdbusplus/server.hpp> |
| 23 | #include <string> |
Vernon Mauery | 16b8693 | 2019-05-01 08:36:11 -0700 | [diff] [blame] | 24 | #include <variant> |
Patrick Venture | 3a5071a | 2018-09-12 13:27:42 -0700 | [diff] [blame] | 25 | #include <xyz/openbmc_project/Common/error.hpp> |
| 26 | |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 27 | void register_netfn_storage_functions() __attribute__((constructor)); |
| 28 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 29 | unsigned int g_sel_time = 0xFFFFFFFF; |
Patrick Venture | db0cbe6 | 2019-09-09 14:47:22 -0700 | [diff] [blame] | 30 | namespace ipmi |
| 31 | { |
| 32 | namespace sensor |
| 33 | { |
| 34 | extern const IdInfoMap sensors; |
| 35 | } // namespace sensor |
| 36 | } // namespace ipmi |
| 37 | |
Dhruvaraj Subhashchandran | e66c3b0 | 2018-02-07 01:21:56 -0600 | [diff] [blame] | 38 | extern const FruMap frus; |
anil kumar appana | 2c7db1d | 2019-05-28 11:20:19 +0000 | [diff] [blame] | 39 | constexpr uint8_t eventDataSize = 3; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 40 | namespace |
| 41 | { |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 42 | constexpr auto TIME_INTERFACE = "xyz.openbmc_project.Time.EpochTime"; |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 43 | constexpr auto BMC_TIME_PATH = "/xyz/openbmc_project/time/bmc"; |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 44 | constexpr auto DBUS_PROPERTIES = "org.freedesktop.DBus.Properties"; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 45 | constexpr auto PROPERTY_ELAPSED = "Elapsed"; |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 46 | |
Lei YU | d955525 | 2021-09-14 20:30:41 +0800 | [diff] [blame^] | 47 | constexpr auto logWatchPath = "/xyz/openbmc_project/logging"; |
Lei YU | d9e5766 | 2021-09-14 18:06:28 +0800 | [diff] [blame] | 48 | constexpr auto logBasePath = "/xyz/openbmc_project/logging/entry"; |
| 49 | constexpr auto logEntryIntf = "xyz.openbmc_project.Logging.Entry"; |
| 50 | constexpr auto logDeleteIntf = "xyz.openbmc_project.Object.Delete"; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 51 | } // namespace |
Vishwanatha Subbanna | 5fba7a6 | 2016-09-01 14:06:07 +0530 | [diff] [blame] | 52 | |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 53 | namespace cache |
| 54 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 55 | /* |
| 56 | * This cache contains the object paths of the logging entries sorted in the |
| 57 | * order of the filename(numeric order). The cache is initialized by |
| 58 | * invoking readLoggingObjectPaths with the cache as the parameter. The |
| 59 | * cache is invoked in the execution of the Get SEL info and Delete SEL |
| 60 | * entry command. The Get SEL Info command is typically invoked before the |
| 61 | * Get SEL entry command, so the cache is utilized for responding to Get SEL |
| 62 | * entry command. The cache is invalidated by clearing after Delete SEL |
| 63 | * entry and Clear SEL command. |
| 64 | */ |
| 65 | ipmi::sel::ObjectPaths paths; |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 66 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 67 | } // namespace cache |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 68 | |
| 69 | using InternalFailure = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 70 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 71 | using namespace phosphor::logging; |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 72 | using namespace ipmi::fru; |
| 73 | |
Lei YU | d9e5766 | 2021-09-14 18:06:28 +0800 | [diff] [blame] | 74 | using SELRecordID = uint16_t; |
| 75 | using SELEntry = ipmi::sel::SELEventRecordFormat; |
| 76 | using SELCacheMap = std::map<SELRecordID, SELEntry>; |
| 77 | |
| 78 | SELCacheMap selCacheMap __attribute__((init_priority(101))); |
Lei YU | d955525 | 2021-09-14 20:30:41 +0800 | [diff] [blame^] | 79 | std::unique_ptr<sdbusplus::bus::match::match> selAddedMatch |
| 80 | __attribute__((init_priority(101))); |
Lei YU | d9e5766 | 2021-09-14 18:06:28 +0800 | [diff] [blame] | 81 | |
| 82 | std::pair<uint16_t, SELEntry> parseLoggingEntry(const std::string& p) |
| 83 | { |
| 84 | namespace fs = std::filesystem; |
| 85 | fs::path entryPath(p); |
| 86 | auto id = static_cast<uint16_t>(std::stoul(entryPath.filename().string())); |
| 87 | // TODO: parse the sel data |
| 88 | return {id, {}}; |
| 89 | } |
| 90 | |
Lei YU | d955525 | 2021-09-14 20:30:41 +0800 | [diff] [blame^] | 91 | static void selAddedCallback(sdbusplus::message::message& m) |
| 92 | { |
| 93 | sdbusplus::message::object_path objPath; |
| 94 | try |
| 95 | { |
| 96 | m.read(objPath); |
| 97 | } |
| 98 | catch (const sdbusplus::exception::exception& e) |
| 99 | { |
| 100 | log<level::ERR>("Failed to read object path"); |
| 101 | return; |
| 102 | } |
| 103 | std::string p = objPath; |
| 104 | selCacheMap.insert(parseLoggingEntry(p)); |
| 105 | } |
| 106 | |
| 107 | void registerSelCallbackHandler() |
| 108 | { |
| 109 | using namespace sdbusplus::bus::match::rules; |
| 110 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
| 111 | if (!selAddedMatch) |
| 112 | { |
| 113 | selAddedMatch = std::make_unique<sdbusplus::bus::match::match>( |
| 114 | bus, interfacesAdded(logWatchPath), |
| 115 | std::bind(selAddedCallback, std::placeholders::_1)); |
| 116 | } |
| 117 | // TODO: Add other callbacks |
| 118 | } |
| 119 | |
Lei YU | d9e5766 | 2021-09-14 18:06:28 +0800 | [diff] [blame] | 120 | void initSELCache() |
| 121 | { |
| 122 | try |
| 123 | { |
| 124 | ipmi::sel::readLoggingObjectPaths(cache::paths); |
| 125 | } |
| 126 | catch (const sdbusplus::exception::exception& e) |
| 127 | { |
| 128 | log<level::ERR>("Failed to get logging object paths"); |
| 129 | return; |
| 130 | } |
| 131 | for (const auto& p : cache::paths) |
| 132 | { |
| 133 | selCacheMap.insert(parseLoggingEntry(p)); |
| 134 | } |
Lei YU | d955525 | 2021-09-14 20:30:41 +0800 | [diff] [blame^] | 135 | registerSelCallbackHandler(); |
Lei YU | d9e5766 | 2021-09-14 18:06:28 +0800 | [diff] [blame] | 136 | } |
| 137 | |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 138 | /** |
| 139 | * @enum Device access mode |
| 140 | */ |
| 141 | enum class AccessMode |
| 142 | { |
| 143 | bytes, ///< Device is accessed by bytes |
| 144 | words ///< Device is accessed by words |
| 145 | }; |
| 146 | |
jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 147 | /** @brief implements the get SEL Info command |
| 148 | * @returns IPMI completion code plus response data |
| 149 | * - selVersion - SEL revision |
| 150 | * - entries - Number of log entries in SEL. |
| 151 | * - freeSpace - Free Space in bytes. |
| 152 | * - addTimeStamp - Most recent addition timestamp |
| 153 | * - eraseTimeStamp - Most recent erase timestamp |
| 154 | * - operationSupport - Reserve & Delete SEL operations supported |
| 155 | */ |
| 156 | |
| 157 | ipmi::RspType<uint8_t, // SEL revision. |
| 158 | uint16_t, // number of log entries in SEL. |
| 159 | uint16_t, // free Space in bytes. |
| 160 | uint32_t, // most recent addition timestamp |
| 161 | uint32_t, // most recent erase timestamp. |
| 162 | |
| 163 | bool, // SEL allocation info supported |
| 164 | bool, // reserve SEL supported |
| 165 | bool, // partial Add SEL Entry supported |
| 166 | bool, // delete SEL supported |
| 167 | uint3_t, // reserved |
| 168 | bool // overflow flag |
| 169 | > |
| 170 | ipmiStorageGetSelInfo() |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 171 | { |
jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 172 | uint16_t entries = 0; |
| 173 | // Most recent addition timestamp. |
| 174 | uint32_t addTimeStamp = ipmi::sel::invalidTimeStamp; |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 175 | |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 176 | try |
| 177 | { |
| 178 | ipmi::sel::readLoggingObjectPaths(cache::paths); |
| 179 | } |
Patrick Williams | ef1259b | 2021-09-02 09:12:33 -0500 | [diff] [blame] | 180 | catch (const sdbusplus::exception::exception& e) |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 181 | { |
| 182 | // No action if reading log objects have failed for this command. |
| 183 | // readLoggingObjectPaths will throw exception if there are no log |
| 184 | // entries. The command will be responded with number of SEL entries |
| 185 | // as 0. |
| 186 | } |
| 187 | |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 188 | if (!cache::paths.empty()) |
| 189 | { |
jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 190 | entries = static_cast<uint16_t>(cache::paths.size()); |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 191 | |
| 192 | try |
| 193 | { |
jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 194 | addTimeStamp = static_cast<uint32_t>( |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 195 | (ipmi::sel::getEntryTimeStamp(cache::paths.back()).count())); |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 196 | } |
Patrick Williams | a2ad2da | 2021-10-06 12:21:46 -0500 | [diff] [blame] | 197 | catch (const InternalFailure& e) |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 198 | { |
| 199 | } |
| 200 | catch (const std::runtime_error& e) |
| 201 | { |
| 202 | log<level::ERR>(e.what()); |
| 203 | } |
| 204 | } |
| 205 | |
jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 206 | constexpr uint8_t selVersion = ipmi::sel::selVersion; |
| 207 | constexpr uint16_t freeSpace = 0xFFFF; |
| 208 | constexpr uint32_t eraseTimeStamp = ipmi::sel::invalidTimeStamp; |
| 209 | constexpr uint3_t reserved{0}; |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 210 | |
jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 211 | return ipmi::responseSuccess( |
| 212 | selVersion, entries, freeSpace, addTimeStamp, eraseTimeStamp, |
| 213 | ipmi::sel::operationSupport::getSelAllocationInfo, |
| 214 | ipmi::sel::operationSupport::reserveSel, |
| 215 | ipmi::sel::operationSupport::partialAddSelEntry, |
| 216 | ipmi::sel::operationSupport::deleteSel, reserved, |
| 217 | ipmi::sel::operationSupport::overflow); |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 218 | } |
| 219 | |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 220 | ipmi_ret_t getSELEntry(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 221 | ipmi_request_t request, ipmi_response_t response, |
| 222 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 223 | { |
Jason M. Bills | 851acb1 | 2019-02-04 14:06:57 -0800 | [diff] [blame] | 224 | if (*data_len != sizeof(ipmi::sel::GetSELEntryRequest)) |
| 225 | { |
| 226 | *data_len = 0; |
| 227 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 228 | } |
| 229 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 230 | auto requestData = |
| 231 | reinterpret_cast<const ipmi::sel::GetSELEntryRequest*>(request); |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 232 | |
| 233 | if (requestData->reservationID != 0) |
| 234 | { |
Jason M. Bills | 13e67c8 | 2018-09-10 14:12:16 -0700 | [diff] [blame] | 235 | if (!checkSELReservation(requestData->reservationID)) |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 236 | { |
| 237 | *data_len = 0; |
| 238 | return IPMI_CC_INVALID_RESERVATION_ID; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | if (cache::paths.empty()) |
| 243 | { |
| 244 | *data_len = 0; |
| 245 | return IPMI_CC_SENSOR_INVALID; |
| 246 | } |
| 247 | |
| 248 | ipmi::sel::ObjectPaths::const_iterator iter; |
| 249 | |
| 250 | // Check for the requested SEL Entry. |
| 251 | if (requestData->selRecordID == ipmi::sel::firstEntry) |
| 252 | { |
| 253 | iter = cache::paths.begin(); |
| 254 | } |
| 255 | else if (requestData->selRecordID == ipmi::sel::lastEntry) |
| 256 | { |
| 257 | iter = cache::paths.end(); |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | std::string objPath = std::string(ipmi::sel::logBasePath) + "/" + |
| 262 | std::to_string(requestData->selRecordID); |
| 263 | |
| 264 | iter = std::find(cache::paths.begin(), cache::paths.end(), objPath); |
| 265 | if (iter == cache::paths.end()) |
| 266 | { |
| 267 | *data_len = 0; |
| 268 | return IPMI_CC_SENSOR_INVALID; |
| 269 | } |
| 270 | } |
| 271 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 272 | ipmi::sel::GetSELEntryResponse record{}; |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 273 | |
| 274 | // Convert the log entry into SEL record. |
| 275 | try |
| 276 | { |
| 277 | record = ipmi::sel::convertLogEntrytoSEL(*iter); |
| 278 | } |
Patrick Williams | a2ad2da | 2021-10-06 12:21:46 -0500 | [diff] [blame] | 279 | catch (const InternalFailure& e) |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 280 | { |
| 281 | *data_len = 0; |
| 282 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 283 | } |
| 284 | catch (const std::runtime_error& e) |
| 285 | { |
| 286 | log<level::ERR>(e.what()); |
| 287 | *data_len = 0; |
| 288 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 289 | } |
| 290 | |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 291 | // Identify the next SEL record ID |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 292 | if (iter != cache::paths.end()) |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 293 | { |
| 294 | ++iter; |
| 295 | if (iter == cache::paths.end()) |
| 296 | { |
| 297 | record.nextRecordID = ipmi::sel::lastEntry; |
| 298 | } |
| 299 | else |
| 300 | { |
Vernon Mauery | 185b9f8 | 2018-07-20 10:52:36 -0700 | [diff] [blame] | 301 | namespace fs = std::filesystem; |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 302 | fs::path path(*iter); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 303 | record.nextRecordID = static_cast<uint16_t>( |
| 304 | std::stoul(std::string(path.filename().c_str()))); |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 305 | } |
| 306 | } |
| 307 | else |
| 308 | { |
| 309 | record.nextRecordID = ipmi::sel::lastEntry; |
| 310 | } |
| 311 | |
| 312 | if (requestData->readLength == ipmi::sel::entireRecord) |
| 313 | { |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 314 | std::memcpy(response, &record, sizeof(record)); |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 315 | *data_len = sizeof(record); |
| 316 | } |
| 317 | else |
| 318 | { |
| 319 | if (requestData->offset >= ipmi::sel::selRecordSize || |
| 320 | requestData->readLength > ipmi::sel::selRecordSize) |
| 321 | { |
| 322 | *data_len = 0; |
| 323 | return IPMI_CC_INVALID_FIELD_REQUEST; |
| 324 | } |
| 325 | |
| 326 | auto diff = ipmi::sel::selRecordSize - requestData->offset; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 327 | auto readLength = |
| 328 | std::min(diff, static_cast<int>(requestData->readLength)); |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 329 | |
Patrick Venture | b51bf9c | 2018-09-10 15:53:14 -0700 | [diff] [blame] | 330 | std::memcpy(response, &record.nextRecordID, |
| 331 | sizeof(record.nextRecordID)); |
| 332 | std::memcpy(static_cast<uint8_t*>(response) + |
| 333 | sizeof(record.nextRecordID), |
Lei YU | af378fa | 2020-12-02 16:28:57 +0800 | [diff] [blame] | 334 | &record.event.eventRecord.recordID + requestData->offset, |
| 335 | readLength); |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 336 | *data_len = sizeof(record.nextRecordID) + readLength; |
| 337 | } |
| 338 | |
| 339 | return IPMI_CC_OK; |
| 340 | } |
| 341 | |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 342 | /** @brief implements the delete SEL entry command |
| 343 | * @request |
| 344 | * - reservationID; // reservation ID. |
| 345 | * - selRecordID; // SEL record ID. |
| 346 | * |
| 347 | * @returns ipmi completion code plus response data |
| 348 | * - Record ID of the deleted record |
| 349 | */ |
| 350 | ipmi::RspType<uint16_t // deleted record ID |
| 351 | > |
| 352 | deleteSELEntry(uint16_t reservationID, uint16_t selRecordID) |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 353 | { |
Jason M. Bills | 851acb1 | 2019-02-04 14:06:57 -0800 | [diff] [blame] | 354 | |
Brad Bishop | 1a4117b | 2018-11-21 15:48:18 -0500 | [diff] [blame] | 355 | namespace fs = std::filesystem; |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 356 | |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 357 | if (!checkSELReservation(reservationID)) |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 358 | { |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 359 | return ipmi::responseInvalidReservationId(); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 360 | } |
| 361 | |
Jason M. Bills | 13e67c8 | 2018-09-10 14:12:16 -0700 | [diff] [blame] | 362 | // Per the IPMI spec, need to cancel the reservation when a SEL entry is |
| 363 | // deleted |
| 364 | cancelSELReservation(); |
| 365 | |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 366 | try |
| 367 | { |
| 368 | ipmi::sel::readLoggingObjectPaths(cache::paths); |
| 369 | } |
Patrick Williams | ef1259b | 2021-09-02 09:12:33 -0500 | [diff] [blame] | 370 | catch (const sdbusplus::exception::exception& e) |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 371 | { |
| 372 | // readLoggingObjectPaths will throw exception if there are no error |
| 373 | // log entries. |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 374 | return ipmi::responseSensorInvalid(); |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 375 | } |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 376 | |
| 377 | if (cache::paths.empty()) |
| 378 | { |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 379 | return ipmi::responseSensorInvalid(); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | ipmi::sel::ObjectPaths::const_iterator iter; |
| 383 | uint16_t delRecordID = 0; |
| 384 | |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 385 | if (selRecordID == ipmi::sel::firstEntry) |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 386 | { |
| 387 | iter = cache::paths.begin(); |
| 388 | fs::path path(*iter); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 389 | delRecordID = static_cast<uint16_t>( |
| 390 | std::stoul(std::string(path.filename().c_str()))); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 391 | } |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 392 | else if (selRecordID == ipmi::sel::lastEntry) |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 393 | { |
| 394 | iter = cache::paths.end(); |
| 395 | fs::path path(*iter); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 396 | delRecordID = static_cast<uint16_t>( |
| 397 | std::stoul(std::string(path.filename().c_str()))); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 398 | } |
| 399 | else |
| 400 | { |
| 401 | std::string objPath = std::string(ipmi::sel::logBasePath) + "/" + |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 402 | std::to_string(selRecordID); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 403 | |
| 404 | iter = std::find(cache::paths.begin(), cache::paths.end(), objPath); |
| 405 | if (iter == cache::paths.end()) |
| 406 | { |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 407 | return ipmi::responseSensorInvalid(); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 408 | } |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 409 | delRecordID = selRecordID; |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
| 413 | std::string service; |
| 414 | |
| 415 | try |
| 416 | { |
| 417 | service = ipmi::getService(bus, ipmi::sel::logDeleteIntf, *iter); |
| 418 | } |
| 419 | catch (const std::runtime_error& e) |
| 420 | { |
| 421 | log<level::ERR>(e.what()); |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 422 | return ipmi::responseUnspecifiedError(); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 423 | } |
| 424 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 425 | auto methodCall = bus.new_method_call(service.c_str(), (*iter).c_str(), |
| 426 | ipmi::sel::logDeleteIntf, "Delete"); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 427 | auto reply = bus.call(methodCall); |
| 428 | if (reply.is_method_error()) |
| 429 | { |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 430 | return ipmi::responseUnspecifiedError(); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | // Invalidate the cache of dbus entry objects. |
| 434 | cache::paths.clear(); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 435 | |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 436 | return ipmi::responseSuccess(delRecordID); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 437 | } |
| 438 | |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 439 | /** @brief implements the Clear SEL command |
| 440 | * @request |
| 441 | * - reservationID // Reservation ID. |
| 442 | * - clr // char array { 'C'(0x43h), 'L'(0x4Ch), 'R'(0x52h) } |
| 443 | * - eraseOperation; // requested operation. |
| 444 | * |
| 445 | * @returns ipmi completion code plus response data |
| 446 | * - erase status |
| 447 | */ |
| 448 | |
| 449 | ipmi::RspType<uint8_t // erase status |
| 450 | > |
| 451 | clearSEL(uint16_t reservationID, const std::array<char, 3>& clr, |
| 452 | uint8_t eraseOperation) |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 453 | { |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 454 | static constexpr std::array<char, 3> clrOk = {'C', 'L', 'R'}; |
| 455 | if (clr != clrOk) |
Jason M. Bills | 851acb1 | 2019-02-04 14:06:57 -0800 | [diff] [blame] | 456 | { |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 457 | return ipmi::responseInvalidFieldRequest(); |
Jason M. Bills | 851acb1 | 2019-02-04 14:06:57 -0800 | [diff] [blame] | 458 | } |
| 459 | |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 460 | if (!checkSELReservation(reservationID)) |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 461 | { |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 462 | return ipmi::responseInvalidReservationId(); |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 463 | } |
| 464 | |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 465 | /* |
| 466 | * Erasure status cannot be fetched from DBUS, so always return erasure |
| 467 | * status as `erase completed`. |
| 468 | */ |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 469 | if (eraseOperation == ipmi::sel::getEraseStatus) |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 470 | { |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 471 | return ipmi::responseSuccess( |
| 472 | static_cast<uint8_t>(ipmi::sel::eraseComplete)); |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 473 | } |
| 474 | |
Jason M. Bills | 13e67c8 | 2018-09-10 14:12:16 -0700 | [diff] [blame] | 475 | // Per the IPMI spec, need to cancel any reservation when the SEL is cleared |
| 476 | cancelSELReservation(); |
| 477 | |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 478 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 479 | ipmi::sel::ObjectPaths objectPaths; |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 480 | auto depth = 0; |
| 481 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 482 | auto mapperCall = |
| 483 | bus.new_method_call(ipmi::sel::mapperBusName, ipmi::sel::mapperObjPath, |
| 484 | ipmi::sel::mapperIntf, "GetSubTreePaths"); |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 485 | mapperCall.append(ipmi::sel::logBasePath); |
| 486 | mapperCall.append(depth); |
| 487 | mapperCall.append(ipmi::sel::ObjectPaths({ipmi::sel::logEntryIntf})); |
| 488 | |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 489 | try |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 490 | { |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 491 | auto reply = bus.call(mapperCall); |
| 492 | if (reply.is_method_error()) |
| 493 | { |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 494 | return ipmi::responseSuccess( |
| 495 | static_cast<uint8_t>(ipmi::sel::eraseComplete)); |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 496 | } |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 497 | |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 498 | reply.read(objectPaths); |
| 499 | if (objectPaths.empty()) |
| 500 | { |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 501 | return ipmi::responseSuccess( |
| 502 | static_cast<uint8_t>(ipmi::sel::eraseComplete)); |
Tom Joseph | e59abfb | 2018-08-06 18:46:27 +0530 | [diff] [blame] | 503 | } |
| 504 | } |
Patrick Williams | ef1259b | 2021-09-02 09:12:33 -0500 | [diff] [blame] | 505 | catch (const sdbusplus::exception::exception& e) |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 506 | { |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 507 | return ipmi::responseSuccess( |
| 508 | static_cast<uint8_t>(ipmi::sel::eraseComplete)); |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | std::string service; |
| 512 | |
| 513 | try |
| 514 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 515 | service = ipmi::getService(bus, ipmi::sel::logDeleteIntf, |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 516 | objectPaths.front()); |
| 517 | } |
| 518 | catch (const std::runtime_error& e) |
| 519 | { |
| 520 | log<level::ERR>(e.what()); |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 521 | return ipmi::responseUnspecifiedError(); |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | for (const auto& iter : objectPaths) |
| 525 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 526 | auto methodCall = bus.new_method_call( |
| 527 | service.c_str(), iter.c_str(), ipmi::sel::logDeleteIntf, "Delete"); |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 528 | |
| 529 | auto reply = bus.call(methodCall); |
| 530 | if (reply.is_method_error()) |
| 531 | { |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 532 | return ipmi::responseUnspecifiedError(); |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 533 | } |
| 534 | } |
| 535 | |
| 536 | // Invalidate the cache of dbus entry objects. |
| 537 | cache::paths.clear(); |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 538 | return ipmi::responseSuccess( |
| 539 | static_cast<uint8_t>(ipmi::sel::eraseComplete)); |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 540 | } |
| 541 | |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 542 | /** @brief implements the get SEL time command |
| 543 | * @returns IPMI completion code plus response data |
| 544 | * -current time |
| 545 | */ |
| 546 | ipmi::RspType<uint32_t> // current time |
| 547 | ipmiStorageGetSelTime() |
Adriana Kobylak | 8e30f2a | 2015-10-20 10:23:51 -0500 | [diff] [blame] | 548 | { |
Vishwanatha Subbanna | 5fba7a6 | 2016-09-01 14:06:07 +0530 | [diff] [blame] | 549 | using namespace std::chrono; |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 550 | uint64_t bmc_time_usec = 0; |
| 551 | std::stringstream bmcTime; |
Adriana Kobylak | 8e30f2a | 2015-10-20 10:23:51 -0500 | [diff] [blame] | 552 | |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 553 | try |
| 554 | { |
| 555 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 556 | auto service = ipmi::getService(bus, TIME_INTERFACE, BMC_TIME_PATH); |
Vernon Mauery | 16b8693 | 2019-05-01 08:36:11 -0700 | [diff] [blame] | 557 | std::variant<uint64_t> value; |
Vishwanatha Subbanna | 5fba7a6 | 2016-09-01 14:06:07 +0530 | [diff] [blame] | 558 | |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 559 | // Get bmc time |
| 560 | auto method = bus.new_method_call(service.c_str(), BMC_TIME_PATH, |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 561 | DBUS_PROPERTIES, "Get"); |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 562 | |
| 563 | method.append(TIME_INTERFACE, PROPERTY_ELAPSED); |
| 564 | auto reply = bus.call(method); |
| 565 | if (reply.is_method_error()) |
| 566 | { |
| 567 | log<level::ERR>("Error getting time", |
| 568 | entry("SERVICE=%s", service.c_str()), |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 569 | entry("PATH=%s", BMC_TIME_PATH)); |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 570 | return ipmi::responseUnspecifiedError(); |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 571 | } |
| 572 | reply.read(value); |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 573 | bmc_time_usec = std::get<uint64_t>(value); |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 574 | } |
Patrick Williams | a2ad2da | 2021-10-06 12:21:46 -0500 | [diff] [blame] | 575 | catch (const InternalFailure& e) |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 576 | { |
| 577 | log<level::ERR>(e.what()); |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 578 | return ipmi::responseUnspecifiedError(); |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 579 | } |
Tom Joseph | 30fd0a1 | 2019-09-24 06:53:22 +0530 | [diff] [blame] | 580 | catch (const std::exception& e) |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 581 | { |
| 582 | log<level::ERR>(e.what()); |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 583 | return ipmi::responseUnspecifiedError(); |
Vishwanatha Subbanna | 5fba7a6 | 2016-09-01 14:06:07 +0530 | [diff] [blame] | 584 | } |
| 585 | |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 586 | bmcTime << "BMC time:" |
| 587 | << duration_cast<seconds>(microseconds(bmc_time_usec)).count(); |
| 588 | log<level::DEBUG>(bmcTime.str().c_str()); |
Nagaraju Goruganti | 8960b7c | 2018-04-29 22:38:40 -0500 | [diff] [blame] | 589 | |
Vishwanatha Subbanna | 5fba7a6 | 2016-09-01 14:06:07 +0530 | [diff] [blame] | 590 | // Time is really long int but IPMI wants just uint32. This works okay until |
| 591 | // the number of seconds since 1970 overflows uint32 size.. Still a whole |
| 592 | // lot of time here to even think about that. |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 593 | return ipmi::responseSuccess( |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 594 | duration_cast<seconds>(microseconds(bmc_time_usec)).count()); |
Adriana Kobylak | 8e30f2a | 2015-10-20 10:23:51 -0500 | [diff] [blame] | 595 | } |
| 596 | |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 597 | /** @brief implements the set SEL time command |
| 598 | * @param selDeviceTime - epoch time |
| 599 | * -local time as the number of seconds from 00:00:00, January 1, 1970 |
| 600 | * @returns IPMI completion code |
| 601 | */ |
| 602 | ipmi::RspType<> ipmiStorageSetSelTime(uint32_t selDeviceTime) |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 603 | { |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 604 | using namespace std::chrono; |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 605 | microseconds usec{seconds(selDeviceTime)}; |
Norman James | 8233044 | 2015-11-19 16:53:26 -0600 | [diff] [blame] | 606 | |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 607 | try |
| 608 | { |
| 609 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 610 | auto service = ipmi::getService(bus, TIME_INTERFACE, BMC_TIME_PATH); |
Andrew Geissler | 6467ed2 | 2020-05-16 16:03:53 -0500 | [diff] [blame] | 611 | std::variant<uint64_t> value{(uint64_t)usec.count()}; |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 612 | |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 613 | // Set bmc time |
| 614 | auto method = bus.new_method_call(service.c_str(), BMC_TIME_PATH, |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 615 | DBUS_PROPERTIES, "Set"); |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 616 | |
| 617 | method.append(TIME_INTERFACE, PROPERTY_ELAPSED, value); |
| 618 | auto reply = bus.call(method); |
| 619 | if (reply.is_method_error()) |
| 620 | { |
| 621 | log<level::ERR>("Error setting time", |
| 622 | entry("SERVICE=%s", service.c_str()), |
George Liu | 4d623e9 | 2020-05-25 16:51:57 +0800 | [diff] [blame] | 623 | entry("PATH=%s", BMC_TIME_PATH)); |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 624 | return ipmi::responseUnspecifiedError(); |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 625 | } |
Norman James | 8233044 | 2015-11-19 16:53:26 -0600 | [diff] [blame] | 626 | } |
Patrick Williams | a2ad2da | 2021-10-06 12:21:46 -0500 | [diff] [blame] | 627 | catch (const InternalFailure& e) |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 628 | { |
| 629 | log<level::ERR>(e.what()); |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 630 | return ipmi::responseUnspecifiedError(); |
Vishwanatha Subbanna | 5fba7a6 | 2016-09-01 14:06:07 +0530 | [diff] [blame] | 631 | } |
Tom Joseph | 30fd0a1 | 2019-09-24 06:53:22 +0530 | [diff] [blame] | 632 | catch (const std::exception& e) |
Lei YU | e893939 | 2017-06-15 10:45:05 +0800 | [diff] [blame] | 633 | { |
| 634 | log<level::ERR>(e.what()); |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 635 | return ipmi::responseUnspecifiedError(); |
Norman James | 8233044 | 2015-11-19 16:53:26 -0600 | [diff] [blame] | 636 | } |
Vishwanatha Subbanna | 5fba7a6 | 2016-09-01 14:06:07 +0530 | [diff] [blame] | 637 | |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 638 | return ipmi::responseSuccess(); |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 639 | } |
| 640 | |
jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 641 | /** @brief implements the reserve SEL command |
| 642 | * @returns IPMI completion code plus response data |
| 643 | * - SEL reservation ID. |
| 644 | */ |
| 645 | ipmi::RspType<uint16_t> ipmiStorageReserveSel() |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 646 | { |
jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 647 | return ipmi::responseSuccess(reserveSel()); |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 648 | } |
| 649 | |
anil kumar appana | 2c7db1d | 2019-05-28 11:20:19 +0000 | [diff] [blame] | 650 | /** @brief implements the Add SEL entry command |
| 651 | * @request |
| 652 | * |
| 653 | * - recordID ID used for SEL Record access |
| 654 | * - recordType Record Type |
| 655 | * - timeStamp Time when event was logged. LS byte first |
| 656 | * - generatorID software ID if event was generated from |
| 657 | * system software |
| 658 | * - evmRev event message format version |
| 659 | * - sensorType sensor type code for service that generated |
| 660 | * the event |
| 661 | * - sensorNumber number of sensors that generated the event |
| 662 | * - eventDir event dir |
| 663 | * - eventData event data field contents |
| 664 | * |
| 665 | * @returns ipmi completion code plus response data |
| 666 | * - RecordID of the Added SEL entry |
| 667 | */ |
| 668 | ipmi::RspType<uint16_t // recordID of the Added SEL entry |
| 669 | > |
| 670 | ipmiStorageAddSEL(uint16_t recordID, uint8_t recordType, uint32_t timeStamp, |
| 671 | uint16_t generatorID, uint8_t evmRev, uint8_t sensorType, |
| 672 | uint8_t sensorNumber, uint8_t eventDir, |
| 673 | std::array<uint8_t, eventDataSize> eventData) |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 674 | { |
Jason M. Bills | 13e67c8 | 2018-09-10 14:12:16 -0700 | [diff] [blame] | 675 | // Per the IPMI spec, need to cancel the reservation when a SEL entry is |
| 676 | // added |
| 677 | cancelSELReservation(); |
Tom Joseph | b647d5b | 2017-10-31 17:25:33 +0530 | [diff] [blame] | 678 | // Hostboot sends SEL with OEM record type 0xDE to indicate that there is |
| 679 | // a maintenance procedure associated with eSEL record. |
| 680 | static constexpr auto procedureType = 0xDE; |
anil kumar appana | 2c7db1d | 2019-05-28 11:20:19 +0000 | [diff] [blame] | 681 | if (recordType == procedureType) |
Tom Joseph | b647d5b | 2017-10-31 17:25:33 +0530 | [diff] [blame] | 682 | { |
| 683 | // In the OEM record type 0xDE, byte 11 in the SEL record indicate the |
| 684 | // procedure number. |
anil kumar appana | 2c7db1d | 2019-05-28 11:20:19 +0000 | [diff] [blame] | 685 | createProcedureLogEntry(sensorType); |
Tom Joseph | b647d5b | 2017-10-31 17:25:33 +0530 | [diff] [blame] | 686 | } |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 687 | |
anil kumar appana | 2c7db1d | 2019-05-28 11:20:19 +0000 | [diff] [blame] | 688 | return ipmi::responseSuccess(recordID); |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 689 | } |
| 690 | |
Kirill Pakhomov | fa6e209 | 2020-04-24 18:57:15 +0300 | [diff] [blame] | 691 | bool isFruPresent(const std::string& fruPath) |
| 692 | { |
| 693 | using namespace ipmi::fru; |
| 694 | |
| 695 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
| 696 | |
| 697 | auto propValue = |
| 698 | ipmi::getDbusProperty(bus, invMgrInterface, invObjPath + fruPath, |
| 699 | invItemInterface, itemPresentProp); |
| 700 | |
| 701 | return std::get<bool>(propValue); |
| 702 | } |
| 703 | |
Pradeep Kumar | b0c794d | 2019-05-02 13:09:14 +0000 | [diff] [blame] | 704 | /** @brief implements the get FRU Inventory Area Info command |
| 705 | * |
| 706 | * @returns IPMI completion code plus response data |
| 707 | * - FRU Inventory area size in bytes, |
| 708 | * - access bit |
| 709 | **/ |
| 710 | ipmi::RspType<uint16_t, // FRU Inventory area size in bytes, |
| 711 | uint8_t // access size (bytes / words) |
| 712 | > |
| 713 | ipmiStorageGetFruInvAreaInfo(uint8_t fruID) |
Marri Devender Rao | fa7b4e2 | 2017-07-03 00:52:20 -0500 | [diff] [blame] | 714 | { |
Tom Joseph | 187f564 | 2018-03-29 13:49:06 +0530 | [diff] [blame] | 715 | |
Pradeep Kumar | b0c794d | 2019-05-02 13:09:14 +0000 | [diff] [blame] | 716 | auto iter = frus.find(fruID); |
Tom Joseph | 187f564 | 2018-03-29 13:49:06 +0530 | [diff] [blame] | 717 | if (iter == frus.end()) |
| 718 | { |
Pradeep Kumar | b0c794d | 2019-05-02 13:09:14 +0000 | [diff] [blame] | 719 | return ipmi::responseSensorInvalid(); |
Tom Joseph | 187f564 | 2018-03-29 13:49:06 +0530 | [diff] [blame] | 720 | } |
| 721 | |
Kirill Pakhomov | fa6e209 | 2020-04-24 18:57:15 +0300 | [diff] [blame] | 722 | auto path = iter->second[0].path; |
| 723 | if (!isFruPresent(path)) |
| 724 | { |
| 725 | return ipmi::responseSensorInvalid(); |
| 726 | } |
| 727 | |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 728 | try |
| 729 | { |
Pradeep Kumar | b0c794d | 2019-05-02 13:09:14 +0000 | [diff] [blame] | 730 | return ipmi::responseSuccess( |
| 731 | static_cast<uint16_t>(getFruAreaData(fruID).size()), |
| 732 | static_cast<uint8_t>(AccessMode::bytes)); |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 733 | } |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 734 | catch (const InternalFailure& e) |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 735 | { |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 736 | log<level::ERR>(e.what()); |
Pradeep Kumar | b0c794d | 2019-05-02 13:09:14 +0000 | [diff] [blame] | 737 | return ipmi::responseUnspecifiedError(); |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 738 | } |
Marri Devender Rao | fa7b4e2 | 2017-07-03 00:52:20 -0500 | [diff] [blame] | 739 | } |
| 740 | |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 741 | /**@brief implements the Read FRU Data command |
| 742 | * @param fruDeviceId - FRU device ID. FFh = reserved |
| 743 | * @param offset - FRU inventory offset to read |
| 744 | * @param readCount - count to read |
| 745 | * |
| 746 | * @return IPMI completion code plus response data |
| 747 | * - returnCount - response data count. |
| 748 | * - data - response data |
| 749 | */ |
| 750 | ipmi::RspType<uint8_t, // count returned |
| 751 | std::vector<uint8_t>> // FRU data |
| 752 | ipmiStorageReadFruData(uint8_t fruDeviceId, uint16_t offset, |
| 753 | uint8_t readCount) |
Marri Devender Rao | fa7b4e2 | 2017-07-03 00:52:20 -0500 | [diff] [blame] | 754 | { |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 755 | if (fruDeviceId == 0xFF) |
Tom Joseph | 187f564 | 2018-03-29 13:49:06 +0530 | [diff] [blame] | 756 | { |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 757 | return ipmi::responseInvalidFieldRequest(); |
Tom Joseph | 187f564 | 2018-03-29 13:49:06 +0530 | [diff] [blame] | 758 | } |
| 759 | |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 760 | auto iter = frus.find(fruDeviceId); |
| 761 | if (iter == frus.end()) |
| 762 | { |
| 763 | return ipmi::responseSensorInvalid(); |
| 764 | } |
| 765 | |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 766 | try |
| 767 | { |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 768 | const auto& fruArea = getFruAreaData(fruDeviceId); |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 769 | auto size = fruArea.size(); |
Nagaraju Goruganti | 7f2d7c9 | 2018-03-21 11:18:30 -0500 | [diff] [blame] | 770 | |
Tom Joseph | efcd68b | 2018-04-26 18:46:27 +0530 | [diff] [blame] | 771 | if (offset >= size) |
| 772 | { |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 773 | return ipmi::responseParmOutOfRange(); |
Tom Joseph | efcd68b | 2018-04-26 18:46:27 +0530 | [diff] [blame] | 774 | } |
| 775 | |
Nagaraju Goruganti | 7f2d7c9 | 2018-03-21 11:18:30 -0500 | [diff] [blame] | 776 | // Write the count of response data. |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 777 | uint8_t returnCount; |
| 778 | if ((offset + readCount) <= size) |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 779 | { |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 780 | returnCount = readCount; |
Nagaraju Goruganti | 7f2d7c9 | 2018-03-21 11:18:30 -0500 | [diff] [blame] | 781 | } |
| 782 | else |
| 783 | { |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 784 | returnCount = size - offset; |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 785 | } |
Ratan Gupta | 2848d60 | 2018-01-31 20:39:20 +0530 | [diff] [blame] | 786 | |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 787 | std::vector<uint8_t> fruData((fruArea.begin() + offset), |
| 788 | (fruArea.begin() + offset + returnCount)); |
Ratan Gupta | 2848d60 | 2018-01-31 20:39:20 +0530 | [diff] [blame] | 789 | |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 790 | return ipmi::responseSuccess(returnCount, fruData); |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 791 | } |
| 792 | catch (const InternalFailure& e) |
| 793 | { |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 794 | log<level::ERR>(e.what()); |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 795 | return ipmi::responseUnspecifiedError(); |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 796 | } |
Marri Devender Rao | fa7b4e2 | 2017-07-03 00:52:20 -0500 | [diff] [blame] | 797 | } |
| 798 | |
Pradeep Kumar | b60e840 | 2019-05-06 15:17:01 +0000 | [diff] [blame] | 799 | ipmi::RspType<uint8_t, // SDR version |
| 800 | uint16_t, // record count LS first |
| 801 | uint16_t, // free space in bytes, LS first |
| 802 | uint32_t, // addition timestamp LS first |
| 803 | uint32_t, // deletion timestamp LS first |
| 804 | uint8_t> // operation Support |
| 805 | ipmiGetRepositoryInfo() |
Dhruvaraj Subhashchandran | e66c3b0 | 2018-02-07 01:21:56 -0600 | [diff] [blame] | 806 | { |
Dhruvaraj Subhashchandran | e66c3b0 | 2018-02-07 01:21:56 -0600 | [diff] [blame] | 807 | |
Pradeep Kumar | b60e840 | 2019-05-06 15:17:01 +0000 | [diff] [blame] | 808 | constexpr uint8_t sdrVersion = 0x51; |
| 809 | constexpr uint16_t freeSpace = 0xFFFF; |
| 810 | constexpr uint32_t additionTimestamp = 0x0; |
| 811 | constexpr uint32_t deletionTimestamp = 0x0; |
| 812 | constexpr uint8_t operationSupport = 0; |
Dhruvaraj Subhashchandran | e66c3b0 | 2018-02-07 01:21:56 -0600 | [diff] [blame] | 813 | |
Patrick Venture | db0cbe6 | 2019-09-09 14:47:22 -0700 | [diff] [blame] | 814 | uint16_t records = frus.size() + ipmi::sensor::sensors.size(); |
Dhruvaraj Subhashchandran | e66c3b0 | 2018-02-07 01:21:56 -0600 | [diff] [blame] | 815 | |
Pradeep Kumar | b60e840 | 2019-05-06 15:17:01 +0000 | [diff] [blame] | 816 | return ipmi::responseSuccess(sdrVersion, records, freeSpace, |
| 817 | additionTimestamp, deletionTimestamp, |
| 818 | operationSupport); |
Dhruvaraj Subhashchandran | e66c3b0 | 2018-02-07 01:21:56 -0600 | [diff] [blame] | 819 | } |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 820 | |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 821 | void register_netfn_storage_functions() |
| 822 | { |
Lei YU | d9e5766 | 2021-09-14 18:06:28 +0800 | [diff] [blame] | 823 | initSELCache(); |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 824 | // <Get SEL Info> |
jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 825 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 826 | ipmi::storage::cmdGetSelInfo, ipmi::Privilege::User, |
| 827 | ipmiStorageGetSelInfo); |
Tom Joseph | 6f7deaa | 2017-06-30 19:03:54 +0530 | [diff] [blame] | 828 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 829 | // <Get SEL Time> |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 830 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 831 | ipmi::storage::cmdGetSelTime, ipmi::Privilege::User, |
| 832 | ipmiStorageGetSelTime); |
Adriana Kobylak | 8e30f2a | 2015-10-20 10:23:51 -0500 | [diff] [blame] | 833 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 834 | // <Set SEL Time> |
jayaprakash Mutyala | db2e8c4 | 2019-05-03 01:38:01 +0000 | [diff] [blame] | 835 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 836 | ipmi::storage::cmdSetSelTime, |
| 837 | ipmi::Privilege::Operator, ipmiStorageSetSelTime); |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 838 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 839 | // <Reserve SEL> |
jayaprakash Mutyala | b755772 | 2019-05-02 21:13:30 +0000 | [diff] [blame] | 840 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 841 | ipmi::storage::cmdReserveSel, ipmi::Privilege::User, |
| 842 | ipmiStorageReserveSel); |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 843 | // <Get SEL Entry> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 844 | ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_GET_SEL_ENTRY, NULL, |
| 845 | getSELEntry, PRIVILEGE_USER); |
Tom Joseph | a495339 | 2017-06-30 19:09:47 +0530 | [diff] [blame] | 846 | |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 847 | // <Delete SEL Entry> |
Pradeep Kumar | 00a18d0 | 2019-04-26 17:04:28 +0000 | [diff] [blame] | 848 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 849 | ipmi::storage::cmdDeleteSelEntry, |
| 850 | ipmi::Privilege::Operator, deleteSELEntry); |
Tom Joseph | 8f4a2aa | 2017-06-30 19:12:49 +0530 | [diff] [blame] | 851 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 852 | // <Add SEL Entry> |
anil kumar appana | 2c7db1d | 2019-05-28 11:20:19 +0000 | [diff] [blame] | 853 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 854 | ipmi::storage::cmdAddSelEntry, |
| 855 | ipmi::Privilege::Operator, ipmiStorageAddSEL); |
| 856 | |
Tom Joseph | 2f05bb5 | 2017-06-30 19:14:49 +0530 | [diff] [blame] | 857 | // <Clear SEL> |
Pradeep Kumar | 4a5a99a | 2019-04-26 15:22:39 +0000 | [diff] [blame] | 858 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 859 | ipmi::storage::cmdClearSel, ipmi::Privilege::Operator, |
| 860 | clearSEL); |
| 861 | |
Marri Devender Rao | fa7b4e2 | 2017-07-03 00:52:20 -0500 | [diff] [blame] | 862 | // <Get FRU Inventory Area Info> |
Pradeep Kumar | b0c794d | 2019-05-02 13:09:14 +0000 | [diff] [blame] | 863 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 864 | ipmi::storage::cmdGetFruInventoryAreaInfo, |
| 865 | ipmi::Privilege::User, ipmiStorageGetFruInvAreaInfo); |
Marri Devender Rao | fa7b4e2 | 2017-07-03 00:52:20 -0500 | [diff] [blame] | 866 | |
Jason M. Bills | b5248c9 | 2019-06-24 15:53:08 -0700 | [diff] [blame] | 867 | // <READ FRU Data> |
anil kumar appana | 5b7c326 | 2019-05-27 18:10:23 +0000 | [diff] [blame] | 868 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 869 | ipmi::storage::cmdReadFruData, |
| 870 | ipmi::Privilege::Operator, ipmiStorageReadFruData); |
Marri Devender Rao | cac383b | 2017-07-03 13:24:27 -0500 | [diff] [blame] | 871 | |
Dhruvaraj Subhashchandran | e66c3b0 | 2018-02-07 01:21:56 -0600 | [diff] [blame] | 872 | // <Get Repository Info> |
Pradeep Kumar | b60e840 | 2019-05-06 15:17:01 +0000 | [diff] [blame] | 873 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 874 | ipmi::storage::cmdGetSdrRepositoryInfo, |
| 875 | ipmi::Privilege::User, ipmiGetRepositoryInfo); |
Dhruvaraj Subhashchandran | e66c3b0 | 2018-02-07 01:21:56 -0600 | [diff] [blame] | 876 | |
Tom Joseph | 5ca5095 | 2018-02-22 00:33:38 +0530 | [diff] [blame] | 877 | // <Reserve SDR Repository> |
jayaprakash Mutyala | d957823 | 2019-05-13 20:22:50 +0000 | [diff] [blame] | 878 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage, |
| 879 | ipmi::storage::cmdReserveSdrRepository, |
| 880 | ipmi::Privilege::User, ipmiSensorReserveSdr); |
Tom Joseph | 5ca5095 | 2018-02-22 00:33:38 +0530 | [diff] [blame] | 881 | |
| 882 | // <Get SDR> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 883 | ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_GET_SDR, nullptr, |
| 884 | ipmi_sen_get_sdr, PRIVILEGE_USER); |
Tom Joseph | 5ca5095 | 2018-02-22 00:33:38 +0530 | [diff] [blame] | 885 | |
Marri Devender Rao | 908f750 | 2017-07-10 01:49:54 -0500 | [diff] [blame] | 886 | ipmi::fru::registerCallbackHandler(); |
Chris Austen | b4f5b92 | 2015-10-13 12:44:43 -0500 | [diff] [blame] | 887 | return; |
| 888 | } |