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