Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 Intel Corporation. |
| 3 | * Copyright (c) 2018-present Facebook. |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include "xyz/openbmc_project/Common/error.hpp" |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 19 | #include <xyz/openbmc_project/Control/Boot/Mode/server.hpp> |
| 20 | #include <xyz/openbmc_project/Control/Boot/Source/server.hpp> |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 21 | #include <xyz/openbmc_project/Control/Boot/Type/server.hpp> |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 22 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 23 | #include <ipmid/api.hpp> |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 24 | #include <ipmid/utils.hpp> |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 25 | #include <commandutils.hpp> |
| 26 | #include <nlohmann/json.hpp> |
| 27 | #include <oemcommands.hpp> |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 28 | #include <phosphor-logging/log.hpp> |
| 29 | #include <sdbusplus/bus.hpp> |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 30 | |
Manikandan Elumalai | 5f8e343 | 2020-12-02 03:46:55 +0530 | [diff] [blame] | 31 | #include <ipmid/api.hpp> |
| 32 | #include <ipmid/api-types.hpp> |
| 33 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 34 | #include <array> |
| 35 | #include <cstring> |
| 36 | #include <fstream> |
| 37 | #include <iomanip> |
| 38 | #include <iostream> |
| 39 | #include <sstream> |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 40 | #include <string> |
| 41 | #include <vector> |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 42 | #include <regex> |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 43 | |
| 44 | #define SIZE_IANA_ID 3 |
| 45 | |
| 46 | namespace ipmi |
| 47 | { |
Vijay Khemka | a723189 | 2019-10-11 11:35:05 -0700 | [diff] [blame] | 48 | |
| 49 | using namespace phosphor::logging; |
| 50 | |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 51 | size_t getSelectorPosition(); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 52 | static void registerOEMFunctions() __attribute__((constructor)); |
| 53 | sdbusplus::bus::bus dbus(ipmid_get_sd_bus_connection()); // from ipmid/api.h |
| 54 | static constexpr size_t maxFRUStringLength = 0x3F; |
Manikandan Elumalai | 5f8e343 | 2020-12-02 03:46:55 +0530 | [diff] [blame] | 55 | constexpr uint8_t cmdSetSystemGuid = 0xEF; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 56 | |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 57 | constexpr uint8_t cmdSetQDimmInfo = 0x12; |
| 58 | constexpr uint8_t cmdGetQDimmInfo = 0x13; |
| 59 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 60 | int plat_udbg_get_post_desc(uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t*, |
| 61 | uint8_t*); |
| 62 | int plat_udbg_get_gpio_desc(uint8_t, uint8_t*, uint8_t*, uint8_t*, uint8_t*, |
| 63 | uint8_t*); |
| 64 | ipmi_ret_t plat_udbg_get_frame_data(uint8_t, uint8_t, uint8_t*, uint8_t*, |
| 65 | uint8_t*); |
| 66 | ipmi_ret_t plat_udbg_control_panel(uint8_t, uint8_t, uint8_t, uint8_t*, |
| 67 | uint8_t*); |
| 68 | int sendMeCmd(uint8_t, uint8_t, std::vector<uint8_t>&, std::vector<uint8_t>&); |
Vijay Khemka | dd14c0f | 2020-03-18 14:48:13 -0700 | [diff] [blame] | 69 | |
Manikandan Elumalai | 5f8e343 | 2020-12-02 03:46:55 +0530 | [diff] [blame] | 70 | int sendBicCmd(uint8_t, uint8_t, uint8_t, std::vector<uint8_t>&, |
| 71 | std::vector<uint8_t>&); |
| 72 | |
Vijay Khemka | feaa981 | 2019-08-27 15:08:08 -0700 | [diff] [blame] | 73 | nlohmann::json oemData __attribute__((init_priority(101))); |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 74 | |
Vijay Khemka | f2246ce | 2020-05-27 14:26:35 -0700 | [diff] [blame] | 75 | static constexpr size_t GUID_SIZE = 16; |
| 76 | // TODO Make offset and location runtime configurable to ensure we |
| 77 | // can make each define their own locations. |
| 78 | static constexpr off_t OFFSET_SYS_GUID = 0x17F0; |
| 79 | static constexpr const char* FRU_EEPROM = "/sys/bus/i2c/devices/6-0054/eeprom"; |
| 80 | |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 81 | enum class LanParam : uint8_t |
| 82 | { |
| 83 | INPROGRESS = 0, |
| 84 | AUTHSUPPORT = 1, |
| 85 | AUTHENABLES = 2, |
| 86 | IP = 3, |
| 87 | IPSRC = 4, |
| 88 | MAC = 5, |
| 89 | SUBNET = 6, |
| 90 | GATEWAY = 12, |
| 91 | VLAN = 20, |
| 92 | CIPHER_SUITE_COUNT = 22, |
| 93 | CIPHER_SUITE_ENTRIES = 23, |
| 94 | IPV6 = 59, |
| 95 | }; |
| 96 | |
Vijay Khemka | a723189 | 2019-10-11 11:35:05 -0700 | [diff] [blame] | 97 | namespace network |
| 98 | { |
| 99 | |
| 100 | constexpr auto ROOT = "/xyz/openbmc_project/network"; |
| 101 | constexpr auto SERVICE = "xyz.openbmc_project.Network"; |
| 102 | constexpr auto IPV4_TYPE = "ipv4"; |
| 103 | constexpr auto IPV6_TYPE = "ipv6"; |
| 104 | constexpr auto IPV4_PREFIX = "169.254"; |
| 105 | constexpr auto IPV6_PREFIX = "fe80"; |
| 106 | constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP"; |
| 107 | constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress"; |
| 108 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 109 | bool isLinkLocalIP(const std::string& address) |
Vijay Khemka | a723189 | 2019-10-11 11:35:05 -0700 | [diff] [blame] | 110 | { |
| 111 | return address.find(IPV4_PREFIX) == 0 || address.find(IPV6_PREFIX) == 0; |
| 112 | } |
| 113 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 114 | DbusObjectInfo getIPObject(sdbusplus::bus::bus& bus, |
| 115 | const std::string& interface, |
| 116 | const std::string& serviceRoot, |
| 117 | const std::string& match) |
Vijay Khemka | a723189 | 2019-10-11 11:35:05 -0700 | [diff] [blame] | 118 | { |
| 119 | auto objectTree = getAllDbusObjects(bus, serviceRoot, interface, match); |
| 120 | |
| 121 | if (objectTree.empty()) |
| 122 | { |
| 123 | log<level::ERR>("No Object has implemented the IP interface", |
| 124 | entry("INTERFACE=%s", interface.c_str())); |
| 125 | } |
| 126 | |
| 127 | DbusObjectInfo objectInfo; |
| 128 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 129 | for (auto& object : objectTree) |
Vijay Khemka | a723189 | 2019-10-11 11:35:05 -0700 | [diff] [blame] | 130 | { |
| 131 | auto variant = |
| 132 | ipmi::getDbusProperty(bus, object.second.begin()->first, |
| 133 | object.first, IP_INTERFACE, "Address"); |
| 134 | |
| 135 | objectInfo = std::make_pair(object.first, object.second.begin()->first); |
| 136 | |
| 137 | // if LinkLocalIP found look for Non-LinkLocalIP |
| 138 | if (isLinkLocalIP(std::get<std::string>(variant))) |
| 139 | { |
| 140 | continue; |
| 141 | } |
| 142 | else |
| 143 | { |
| 144 | break; |
| 145 | } |
| 146 | } |
| 147 | return objectInfo; |
| 148 | } |
| 149 | |
| 150 | } // namespace network |
| 151 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 152 | namespace boot |
| 153 | { |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 154 | using BootSource = |
| 155 | sdbusplus::xyz::openbmc_project::Control::Boot::server::Source::Sources; |
| 156 | using BootMode = |
| 157 | sdbusplus::xyz::openbmc_project::Control::Boot::server::Mode::Modes; |
| 158 | using BootType = |
| 159 | sdbusplus::xyz::openbmc_project::Control::Boot::server::Type::Types; |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 160 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 161 | using IpmiValue = uint8_t; |
| 162 | |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 163 | std::map<IpmiValue, BootSource> sourceIpmiToDbus = { |
| 164 | {0x0f, BootSource::Default}, {0x00, BootSource::RemovableMedia}, |
| 165 | {0x01, BootSource::Network}, {0x02, BootSource::Disk}, |
| 166 | {0x03, BootSource::ExternalMedia}, {0x09, BootSource::Network}}; |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 167 | |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 168 | std::map<IpmiValue, BootMode> modeIpmiToDbus = {{0x06, BootMode::Setup}, |
| 169 | {0x00, BootMode::Regular}}; |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 170 | |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 171 | std::map<IpmiValue, BootType> typeIpmiToDbus = {{0x00, BootType::Legacy}, |
| 172 | {0x01, BootType::EFI}}; |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 173 | |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 174 | std::map<std::optional<BootSource>, IpmiValue> sourceDbusToIpmi = { |
| 175 | {BootSource::Default, 0x0f}, |
| 176 | {BootSource::RemovableMedia, 0x00}, |
| 177 | {BootSource::Network, 0x01}, |
| 178 | {BootSource::Disk, 0x02}, |
| 179 | {BootSource::ExternalMedia, 0x03}}; |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 180 | |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 181 | std::map<std::optional<BootMode>, IpmiValue> modeDbusToIpmi = { |
| 182 | {BootMode::Setup, 0x06}, {BootMode::Regular, 0x00}}; |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 183 | |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 184 | std::map<std::optional<BootType>, IpmiValue> typeDbusToIpmi = { |
| 185 | {BootType::Legacy, 0x00}, {BootType::EFI, 0x01}}; |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 186 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 187 | static constexpr auto bootModeIntf = "xyz.openbmc_project.Control.Boot.Mode"; |
| 188 | static constexpr auto bootSourceIntf = |
| 189 | "xyz.openbmc_project.Control.Boot.Source"; |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 190 | static constexpr auto bootTypeIntf = "xyz.openbmc_project.Control.Boot.Type"; |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 191 | static constexpr auto bootSourceProp = "BootSource"; |
| 192 | static constexpr auto bootModeProp = "BootMode"; |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 193 | static constexpr auto bootTypeProp = "BootType"; |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 194 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 195 | std::tuple<std::string, std::string> objPath(size_t id) |
| 196 | { |
| 197 | std::string hostName = "host" + std::to_string(id); |
| 198 | std::string bootObjPath = |
| 199 | "/xyz/openbmc_project/control/" + hostName + "/boot"; |
| 200 | return std::make_tuple(std::move(bootObjPath), std::move(hostName)); |
| 201 | } |
| 202 | |
| 203 | } // namespace boot |
| 204 | |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 205 | //---------------------------------------------------------------------- |
| 206 | // Helper functions for storing oem data |
| 207 | //---------------------------------------------------------------------- |
| 208 | |
| 209 | void flushOemData() |
| 210 | { |
| 211 | std::ofstream file(JSON_OEM_DATA_FILE); |
| 212 | file << oemData; |
Vijay Khemka | feaa981 | 2019-08-27 15:08:08 -0700 | [diff] [blame] | 213 | file.close(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 214 | return; |
| 215 | } |
| 216 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 217 | std::string bytesToStr(uint8_t* byte, int len) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 218 | { |
| 219 | std::stringstream ss; |
| 220 | int i; |
| 221 | |
| 222 | ss << std::hex; |
| 223 | for (i = 0; i < len; i++) |
| 224 | { |
| 225 | ss << std::setw(2) << std::setfill('0') << (int)byte[i]; |
| 226 | } |
| 227 | |
| 228 | return ss.str(); |
| 229 | } |
| 230 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 231 | int strToBytes(std::string& str, uint8_t* data) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 232 | { |
| 233 | std::string sstr; |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 234 | size_t i; |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 235 | |
| 236 | for (i = 0; i < (str.length()) / 2; i++) |
| 237 | { |
| 238 | sstr = str.substr(i * 2, 2); |
| 239 | data[i] = (uint8_t)std::strtol(sstr.c_str(), NULL, 16); |
| 240 | } |
| 241 | return i; |
| 242 | } |
| 243 | |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 244 | int readDimmType(std::string& data, uint8_t param) |
| 245 | { |
| 246 | nlohmann::json dimmObj; |
| 247 | /* Get dimm type names stored in json file */ |
| 248 | std::ifstream file(JSON_DIMM_TYPE_FILE); |
| 249 | if (file) |
| 250 | { |
| 251 | file >> dimmObj; |
| 252 | file.close(); |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 257 | "DIMM type names file not found", |
| 258 | phosphor::logging::entry("DIMM_TYPE_FILE=%s", JSON_DIMM_TYPE_FILE)); |
| 259 | return -1; |
| 260 | } |
| 261 | |
| 262 | std::string dimmKey = "dimm_type" + std::to_string(param); |
| 263 | auto obj = dimmObj[dimmKey]["short_name"]; |
| 264 | data = obj; |
| 265 | return 0; |
| 266 | } |
| 267 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 268 | ipmi_ret_t getNetworkData(uint8_t lan_param, char* data) |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 269 | { |
| 270 | ipmi_ret_t rc = IPMI_CC_OK; |
| 271 | sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection()); |
| 272 | |
| 273 | const std::string ethdevice = "eth0"; |
| 274 | |
| 275 | switch (static_cast<LanParam>(lan_param)) |
| 276 | { |
Vijay Khemka | d119402 | 2020-05-27 18:58:33 -0700 | [diff] [blame] | 277 | case LanParam::IP: |
| 278 | { |
Vijay Khemka | a723189 | 2019-10-11 11:35:05 -0700 | [diff] [blame] | 279 | auto ethIP = ethdevice + "/" + ipmi::network::IPV4_TYPE; |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 280 | std::string ipaddress; |
Vijay Khemka | a723189 | 2019-10-11 11:35:05 -0700 | [diff] [blame] | 281 | auto ipObjectInfo = ipmi::network::getIPObject( |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 282 | bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT, ethIP); |
| 283 | |
| 284 | auto properties = ipmi::getAllDbusProperties( |
| 285 | bus, ipObjectInfo.second, ipObjectInfo.first, |
| 286 | ipmi::network::IP_INTERFACE); |
| 287 | |
Patrick Williams | ef0efbc | 2020-05-13 11:26:51 -0500 | [diff] [blame] | 288 | ipaddress = std::get<std::string>(properties["Address"]); |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 289 | |
| 290 | std::strcpy(data, ipaddress.c_str()); |
| 291 | } |
| 292 | break; |
| 293 | |
Vijay Khemka | d119402 | 2020-05-27 18:58:33 -0700 | [diff] [blame] | 294 | case LanParam::IPV6: |
| 295 | { |
Vijay Khemka | a723189 | 2019-10-11 11:35:05 -0700 | [diff] [blame] | 296 | auto ethIP = ethdevice + "/" + ipmi::network::IPV6_TYPE; |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 297 | std::string ipaddress; |
Vijay Khemka | a723189 | 2019-10-11 11:35:05 -0700 | [diff] [blame] | 298 | auto ipObjectInfo = ipmi::network::getIPObject( |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 299 | bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT, ethIP); |
| 300 | |
| 301 | auto properties = ipmi::getAllDbusProperties( |
| 302 | bus, ipObjectInfo.second, ipObjectInfo.first, |
| 303 | ipmi::network::IP_INTERFACE); |
| 304 | |
Patrick Williams | ef0efbc | 2020-05-13 11:26:51 -0500 | [diff] [blame] | 305 | ipaddress = std::get<std::string>(properties["Address"]); |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 306 | |
| 307 | std::strcpy(data, ipaddress.c_str()); |
| 308 | } |
| 309 | break; |
| 310 | |
Vijay Khemka | d119402 | 2020-05-27 18:58:33 -0700 | [diff] [blame] | 311 | case LanParam::MAC: |
| 312 | { |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 313 | std::string macAddress; |
| 314 | auto macObjectInfo = |
| 315 | ipmi::getDbusObject(bus, ipmi::network::MAC_INTERFACE, |
| 316 | ipmi::network::ROOT, ethdevice); |
| 317 | |
| 318 | auto variant = ipmi::getDbusProperty( |
| 319 | bus, macObjectInfo.second, macObjectInfo.first, |
| 320 | ipmi::network::MAC_INTERFACE, "MACAddress"); |
| 321 | |
Patrick Williams | ef0efbc | 2020-05-13 11:26:51 -0500 | [diff] [blame] | 322 | macAddress = std::get<std::string>(variant); |
Vijay Khemka | 1b6fae3 | 2019-03-25 17:43:01 -0700 | [diff] [blame] | 323 | |
| 324 | sscanf(macAddress.c_str(), ipmi::network::MAC_ADDRESS_FORMAT, |
| 325 | (data), (data + 1), (data + 2), (data + 3), (data + 4), |
| 326 | (data + 5)); |
| 327 | std::strcpy(data, macAddress.c_str()); |
| 328 | } |
| 329 | break; |
| 330 | |
| 331 | default: |
| 332 | rc = IPMI_CC_PARM_OUT_OF_RANGE; |
| 333 | } |
| 334 | return rc; |
| 335 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 336 | |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 337 | bool isMultiHostPlatform() |
| 338 | { |
| 339 | bool platform; |
Jayashree Dhanapal | 4ec8056 | 2022-06-28 15:41:47 +0530 | [diff] [blame] | 340 | if (hostInstances == "0") |
Karthikeyan Pasupathi | 39836ff | 2022-01-17 12:20:06 +0530 | [diff] [blame] | 341 | { |
| 342 | platform = false; |
| 343 | } |
| 344 | else |
| 345 | { |
| 346 | platform = true; |
| 347 | } |
| 348 | return platform; |
| 349 | } |
| 350 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 351 | // return code: 0 successful |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 352 | int8_t getFruData(std::string& data, std::string& name) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 353 | { |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 354 | size_t pos; |
| 355 | static constexpr const auto depth = 0; |
| 356 | std::vector<std::string> paths; |
| 357 | std::string machinePath; |
| 358 | std::string baseBoard = "Baseboard"; |
| 359 | |
| 360 | bool platform = isMultiHostPlatform(); |
| 361 | if (platform == true) |
| 362 | { |
| 363 | pos = getSelectorPosition(); |
| 364 | } |
| 365 | |
| 366 | sd_bus* bus = NULL; |
| 367 | int ret = sd_bus_default_system(&bus); |
| 368 | if (ret < 0) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 369 | { |
| 370 | phosphor::logging::log<phosphor::logging::level::ERR>( |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 371 | "Failed to connect to system bus", |
| 372 | phosphor::logging::entry("ERRNO=0x%X", -ret)); |
| 373 | sd_bus_unref(bus); |
| 374 | return -1; |
| 375 | } |
| 376 | sdbusplus::bus::bus dbus(bus); |
| 377 | auto mapperCall = dbus.new_method_call("xyz.openbmc_project.ObjectMapper", |
| 378 | "/xyz/openbmc_project/object_mapper", |
| 379 | "xyz.openbmc_project.ObjectMapper", |
| 380 | "GetSubTreePaths"); |
| 381 | static constexpr std::array<const char*, 1> interface = { |
| 382 | "xyz.openbmc_project.Inventory.Decorator.Asset"}; |
| 383 | mapperCall.append("/xyz/openbmc_project/inventory/", depth, interface); |
| 384 | |
| 385 | try |
| 386 | { |
| 387 | auto reply = dbus.call(mapperCall); |
| 388 | reply.read(paths); |
| 389 | } |
| 390 | catch (sdbusplus::exception_t& e) |
| 391 | { |
| 392 | phosphor::logging::log<phosphor::logging::level::ERR>(e.what()); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 393 | return -1; |
| 394 | } |
| 395 | |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 396 | for (const auto& path : paths) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 397 | { |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 398 | if (platform == true) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 399 | { |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 400 | if (pos == BMC_POS) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 401 | { |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 402 | machinePath = baseBoard; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 403 | } |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 404 | else |
| 405 | { |
| 406 | machinePath = "_" + std::to_string(pos); |
| 407 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 408 | } |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 409 | else |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 410 | { |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 411 | machinePath = baseBoard; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 412 | } |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 413 | |
| 414 | auto found = path.find(machinePath); |
Patrick Williams | 123cbcc | 2022-06-24 06:13:59 -0500 | [diff] [blame] | 415 | if (found == std::string::npos) |
Karthikeyan Pasupathi | 98aabdb | 2022-04-06 17:18:51 +0530 | [diff] [blame] | 416 | { |
| 417 | continue; |
| 418 | } |
| 419 | |
| 420 | std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus(); |
| 421 | std::string service = getService( |
| 422 | *dbus, "xyz.openbmc_project.Inventory.Decorator.Asset", path); |
| 423 | |
| 424 | auto Value = ipmi::getDbusProperty( |
| 425 | *dbus, service, path, |
| 426 | "xyz.openbmc_project.Inventory.Decorator.Asset", name); |
| 427 | |
| 428 | data = std::get<std::string>(Value); |
| 429 | return 0; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 430 | } |
| 431 | return -1; |
| 432 | } |
| 433 | |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 434 | int8_t sysConfig(std::vector<std::string>& data, size_t pos) |
| 435 | { |
| 436 | nlohmann::json sysObj; |
| 437 | std::string dimmInfo = KEY_Q_DIMM_INFO + std::to_string(pos); |
| 438 | std::string result, typeName; |
| 439 | uint8_t res[MAX_BUF]; |
| 440 | |
| 441 | /* Get sysConfig data stored in json file */ |
| 442 | std::ifstream file(JSON_OEM_DATA_FILE); |
| 443 | if (file) |
| 444 | { |
| 445 | file >> sysObj; |
| 446 | file.close(); |
| 447 | } |
| 448 | else |
| 449 | { |
| 450 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 451 | "oemData file not found", |
| 452 | phosphor::logging::entry("OEM_DATA_FILE=%s", JSON_OEM_DATA_FILE)); |
| 453 | return -1; |
| 454 | } |
| 455 | |
| 456 | if (sysObj.find(dimmInfo) == sysObj.end()) |
| 457 | { |
| 458 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 459 | "sysconfig key not available", |
| 460 | phosphor::logging::entry("SYS_JSON_KEY=%s", dimmInfo.c_str())); |
| 461 | return -1; |
| 462 | } |
| 463 | /* Get dimm type names stored in json file */ |
| 464 | nlohmann::json dimmObj; |
| 465 | std::ifstream dimmFile(JSON_DIMM_TYPE_FILE); |
| 466 | if (file) |
| 467 | { |
| 468 | dimmFile >> dimmObj; |
| 469 | dimmFile.close(); |
| 470 | } |
| 471 | else |
| 472 | { |
| 473 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 474 | "DIMM type names file not found", |
| 475 | phosphor::logging::entry("DIMM_TYPE_FILE=%s", JSON_DIMM_TYPE_FILE)); |
| 476 | return -1; |
| 477 | } |
| 478 | std::vector<std::string> a; |
| 479 | for (auto& j : dimmObj.items()) |
| 480 | { |
| 481 | std::string name = j.key(); |
| 482 | a.push_back(name); |
| 483 | } |
| 484 | |
| 485 | uint8_t len = a.size(); |
| 486 | for (uint8_t ii = 0; ii < len; ii++) |
| 487 | { |
| 488 | std::string indKey = std::to_string(ii); |
| 489 | std::string speedSize = sysObj[dimmInfo][indKey][DIMM_SPEED]; |
| 490 | strToBytes(speedSize, res); |
| 491 | auto speed = (res[1] << 8 | res[0]); |
| 492 | size_t dimmSize = ((res[3] << 8 | res[2]) / 1000); |
| 493 | |
| 494 | if (dimmSize == 0) |
| 495 | { |
| 496 | std::cerr << "Dimm information not available for slot_" + |
| 497 | std::to_string(ii) |
| 498 | << std::endl; |
| 499 | continue; |
| 500 | } |
| 501 | std::string type = sysObj[dimmInfo][indKey][DIMM_TYPE]; |
| 502 | std::string dualInlineMem = sysObj[dimmInfo][indKey][KEY_DIMM_TYPE]; |
| 503 | strToBytes(type, res); |
| 504 | size_t dimmType = res[0]; |
| 505 | if (dimmVenMap.find(dimmType) == dimmVenMap.end()) |
| 506 | { |
| 507 | typeName = "unknown"; |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | typeName = dimmVenMap[dimmType]; |
| 512 | } |
| 513 | result = dualInlineMem + "/" + typeName + "/" + std::to_string(speed) + |
| 514 | "MHz" + "/" + std::to_string(dimmSize) + "GB"; |
| 515 | data.push_back(result); |
| 516 | } |
| 517 | return 0; |
| 518 | } |
| 519 | |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 520 | int8_t procInfo(std::string& result, size_t pos) |
| 521 | { |
| 522 | std::vector<char> data; |
| 523 | uint8_t res[MAX_BUF]; |
| 524 | std::string procIndex = "00"; |
| 525 | nlohmann::json proObj; |
| 526 | std::string procInfo = KEY_Q_PROC_INFO + std::to_string(pos); |
| 527 | /* Get processor data stored in json file */ |
| 528 | std::ifstream file(JSON_OEM_DATA_FILE); |
| 529 | if (file) |
| 530 | { |
| 531 | file >> proObj; |
| 532 | file.close(); |
| 533 | } |
| 534 | else |
| 535 | { |
| 536 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 537 | "oemData file not found", |
| 538 | phosphor::logging::entry("OEM_DATA_FILE=%s", JSON_OEM_DATA_FILE)); |
| 539 | return -1; |
| 540 | } |
| 541 | if (proObj.find(procInfo) == proObj.end()) |
| 542 | { |
| 543 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 544 | "processor info key not available", |
| 545 | phosphor::logging::entry("PROC_JSON_KEY=%s", procInfo.c_str())); |
| 546 | return -1; |
| 547 | } |
| 548 | std::string procName = proObj[procInfo][procIndex][KEY_PROC_NAME]; |
| 549 | std::string basicInfo = proObj[procInfo][procIndex][KEY_BASIC_INFO]; |
| 550 | // Processor Product Name |
| 551 | strToBytes(procName, res); |
| 552 | data.assign(reinterpret_cast<char*>(&res), |
| 553 | reinterpret_cast<char*>(&res) + sizeof(res)); |
| 554 | |
| 555 | std::string s(data.begin(), data.end()); |
| 556 | std::regex regex(" "); |
| 557 | std::vector<std::string> productName( |
| 558 | std::sregex_token_iterator(s.begin(), s.end(), regex, -1), |
| 559 | std::sregex_token_iterator()); |
| 560 | |
| 561 | // Processor core and frequency |
| 562 | strToBytes(basicInfo, res); |
| 563 | uint16_t coreNum = res[0]; |
| 564 | double procFrequency = (float)(res[4] << 8 | res[3]) / 1000; |
| 565 | result = "CPU:" + productName[2] + "/" + std::to_string(procFrequency) + |
| 566 | "GHz" + "/" + std::to_string(coreNum) + "c"; |
| 567 | return 0; |
| 568 | } |
| 569 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 570 | typedef struct |
| 571 | { |
| 572 | uint8_t cur_power_state; |
| 573 | uint8_t last_power_event; |
| 574 | uint8_t misc_power_state; |
| 575 | uint8_t front_panel_button_cap_status; |
| 576 | } ipmi_get_chassis_status_t; |
| 577 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 578 | //---------------------------------------------------------------------- |
| 579 | // Get Debug Frame Info |
| 580 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 581 | ipmi_ret_t ipmiOemDbgGetFrameInfo(ipmi_netfn_t, ipmi_cmd_t, |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 582 | ipmi_request_t request, |
| 583 | ipmi_response_t response, |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 584 | ipmi_data_len_t data_len, ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 585 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 586 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
| 587 | uint8_t* res = reinterpret_cast<uint8_t*>(response); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 588 | uint8_t num_frames = 3; |
| 589 | |
| 590 | std::memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 591 | res[SIZE_IANA_ID] = num_frames; |
| 592 | *data_len = SIZE_IANA_ID + 1; |
| 593 | |
| 594 | return IPMI_CC_OK; |
| 595 | } |
| 596 | |
| 597 | //---------------------------------------------------------------------- |
| 598 | // Get Debug Updated Frames |
| 599 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 600 | ipmi_ret_t ipmiOemDbgGetUpdFrames(ipmi_netfn_t, ipmi_cmd_t, |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 601 | ipmi_request_t request, |
| 602 | ipmi_response_t response, |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 603 | ipmi_data_len_t data_len, ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 604 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 605 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
| 606 | uint8_t* res = reinterpret_cast<uint8_t*>(response); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 607 | uint8_t num_updates = 3; |
| 608 | *data_len = 4; |
| 609 | |
| 610 | std::memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 611 | res[SIZE_IANA_ID] = num_updates; |
| 612 | *data_len = SIZE_IANA_ID + num_updates + 1; |
| 613 | res[SIZE_IANA_ID + 1] = 1; // info page update |
| 614 | res[SIZE_IANA_ID + 2] = 2; // cri sel update |
| 615 | res[SIZE_IANA_ID + 3] = 3; // cri sensor update |
| 616 | |
| 617 | return IPMI_CC_OK; |
| 618 | } |
| 619 | |
| 620 | //---------------------------------------------------------------------- |
| 621 | // Get Debug POST Description |
| 622 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 623 | ipmi_ret_t ipmiOemDbgGetPostDesc(ipmi_netfn_t, ipmi_cmd_t, |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 624 | ipmi_request_t request, |
| 625 | ipmi_response_t response, |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 626 | ipmi_data_len_t data_len, ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 627 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 628 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
| 629 | uint8_t* res = reinterpret_cast<uint8_t*>(response); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 630 | uint8_t index = 0; |
| 631 | uint8_t next = 0; |
| 632 | uint8_t end = 0; |
| 633 | uint8_t phase = 0; |
Vijay Khemka | cc0d6d9 | 2019-08-27 14:51:17 -0700 | [diff] [blame] | 634 | uint8_t descLen = 0; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 635 | int ret; |
| 636 | |
| 637 | index = req[3]; |
| 638 | phase = req[4]; |
| 639 | |
Vijay Khemka | cc0d6d9 | 2019-08-27 14:51:17 -0700 | [diff] [blame] | 640 | ret = plat_udbg_get_post_desc(index, &next, phase, &end, &descLen, &res[8]); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 641 | if (ret) |
| 642 | { |
| 643 | memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 644 | *data_len = SIZE_IANA_ID; |
| 645 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 646 | } |
| 647 | |
| 648 | memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 649 | res[3] = index; |
| 650 | res[4] = next; |
| 651 | res[5] = phase; |
| 652 | res[6] = end; |
Vijay Khemka | cc0d6d9 | 2019-08-27 14:51:17 -0700 | [diff] [blame] | 653 | res[7] = descLen; |
| 654 | *data_len = SIZE_IANA_ID + 5 + descLen; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 655 | |
| 656 | return IPMI_CC_OK; |
| 657 | } |
| 658 | |
| 659 | //---------------------------------------------------------------------- |
| 660 | // Get Debug GPIO Description |
| 661 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 662 | ipmi_ret_t ipmiOemDbgGetGpioDesc(ipmi_netfn_t, ipmi_cmd_t, |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 663 | ipmi_request_t request, |
| 664 | ipmi_response_t response, |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 665 | ipmi_data_len_t data_len, ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 666 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 667 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
| 668 | uint8_t* res = reinterpret_cast<uint8_t*>(response); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 669 | |
Vijay Khemka | 38183d6 | 2019-08-28 16:19:33 -0700 | [diff] [blame] | 670 | uint8_t index = 0; |
| 671 | uint8_t next = 0; |
| 672 | uint8_t level = 0; |
| 673 | uint8_t pinDef = 0; |
| 674 | uint8_t descLen = 0; |
| 675 | int ret; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 676 | |
Vijay Khemka | 38183d6 | 2019-08-28 16:19:33 -0700 | [diff] [blame] | 677 | index = req[3]; |
| 678 | |
| 679 | ret = plat_udbg_get_gpio_desc(index, &next, &level, &pinDef, &descLen, |
| 680 | &res[8]); |
| 681 | if (ret) |
| 682 | { |
| 683 | memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 684 | *data_len = SIZE_IANA_ID; |
| 685 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 686 | } |
| 687 | |
| 688 | memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 689 | res[3] = index; |
| 690 | res[4] = next; |
| 691 | res[5] = level; |
| 692 | res[6] = pinDef; |
| 693 | res[7] = descLen; |
| 694 | *data_len = SIZE_IANA_ID + 5 + descLen; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 695 | |
| 696 | return IPMI_CC_OK; |
| 697 | } |
| 698 | |
| 699 | //---------------------------------------------------------------------- |
| 700 | // Get Debug Frame Data |
| 701 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 702 | ipmi_ret_t ipmiOemDbgGetFrameData(ipmi_netfn_t, ipmi_cmd_t, |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 703 | ipmi_request_t request, |
| 704 | ipmi_response_t response, |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 705 | ipmi_data_len_t data_len, ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 706 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 707 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
| 708 | uint8_t* res = reinterpret_cast<uint8_t*>(response); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 709 | uint8_t frame; |
| 710 | uint8_t page; |
| 711 | uint8_t next; |
| 712 | uint8_t count; |
| 713 | int ret; |
| 714 | |
| 715 | frame = req[3]; |
| 716 | page = req[4]; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 717 | |
| 718 | ret = plat_udbg_get_frame_data(frame, page, &next, &count, &res[7]); |
| 719 | if (ret) |
| 720 | { |
| 721 | memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 722 | *data_len = SIZE_IANA_ID; |
| 723 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 724 | } |
| 725 | |
| 726 | memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 727 | res[3] = frame; |
| 728 | res[4] = page; |
| 729 | res[5] = next; |
| 730 | res[6] = count; |
| 731 | *data_len = SIZE_IANA_ID + 4 + count; |
| 732 | |
| 733 | return IPMI_CC_OK; |
| 734 | } |
| 735 | |
| 736 | //---------------------------------------------------------------------- |
| 737 | // Get Debug Control Panel |
| 738 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 739 | ipmi_ret_t ipmiOemDbgGetCtrlPanel(ipmi_netfn_t, ipmi_cmd_t, |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 740 | ipmi_request_t request, |
| 741 | ipmi_response_t response, |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 742 | ipmi_data_len_t data_len, ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 743 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 744 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
| 745 | uint8_t* res = reinterpret_cast<uint8_t*>(response); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 746 | |
| 747 | uint8_t panel; |
| 748 | uint8_t operation; |
| 749 | uint8_t item; |
| 750 | uint8_t count; |
| 751 | ipmi_ret_t ret; |
| 752 | |
| 753 | panel = req[3]; |
| 754 | operation = req[4]; |
| 755 | item = req[5]; |
| 756 | |
| 757 | ret = plat_udbg_control_panel(panel, operation, item, &count, &res[3]); |
| 758 | |
| 759 | std::memcpy(res, req, SIZE_IANA_ID); // IANA ID |
| 760 | *data_len = SIZE_IANA_ID + count; |
| 761 | |
| 762 | return ret; |
| 763 | } |
| 764 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 765 | //---------------------------------------------------------------------- |
| 766 | // Set Dimm Info (CMD_OEM_SET_DIMM_INFO) |
| 767 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 768 | ipmi_ret_t ipmiOemSetDimmInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, |
| 769 | ipmi_response_t, ipmi_data_len_t data_len, |
| 770 | ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 771 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 772 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 773 | |
| 774 | uint8_t index = req[0]; |
| 775 | uint8_t type = req[1]; |
| 776 | uint16_t speed; |
| 777 | uint32_t size; |
| 778 | |
| 779 | memcpy(&speed, &req[2], 2); |
| 780 | memcpy(&size, &req[4], 4); |
| 781 | |
| 782 | std::stringstream ss; |
| 783 | ss << std::hex; |
| 784 | ss << std::setw(2) << std::setfill('0') << (int)index; |
| 785 | |
| 786 | oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_INDEX] = index; |
| 787 | oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_TYPE] = type; |
| 788 | oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_SPEED] = speed; |
| 789 | oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_SIZE] = size; |
| 790 | |
| 791 | flushOemData(); |
| 792 | |
| 793 | *data_len = 0; |
| 794 | |
| 795 | return IPMI_CC_OK; |
| 796 | } |
| 797 | |
| 798 | //---------------------------------------------------------------------- |
| 799 | // Get Board ID (CMD_OEM_GET_BOARD_ID) |
| 800 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 801 | ipmi_ret_t ipmiOemGetBoardID(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, |
| 802 | ipmi_response_t, ipmi_data_len_t data_len, |
| 803 | ipmi_context_t) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 804 | { |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 805 | /* TODO: Needs to implement this after GPIO implementation */ |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 806 | *data_len = 0; |
| 807 | |
| 808 | return IPMI_CC_OK; |
| 809 | } |
| 810 | |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 811 | /* Helper functions to set boot order */ |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 812 | void setBootOrder(std::string bootObjPath, uint8_t* data, |
| 813 | std::string bootOrderKey) |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 814 | { |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 815 | std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus(); |
| 816 | |
| 817 | // SETTING BOOT MODE PROPERTY |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 818 | uint8_t bootModeBit = data[0] & 0x06; |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 819 | auto bootValue = ipmi::boot::modeIpmiToDbus.at(bootModeBit); |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 820 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 821 | std::string bootOption = |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 822 | sdbusplus::message::convert_to_string<boot::BootMode>(bootValue); |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 823 | |
| 824 | std::string service = |
| 825 | getService(*dbus, ipmi::boot::bootModeIntf, bootObjPath); |
| 826 | setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootModeIntf, |
| 827 | ipmi::boot::bootModeProp, bootOption); |
| 828 | |
| 829 | // SETTING BOOT SOURCE PROPERTY |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 830 | auto bootOrder = ipmi::boot::sourceIpmiToDbus.at(data[1]); |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 831 | std::string bootSource = |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 832 | sdbusplus::message::convert_to_string<boot::BootSource>(bootOrder); |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 833 | |
| 834 | service = getService(*dbus, ipmi::boot::bootSourceIntf, bootObjPath); |
| 835 | setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootSourceIntf, |
| 836 | ipmi::boot::bootSourceProp, bootSource); |
| 837 | |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 838 | // SETTING BOOT TYPE PROPERTY |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 839 | uint8_t bootTypeBit = data[0] & 0x01; |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 840 | auto bootTypeVal = ipmi::boot::typeIpmiToDbus.at(bootTypeBit); |
| 841 | |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 842 | std::string bootType = |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 843 | sdbusplus::message::convert_to_string<boot::BootType>(bootTypeVal); |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 844 | |
| 845 | service = getService(*dbus, ipmi::boot::bootTypeIntf, bootObjPath); |
| 846 | |
| 847 | setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootTypeIntf, |
| 848 | ipmi::boot::bootTypeProp, bootType); |
| 849 | |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 850 | nlohmann::json bootMode; |
| 851 | uint8_t mode = data[0]; |
| 852 | int i; |
| 853 | |
| 854 | bootMode["UEFI"] = (mode & BOOT_MODE_UEFI ? true : false); |
| 855 | bootMode["CMOS_CLR"] = (mode & BOOT_MODE_CMOS_CLR ? true : false); |
| 856 | bootMode["FORCE_BOOT"] = (mode & BOOT_MODE_FORCE_BOOT ? true : false); |
| 857 | bootMode["BOOT_FLAG"] = (mode & BOOT_MODE_BOOT_FLAG ? true : false); |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 858 | oemData[bootOrderKey][KEY_BOOT_MODE] = bootMode; |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 859 | |
| 860 | /* Initialize boot sequence array */ |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 861 | oemData[bootOrderKey][KEY_BOOT_SEQ] = {}; |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 862 | for (i = 1; i < SIZE_BOOT_ORDER; i++) |
| 863 | { |
| 864 | if (data[i] >= BOOT_SEQ_ARRAY_SIZE) |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 865 | oemData[bootOrderKey][KEY_BOOT_SEQ][i - 1] = "NA"; |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 866 | else |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 867 | oemData[bootOrderKey][KEY_BOOT_SEQ][i - 1] = bootSeq[data[i]]; |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 868 | } |
| 869 | |
| 870 | flushOemData(); |
| 871 | } |
| 872 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 873 | //---------------------------------------------------------------------- |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 874 | // Set Boot Order (CMD_OEM_SET_BOOT_ORDER) |
| 875 | //---------------------------------------------------------------------- |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 876 | ipmi::RspType<std::vector<uint8_t>> |
| 877 | ipmiOemSetBootOrder(ipmi::Context::ptr ctx, std::vector<uint8_t> data) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 878 | { |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 879 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 880 | uint8_t bootSeq[SIZE_BOOT_ORDER]; |
| 881 | size_t len = data.size(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 882 | |
| 883 | if (len != SIZE_BOOT_ORDER) |
| 884 | { |
| 885 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 886 | "Invalid Boot order length received"); |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 887 | return ipmi::responseReqDataLenInvalid(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 888 | } |
| 889 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 890 | std::copy(std::begin(data), std::end(data), bootSeq); |
Jayashree Dhanapal | 4ec8056 | 2022-06-28 15:41:47 +0530 | [diff] [blame] | 891 | std::optional<size_t> hostId = findHost(ctx->hostIdx); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 892 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 893 | if (!hostId) |
| 894 | { |
| 895 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 896 | "Invalid Host Id received"); |
| 897 | return ipmi::responseInvalidCommand(); |
| 898 | } |
| 899 | auto [bootObjPath, hostName] = ipmi::boot::objPath(*hostId); |
| 900 | |
| 901 | setBootOrder(bootObjPath, bootSeq, hostName); |
| 902 | |
| 903 | return ipmi::responseSuccess(data); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 904 | } |
| 905 | |
| 906 | //---------------------------------------------------------------------- |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 907 | // Get Boot Order (CMD_OEM_GET_BOOT_ORDER) |
| 908 | //---------------------------------------------------------------------- |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 909 | ipmi::RspType<uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t> |
| 910 | ipmiOemGetBootOrder(ipmi::Context::ptr ctx) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 911 | { |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 912 | uint8_t bootSeq[SIZE_BOOT_ORDER]; |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 913 | uint8_t mode = 0; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 914 | |
Jayashree Dhanapal | 4ec8056 | 2022-06-28 15:41:47 +0530 | [diff] [blame] | 915 | std::optional<size_t> hostId = findHost(ctx->hostIdx); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 916 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 917 | if (!hostId) |
| 918 | { |
| 919 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 920 | "Invalid Host Id received"); |
| 921 | return ipmi::responseInvalidCommand(); |
| 922 | } |
| 923 | auto [bootObjPath, hostName] = ipmi::boot::objPath(*hostId); |
| 924 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 925 | std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus(); |
| 926 | |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 927 | // GETTING PROPERTY OF MODE INTERFACE |
| 928 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 929 | std::string service = |
| 930 | getService(*dbus, ipmi::boot::bootModeIntf, bootObjPath); |
| 931 | Value variant = |
| 932 | getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootModeIntf, |
| 933 | ipmi::boot::bootModeProp); |
| 934 | |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 935 | auto bootMode = sdbusplus::message::convert_from_string<boot::BootMode>( |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 936 | std::get<std::string>(variant)); |
| 937 | |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 938 | uint8_t bootOption = ipmi::boot::modeDbusToIpmi.at(bootMode); |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 939 | |
| 940 | // GETTING PROPERTY OF SOURCE INTERFACE |
| 941 | |
| 942 | service = getService(*dbus, ipmi::boot::bootSourceIntf, bootObjPath); |
| 943 | variant = |
| 944 | getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootSourceIntf, |
| 945 | ipmi::boot::bootSourceProp); |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 946 | |
| 947 | auto bootSource = sdbusplus::message::convert_from_string<boot::BootSource>( |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 948 | std::get<std::string>(variant)); |
| 949 | |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 950 | uint8_t bootOrder = ipmi::boot::sourceDbusToIpmi.at(bootSource); |
| 951 | |
| 952 | // GETTING PROPERTY OF TYPE INTERFACE |
| 953 | |
| 954 | service = getService(*dbus, ipmi::boot::bootTypeIntf, bootObjPath); |
| 955 | variant = |
| 956 | getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootTypeIntf, |
| 957 | ipmi::boot::bootTypeProp); |
Jayashree Dhanapal | 77ee489 | 2022-04-08 16:53:51 +0530 | [diff] [blame] | 958 | |
| 959 | auto bootType = sdbusplus::message::convert_from_string<boot::BootType>( |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 960 | std::get<std::string>(variant)); |
| 961 | |
| 962 | uint8_t bootTypeVal = ipmi::boot::typeDbusToIpmi.at(bootType); |
| 963 | |
| 964 | uint8_t bootVal = bootOption | bootTypeVal; |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 965 | |
| 966 | if (oemData.find(hostName) == oemData.end()) |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 967 | { |
| 968 | /* Return default boot order 0100090203ff */ |
| 969 | uint8_t defaultBoot[SIZE_BOOT_ORDER] = { |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 970 | BOOT_MODE_UEFI, |
| 971 | static_cast<uint8_t>(bootMap["USB_DEV"]), |
| 972 | static_cast<uint8_t>(bootMap["NET_IPV6"]), |
| 973 | static_cast<uint8_t>(bootMap["SATA_HDD"]), |
| 974 | static_cast<uint8_t>(bootMap["SATA_CD"]), |
| 975 | 0xff}; |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 976 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 977 | memcpy(bootSeq, defaultBoot, SIZE_BOOT_ORDER); |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 978 | phosphor::logging::log<phosphor::logging::level::INFO>( |
| 979 | "Set default boot order"); |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 980 | setBootOrder(bootObjPath, defaultBoot, hostName); |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 981 | } |
| 982 | else |
| 983 | { |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 984 | nlohmann::json bootMode = oemData[hostName][KEY_BOOT_MODE]; |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 985 | if (bootMode["UEFI"]) |
| 986 | mode |= BOOT_MODE_UEFI; |
| 987 | if (bootMode["CMOS_CLR"]) |
| 988 | mode |= BOOT_MODE_CMOS_CLR; |
| 989 | if (bootMode["BOOT_FLAG"]) |
| 990 | mode |= BOOT_MODE_BOOT_FLAG; |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 991 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 992 | bootSeq[0] = mode; |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 993 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 994 | for (int i = 1; i < SIZE_BOOT_ORDER; i++) |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 995 | { |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 996 | std::string seqStr = oemData[hostName][KEY_BOOT_SEQ][i - 1]; |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 997 | if (bootMap.find(seqStr) != bootMap.end()) |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 998 | bootSeq[i] = bootMap[seqStr]; |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 999 | else |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 1000 | bootSeq[i] = 0xff; |
Vijay Khemka | 877d5dd | 2019-12-16 14:46:21 -0800 | [diff] [blame] | 1001 | } |
| 1002 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1003 | |
Jayashree Dhanapal | 778147d | 2022-03-30 16:48:53 +0530 | [diff] [blame] | 1004 | return ipmi::responseSuccess(bootVal, bootOrder, bootSeq[2], bootSeq[3], |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 1005 | bootSeq[4], bootSeq[5]); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1006 | } |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1007 | // Set Machine Config Info (CMD_OEM_SET_MACHINE_CONFIG_INFO) |
| 1008 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1009 | ipmi_ret_t ipmiOemSetMachineCfgInfo(ipmi_netfn_t, ipmi_cmd_t, |
| 1010 | ipmi_request_t request, ipmi_response_t, |
| 1011 | ipmi_data_len_t data_len, ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1012 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1013 | machineConfigInfo_t* req = reinterpret_cast<machineConfigInfo_t*>(request); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1014 | uint8_t len = *data_len; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1015 | |
| 1016 | *data_len = 0; |
| 1017 | |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1018 | if (len < sizeof(machineConfigInfo_t)) |
| 1019 | { |
| 1020 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1021 | "Invalid machine configuration length received"); |
| 1022 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 1023 | } |
| 1024 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1025 | if (req->chassis_type >= sizeof(chassisType) / sizeof(uint8_t*)) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1026 | oemData[KEY_MC_CONFIG][KEY_MC_CHAS_TYPE] = "UNKNOWN"; |
| 1027 | else |
| 1028 | oemData[KEY_MC_CONFIG][KEY_MC_CHAS_TYPE] = |
| 1029 | chassisType[req->chassis_type]; |
| 1030 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1031 | if (req->mb_type >= sizeof(mbType) / sizeof(uint8_t*)) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1032 | oemData[KEY_MC_CONFIG][KEY_MC_MB_TYPE] = "UNKNOWN"; |
| 1033 | else |
| 1034 | oemData[KEY_MC_CONFIG][KEY_MC_MB_TYPE] = mbType[req->mb_type]; |
| 1035 | |
| 1036 | oemData[KEY_MC_CONFIG][KEY_MC_PROC_CNT] = req->proc_cnt; |
| 1037 | oemData[KEY_MC_CONFIG][KEY_MC_MEM_CNT] = req->mem_cnt; |
| 1038 | oemData[KEY_MC_CONFIG][KEY_MC_HDD35_CNT] = req->hdd35_cnt; |
| 1039 | oemData[KEY_MC_CONFIG][KEY_MC_HDD25_CNT] = req->hdd25_cnt; |
| 1040 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1041 | if (req->riser_type >= sizeof(riserType) / sizeof(uint8_t*)) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1042 | oemData[KEY_MC_CONFIG][KEY_MC_RSR_TYPE] = "UNKNOWN"; |
| 1043 | else |
| 1044 | oemData[KEY_MC_CONFIG][KEY_MC_RSR_TYPE] = riserType[req->riser_type]; |
| 1045 | |
| 1046 | oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC] = {}; |
| 1047 | int i = 0; |
| 1048 | if (req->pcie_card_loc & BIT_0) |
| 1049 | oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT1"; |
| 1050 | if (req->pcie_card_loc & BIT_1) |
| 1051 | oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT2"; |
| 1052 | if (req->pcie_card_loc & BIT_2) |
| 1053 | oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT3"; |
| 1054 | if (req->pcie_card_loc & BIT_3) |
| 1055 | oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT4"; |
| 1056 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1057 | if (req->slot1_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*)) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1058 | oemData[KEY_MC_CONFIG][KEY_MC_SLOT1_TYPE] = "UNKNOWN"; |
| 1059 | else |
| 1060 | oemData[KEY_MC_CONFIG][KEY_MC_SLOT1_TYPE] = |
| 1061 | pcieType[req->slot1_pcie_type]; |
| 1062 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1063 | if (req->slot2_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*)) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1064 | oemData[KEY_MC_CONFIG][KEY_MC_SLOT2_TYPE] = "UNKNOWN"; |
| 1065 | else |
| 1066 | oemData[KEY_MC_CONFIG][KEY_MC_SLOT2_TYPE] = |
| 1067 | pcieType[req->slot2_pcie_type]; |
| 1068 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1069 | if (req->slot3_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*)) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1070 | oemData[KEY_MC_CONFIG][KEY_MC_SLOT3_TYPE] = "UNKNOWN"; |
| 1071 | else |
| 1072 | oemData[KEY_MC_CONFIG][KEY_MC_SLOT3_TYPE] = |
| 1073 | pcieType[req->slot3_pcie_type]; |
| 1074 | |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1075 | if (req->slot4_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*)) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1076 | oemData[KEY_MC_CONFIG][KEY_MC_SLOT4_TYPE] = "UNKNOWN"; |
| 1077 | else |
| 1078 | oemData[KEY_MC_CONFIG][KEY_MC_SLOT4_TYPE] = |
| 1079 | pcieType[req->slot4_pcie_type]; |
| 1080 | |
| 1081 | oemData[KEY_MC_CONFIG][KEY_MC_AEP_CNT] = req->aep_mem_cnt; |
| 1082 | |
| 1083 | flushOemData(); |
| 1084 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1085 | return IPMI_CC_OK; |
| 1086 | } |
| 1087 | |
| 1088 | //---------------------------------------------------------------------- |
| 1089 | // Set POST start (CMD_OEM_SET_POST_START) |
| 1090 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1091 | ipmi_ret_t ipmiOemSetPostStart(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, |
| 1092 | ipmi_response_t, ipmi_data_len_t data_len, |
| 1093 | ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1094 | { |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1095 | phosphor::logging::log<phosphor::logging::level::INFO>("POST Start Event"); |
| 1096 | |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1097 | /* Do nothing, return success */ |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1098 | *data_len = 0; |
| 1099 | return IPMI_CC_OK; |
| 1100 | } |
| 1101 | |
| 1102 | //---------------------------------------------------------------------- |
| 1103 | // Set POST End (CMD_OEM_SET_POST_END) |
| 1104 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1105 | ipmi_ret_t ipmiOemSetPostEnd(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, |
| 1106 | ipmi_response_t, ipmi_data_len_t data_len, |
| 1107 | ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1108 | { |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1109 | struct timespec ts; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1110 | |
| 1111 | phosphor::logging::log<phosphor::logging::level::INFO>("POST End Event"); |
| 1112 | |
| 1113 | *data_len = 0; |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1114 | |
| 1115 | // Timestamp post end time. |
| 1116 | clock_gettime(CLOCK_REALTIME, &ts); |
| 1117 | oemData[KEY_TS_SLED] = ts.tv_sec; |
| 1118 | flushOemData(); |
| 1119 | |
| 1120 | // Sync time with system |
| 1121 | // TODO: Add code for syncing time |
| 1122 | |
| 1123 | return IPMI_CC_OK; |
| 1124 | } |
| 1125 | |
| 1126 | //---------------------------------------------------------------------- |
| 1127 | // Set PPIN Info (CMD_OEM_SET_PPIN_INFO) |
| 1128 | //---------------------------------------------------------------------- |
| 1129 | // Inform BMC about PPIN data of 8 bytes for each CPU |
| 1130 | // |
| 1131 | // Request: |
| 1132 | // Byte 1:8 – CPU0 PPIN data |
| 1133 | // Optional: |
| 1134 | // Byte 9:16 – CPU1 PPIN data |
| 1135 | // |
| 1136 | // Response: |
| 1137 | // Byte 1 – Completion Code |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1138 | ipmi_ret_t ipmiOemSetPPINInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, |
| 1139 | ipmi_response_t, ipmi_data_len_t data_len, |
| 1140 | ipmi_context_t) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1141 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1142 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1143 | std::string ppinStr; |
| 1144 | int len; |
| 1145 | |
| 1146 | if (*data_len > SIZE_CPU_PPIN * 2) |
| 1147 | len = SIZE_CPU_PPIN * 2; |
| 1148 | else |
| 1149 | len = *data_len; |
| 1150 | *data_len = 0; |
| 1151 | |
| 1152 | ppinStr = bytesToStr(req, len); |
| 1153 | oemData[KEY_PPIN_INFO] = ppinStr.c_str(); |
| 1154 | flushOemData(); |
| 1155 | |
| 1156 | return IPMI_CC_OK; |
| 1157 | } |
| 1158 | |
| 1159 | //---------------------------------------------------------------------- |
| 1160 | // Set ADR Trigger (CMD_OEM_SET_ADR_TRIGGER) |
| 1161 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1162 | ipmi_ret_t ipmiOemSetAdrTrigger(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, |
| 1163 | ipmi_response_t, ipmi_data_len_t data_len, |
| 1164 | ipmi_context_t) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1165 | { |
| 1166 | /* Do nothing, return success */ |
| 1167 | *data_len = 0; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1168 | return IPMI_CC_OK; |
| 1169 | } |
| 1170 | |
Vijay Khemka | f2246ce | 2020-05-27 14:26:35 -0700 | [diff] [blame] | 1171 | // Helper function to set guid at offset in EEPROM |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1172 | [[maybe_unused]] static int setGUID(off_t offset, uint8_t* guid) |
Vijay Khemka | f2246ce | 2020-05-27 14:26:35 -0700 | [diff] [blame] | 1173 | { |
| 1174 | int fd = -1; |
| 1175 | ssize_t len; |
| 1176 | int ret = 0; |
| 1177 | |
| 1178 | errno = 0; |
| 1179 | |
| 1180 | // Check if file is present |
| 1181 | if (access(FRU_EEPROM, F_OK) == -1) |
| 1182 | { |
| 1183 | std::cerr << "Unable to access: " << FRU_EEPROM << std::endl; |
| 1184 | return errno; |
| 1185 | } |
| 1186 | |
| 1187 | // Open the file |
| 1188 | fd = open(FRU_EEPROM, O_WRONLY); |
| 1189 | if (fd == -1) |
| 1190 | { |
| 1191 | std::cerr << "Unable to open: " << FRU_EEPROM << std::endl; |
| 1192 | return errno; |
| 1193 | } |
| 1194 | |
| 1195 | // seek to the offset |
| 1196 | lseek(fd, offset, SEEK_SET); |
| 1197 | |
| 1198 | // Write bytes to location |
| 1199 | len = write(fd, guid, GUID_SIZE); |
| 1200 | if (len != GUID_SIZE) |
| 1201 | { |
| 1202 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1203 | "GUID write data to EEPROM failed"); |
| 1204 | ret = errno; |
| 1205 | } |
| 1206 | |
| 1207 | close(fd); |
| 1208 | return ret; |
| 1209 | } |
| 1210 | |
| 1211 | //---------------------------------------------------------------------- |
| 1212 | // Set System GUID (CMD_OEM_SET_SYSTEM_GUID) |
| 1213 | //---------------------------------------------------------------------- |
Manikandan Elumalai | 5f8e343 | 2020-12-02 03:46:55 +0530 | [diff] [blame] | 1214 | #if BIC_ENABLED |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1215 | ipmi::RspType<> ipmiOemSetSystemGuid(ipmi::Context::ptr ctx, uint8_t, |
Manikandan Elumalai | 5f8e343 | 2020-12-02 03:46:55 +0530 | [diff] [blame] | 1216 | std::vector<uint8_t> reqData) |
| 1217 | { |
| 1218 | std::vector<uint8_t> respData; |
| 1219 | |
| 1220 | if (reqData.size() != GUID_SIZE) // 16bytes |
| 1221 | { |
| 1222 | |
| 1223 | return ipmi::responseReqDataLenInvalid(); |
| 1224 | } |
| 1225 | |
Manikandan Elumalai | 5f8e343 | 2020-12-02 03:46:55 +0530 | [diff] [blame] | 1226 | uint8_t bicAddr = (uint8_t)ctx->hostIdx << 2; |
| 1227 | |
| 1228 | if (sendBicCmd(ctx->netFn, ctx->cmd, bicAddr, reqData, respData)) |
| 1229 | return ipmi::responseUnspecifiedError(); |
| 1230 | |
| 1231 | return ipmi::responseSuccess(); |
| 1232 | } |
| 1233 | |
| 1234 | #else |
Vijay Khemka | f2246ce | 2020-05-27 14:26:35 -0700 | [diff] [blame] | 1235 | ipmi_ret_t ipmiOemSetSystemGuid(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 1236 | ipmi_request_t request, |
| 1237 | ipmi_response_t response, |
| 1238 | ipmi_data_len_t data_len, |
| 1239 | ipmi_context_t context) |
| 1240 | { |
| 1241 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
| 1242 | |
| 1243 | if (*data_len != GUID_SIZE) // 16bytes |
| 1244 | { |
| 1245 | *data_len = 0; |
| 1246 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 1247 | } |
| 1248 | |
| 1249 | *data_len = 0; |
| 1250 | |
| 1251 | if (setGUID(OFFSET_SYS_GUID, req)) |
| 1252 | { |
| 1253 | return IPMI_CC_UNSPECIFIED_ERROR; |
| 1254 | } |
| 1255 | return IPMI_CC_OK; |
| 1256 | } |
Manikandan Elumalai | 5f8e343 | 2020-12-02 03:46:55 +0530 | [diff] [blame] | 1257 | #endif |
Vijay Khemka | f2246ce | 2020-05-27 14:26:35 -0700 | [diff] [blame] | 1258 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1259 | //---------------------------------------------------------------------- |
| 1260 | // Set Bios Flash Info (CMD_OEM_SET_BIOS_FLASH_INFO) |
| 1261 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1262 | ipmi_ret_t ipmiOemSetBiosFlashInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, |
| 1263 | ipmi_response_t, ipmi_data_len_t data_len, |
| 1264 | ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1265 | { |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1266 | /* Do nothing, return success */ |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1267 | *data_len = 0; |
| 1268 | return IPMI_CC_OK; |
| 1269 | } |
| 1270 | |
| 1271 | //---------------------------------------------------------------------- |
| 1272 | // Set PPR (CMD_OEM_SET_PPR) |
| 1273 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1274 | ipmi_ret_t ipmiOemSetPpr(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, |
| 1275 | ipmi_response_t, ipmi_data_len_t data_len, |
| 1276 | ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1277 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1278 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1279 | uint8_t pprCnt, pprAct, pprIndex; |
| 1280 | uint8_t selParam = req[0]; |
| 1281 | uint8_t len = *data_len; |
| 1282 | std::stringstream ss; |
| 1283 | std::string str; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1284 | |
| 1285 | *data_len = 0; |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1286 | |
| 1287 | switch (selParam) |
| 1288 | { |
| 1289 | case PPR_ACTION: |
| 1290 | if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) == |
| 1291 | oemData[KEY_PPR].end()) |
| 1292 | return CC_PARAM_NOT_SUPP_IN_CURR_STATE; |
| 1293 | |
| 1294 | pprCnt = oemData[KEY_PPR][KEY_PPR_ROW_COUNT]; |
| 1295 | if (pprCnt == 0) |
| 1296 | return CC_PARAM_NOT_SUPP_IN_CURR_STATE; |
| 1297 | |
| 1298 | pprAct = req[1]; |
| 1299 | /* Check if ppr is enabled or disabled */ |
| 1300 | if (!(pprAct & 0x80)) |
| 1301 | pprAct = 0; |
| 1302 | |
| 1303 | oemData[KEY_PPR][KEY_PPR_ACTION] = pprAct; |
| 1304 | break; |
| 1305 | case PPR_ROW_COUNT: |
| 1306 | if (req[1] > 100) |
| 1307 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1308 | |
| 1309 | oemData[KEY_PPR][KEY_PPR_ROW_COUNT] = req[1]; |
| 1310 | break; |
| 1311 | case PPR_ROW_ADDR: |
| 1312 | pprIndex = req[1]; |
| 1313 | if (pprIndex > 100) |
| 1314 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1315 | |
| 1316 | if (len < PPR_ROW_ADDR_LEN + 1) |
| 1317 | { |
| 1318 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1319 | "Invalid PPR Row Address length received"); |
| 1320 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 1321 | } |
| 1322 | |
| 1323 | ss << std::hex; |
| 1324 | ss << std::setw(2) << std::setfill('0') << (int)pprIndex; |
| 1325 | |
| 1326 | oemData[KEY_PPR][ss.str()][KEY_PPR_INDEX] = pprIndex; |
| 1327 | |
| 1328 | str = bytesToStr(&req[1], PPR_ROW_ADDR_LEN); |
| 1329 | oemData[KEY_PPR][ss.str()][KEY_PPR_ROW_ADDR] = str.c_str(); |
| 1330 | break; |
| 1331 | case PPR_HISTORY_DATA: |
| 1332 | pprIndex = req[1]; |
| 1333 | if (pprIndex > 100) |
| 1334 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1335 | |
| 1336 | if (len < PPR_HST_DATA_LEN + 1) |
| 1337 | { |
| 1338 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1339 | "Invalid PPR history data length received"); |
| 1340 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 1341 | } |
| 1342 | |
| 1343 | ss << std::hex; |
| 1344 | ss << std::setw(2) << std::setfill('0') << (int)pprIndex; |
| 1345 | |
| 1346 | oemData[KEY_PPR][ss.str()][KEY_PPR_INDEX] = pprIndex; |
| 1347 | |
| 1348 | str = bytesToStr(&req[1], PPR_HST_DATA_LEN); |
| 1349 | oemData[KEY_PPR][ss.str()][KEY_PPR_HST_DATA] = str.c_str(); |
| 1350 | break; |
| 1351 | default: |
| 1352 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1353 | break; |
| 1354 | } |
| 1355 | |
| 1356 | flushOemData(); |
| 1357 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1358 | return IPMI_CC_OK; |
| 1359 | } |
| 1360 | |
| 1361 | //---------------------------------------------------------------------- |
| 1362 | // Get PPR (CMD_OEM_GET_PPR) |
| 1363 | //---------------------------------------------------------------------- |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1364 | ipmi_ret_t ipmiOemGetPpr(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, |
| 1365 | ipmi_response_t response, ipmi_data_len_t data_len, |
| 1366 | ipmi_context_t) |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1367 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1368 | uint8_t* req = reinterpret_cast<uint8_t*>(request); |
| 1369 | uint8_t* res = reinterpret_cast<uint8_t*>(response); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1370 | uint8_t pprCnt, pprIndex; |
| 1371 | uint8_t selParam = req[0]; |
| 1372 | std::stringstream ss; |
| 1373 | std::string str; |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1374 | |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1375 | /* Any failure will return zero length data */ |
| 1376 | *data_len = 0; |
| 1377 | |
| 1378 | switch (selParam) |
| 1379 | { |
| 1380 | case PPR_ACTION: |
| 1381 | res[0] = 0; |
| 1382 | *data_len = 1; |
| 1383 | |
| 1384 | if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) != |
| 1385 | oemData[KEY_PPR].end()) |
| 1386 | { |
| 1387 | pprCnt = oemData[KEY_PPR][KEY_PPR_ROW_COUNT]; |
| 1388 | if (pprCnt != 0) |
| 1389 | { |
| 1390 | if (oemData[KEY_PPR].find(KEY_PPR_ACTION) != |
| 1391 | oemData[KEY_PPR].end()) |
| 1392 | { |
| 1393 | res[0] = oemData[KEY_PPR][KEY_PPR_ACTION]; |
| 1394 | } |
| 1395 | } |
| 1396 | } |
| 1397 | break; |
| 1398 | case PPR_ROW_COUNT: |
| 1399 | res[0] = 0; |
| 1400 | *data_len = 1; |
| 1401 | if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) != |
| 1402 | oemData[KEY_PPR].end()) |
| 1403 | res[0] = oemData[KEY_PPR][KEY_PPR_ROW_COUNT]; |
| 1404 | break; |
| 1405 | case PPR_ROW_ADDR: |
| 1406 | pprIndex = req[1]; |
| 1407 | if (pprIndex > 100) |
| 1408 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1409 | |
| 1410 | ss << std::hex; |
| 1411 | ss << std::setw(2) << std::setfill('0') << (int)pprIndex; |
| 1412 | |
| 1413 | if (oemData[KEY_PPR].find(ss.str()) == oemData[KEY_PPR].end()) |
| 1414 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1415 | |
| 1416 | if (oemData[KEY_PPR][ss.str()].find(KEY_PPR_ROW_ADDR) == |
| 1417 | oemData[KEY_PPR][ss.str()].end()) |
| 1418 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1419 | |
| 1420 | str = oemData[KEY_PPR][ss.str()][KEY_PPR_ROW_ADDR]; |
| 1421 | *data_len = strToBytes(str, res); |
| 1422 | break; |
| 1423 | case PPR_HISTORY_DATA: |
| 1424 | pprIndex = req[1]; |
| 1425 | if (pprIndex > 100) |
| 1426 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1427 | |
| 1428 | ss << std::hex; |
| 1429 | ss << std::setw(2) << std::setfill('0') << (int)pprIndex; |
| 1430 | |
| 1431 | if (oemData[KEY_PPR].find(ss.str()) == oemData[KEY_PPR].end()) |
| 1432 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1433 | |
| 1434 | if (oemData[KEY_PPR][ss.str()].find(KEY_PPR_HST_DATA) == |
| 1435 | oemData[KEY_PPR][ss.str()].end()) |
| 1436 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1437 | |
| 1438 | str = oemData[KEY_PPR][ss.str()][KEY_PPR_HST_DATA]; |
| 1439 | *data_len = strToBytes(str, res); |
| 1440 | break; |
| 1441 | default: |
| 1442 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1443 | break; |
| 1444 | } |
| 1445 | |
| 1446 | return IPMI_CC_OK; |
| 1447 | } |
| 1448 | |
| 1449 | /* FB OEM QC Commands */ |
| 1450 | |
| 1451 | //---------------------------------------------------------------------- |
| 1452 | // Set Proc Info (CMD_OEM_Q_SET_PROC_INFO) |
| 1453 | //---------------------------------------------------------------------- |
| 1454 | //"Request: |
| 1455 | // Byte 1:3 – Manufacturer ID – XXYYZZ h, LSB first |
| 1456 | // Byte 4 – Processor Index, 0 base |
| 1457 | // Byte 5 – Parameter Selector |
| 1458 | // Byte 6..N – Configuration parameter data (see below for Parameters |
| 1459 | // of Processor Information) |
| 1460 | // Response: |
| 1461 | // Byte 1 – Completion code |
| 1462 | // |
| 1463 | // Parameter#1: (Processor Product Name) |
| 1464 | // |
| 1465 | // Byte 1..48 –Product name(ASCII code) |
| 1466 | // Ex. Intel(R) Xeon(R) CPU E5-2685 v3 @ 2.60GHz |
| 1467 | // |
| 1468 | // Param#2: Processor Basic Information |
| 1469 | // Byte 1 – Core Number |
| 1470 | // Byte 2 – Thread Number (LSB) |
| 1471 | // Byte 3 – Thread Number (MSB) |
| 1472 | // Byte 4 – Processor frequency in MHz (LSB) |
| 1473 | // Byte 5 – Processor frequency in MHz (MSB) |
| 1474 | // Byte 6..7 – Revision |
| 1475 | // |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 1476 | |
| 1477 | ipmi::RspType<> ipmiOemQSetProcInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t, |
| 1478 | uint8_t, uint8_t procIndex, |
| 1479 | uint8_t paramSel, |
| 1480 | std::vector<uint8_t> request) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1481 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1482 | uint8_t numParam = sizeof(cpuInfoKey) / sizeof(uint8_t*); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1483 | std::stringstream ss; |
| 1484 | std::string str; |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 1485 | uint8_t len = request.size(); |
| 1486 | auto hostId = findHost(ctx->hostIdx); |
| 1487 | if (!hostId) |
| 1488 | { |
| 1489 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1490 | "Invalid Host Id received"); |
| 1491 | return ipmi::responseInvalidCommand(); |
| 1492 | } |
| 1493 | std::string procInfo = KEY_Q_PROC_INFO + std::to_string(*hostId); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1494 | /* check for requested data params */ |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 1495 | if (len < 5 || paramSel < 1 || paramSel >= numParam) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1496 | { |
| 1497 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1498 | "Invalid parameter received"); |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 1499 | return ipmi::responseParmOutOfRange(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1500 | } |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1501 | ss << std::hex; |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 1502 | ss << std::setw(2) << std::setfill('0') << (int)procIndex; |
| 1503 | oemData[procInfo][ss.str()][KEY_PROC_INDEX] = procIndex; |
| 1504 | str = bytesToStr(request.data(), len); |
| 1505 | oemData[procInfo][ss.str()][cpuInfoKey[paramSel]] = str.c_str(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1506 | flushOemData(); |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 1507 | return ipmi::responseSuccess(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1508 | } |
| 1509 | |
| 1510 | //---------------------------------------------------------------------- |
| 1511 | // Get Proc Info (CMD_OEM_Q_GET_PROC_INFO) |
| 1512 | //---------------------------------------------------------------------- |
| 1513 | // Request: |
| 1514 | // Byte 1:3 – Manufacturer ID – XXYYZZ h, LSB first |
| 1515 | // Byte 4 – Processor Index, 0 base |
| 1516 | // Byte 5 – Parameter Selector |
| 1517 | // Response: |
| 1518 | // Byte 1 – Completion code |
| 1519 | // Byte 2..N – Configuration Parameter Data (see below for Parameters |
| 1520 | // of Processor Information) |
| 1521 | // |
| 1522 | // Parameter#1: (Processor Product Name) |
| 1523 | // |
| 1524 | // Byte 1..48 –Product name(ASCII code) |
| 1525 | // Ex. Intel(R) Xeon(R) CPU E5-2685 v3 @ 2.60GHz |
| 1526 | // |
| 1527 | // Param#2: Processor Basic Information |
| 1528 | // Byte 1 – Core Number |
| 1529 | // Byte 2 – Thread Number (LSB) |
| 1530 | // Byte 3 – Thread Number (MSB) |
| 1531 | // Byte 4 – Processor frequency in MHz (LSB) |
| 1532 | // Byte 5 – Processor frequency in MHz (MSB) |
| 1533 | // Byte 6..7 – Revision |
| 1534 | // |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 1535 | |
| 1536 | ipmi::RspType<std::vector<uint8_t>> |
| 1537 | ipmiOemQGetProcInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t, uint8_t, |
| 1538 | uint8_t procIndex, uint8_t paramSel) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1539 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1540 | uint8_t numParam = sizeof(cpuInfoKey) / sizeof(uint8_t*); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1541 | std::stringstream ss; |
| 1542 | std::string str; |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 1543 | uint8_t res[MAX_BUF]; |
| 1544 | auto hostId = findHost(ctx->hostIdx); |
| 1545 | if (!hostId) |
| 1546 | { |
| 1547 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1548 | "Invalid Host Id received"); |
| 1549 | return ipmi::responseInvalidCommand(); |
| 1550 | } |
| 1551 | std::string procInfo = KEY_Q_PROC_INFO + std::to_string(*hostId); |
| 1552 | if (paramSel < 1 || paramSel >= numParam) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1553 | { |
| 1554 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1555 | "Invalid parameter received"); |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 1556 | return ipmi::responseParmOutOfRange(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1557 | } |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1558 | ss << std::hex; |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 1559 | ss << std::setw(2) << std::setfill('0') << (int)procIndex; |
| 1560 | if (oemData[procInfo].find(ss.str()) == oemData[procInfo].end()) |
| 1561 | return ipmi::responseCommandNotAvailable(); |
| 1562 | if (oemData[procInfo][ss.str()].find(cpuInfoKey[paramSel]) == |
| 1563 | oemData[procInfo][ss.str()].end()) |
| 1564 | return ipmi::responseCommandNotAvailable(); |
| 1565 | str = oemData[procInfo][ss.str()][cpuInfoKey[paramSel]]; |
| 1566 | int dataLen = strToBytes(str, res); |
| 1567 | std::vector<uint8_t> response(&res[0], &res[dataLen]); |
| 1568 | return ipmi::responseSuccess(response); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1569 | } |
| 1570 | |
| 1571 | //---------------------------------------------------------------------- |
| 1572 | // Set Dimm Info (CMD_OEM_Q_SET_DIMM_INFO) |
| 1573 | //---------------------------------------------------------------------- |
| 1574 | // Request: |
| 1575 | // Byte 1:3 – Manufacturer ID – XXYYZZh, LSB first |
| 1576 | // Byte 4 – DIMM Index, 0 base |
| 1577 | // Byte 5 – Parameter Selector |
| 1578 | // Byte 6..N – Configuration parameter data (see below for Parameters |
| 1579 | // of DIMM Information) |
| 1580 | // Response: |
| 1581 | // Byte 1 – Completion code |
| 1582 | // |
| 1583 | // Param#1 (DIMM Location): |
| 1584 | // Byte 1 – DIMM Present |
| 1585 | // Byte 1 – DIMM Present |
| 1586 | // 01h – Present |
| 1587 | // FFh – Not Present |
| 1588 | // Byte 2 – Node Number, 0 base |
| 1589 | // Byte 3 – Channel Number , 0 base |
| 1590 | // Byte 4 – DIMM Number , 0 base |
| 1591 | // |
| 1592 | // Param#2 (DIMM Type): |
| 1593 | // Byte 1 – DIMM Type |
| 1594 | // Bit [7:6] |
| 1595 | // For DDR3 |
| 1596 | // 00 – Normal Voltage (1.5V) |
| 1597 | // 01 – Ultra Low Voltage (1.25V) |
| 1598 | // 10 – Low Voltage (1.35V) |
| 1599 | // 11 – Reserved |
| 1600 | // For DDR4 |
| 1601 | // 00 – Reserved |
| 1602 | // 01 – Reserved |
| 1603 | // 10 – Reserved |
| 1604 | // 11 – Normal Voltage (1.2V) |
| 1605 | // Bit [5:0] |
| 1606 | // 0x00 – SDRAM |
| 1607 | // 0x01 – DDR-1 RAM |
| 1608 | // 0x02 – Rambus |
| 1609 | // 0x03 – DDR-2 RAM |
| 1610 | // 0x04 – FBDIMM |
| 1611 | // 0x05 – DDR-3 RAM |
| 1612 | // 0x06 – DDR-4 RAM |
| 1613 | // |
| 1614 | // Param#3 (DIMM Speed): |
| 1615 | // Byte 1..2 – DIMM speed in MHz, LSB |
| 1616 | // Byte 3..6 – DIMM size in Mbytes, LSB |
| 1617 | // |
| 1618 | // Param#4 (Module Part Number): |
| 1619 | // Byte 1..20 –Module Part Number (JEDEC Standard No. 21-C) |
| 1620 | // |
| 1621 | // Param#5 (Module Serial Number): |
| 1622 | // Byte 1..4 –Module Serial Number (JEDEC Standard No. 21-C) |
| 1623 | // |
| 1624 | // Param#6 (Module Manufacturer ID): |
| 1625 | // Byte 1 - Module Manufacturer ID, LSB |
| 1626 | // Byte 2 - Module Manufacturer ID, MSB |
| 1627 | // |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1628 | ipmi::RspType<> ipmiOemQSetDimmInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t, |
| 1629 | uint8_t, uint8_t dimmIndex, |
| 1630 | uint8_t paramSel, |
| 1631 | std::vector<uint8_t> request) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1632 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1633 | uint8_t numParam = sizeof(dimmInfoKey) / sizeof(uint8_t*); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1634 | std::stringstream ss; |
| 1635 | std::string str; |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1636 | uint8_t len = request.size(); |
| 1637 | std::string dimmType; |
| 1638 | readDimmType(dimmType, dimmIndex); |
Patrick Williams | 6d9e9a7 | 2022-07-18 10:30:50 -0500 | [diff] [blame] | 1639 | auto hostId = findHost(ctx->hostIdx); |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1640 | if (!hostId) |
| 1641 | { |
| 1642 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1643 | "Invalid Host Id received"); |
| 1644 | return ipmi::responseInvalidCommand(); |
| 1645 | } |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1646 | |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1647 | std::string dimmInfo = KEY_Q_DIMM_INFO + std::to_string(*hostId); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1648 | |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1649 | if (len < 3 || paramSel < 1 || paramSel >= numParam) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1650 | { |
| 1651 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1652 | "Invalid parameter received"); |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1653 | return ipmi::responseParmOutOfRange(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1654 | } |
| 1655 | |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1656 | ss << std::hex; |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1657 | ss << (int)dimmIndex; |
| 1658 | oemData[dimmInfo][ss.str()][KEY_DIMM_INDEX] = dimmIndex; |
| 1659 | oemData[dimmInfo][ss.str()][KEY_DIMM_TYPE] = dimmType; |
| 1660 | str = bytesToStr(request.data(), len); |
| 1661 | oemData[dimmInfo][ss.str()][dimmInfoKey[paramSel]] = str.c_str(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1662 | flushOemData(); |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1663 | return ipmi::responseSuccess(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1664 | } |
| 1665 | |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1666 | // Get Dimm Info (CMD_OEM_Q_GET_DIMM_INFO) |
| 1667 | //---------------------------------------------------------------------- |
| 1668 | // Request: |
| 1669 | // Byte 1:3 – Manufacturer ID – XXYYZZh, LSB first |
| 1670 | // Byte 4 – DIMM Index, 0 base |
| 1671 | // Byte 5 – Parameter Selector |
| 1672 | // Byte 6..N – Configuration parameter data (see below for Parameters |
| 1673 | // of DIMM Information) |
| 1674 | // Response: |
| 1675 | // Byte 1 – Completion code |
| 1676 | // Byte 2..N – Configuration Parameter Data (see Table_1213h Parameters |
| 1677 | // of DIMM Information) |
| 1678 | // |
| 1679 | // Param#1 (DIMM Location): |
| 1680 | // Byte 1 – DIMM Present |
| 1681 | // Byte 1 – DIMM Present |
| 1682 | // 01h – Present |
| 1683 | // FFh – Not Present |
| 1684 | // Byte 2 – Node Number, 0 base |
| 1685 | // Byte 3 – Channel Number , 0 base |
| 1686 | // Byte 4 – DIMM Number , 0 base |
| 1687 | // |
| 1688 | // Param#2 (DIMM Type): |
| 1689 | // Byte 1 – DIMM Type |
| 1690 | // Bit [7:6] |
| 1691 | // For DDR3 |
| 1692 | // 00 – Normal Voltage (1.5V) |
| 1693 | // 01 – Ultra Low Voltage (1.25V) |
| 1694 | // 10 – Low Voltage (1.35V) |
| 1695 | // 11 – Reserved |
| 1696 | // For DDR4 |
| 1697 | // 00 – Reserved |
| 1698 | // 01 – Reserved |
| 1699 | // 10 – Reserved |
| 1700 | // 11 – Normal Voltage (1.2V) |
| 1701 | // Bit [5:0] |
| 1702 | // 0x00 – SDRAM |
| 1703 | // 0x01 – DDR-1 RAM |
| 1704 | // 0x02 – Rambus |
| 1705 | // 0x03 – DDR-2 RAM |
| 1706 | // 0x04 – FBDIMM |
| 1707 | // 0x05 – DDR-3 RAM |
| 1708 | // 0x06 – DDR-4 RAM |
| 1709 | // |
| 1710 | // Param#3 (DIMM Speed): |
| 1711 | // Byte 1..2 – DIMM speed in MHz, LSB |
| 1712 | // Byte 3..6 – DIMM size in Mbytes, LSB |
| 1713 | // |
| 1714 | // Param#4 (Module Part Number): |
| 1715 | // Byte 1..20 –Module Part Number (JEDEC Standard No. 21-C) |
| 1716 | // |
| 1717 | // Param#5 (Module Serial Number): |
| 1718 | // Byte 1..4 –Module Serial Number (JEDEC Standard No. 21-C) |
| 1719 | // |
| 1720 | // Param#6 (Module Manufacturer ID): |
| 1721 | // Byte 1 - Module Manufacturer ID, LSB |
| 1722 | // Byte 2 - Module Manufacturer ID, MSB |
| 1723 | // |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1724 | ipmi::RspType<std::vector<uint8_t>> |
| 1725 | ipmiOemQGetDimmInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t, uint8_t, |
| 1726 | uint8_t dimmIndex, uint8_t paramSel) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1727 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1728 | uint8_t numParam = sizeof(dimmInfoKey) / sizeof(uint8_t*); |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1729 | uint8_t res[MAX_BUF]; |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1730 | std::stringstream ss; |
| 1731 | std::string str; |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1732 | std::string dimmType; |
| 1733 | readDimmType(dimmType, dimmIndex); |
Patrick Williams | 6d9e9a7 | 2022-07-18 10:30:50 -0500 | [diff] [blame] | 1734 | auto hostId = findHost(ctx->hostIdx); |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1735 | if (!hostId) |
| 1736 | { |
| 1737 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1738 | "Invalid Host Id received"); |
| 1739 | return ipmi::responseInvalidCommand(); |
| 1740 | } |
| 1741 | std::string dimmInfo = KEY_Q_DIMM_INFO + std::to_string(*hostId); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1742 | |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1743 | if (paramSel < 1 || paramSel >= numParam) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1744 | { |
| 1745 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1746 | "Invalid parameter received"); |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1747 | return ipmi::responseParmOutOfRange(); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1748 | } |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1749 | ss << std::hex; |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 1750 | ss << (int)dimmIndex; |
| 1751 | oemData[dimmInfo][ss.str()][KEY_DIMM_TYPE] = dimmType; |
| 1752 | if (oemData[dimmInfo].find(ss.str()) == oemData[dimmInfo].end()) |
| 1753 | return ipmi::responseCommandNotAvailable(); |
| 1754 | if (oemData[dimmInfo][ss.str()].find(dimmInfoKey[paramSel]) == |
| 1755 | oemData[dimmInfo][ss.str()].end()) |
| 1756 | return ipmi::responseCommandNotAvailable(); |
| 1757 | str = oemData[dimmInfo][ss.str()][dimmInfoKey[paramSel]]; |
| 1758 | int data_length = strToBytes(str, res); |
| 1759 | std::vector<uint8_t> response(&res[0], &res[data_length]); |
| 1760 | return ipmi::responseSuccess(response); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1761 | } |
| 1762 | |
| 1763 | //---------------------------------------------------------------------- |
| 1764 | // Set Drive Info (CMD_OEM_Q_SET_DRIVE_INFO) |
| 1765 | //---------------------------------------------------------------------- |
| 1766 | // BIOS issue this command to provide HDD information to BMC. |
| 1767 | // |
| 1768 | // BIOS just can get information by standard ATA / SMART command for |
| 1769 | // OB SATA controller. |
| 1770 | // BIOS can get |
| 1771 | // 1. Serial Number |
| 1772 | // 2. Model Name |
| 1773 | // 3. HDD FW Version |
| 1774 | // 4. HDD Capacity |
| 1775 | // 5. HDD WWN |
| 1776 | // |
| 1777 | // Use Get HDD info Param #5 to know the MAX HDD info index. |
| 1778 | // |
| 1779 | // Request: |
| 1780 | // Byte 1:3 – Quanta Manufacturer ID – 001C4Ch, LSB first |
| 1781 | // Byte 4 – |
| 1782 | // [7:4] Reserved |
| 1783 | // [3:0] HDD Controller Type |
| 1784 | // 0x00 – BIOS |
| 1785 | // 0x01 – Expander |
| 1786 | // 0x02 – LSI |
| 1787 | // Byte 5 – HDD Info Index, 0 base |
| 1788 | // Byte 6 – Parameter Selector |
| 1789 | // Byte 7..N – Configuration parameter data (see Table_1415h Parameters of HDD |
| 1790 | // Information) |
| 1791 | // |
| 1792 | // Response: |
| 1793 | // Byte 1 – Completion Code |
| 1794 | // |
| 1795 | // Param#0 (HDD Location): |
| 1796 | // Byte 1 – Controller |
| 1797 | // [7:3] Device Number |
| 1798 | // [2:0] Function Number |
| 1799 | // For Intel C610 series (Wellsburg) |
| 1800 | // D31:F2 (0xFA) – SATA control 1 |
| 1801 | // D31:F5 (0xFD) – SATA control 2 |
| 1802 | // D17:F4 (0x8C) – sSata control |
| 1803 | // Byte 2 – Port Number |
| 1804 | // Byte 3 – Location (0xFF: No HDD Present) |
| 1805 | // BIOS default set Byte 3 to 0xFF, if No HDD Present. And then skip send param |
| 1806 | // #1~4, #6, #7 to BMC (still send param #5) BIOS default set Byte 3 to 0, if |
| 1807 | // the HDD present. BMC or other people who know the HDD location has |
| 1808 | // responsibility for update Location info |
| 1809 | // |
| 1810 | // Param#1 (Serial Number): |
| 1811 | // Bytes 1..33: HDD Serial Number |
| 1812 | // |
| 1813 | // Param#2 (Model Name): |
| 1814 | // Byte 1..33 – HDD Model Name |
| 1815 | // |
| 1816 | // Param#3 (HDD FW Version): |
| 1817 | // Byte 1..17 –HDD FW version |
| 1818 | // |
| 1819 | // Param#4 (Capacity): |
| 1820 | // Byte 1..4 –HDD Block Size, LSB |
| 1821 | // Byte 5..12 - HDD Block Number, LSB |
| 1822 | // HDD Capacity = HDD Block size * HDD BLock number (Unit Byte) |
| 1823 | // |
| 1824 | // Param#5 (Max HDD Quantity): |
| 1825 | // Byte 1 - Max HDD Quantity |
| 1826 | // Max supported port numbers in this PCH |
| 1827 | // |
| 1828 | // Param#6 (HDD Type) |
| 1829 | // Byte 1 – HDD Type |
| 1830 | // 0h – Reserved |
| 1831 | // 1h – SAS |
| 1832 | // 2h – SATA |
| 1833 | // 3h – PCIE SSD (NVME) |
| 1834 | // |
| 1835 | // Param#7 (HDD WWN) |
| 1836 | // Data 1...8: HDD World Wide Name, LSB |
| 1837 | // |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1838 | ipmi_ret_t ipmiOemQSetDriveInfo(ipmi_netfn_t, ipmi_cmd_t, |
| 1839 | ipmi_request_t request, ipmi_response_t, |
| 1840 | ipmi_data_len_t data_len, ipmi_context_t) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1841 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1842 | qDriveInfo_t* req = reinterpret_cast<qDriveInfo_t*>(request); |
| 1843 | uint8_t numParam = sizeof(driveInfoKey) / sizeof(uint8_t*); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1844 | uint8_t ctrlType = req->hddCtrlType & 0x0f; |
| 1845 | std::stringstream ss; |
| 1846 | std::string str; |
| 1847 | uint8_t len = *data_len; |
| 1848 | |
| 1849 | *data_len = 0; |
| 1850 | |
| 1851 | /* check for requested data params */ |
| 1852 | if (len < 6 || req->paramSel < 1 || req->paramSel >= numParam || |
| 1853 | ctrlType > 2) |
| 1854 | { |
| 1855 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1856 | "Invalid parameter received"); |
| 1857 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1858 | } |
| 1859 | |
| 1860 | len = len - 6; // Get Actual data length |
| 1861 | |
| 1862 | ss << std::hex; |
| 1863 | ss << std::setw(2) << std::setfill('0') << (int)req->hddIndex; |
| 1864 | oemData[KEY_Q_DRIVE_INFO][KEY_HDD_CTRL_TYPE] = req->hddCtrlType; |
| 1865 | oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()][KEY_HDD_INDEX] = |
| 1866 | req->hddIndex; |
| 1867 | |
| 1868 | str = bytesToStr(req->data, len); |
| 1869 | oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()] |
| 1870 | [driveInfoKey[req->paramSel]] = str.c_str(); |
| 1871 | flushOemData(); |
| 1872 | |
| 1873 | return IPMI_CC_OK; |
| 1874 | } |
| 1875 | |
| 1876 | //---------------------------------------------------------------------- |
| 1877 | // Get Drive Info (CMD_OEM_Q_GET_DRIVE_INFO) |
| 1878 | //---------------------------------------------------------------------- |
| 1879 | // BMC needs to check HDD presented or not first. If NOT presented, return |
| 1880 | // completion code 0xD5. |
| 1881 | // |
| 1882 | // Request: |
| 1883 | // Byte 1:3 – Quanta Manufacturer ID – 001C4Ch, LSB first |
| 1884 | // Byte 4 – |
| 1885 | //[7:4] Reserved |
| 1886 | //[3:0] HDD Controller Type |
| 1887 | // 0x00 – BIOS |
| 1888 | // 0x01 – Expander |
| 1889 | // 0x02 – LSI |
| 1890 | // Byte 5 – HDD Index, 0 base |
| 1891 | // Byte 6 – Parameter Selector (See Above Set HDD Information) |
| 1892 | // Response: |
| 1893 | // Byte 1 – Completion Code |
| 1894 | // 0xD5 – Not support in current status (HDD Not Present) |
| 1895 | // Byte 2..N – Configuration parameter data (see Table_1415h Parameters of HDD |
| 1896 | // Information) |
| 1897 | // |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1898 | ipmi_ret_t ipmiOemQGetDriveInfo(ipmi_netfn_t, ipmi_cmd_t, |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1899 | ipmi_request_t request, |
| 1900 | ipmi_response_t response, |
Willy Tu | e39f939 | 2022-06-15 13:24:20 -0700 | [diff] [blame] | 1901 | ipmi_data_len_t data_len, ipmi_context_t) |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1902 | { |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1903 | qDriveInfo_t* req = reinterpret_cast<qDriveInfo_t*>(request); |
| 1904 | uint8_t numParam = sizeof(driveInfoKey) / sizeof(uint8_t*); |
| 1905 | uint8_t* res = reinterpret_cast<uint8_t*>(response); |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1906 | uint8_t ctrlType = req->hddCtrlType & 0x0f; |
| 1907 | std::stringstream ss; |
| 1908 | std::string str; |
| 1909 | |
| 1910 | *data_len = 0; |
| 1911 | |
| 1912 | /* check for requested data params */ |
| 1913 | if (req->paramSel < 1 || req->paramSel >= numParam || ctrlType > 2) |
| 1914 | { |
| 1915 | phosphor::logging::log<phosphor::logging::level::ERR>( |
| 1916 | "Invalid parameter received"); |
| 1917 | return IPMI_CC_PARM_OUT_OF_RANGE; |
| 1918 | } |
| 1919 | |
| 1920 | if (oemData[KEY_Q_DRIVE_INFO].find(ctrlTypeKey[ctrlType]) == |
| 1921 | oemData[KEY_Q_DRIVE_INFO].end()) |
| 1922 | return CC_PARAM_NOT_SUPP_IN_CURR_STATE; |
| 1923 | |
| 1924 | ss << std::hex; |
| 1925 | ss << std::setw(2) << std::setfill('0') << (int)req->hddIndex; |
| 1926 | |
| 1927 | if (oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]].find(ss.str()) == |
| 1928 | oemData[KEY_Q_DRIVE_INFO].end()) |
| 1929 | return CC_PARAM_NOT_SUPP_IN_CURR_STATE; |
| 1930 | |
| 1931 | if (oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()].find( |
| 1932 | dimmInfoKey[req->paramSel]) == |
| 1933 | oemData[KEY_Q_DRIVE_INFO][ss.str()].end()) |
| 1934 | return CC_PARAM_NOT_SUPP_IN_CURR_STATE; |
| 1935 | |
| 1936 | str = oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()] |
| 1937 | [dimmInfoKey[req->paramSel]]; |
| 1938 | *data_len = strToBytes(str, res); |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1939 | |
| 1940 | return IPMI_CC_OK; |
| 1941 | } |
| 1942 | |
Vijay Khemka | dd14c0f | 2020-03-18 14:48:13 -0700 | [diff] [blame] | 1943 | /* Helper function for sending DCMI commands to ME and getting response back */ |
| 1944 | ipmi::RspType<std::vector<uint8_t>> sendDCMICmd(uint8_t cmd, |
Vijay Khemka | 63c99be | 2020-05-27 19:14:35 -0700 | [diff] [blame] | 1945 | std::vector<uint8_t>& cmdData) |
Vijay Khemka | dd14c0f | 2020-03-18 14:48:13 -0700 | [diff] [blame] | 1946 | { |
| 1947 | std::vector<uint8_t> respData; |
| 1948 | |
| 1949 | /* Add group id as first byte to request for ME command */ |
| 1950 | cmdData.insert(cmdData.begin(), groupDCMI); |
| 1951 | |
| 1952 | if (sendMeCmd(ipmi::netFnGroup, cmd, cmdData, respData)) |
| 1953 | return ipmi::responseUnspecifiedError(); |
| 1954 | |
| 1955 | /* Remove group id as first byte as it will be added by IPMID */ |
| 1956 | respData.erase(respData.begin()); |
| 1957 | |
| 1958 | return ipmi::responseSuccess(std::move(respData)); |
| 1959 | } |
| 1960 | |
| 1961 | /* DCMI Command handellers. */ |
| 1962 | |
| 1963 | ipmi::RspType<std::vector<uint8_t>> |
| 1964 | ipmiOemDCMIGetPowerReading(std::vector<uint8_t> reqData) |
| 1965 | { |
| 1966 | return sendDCMICmd(ipmi::dcmi::cmdGetPowerReading, reqData); |
| 1967 | } |
| 1968 | |
| 1969 | ipmi::RspType<std::vector<uint8_t>> |
| 1970 | ipmiOemDCMIGetPowerLimit(std::vector<uint8_t> reqData) |
| 1971 | { |
| 1972 | return sendDCMICmd(ipmi::dcmi::cmdGetPowerLimit, reqData); |
| 1973 | } |
| 1974 | |
| 1975 | ipmi::RspType<std::vector<uint8_t>> |
| 1976 | ipmiOemDCMISetPowerLimit(std::vector<uint8_t> reqData) |
| 1977 | { |
| 1978 | return sendDCMICmd(ipmi::dcmi::cmdSetPowerLimit, reqData); |
| 1979 | } |
| 1980 | |
| 1981 | ipmi::RspType<std::vector<uint8_t>> |
| 1982 | ipmiOemDCMIApplyPowerLimit(std::vector<uint8_t> reqData) |
| 1983 | { |
| 1984 | return sendDCMICmd(ipmi::dcmi::cmdActDeactivatePwrLimit, reqData); |
| 1985 | } |
| 1986 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1987 | static void registerOEMFunctions(void) |
| 1988 | { |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1989 | /* Get OEM data from json file */ |
| 1990 | std::ifstream file(JSON_OEM_DATA_FILE); |
| 1991 | if (file) |
Vijay Khemka | feaa981 | 2019-08-27 15:08:08 -0700 | [diff] [blame] | 1992 | { |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1993 | file >> oemData; |
Vijay Khemka | feaa981 | 2019-08-27 15:08:08 -0700 | [diff] [blame] | 1994 | file.close(); |
| 1995 | } |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 1996 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 1997 | phosphor::logging::log<phosphor::logging::level::INFO>( |
| 1998 | "Registering OEM commands"); |
Vijay Khemka | 7c0aea4 | 2020-03-05 13:31:53 -0800 | [diff] [blame] | 1999 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 2000 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_INFO, |
| 2001 | NULL, ipmiOemDbgGetFrameInfo, |
| 2002 | PRIVILEGE_USER); // get debug frame info |
| 2003 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, |
| 2004 | CMD_OEM_USB_DBG_GET_UPDATED_FRAMES, NULL, |
| 2005 | ipmiOemDbgGetUpdFrames, |
| 2006 | PRIVILEGE_USER); // get debug updated frames |
| 2007 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_POST_DESC, |
| 2008 | NULL, ipmiOemDbgGetPostDesc, |
| 2009 | PRIVILEGE_USER); // get debug post description |
| 2010 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_GPIO_DESC, |
| 2011 | NULL, ipmiOemDbgGetGpioDesc, |
| 2012 | PRIVILEGE_USER); // get debug gpio description |
| 2013 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_DATA, |
| 2014 | NULL, ipmiOemDbgGetFrameData, |
| 2015 | PRIVILEGE_USER); // get debug frame data |
| 2016 | ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_CTRL_PANEL, |
| 2017 | NULL, ipmiOemDbgGetCtrlPanel, |
| 2018 | PRIVILEGE_USER); // get debug control panel |
| 2019 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_DIMM_INFO, NULL, |
| 2020 | ipmiOemSetDimmInfo, |
| 2021 | PRIVILEGE_USER); // Set Dimm Info |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 2022 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_BOARD_ID, NULL, |
| 2023 | ipmiOemGetBoardID, |
| 2024 | PRIVILEGE_USER); // Get Board ID |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 2025 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_MACHINE_CONFIG_INFO, NULL, |
| 2026 | ipmiOemSetMachineCfgInfo, |
| 2027 | PRIVILEGE_USER); // Set Machine Config Info |
| 2028 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_START, NULL, |
| 2029 | ipmiOemSetPostStart, |
| 2030 | PRIVILEGE_USER); // Set POST start |
| 2031 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_END, NULL, |
| 2032 | ipmiOemSetPostEnd, |
| 2033 | PRIVILEGE_USER); // Set POST End |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 2034 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPIN_INFO, NULL, |
| 2035 | ipmiOemSetPPINInfo, |
| 2036 | PRIVILEGE_USER); // Set PPIN Info |
Manikandan Elumalai | 5f8e343 | 2020-12-02 03:46:55 +0530 | [diff] [blame] | 2037 | #if BIC_ENABLED |
| 2038 | |
| 2039 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne, |
| 2040 | ipmi::cmdSetSystemGuid, ipmi::Privilege::User, |
| 2041 | ipmiOemSetSystemGuid); |
| 2042 | #else |
| 2043 | |
Vijay Khemka | f2246ce | 2020-05-27 14:26:35 -0700 | [diff] [blame] | 2044 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_SYSTEM_GUID, NULL, |
| 2045 | ipmiOemSetSystemGuid, |
| 2046 | PRIVILEGE_USER); // Set System GUID |
Manikandan Elumalai | 5f8e343 | 2020-12-02 03:46:55 +0530 | [diff] [blame] | 2047 | #endif |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 2048 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_ADR_TRIGGER, NULL, |
| 2049 | ipmiOemSetAdrTrigger, |
| 2050 | PRIVILEGE_USER); // Set ADR Trigger |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 2051 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_BIOS_FLASH_INFO, NULL, |
| 2052 | ipmiOemSetBiosFlashInfo, |
| 2053 | PRIVILEGE_USER); // Set Bios Flash Info |
| 2054 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPR, NULL, ipmiOemSetPpr, |
| 2055 | PRIVILEGE_USER); // Set PPR |
| 2056 | ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_PPR, NULL, ipmiOemGetPpr, |
| 2057 | PRIVILEGE_USER); // Get PPR |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 2058 | /* FB OEM QC Commands */ |
Karthikeyan Pasupathi | d532fec | 2022-07-14 14:43:42 +0530 | [diff] [blame^] | 2059 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour, |
| 2060 | CMD_OEM_Q_SET_PROC_INFO, ipmi::Privilege::User, |
| 2061 | ipmiOemQSetProcInfo); // Set Proc Info |
| 2062 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour, |
| 2063 | CMD_OEM_Q_GET_PROC_INFO, ipmi::Privilege::User, |
| 2064 | ipmiOemQGetProcInfo); // Get Proc Info |
Karthikeyan Pasupathi | 10ff3d8 | 2022-04-06 16:27:25 +0530 | [diff] [blame] | 2065 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour, |
| 2066 | ipmi::cmdSetQDimmInfo, ipmi::Privilege::User, |
| 2067 | ipmiOemQSetDimmInfo); // Set Dimm Info |
| 2068 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour, |
| 2069 | ipmi::cmdGetQDimmInfo, ipmi::Privilege::User, |
| 2070 | ipmiOemQGetDimmInfo); // Get Dimm Info |
Vijay Khemka | 1d4a069 | 2019-04-09 15:20:28 -0700 | [diff] [blame] | 2071 | ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_SET_DRIVE_INFO, NULL, |
| 2072 | ipmiOemQSetDriveInfo, |
| 2073 | PRIVILEGE_USER); // Set Drive Info |
| 2074 | ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_GET_DRIVE_INFO, NULL, |
| 2075 | ipmiOemQGetDriveInfo, |
| 2076 | PRIVILEGE_USER); // Get Drive Info |
Vijay Khemka | dd14c0f | 2020-03-18 14:48:13 -0700 | [diff] [blame] | 2077 | |
| 2078 | /* FB OEM DCMI Commands as per DCMI spec 1.5 Section 6 */ |
| 2079 | ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI, |
| 2080 | ipmi::dcmi::cmdGetPowerReading, |
| 2081 | ipmi::Privilege::User, |
| 2082 | ipmiOemDCMIGetPowerReading); // Get Power Reading |
| 2083 | |
| 2084 | ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI, |
| 2085 | ipmi::dcmi::cmdGetPowerLimit, |
| 2086 | ipmi::Privilege::User, |
| 2087 | ipmiOemDCMIGetPowerLimit); // Get Power Limit |
| 2088 | |
| 2089 | ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI, |
| 2090 | ipmi::dcmi::cmdSetPowerLimit, |
| 2091 | ipmi::Privilege::Operator, |
| 2092 | ipmiOemDCMISetPowerLimit); // Set Power Limit |
| 2093 | |
| 2094 | ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI, |
| 2095 | ipmi::dcmi::cmdActDeactivatePwrLimit, |
| 2096 | ipmi::Privilege::Operator, |
| 2097 | ipmiOemDCMIApplyPowerLimit); // Apply Power Limit |
| 2098 | |
Jayashree-D | f0cf665 | 2020-11-30 11:03:30 +0530 | [diff] [blame] | 2099 | /* FB OEM BOOT ORDER COMMANDS */ |
| 2100 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne, |
| 2101 | CMD_OEM_GET_BOOT_ORDER, ipmi::Privilege::User, |
| 2102 | ipmiOemGetBootOrder); // Get Boot Order |
| 2103 | |
| 2104 | ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne, |
| 2105 | CMD_OEM_SET_BOOT_ORDER, ipmi::Privilege::User, |
| 2106 | ipmiOemSetBootOrder); // Set Boot Order |
| 2107 | |
Vijay Khemka | e7d23d0 | 2019-03-08 13:13:40 -0800 | [diff] [blame] | 2108 | return; |
| 2109 | } |
| 2110 | |
| 2111 | } // namespace ipmi |