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