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