vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 1 | #include "apphandler.h" |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 2 | |
| 3 | #include <arpa/inet.h> |
| 4 | #include <mapper.h> |
| 5 | #include <stdint.h> |
| 6 | #include <stdio.h> |
| 7 | #include <systemd/sd-bus.h> |
| 8 | |
Patrick Williams | 37af733 | 2016-09-02 21:21:42 -0500 | [diff] [blame] | 9 | #include "host-ipmid/ipmid-api.h" |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 10 | |
Vernon Mauery | 185b9f8 | 2018-07-20 10:52:36 -0700 | [diff] [blame] | 11 | #if __has_include(<filesystem>) |
| 12 | #include <filesystem> |
| 13 | #elif __has_include(<experimental/filesystem>) |
| 14 | #include <experimental/filesystem> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 15 | namespace std |
| 16 | { |
| 17 | // splice experimental::filesystem into std |
| 18 | namespace filesystem = std::experimental::filesystem; |
| 19 | } // namespace std |
Vernon Mauery | 185b9f8 | 2018-07-20 10:52:36 -0700 | [diff] [blame] | 20 | #else |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 21 | #error filesystem not available |
Vernon Mauery | 185b9f8 | 2018-07-20 10:52:36 -0700 | [diff] [blame] | 22 | #endif |
Ratan Gupta | 62736ec | 2017-09-02 12:02:47 +0530 | [diff] [blame] | 23 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 24 | #include "app/channel.hpp" |
| 25 | #include "app/watchdog.hpp" |
| 26 | #include "ipmid.hpp" |
| 27 | #include "nlohmann/json.hpp" |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 28 | #include "transporthandler.hpp" |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 29 | #include "types.hpp" |
| 30 | #include "utils.hpp" |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 31 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 32 | #include <array> |
| 33 | #include <cstddef> |
| 34 | #include <fstream> |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 35 | #include <phosphor-logging/elog-errors.hpp> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 36 | #include <phosphor-logging/log.hpp> |
| 37 | #include <string> |
| 38 | #include <vector> |
| 39 | #include <xyz/openbmc_project/Common/error.hpp> |
| 40 | #include <xyz/openbmc_project/Software/Activation/server.hpp> |
| 41 | #include <xyz/openbmc_project/Software/Version/server.hpp> |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 42 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 43 | extern sd_bus* bus; |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 44 | |
Marri Devender Rao | 5e007a5 | 2018-01-08 06:18:36 -0600 | [diff] [blame] | 45 | constexpr auto bmc_interface = "xyz.openbmc_project.Inventory.Item.Bmc"; |
| 46 | constexpr auto bmc_guid_interface = "xyz.openbmc_project.Common.UUID"; |
| 47 | constexpr auto bmc_guid_property = "UUID"; |
| 48 | constexpr auto bmc_guid_len = 16; |
| 49 | |
Nagaraju Goruganti | 744398d | 2018-02-20 09:52:00 -0600 | [diff] [blame] | 50 | static constexpr auto redundancyIntf = |
| 51 | "xyz.openbmc_project.Software.RedundancyPriority"; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 52 | static constexpr auto versionIntf = "xyz.openbmc_project.Software.Version"; |
Nagaraju Goruganti | 744398d | 2018-02-20 09:52:00 -0600 | [diff] [blame] | 53 | static constexpr auto activationIntf = |
| 54 | "xyz.openbmc_project.Software.Activation"; |
| 55 | static constexpr auto softwareRoot = "/xyz/openbmc_project/software"; |
| 56 | |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 57 | void register_netfn_app_functions() __attribute__((constructor)); |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 58 | |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 59 | using namespace phosphor::logging; |
| 60 | using namespace sdbusplus::xyz::openbmc_project::Common::Error; |
Nagaraju Goruganti | 744398d | 2018-02-20 09:52:00 -0600 | [diff] [blame] | 61 | using Version = sdbusplus::xyz::openbmc_project::Software::server::Version; |
| 62 | using Activation = |
| 63 | sdbusplus::xyz::openbmc_project::Software::server::Activation; |
Vernon Mauery | 185b9f8 | 2018-07-20 10:52:36 -0700 | [diff] [blame] | 64 | namespace fs = std::filesystem; |
Ratan Gupta | b8e9955 | 2017-07-27 07:07:48 +0530 | [diff] [blame] | 65 | |
Nan Li | ee0cb90 | 2016-07-11 15:38:03 +0800 | [diff] [blame] | 66 | // Offset in get device id command. |
| 67 | typedef struct |
| 68 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 69 | uint8_t id; |
| 70 | uint8_t revision; |
| 71 | uint8_t fw[2]; |
| 72 | uint8_t ipmi_ver; |
| 73 | uint8_t addn_dev_support; |
| 74 | uint8_t manuf_id[3]; |
| 75 | uint8_t prod_id[2]; |
| 76 | uint8_t aux[4]; |
| 77 | } __attribute__((packed)) ipmi_device_id_t; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 78 | |
Nagaraju Goruganti | 744398d | 2018-02-20 09:52:00 -0600 | [diff] [blame] | 79 | /** |
| 80 | * @brief Returns the Version info from primary s/w object |
| 81 | * |
| 82 | * Get the Version info from the active s/w object which is having high |
| 83 | * "Priority" value(a smaller number is a higher priority) and "Purpose" |
| 84 | * is "BMC" from the list of all s/w objects those are implementing |
| 85 | * RedundancyPriority interface from the given softwareRoot path. |
| 86 | * |
| 87 | * @return On success returns the Version info from primary s/w object. |
| 88 | * |
| 89 | */ |
| 90 | std::string getActiveSoftwareVersionInfo() |
| 91 | { |
| 92 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
| 93 | |
| 94 | std::string revision{}; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 95 | auto objectTree = |
| 96 | ipmi::getAllDbusObjects(bus, softwareRoot, redundancyIntf, ""); |
Nagaraju Goruganti | 744398d | 2018-02-20 09:52:00 -0600 | [diff] [blame] | 97 | if (objectTree.empty()) |
| 98 | { |
| 99 | log<level::ERR>("No Obj has implemented the s/w redundancy interface", |
| 100 | entry("INTERFACE=%s", redundancyIntf)); |
| 101 | elog<InternalFailure>(); |
| 102 | } |
| 103 | |
| 104 | auto objectFound = false; |
| 105 | for (auto& softObject : objectTree) |
| 106 | { |
| 107 | auto service = ipmi::getService(bus, redundancyIntf, softObject.first); |
| 108 | auto objValueTree = ipmi::getManagedObjects(bus, service, softwareRoot); |
| 109 | |
| 110 | auto minPriority = 0xFF; |
| 111 | for (const auto& objIter : objValueTree) |
| 112 | { |
| 113 | try |
| 114 | { |
| 115 | auto& intfMap = objIter.second; |
| 116 | auto& redundancyPriorityProps = intfMap.at(redundancyIntf); |
| 117 | auto& versionProps = intfMap.at(versionIntf); |
| 118 | auto& activationProps = intfMap.at(activationIntf); |
| 119 | auto priority = |
| 120 | redundancyPriorityProps.at("Priority").get<uint8_t>(); |
| 121 | auto purpose = versionProps.at("Purpose").get<std::string>(); |
| 122 | auto activation = |
| 123 | activationProps.at("Activation").get<std::string>(); |
| 124 | auto version = versionProps.at("Version").get<std::string>(); |
| 125 | if ((Version::convertVersionPurposeFromString(purpose) == |
| 126 | Version::VersionPurpose::BMC) && |
| 127 | (Activation::convertActivationsFromString(activation) == |
| 128 | Activation::Activations::Active)) |
| 129 | { |
| 130 | if (priority < minPriority) |
| 131 | { |
| 132 | minPriority = priority; |
| 133 | objectFound = true; |
| 134 | revision = std::move(version); |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | catch (const std::exception& e) |
| 139 | { |
| 140 | log<level::ERR>(e.what()); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | if (!objectFound) |
| 146 | { |
| 147 | log<level::ERR>("Could not found an BMC software Object"); |
| 148 | elog<InternalFailure>(); |
| 149 | } |
| 150 | |
| 151 | return revision; |
| 152 | } |
| 153 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 154 | ipmi_ret_t ipmi_app_set_acpi_power_state(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 155 | ipmi_request_t request, |
| 156 | ipmi_response_t response, |
| 157 | ipmi_data_len_t data_len, |
| 158 | ipmi_context_t context) |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 159 | { |
| 160 | ipmi_ret_t rc = IPMI_CC_OK; |
| 161 | *data_len = 0; |
| 162 | |
Aditya Saripalli | 5fb1460 | 2017-11-09 14:46:27 +0530 | [diff] [blame] | 163 | log<level::DEBUG>("IPMI SET ACPI STATE Ignoring for now\n"); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 164 | return rc; |
| 165 | } |
| 166 | |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 167 | typedef struct |
| 168 | { |
| 169 | char major; |
| 170 | char minor; |
Chris Austen | 176c965 | 2016-04-30 16:32:17 -0500 | [diff] [blame] | 171 | uint16_t d[2]; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 172 | } rev_t; |
| 173 | |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 174 | /* Currently supports the vx.x-x-[-x] and v1.x.x-x-[-x] format. It will */ |
| 175 | /* return -1 if not in those formats, this routine knows how to parse */ |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 176 | /* version = v0.6-19-gf363f61-dirty */ |
| 177 | /* ^ ^ ^^ ^ */ |
| 178 | /* | | |----------|-- additional details */ |
| 179 | /* | |---------------- Minor */ |
| 180 | /* |------------------ Major */ |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 181 | /* and version = v1.99.10-113-g65edf7d-r3-0-g9e4f715 */ |
| 182 | /* ^ ^ ^^ ^ */ |
| 183 | /* | | |--|---------- additional details */ |
| 184 | /* | |---------------- Minor */ |
| 185 | /* |------------------ Major */ |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 186 | /* Additional details : If the option group exists it will force Auxiliary */ |
| 187 | /* Firmware Revision Information 4th byte to 1 indicating the build was */ |
| 188 | /* derived with additional edits */ |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 189 | int convert_version(const char* p, rev_t* rev) |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 190 | { |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 191 | std::string s(p); |
| 192 | std::string token; |
Chris Austen | 176c965 | 2016-04-30 16:32:17 -0500 | [diff] [blame] | 193 | uint16_t commits; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 194 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 195 | auto location = s.find_first_of('v'); |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 196 | if (location != std::string::npos) |
| 197 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 198 | s = s.substr(location + 1); |
Chris Austen | 176c965 | 2016-04-30 16:32:17 -0500 | [diff] [blame] | 199 | } |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 200 | |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 201 | if (!s.empty()) |
| 202 | { |
| 203 | location = s.find_first_of("."); |
| 204 | if (location != std::string::npos) |
| 205 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 206 | rev->major = |
| 207 | static_cast<char>(std::stoi(s.substr(0, location), 0, 16)); |
| 208 | token = s.substr(location + 1); |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 209 | } |
Chris Austen | 176c965 | 2016-04-30 16:32:17 -0500 | [diff] [blame] | 210 | |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 211 | if (!token.empty()) |
| 212 | { |
| 213 | location = token.find_first_of(".-"); |
| 214 | if (location != std::string::npos) |
| 215 | { |
Patrick Venture | d211702 | 2018-02-06 08:54:37 -0800 | [diff] [blame] | 216 | rev->minor = static_cast<char>( |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 217 | std::stoi(token.substr(0, location), 0, 16)); |
| 218 | token = token.substr(location + 1); |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 219 | } |
| 220 | } |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 221 | |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 222 | // Capture the number of commits on top of the minor tag. |
| 223 | // I'm using BE format like the ipmi spec asked for |
| 224 | location = token.find_first_of(".-"); |
| 225 | if (!token.empty()) |
| 226 | { |
| 227 | commits = std::stoi(token.substr(0, location), 0, 16); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 228 | rev->d[0] = (commits >> 8) | (commits << 8); |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 229 | |
| 230 | // commit number we skip |
| 231 | location = token.find_first_of(".-"); |
| 232 | if (location != std::string::npos) |
| 233 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 234 | token = token.substr(location + 1); |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 235 | } |
| 236 | } |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 237 | else |
| 238 | { |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 239 | rev->d[0] = 0; |
| 240 | } |
| 241 | |
| 242 | if (location != std::string::npos) |
| 243 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 244 | token = token.substr(location + 1); |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | // Any value of the optional parameter forces it to 1 |
| 248 | location = token.find_first_of(".-"); |
| 249 | if (location != std::string::npos) |
| 250 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 251 | token = token.substr(location + 1); |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 252 | } |
| 253 | commits = (!token.empty()) ? 1 : 0; |
| 254 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 255 | // We do this operation to get this displayed in least significant bytes |
| 256 | // of ipmitool device id command. |
| 257 | rev->d[1] = (commits >> 8) | (commits << 8); |
Dinesh Chinari | 2b7e07d | 2017-11-08 15:38:50 -0600 | [diff] [blame] | 258 | } |
| 259 | |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 260 | return 0; |
| 261 | } |
| 262 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 263 | ipmi_ret_t ipmi_app_get_device_id(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 264 | ipmi_request_t request, |
| 265 | ipmi_response_t response, |
| 266 | ipmi_data_len_t data_len, |
| 267 | ipmi_context_t context) |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 268 | { |
| 269 | ipmi_ret_t rc = IPMI_CC_OK; |
Nagaraju Goruganti | 744398d | 2018-02-20 09:52:00 -0600 | [diff] [blame] | 270 | int r = -1; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 271 | rev_t rev = {0}; |
David Cobbley | a1adb07 | 2017-11-21 15:58:13 -0800 | [diff] [blame] | 272 | static ipmi_device_id_t dev_id{}; |
| 273 | static bool dev_id_initialized = false; |
| 274 | const char* filename = "/usr/share/ipmi-providers/dev_id.json"; |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 275 | |
| 276 | // Data length |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 277 | *data_len = sizeof(dev_id); |
| 278 | |
David Cobbley | a1adb07 | 2017-11-21 15:58:13 -0800 | [diff] [blame] | 279 | if (!dev_id_initialized) |
| 280 | { |
Nagaraju Goruganti | 744398d | 2018-02-20 09:52:00 -0600 | [diff] [blame] | 281 | try |
| 282 | { |
| 283 | auto version = getActiveSoftwareVersionInfo(); |
| 284 | r = convert_version(version.c_str(), &rev); |
David Cobbley | a1adb07 | 2017-11-21 15:58:13 -0800 | [diff] [blame] | 285 | } |
Nagaraju Goruganti | 744398d | 2018-02-20 09:52:00 -0600 | [diff] [blame] | 286 | catch (const std::exception& e) |
| 287 | { |
| 288 | log<level::ERR>(e.what()); |
| 289 | } |
Nan Li | ee0cb90 | 2016-07-11 15:38:03 +0800 | [diff] [blame] | 290 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 291 | if (r >= 0) |
| 292 | { |
Nagaraju Goruganti | 744398d | 2018-02-20 09:52:00 -0600 | [diff] [blame] | 293 | // bit7 identifies if the device is available |
| 294 | // 0=normal operation |
| 295 | // 1=device firmware, SDR update, |
| 296 | // or self-initialization in progress. |
| 297 | // our SDR is normal working condition, so mask: |
| 298 | dev_id.fw[0] = 0x7F & rev.major; |
| 299 | |
| 300 | rev.minor = (rev.minor > 99 ? 99 : rev.minor); |
| 301 | dev_id.fw[1] = rev.minor % 10 + (rev.minor / 10) * 16; |
| 302 | memcpy(&dev_id.aux, rev.d, 4); |
David Cobbley | a1adb07 | 2017-11-21 15:58:13 -0800 | [diff] [blame] | 303 | } |
Nan Li | ee0cb90 | 2016-07-11 15:38:03 +0800 | [diff] [blame] | 304 | |
David Cobbley | a1adb07 | 2017-11-21 15:58:13 -0800 | [diff] [blame] | 305 | // IPMI Spec version 2.0 |
| 306 | dev_id.ipmi_ver = 2; |
Adriana Kobylak | 0e91264 | 2016-06-22 16:54:39 -0500 | [diff] [blame] | 307 | |
David Cobbley | a1adb07 | 2017-11-21 15:58:13 -0800 | [diff] [blame] | 308 | std::ifstream dev_id_file(filename); |
| 309 | if (dev_id_file.is_open()) |
| 310 | { |
| 311 | auto data = nlohmann::json::parse(dev_id_file, nullptr, false); |
| 312 | if (!data.is_discarded()) |
| 313 | { |
| 314 | dev_id.id = data.value("id", 0); |
| 315 | dev_id.revision = data.value("revision", 0); |
| 316 | dev_id.addn_dev_support = data.value("addn_dev_support", 0); |
| 317 | dev_id.manuf_id[2] = data.value("manuf_id", 0) >> 16; |
| 318 | dev_id.manuf_id[1] = data.value("manuf_id", 0) >> 8; |
| 319 | dev_id.manuf_id[0] = data.value("manuf_id", 0); |
| 320 | dev_id.prod_id[1] = data.value("prod_id", 0) >> 8; |
| 321 | dev_id.prod_id[0] = data.value("prod_id", 0); |
Tom Joseph | af8a098 | 2018-03-09 07:54:02 -0600 | [diff] [blame] | 322 | dev_id.aux[3] = data.value("aux", 0); |
| 323 | dev_id.aux[2] = data.value("aux", 0) >> 8; |
| 324 | dev_id.aux[1] = data.value("aux", 0) >> 16; |
| 325 | dev_id.aux[0] = data.value("aux", 0) >> 24; |
David Cobbley | a1adb07 | 2017-11-21 15:58:13 -0800 | [diff] [blame] | 326 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 327 | // Don't read the file every time if successful |
David Cobbley | a1adb07 | 2017-11-21 15:58:13 -0800 | [diff] [blame] | 328 | dev_id_initialized = true; |
| 329 | } |
| 330 | else |
| 331 | { |
| 332 | log<level::ERR>("Device ID JSON parser failure"); |
| 333 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 334 | } |
| 335 | } |
| 336 | else |
| 337 | { |
| 338 | log<level::ERR>("Device ID file not found"); |
| 339 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 340 | } |
| 341 | } |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 342 | |
| 343 | // Pack the actual response |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 344 | memcpy(response, &dev_id, *data_len); |
Nagaraju Goruganti | 744398d | 2018-02-20 09:52:00 -0600 | [diff] [blame] | 345 | |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 346 | return rc; |
| 347 | } |
| 348 | |
Nan Li | 41fa24a | 2016-11-10 20:12:37 +0800 | [diff] [blame] | 349 | ipmi_ret_t ipmi_app_get_self_test_results(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 350 | ipmi_request_t request, |
| 351 | ipmi_response_t response, |
| 352 | ipmi_data_len_t data_len, |
| 353 | ipmi_context_t context) |
Nan Li | 41fa24a | 2016-11-10 20:12:37 +0800 | [diff] [blame] | 354 | { |
| 355 | ipmi_ret_t rc = IPMI_CC_OK; |
| 356 | |
| 357 | // Byte 2: |
| 358 | // 55h - No error. |
Gunnar Mills | 8991dd6 | 2017-10-25 17:11:29 -0500 | [diff] [blame] | 359 | // 56h - Self Test function not implemented in this controller. |
Nan Li | 41fa24a | 2016-11-10 20:12:37 +0800 | [diff] [blame] | 360 | // 57h - Corrupted or inaccesssible data or devices. |
| 361 | // 58h - Fatal hardware error. |
| 362 | // FFh - reserved. |
| 363 | // all other: Device-specific 'internal failure'. |
| 364 | // Byte 3: |
| 365 | // For byte 2 = 55h, 56h, FFh: 00h |
| 366 | // For byte 2 = 58h, all other: Device-specific |
| 367 | // For byte 2 = 57h: self-test error bitfield. |
| 368 | // Note: returning 57h does not imply that all test were run. |
| 369 | // [7] 1b = Cannot access SEL device. |
| 370 | // [6] 1b = Cannot access SDR Repository. |
| 371 | // [5] 1b = Cannot access BMC FRU device. |
| 372 | // [4] 1b = IPMB signal lines do not respond. |
| 373 | // [3] 1b = SDR Repository empty. |
| 374 | // [2] 1b = Internal Use Area of BMC FRU corrupted. |
| 375 | // [1] 1b = controller update 'boot block' firmware corrupted. |
| 376 | // [0] 1b = controller operational firmware corrupted. |
| 377 | |
| 378 | char selftestresults[2] = {0}; |
| 379 | |
| 380 | *data_len = 2; |
| 381 | |
| 382 | selftestresults[0] = 0x56; |
| 383 | selftestresults[1] = 0; |
| 384 | |
| 385 | memcpy(response, selftestresults, *data_len); |
| 386 | |
| 387 | return rc; |
| 388 | } |
| 389 | |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 390 | ipmi_ret_t ipmi_app_get_device_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 391 | ipmi_request_t request, |
| 392 | ipmi_response_t response, |
| 393 | ipmi_data_len_t data_len, |
| 394 | ipmi_context_t context) |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 395 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 396 | const char* objname = "/org/openbmc/control/chassis0"; |
| 397 | const char* iface = "org.freedesktop.DBus.Properties"; |
| 398 | const char* chassis_iface = "org.openbmc.control.Chassis"; |
| 399 | sd_bus_message* reply = NULL; |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 400 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 401 | int r = 0; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 402 | char* uuid = NULL; |
| 403 | char* busname = NULL; |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 404 | |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 405 | // UUID is in RFC4122 format. Ex: 61a39523-78f2-11e5-9862-e6402cfc3223 |
Patrick Venture | d211702 | 2018-02-06 08:54:37 -0800 | [diff] [blame] | 406 | // Per IPMI Spec 2.0 need to convert to 16 hex bytes and reverse the byte |
| 407 | // order |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 408 | // Ex: 0x2332fc2c40e66298e511f2782395a361 |
| 409 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 410 | const int resp_size = 16; // Response is 16 hex bytes per IPMI Spec |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 411 | uint8_t resp_uuid[resp_size]; // Array to hold the formatted response |
Patrick Venture | d211702 | 2018-02-06 08:54:37 -0800 | [diff] [blame] | 412 | // Point resp end of array to save in reverse order |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 413 | int resp_loc = resp_size - 1; |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 414 | int i = 0; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 415 | char* tokptr = NULL; |
| 416 | char* id_octet = NULL; |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 417 | |
| 418 | // Status code. |
| 419 | ipmi_ret_t rc = IPMI_CC_OK; |
| 420 | *data_len = 0; |
| 421 | |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 422 | // Call Get properties method with the interface and property name |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 423 | r = mapper_get_service(bus, objname, &busname); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 424 | if (r < 0) |
| 425 | { |
| 426 | log<level::ERR>("Failed to get bus name", entry("BUS=%s", objname), |
Aditya Saripalli | 5fb1460 | 2017-11-09 14:46:27 +0530 | [diff] [blame] | 427 | entry("ERRNO=0x%X", -r)); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 428 | goto finish; |
| 429 | } |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 430 | r = sd_bus_call_method(bus, busname, objname, iface, "Get", &error, &reply, |
| 431 | "ss", chassis_iface, "uuid"); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 432 | if (r < 0) |
| 433 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 434 | log<level::ERR>("Failed to call Get Method", entry("ERRNO=0x%X", -r)); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 435 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 436 | goto finish; |
| 437 | } |
| 438 | |
| 439 | r = sd_bus_message_read(reply, "v", "s", &uuid); |
| 440 | if (r < 0 || uuid == NULL) |
| 441 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 442 | log<level::ERR>("Failed to get a response", entry("ERRNO=0x%X", -r)); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 443 | rc = IPMI_CC_RESPONSE_ERROR; |
| 444 | goto finish; |
| 445 | } |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 446 | |
| 447 | // Traverse the UUID |
Patrick Venture | d211702 | 2018-02-06 08:54:37 -0800 | [diff] [blame] | 448 | // Get the UUID octects separated by dash |
| 449 | id_octet = strtok_r(uuid, "-", &tokptr); |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 450 | |
| 451 | if (id_octet == NULL) |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 452 | { |
| 453 | // Error |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 454 | log<level::ERR>("Unexpected UUID format", entry("UUID=%s", uuid)); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 455 | rc = IPMI_CC_RESPONSE_ERROR; |
| 456 | goto finish; |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | while (id_octet != NULL) |
| 460 | { |
| 461 | // Calculate the octet string size since it varies |
| 462 | // Divide it by 2 for the array size since 1 byte is built from 2 chars |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 463 | int tmp_size = strlen(id_octet) / 2; |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 464 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 465 | for (i = 0; i < tmp_size; i++) |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 466 | { |
Patrick Venture | d211702 | 2018-02-06 08:54:37 -0800 | [diff] [blame] | 467 | // Holder of the 2 chars that will become a byte |
| 468 | char tmp_array[3] = {0}; |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 469 | strncpy(tmp_array, id_octet, 2); // 2 chars at a time |
| 470 | |
| 471 | int resp_byte = strtoul(tmp_array, NULL, 16); // Convert to hex byte |
Patrick Venture | d211702 | 2018-02-06 08:54:37 -0800 | [diff] [blame] | 472 | // Copy end to first |
| 473 | memcpy((void*)&resp_uuid[resp_loc], &resp_byte, 1); |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 474 | resp_loc--; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 475 | id_octet += 2; // Finished with the 2 chars, advance |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 476 | } |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 477 | id_octet = strtok_r(NULL, "-", &tokptr); // Get next octet |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | // Data length |
| 481 | *data_len = resp_size; |
| 482 | |
| 483 | // Pack the actual response |
| 484 | memcpy(response, &resp_uuid, *data_len); |
| 485 | |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 486 | finish: |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 487 | sd_bus_error_free(&error); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 488 | reply = sd_bus_message_unref(reply); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 489 | free(busname); |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 490 | |
| 491 | return rc; |
| 492 | } |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 493 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 494 | ipmi_ret_t ipmi_app_get_bt_capabilities(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 495 | ipmi_request_t request, |
| 496 | ipmi_response_t response, |
| 497 | ipmi_data_len_t data_len, |
| 498 | ipmi_context_t context) |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 499 | { |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 500 | |
| 501 | // Status code. |
| 502 | ipmi_ret_t rc = IPMI_CC_OK; |
| 503 | |
Adriana Kobylak | 88ad815 | 2016-12-13 10:09:08 -0600 | [diff] [blame] | 504 | // Per IPMI 2.0 spec, the input and output buffer size must be the max |
| 505 | // buffer size minus one byte to allocate space for the length byte. |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 506 | uint8_t str[] = {0x01, MAX_IPMI_BUFFER - 1, MAX_IPMI_BUFFER - 1, 0x0A, |
| 507 | 0x01}; |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 508 | |
| 509 | // Data length |
| 510 | *data_len = sizeof(str); |
| 511 | |
| 512 | // Pack the actual response |
| 513 | memcpy(response, &str, *data_len); |
| 514 | |
| 515 | return rc; |
| 516 | } |
| 517 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 518 | ipmi_ret_t ipmi_app_wildcard_handler(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 519 | ipmi_request_t request, |
| 520 | ipmi_response_t response, |
| 521 | ipmi_data_len_t data_len, |
| 522 | ipmi_context_t context) |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 523 | { |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 524 | // Status code. |
Nan Li | 70aa8d9 | 2016-08-29 00:11:10 +0800 | [diff] [blame] | 525 | ipmi_ret_t rc = IPMI_CC_INVALID; |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 526 | |
| 527 | *data_len = strlen("THIS IS WILDCARD"); |
| 528 | |
| 529 | // Now pack actual response |
| 530 | memcpy(response, "THIS IS WILDCARD", *data_len); |
| 531 | |
| 532 | return rc; |
| 533 | } |
| 534 | |
Marri Devender Rao | 5e007a5 | 2018-01-08 06:18:36 -0600 | [diff] [blame] | 535 | ipmi_ret_t ipmi_app_get_sys_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 536 | ipmi_request_t request, |
| 537 | ipmi_response_t response, |
| 538 | ipmi_data_len_t data_len, |
| 539 | ipmi_context_t context) |
Marri Devender Rao | 5e007a5 | 2018-01-08 06:18:36 -0600 | [diff] [blame] | 540 | |
| 541 | { |
| 542 | ipmi_ret_t rc = IPMI_CC_OK; |
| 543 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
| 544 | |
| 545 | try |
| 546 | { |
| 547 | // Get the Inventory object implementing BMC interface |
| 548 | ipmi::DbusObjectInfo bmcObject = |
| 549 | ipmi::getDbusObject(bus, bmc_interface); |
| 550 | |
| 551 | // Read UUID property value from bmcObject |
| 552 | // UUID is in RFC4122 format Ex: 61a39523-78f2-11e5-9862-e6402cfc3223 |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 553 | auto variant = |
| 554 | ipmi::getDbusProperty(bus, bmcObject.second, bmcObject.first, |
| 555 | bmc_guid_interface, bmc_guid_property); |
Marri Devender Rao | 5e007a5 | 2018-01-08 06:18:36 -0600 | [diff] [blame] | 556 | std::string guidProp = variant.get<std::string>(); |
| 557 | |
| 558 | // Erase "-" characters from the property value |
| 559 | guidProp.erase(std::remove(guidProp.begin(), guidProp.end(), '-'), |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 560 | guidProp.end()); |
Marri Devender Rao | 5e007a5 | 2018-01-08 06:18:36 -0600 | [diff] [blame] | 561 | |
| 562 | auto guidPropLen = guidProp.length(); |
| 563 | // Validate UUID data |
| 564 | // Divide by 2 as 1 byte is built from 2 chars |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 565 | if ((guidPropLen <= 0) || ((guidPropLen / 2) != bmc_guid_len)) |
Marri Devender Rao | 5e007a5 | 2018-01-08 06:18:36 -0600 | [diff] [blame] | 566 | |
| 567 | { |
| 568 | log<level::ERR>("Invalid UUID property value", |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 569 | entry("UUID_LENGTH=%d", guidPropLen)); |
Marri Devender Rao | 5e007a5 | 2018-01-08 06:18:36 -0600 | [diff] [blame] | 570 | return IPMI_CC_RESPONSE_ERROR; |
| 571 | } |
| 572 | |
| 573 | // Convert data in RFC4122(MSB) format to LSB format |
| 574 | // Get 2 characters at a time as 1 byte is built from 2 chars and |
| 575 | // convert to hex byte |
| 576 | // TODO: Data printed for GUID command is not as per the |
| 577 | // GUID format defined in IPMI specification 2.0 section 20.8 |
| 578 | // Ticket raised: https://sourceforge.net/p/ipmitool/bugs/501/ |
| 579 | uint8_t respGuid[bmc_guid_len]; |
| 580 | for (size_t i = 0, respLoc = (bmc_guid_len - 1); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 581 | i < guidPropLen && respLoc >= 0; i += 2, respLoc--) |
Marri Devender Rao | 5e007a5 | 2018-01-08 06:18:36 -0600 | [diff] [blame] | 582 | { |
| 583 | auto value = static_cast<uint8_t>( |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 584 | std::stoi(guidProp.substr(i, 2).c_str(), NULL, 16)); |
Marri Devender Rao | 5e007a5 | 2018-01-08 06:18:36 -0600 | [diff] [blame] | 585 | respGuid[respLoc] = value; |
| 586 | } |
| 587 | |
| 588 | *data_len = bmc_guid_len; |
| 589 | memcpy(response, &respGuid, bmc_guid_len); |
| 590 | } |
| 591 | catch (const InternalFailure& e) |
| 592 | { |
| 593 | log<level::ERR>("Failed in reading BMC UUID property", |
| 594 | entry("INTERFACE=%s", bmc_interface), |
| 595 | entry("PROPERTY_INTERFACE=%s", bmc_guid_interface), |
| 596 | entry("PROPERTY=%s", bmc_guid_property)); |
| 597 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 598 | } |
| 599 | return rc; |
| 600 | } |
| 601 | |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 602 | void register_netfn_app_functions() |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 603 | { |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 604 | // <Get BT Interface Capabilities> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 605 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CAP_BIT, NULL, |
| 606 | ipmi_app_get_bt_capabilities, PRIVILEGE_USER); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 607 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 608 | // <Wildcard Command> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 609 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_WILDCARD, NULL, |
| 610 | ipmi_app_wildcard_handler, PRIVILEGE_USER); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 611 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 612 | // <Reset Watchdog Timer> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 613 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_RESET_WD, NULL, |
| 614 | ipmi_app_watchdog_reset, PRIVILEGE_OPERATOR); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 615 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 616 | // <Set Watchdog Timer> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 617 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_WD, NULL, |
| 618 | ipmi_app_watchdog_set, PRIVILEGE_OPERATOR); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 619 | |
William A. Kennington III | 73f4451 | 2018-02-09 15:28:46 -0800 | [diff] [blame] | 620 | // <Get Watchdog Timer> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 621 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_WD, NULL, |
| 622 | ipmi_app_watchdog_get, PRIVILEGE_OPERATOR); |
William A. Kennington III | 73f4451 | 2018-02-09 15:28:46 -0800 | [diff] [blame] | 623 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 624 | // <Get Device ID> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 625 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_ID, NULL, |
| 626 | ipmi_app_get_device_id, PRIVILEGE_USER); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 627 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 628 | // <Get Self Test Results> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 629 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_SELF_TEST_RESULTS, NULL, |
| 630 | ipmi_app_get_self_test_results, PRIVILEGE_USER); |
Nan Li | 41fa24a | 2016-11-10 20:12:37 +0800 | [diff] [blame] | 631 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 632 | // <Get Device GUID> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 633 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_GUID, NULL, |
| 634 | ipmi_app_get_device_guid, PRIVILEGE_USER); |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 635 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 636 | // <Set ACPI Power State> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 637 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_ACPI, NULL, |
| 638 | ipmi_app_set_acpi_power_state, PRIVILEGE_ADMIN); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 639 | |
Tom Joseph | 69fabfe | 2017-08-04 10:15:01 +0530 | [diff] [blame] | 640 | // <Get Channel Access> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 641 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHANNEL_ACCESS, NULL, |
| 642 | ipmi_get_channel_access, PRIVILEGE_USER); |
Tom Joseph | 69fabfe | 2017-08-04 10:15:01 +0530 | [diff] [blame] | 643 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 644 | // <Get Channel Info Command> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 645 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHAN_INFO, NULL, |
| 646 | ipmi_app_channel_info, PRIVILEGE_USER); |
Chris Austen | c2cd29d | 2016-02-05 20:02:29 -0600 | [diff] [blame] | 647 | |
Marri Devender Rao | 5e007a5 | 2018-01-08 06:18:36 -0600 | [diff] [blame] | 648 | // <Get System GUID Command> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 649 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_SYS_GUID, NULL, |
| 650 | ipmi_app_get_sys_guid, PRIVILEGE_USER); |
Tom Joseph | 7cbe228 | 2018-03-21 21:17:33 +0530 | [diff] [blame] | 651 | |
| 652 | // <Get Channel Cipher Suites Command> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 653 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHAN_CIPHER_SUITES, NULL, |
| 654 | getChannelCipherSuites, PRIVILEGE_CALLBACK); |
Tom Joseph | 1322768 | 2018-08-10 01:05:21 +0530 | [diff] [blame^] | 655 | |
| 656 | // <Set Channel Access Command> |
| 657 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_CHAN_ACCESS, NULL, |
| 658 | ipmi_set_channel_access, PRIVILEGE_ADMIN); |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 659 | return; |
| 660 | } |