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