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