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