1e7d23d0eSVijay Khemka /* 2e7d23d0eSVijay Khemka * Copyright (c) 2018 Intel Corporation. 3e7d23d0eSVijay Khemka * Copyright (c) 2018-present Facebook. 4e7d23d0eSVijay Khemka * 5e7d23d0eSVijay Khemka * Licensed under the Apache License, Version 2.0 (the "License"); 6e7d23d0eSVijay Khemka * you may not use this file except in compliance with the License. 7e7d23d0eSVijay Khemka * You may obtain a copy of the License at 8e7d23d0eSVijay Khemka * 9e7d23d0eSVijay Khemka * http://www.apache.org/licenses/LICENSE-2.0 10e7d23d0eSVijay Khemka * 11e7d23d0eSVijay Khemka * Unless required by applicable law or agreed to in writing, software 12e7d23d0eSVijay Khemka * distributed under the License is distributed on an "AS IS" BASIS, 13e7d23d0eSVijay Khemka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14e7d23d0eSVijay Khemka * See the License for the specific language governing permissions and 15e7d23d0eSVijay Khemka * limitations under the License. 16e7d23d0eSVijay Khemka */ 17e7d23d0eSVijay Khemka 18e7d23d0eSVijay Khemka #include "xyz/openbmc_project/Common/error.hpp" 19f0cf6658SJayashree-D #include <xyz/openbmc_project/Control/Boot/Mode/server.hpp> 20f0cf6658SJayashree-D #include <xyz/openbmc_project/Control/Boot/Source/server.hpp> 21778147daSJayashree Dhanapal #include <xyz/openbmc_project/Control/Boot/Type/server.hpp> 22e7d23d0eSVijay Khemka 2363c99be4SVijay Khemka #include <ipmid/api.hpp> 241b6fae3fSVijay Khemka #include <ipmid/utils.hpp> 2563c99be4SVijay Khemka #include <commandutils.hpp> 2663c99be4SVijay Khemka #include <nlohmann/json.hpp> 2763c99be4SVijay Khemka #include <oemcommands.hpp> 28e7d23d0eSVijay Khemka #include <phosphor-logging/log.hpp> 29e7d23d0eSVijay Khemka #include <sdbusplus/bus.hpp> 3063c99be4SVijay Khemka 315f8e3435SManikandan Elumalai #include <ipmid/api.hpp> 325f8e3435SManikandan Elumalai #include <ipmid/api-types.hpp> 335f8e3435SManikandan Elumalai 3463c99be4SVijay Khemka #include <array> 3563c99be4SVijay Khemka #include <cstring> 3663c99be4SVijay Khemka #include <fstream> 3763c99be4SVijay Khemka #include <iomanip> 3863c99be4SVijay Khemka #include <iostream> 3963c99be4SVijay Khemka #include <sstream> 40e7d23d0eSVijay Khemka #include <string> 41e7d23d0eSVijay Khemka #include <vector> 42d532fecaSKarthikeyan Pasupathi #include <regex> 43e7d23d0eSVijay Khemka 44e7d23d0eSVijay Khemka #define SIZE_IANA_ID 3 45e7d23d0eSVijay Khemka 46e7d23d0eSVijay Khemka namespace ipmi 47e7d23d0eSVijay Khemka { 48a7231893SVijay Khemka 49a7231893SVijay Khemka using namespace phosphor::logging; 50a7231893SVijay Khemka 5198aabdb1SKarthikeyan Pasupathi size_t getSelectorPosition(); 52e7d23d0eSVijay Khemka static void registerOEMFunctions() __attribute__((constructor)); 53cd315e07SPatrick Williams sdbusplus::bus_t dbus(ipmid_get_sd_bus_connection()); // from ipmid/api.h 54e7d23d0eSVijay Khemka static constexpr size_t maxFRUStringLength = 0x3F; 555f8e3435SManikandan Elumalai constexpr uint8_t cmdSetSystemGuid = 0xEF; 56e7d23d0eSVijay Khemka 5710ff3d86SKarthikeyan Pasupathi constexpr uint8_t cmdSetQDimmInfo = 0x12; 5810ff3d86SKarthikeyan Pasupathi constexpr uint8_t cmdGetQDimmInfo = 0x13; 5910ff3d86SKarthikeyan Pasupathi 60cc0d6d92SVijay Khemka int plat_udbg_get_post_desc(uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t*, 61cc0d6d92SVijay Khemka uint8_t*); 6238183d66SVijay Khemka int plat_udbg_get_gpio_desc(uint8_t, uint8_t*, uint8_t*, uint8_t*, uint8_t*, 6338183d66SVijay Khemka uint8_t*); 64e7d23d0eSVijay Khemka ipmi_ret_t plat_udbg_get_frame_data(uint8_t, uint8_t, uint8_t*, uint8_t*, 65e7d23d0eSVijay Khemka uint8_t*); 66e7d23d0eSVijay Khemka ipmi_ret_t plat_udbg_control_panel(uint8_t, uint8_t, uint8_t, uint8_t*, 67e7d23d0eSVijay Khemka uint8_t*); 68dd14c0f7SVijay Khemka int sendMeCmd(uint8_t, uint8_t, std::vector<uint8_t>&, std::vector<uint8_t>&); 69dd14c0f7SVijay Khemka 705f8e3435SManikandan Elumalai int sendBicCmd(uint8_t, uint8_t, uint8_t, std::vector<uint8_t>&, 715f8e3435SManikandan Elumalai std::vector<uint8_t>&); 725f8e3435SManikandan Elumalai 73feaa9811SVijay Khemka nlohmann::json oemData __attribute__((init_priority(101))); 741b6fae3fSVijay Khemka 75f2246ce8SVijay Khemka static constexpr size_t GUID_SIZE = 16; 76f2246ce8SVijay Khemka // TODO Make offset and location runtime configurable to ensure we 77f2246ce8SVijay Khemka // can make each define their own locations. 78f2246ce8SVijay Khemka static constexpr off_t OFFSET_SYS_GUID = 0x17F0; 79f2246ce8SVijay Khemka static constexpr const char* FRU_EEPROM = "/sys/bus/i2c/devices/6-0054/eeprom"; 80f2246ce8SVijay Khemka 811b6fae3fSVijay Khemka enum class LanParam : uint8_t 821b6fae3fSVijay Khemka { 831b6fae3fSVijay Khemka INPROGRESS = 0, 841b6fae3fSVijay Khemka AUTHSUPPORT = 1, 851b6fae3fSVijay Khemka AUTHENABLES = 2, 861b6fae3fSVijay Khemka IP = 3, 871b6fae3fSVijay Khemka IPSRC = 4, 881b6fae3fSVijay Khemka MAC = 5, 891b6fae3fSVijay Khemka SUBNET = 6, 901b6fae3fSVijay Khemka GATEWAY = 12, 911b6fae3fSVijay Khemka VLAN = 20, 921b6fae3fSVijay Khemka CIPHER_SUITE_COUNT = 22, 931b6fae3fSVijay Khemka CIPHER_SUITE_ENTRIES = 23, 941b6fae3fSVijay Khemka IPV6 = 59, 951b6fae3fSVijay Khemka }; 961b6fae3fSVijay Khemka 97a7231893SVijay Khemka namespace network 98a7231893SVijay Khemka { 99a7231893SVijay Khemka 100a7231893SVijay Khemka constexpr auto ROOT = "/xyz/openbmc_project/network"; 101a7231893SVijay Khemka constexpr auto SERVICE = "xyz.openbmc_project.Network"; 102a7231893SVijay Khemka constexpr auto IPV4_TYPE = "ipv4"; 103a7231893SVijay Khemka constexpr auto IPV6_TYPE = "ipv6"; 104a7231893SVijay Khemka constexpr auto IPV4_PREFIX = "169.254"; 105a7231893SVijay Khemka constexpr auto IPV6_PREFIX = "fe80"; 106a7231893SVijay Khemka constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP"; 107a7231893SVijay Khemka constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress"; 108a7231893SVijay Khemka 109a7231893SVijay Khemka bool isLinkLocalIP(const std::string& address) 110a7231893SVijay Khemka { 111a7231893SVijay Khemka return address.find(IPV4_PREFIX) == 0 || address.find(IPV6_PREFIX) == 0; 112a7231893SVijay Khemka } 113a7231893SVijay Khemka 114cd315e07SPatrick Williams DbusObjectInfo getIPObject(sdbusplus::bus_t& bus, const std::string& interface, 115a7231893SVijay Khemka const std::string& serviceRoot, 116a7231893SVijay Khemka const std::string& match) 117a7231893SVijay Khemka { 118a7231893SVijay Khemka auto objectTree = getAllDbusObjects(bus, serviceRoot, interface, match); 119a7231893SVijay Khemka 120a7231893SVijay Khemka if (objectTree.empty()) 121a7231893SVijay Khemka { 122a7231893SVijay Khemka log<level::ERR>("No Object has implemented the IP interface", 123a7231893SVijay Khemka entry("INTERFACE=%s", interface.c_str())); 124a7231893SVijay Khemka } 125a7231893SVijay Khemka 126a7231893SVijay Khemka DbusObjectInfo objectInfo; 127a7231893SVijay Khemka 128a7231893SVijay Khemka for (auto& object : objectTree) 129a7231893SVijay Khemka { 130a7231893SVijay Khemka auto variant = 131a7231893SVijay Khemka ipmi::getDbusProperty(bus, object.second.begin()->first, 132a7231893SVijay Khemka object.first, IP_INTERFACE, "Address"); 133a7231893SVijay Khemka 134a7231893SVijay Khemka objectInfo = std::make_pair(object.first, object.second.begin()->first); 135a7231893SVijay Khemka 136a7231893SVijay Khemka // if LinkLocalIP found look for Non-LinkLocalIP 137a7231893SVijay Khemka if (isLinkLocalIP(std::get<std::string>(variant))) 138a7231893SVijay Khemka { 139a7231893SVijay Khemka continue; 140a7231893SVijay Khemka } 141a7231893SVijay Khemka else 142a7231893SVijay Khemka { 143a7231893SVijay Khemka break; 144a7231893SVijay Khemka } 145a7231893SVijay Khemka } 146a7231893SVijay Khemka return objectInfo; 147a7231893SVijay Khemka } 148a7231893SVijay Khemka 149a7231893SVijay Khemka } // namespace network 150a7231893SVijay Khemka 151f0cf6658SJayashree-D namespace boot 152f0cf6658SJayashree-D { 15377ee489fSJayashree Dhanapal using BootSource = 15477ee489fSJayashree Dhanapal sdbusplus::xyz::openbmc_project::Control::Boot::server::Source::Sources; 15577ee489fSJayashree Dhanapal using BootMode = 15677ee489fSJayashree Dhanapal sdbusplus::xyz::openbmc_project::Control::Boot::server::Mode::Modes; 15777ee489fSJayashree Dhanapal using BootType = 15877ee489fSJayashree Dhanapal sdbusplus::xyz::openbmc_project::Control::Boot::server::Type::Types; 159f0cf6658SJayashree-D 160f0cf6658SJayashree-D using IpmiValue = uint8_t; 161f0cf6658SJayashree-D 16277ee489fSJayashree Dhanapal std::map<IpmiValue, BootSource> sourceIpmiToDbus = { 16377ee489fSJayashree Dhanapal {0x0f, BootSource::Default}, {0x00, BootSource::RemovableMedia}, 16477ee489fSJayashree Dhanapal {0x01, BootSource::Network}, {0x02, BootSource::Disk}, 16577ee489fSJayashree Dhanapal {0x03, BootSource::ExternalMedia}, {0x09, BootSource::Network}}; 166f0cf6658SJayashree-D 16777ee489fSJayashree Dhanapal std::map<IpmiValue, BootMode> modeIpmiToDbus = {{0x06, BootMode::Setup}, 16877ee489fSJayashree Dhanapal {0x00, BootMode::Regular}}; 169f0cf6658SJayashree-D 17077ee489fSJayashree Dhanapal std::map<IpmiValue, BootType> typeIpmiToDbus = {{0x00, BootType::Legacy}, 17177ee489fSJayashree Dhanapal {0x01, BootType::EFI}}; 172778147daSJayashree Dhanapal 17377ee489fSJayashree Dhanapal std::map<std::optional<BootSource>, IpmiValue> sourceDbusToIpmi = { 17477ee489fSJayashree Dhanapal {BootSource::Default, 0x0f}, 17577ee489fSJayashree Dhanapal {BootSource::RemovableMedia, 0x00}, 17677ee489fSJayashree Dhanapal {BootSource::Network, 0x01}, 17777ee489fSJayashree Dhanapal {BootSource::Disk, 0x02}, 17877ee489fSJayashree Dhanapal {BootSource::ExternalMedia, 0x03}}; 179f0cf6658SJayashree-D 18077ee489fSJayashree Dhanapal std::map<std::optional<BootMode>, IpmiValue> modeDbusToIpmi = { 18177ee489fSJayashree Dhanapal {BootMode::Setup, 0x06}, {BootMode::Regular, 0x00}}; 182f0cf6658SJayashree-D 18377ee489fSJayashree Dhanapal std::map<std::optional<BootType>, IpmiValue> typeDbusToIpmi = { 18477ee489fSJayashree Dhanapal {BootType::Legacy, 0x00}, {BootType::EFI, 0x01}}; 185778147daSJayashree Dhanapal 186f0cf6658SJayashree-D static constexpr auto bootModeIntf = "xyz.openbmc_project.Control.Boot.Mode"; 187f0cf6658SJayashree-D static constexpr auto bootSourceIntf = 188f0cf6658SJayashree-D "xyz.openbmc_project.Control.Boot.Source"; 189778147daSJayashree Dhanapal static constexpr auto bootTypeIntf = "xyz.openbmc_project.Control.Boot.Type"; 190f0cf6658SJayashree-D static constexpr auto bootSourceProp = "BootSource"; 191f0cf6658SJayashree-D static constexpr auto bootModeProp = "BootMode"; 192778147daSJayashree Dhanapal static constexpr auto bootTypeProp = "BootType"; 193f0cf6658SJayashree-D 194f0cf6658SJayashree-D std::tuple<std::string, std::string> objPath(size_t id) 195f0cf6658SJayashree-D { 196f0cf6658SJayashree-D std::string hostName = "host" + std::to_string(id); 197f0cf6658SJayashree-D std::string bootObjPath = 198f0cf6658SJayashree-D "/xyz/openbmc_project/control/" + hostName + "/boot"; 199f0cf6658SJayashree-D return std::make_tuple(std::move(bootObjPath), std::move(hostName)); 200f0cf6658SJayashree-D } 201f0cf6658SJayashree-D 202f0cf6658SJayashree-D } // namespace boot 203f0cf6658SJayashree-D 2041d4a0697SVijay Khemka //---------------------------------------------------------------------- 2051d4a0697SVijay Khemka // Helper functions for storing oem data 2061d4a0697SVijay Khemka //---------------------------------------------------------------------- 2071d4a0697SVijay Khemka 2081d4a0697SVijay Khemka void flushOemData() 2091d4a0697SVijay Khemka { 2101d4a0697SVijay Khemka std::ofstream file(JSON_OEM_DATA_FILE); 2111d4a0697SVijay Khemka file << oemData; 212feaa9811SVijay Khemka file.close(); 2131d4a0697SVijay Khemka return; 2141d4a0697SVijay Khemka } 2151d4a0697SVijay Khemka 2161d4a0697SVijay Khemka std::string bytesToStr(uint8_t* byte, int len) 2171d4a0697SVijay Khemka { 2181d4a0697SVijay Khemka std::stringstream ss; 2191d4a0697SVijay Khemka int i; 2201d4a0697SVijay Khemka 2211d4a0697SVijay Khemka ss << std::hex; 2221d4a0697SVijay Khemka for (i = 0; i < len; i++) 2231d4a0697SVijay Khemka { 2241d4a0697SVijay Khemka ss << std::setw(2) << std::setfill('0') << (int)byte[i]; 2251d4a0697SVijay Khemka } 2261d4a0697SVijay Khemka 2271d4a0697SVijay Khemka return ss.str(); 2281d4a0697SVijay Khemka } 2291d4a0697SVijay Khemka 2301d4a0697SVijay Khemka int strToBytes(std::string& str, uint8_t* data) 2311d4a0697SVijay Khemka { 2321d4a0697SVijay Khemka std::string sstr; 233e39f9393SWilly Tu size_t i; 2341d4a0697SVijay Khemka 2351d4a0697SVijay Khemka for (i = 0; i < (str.length()) / 2; i++) 2361d4a0697SVijay Khemka { 2371d4a0697SVijay Khemka sstr = str.substr(i * 2, 2); 2381d4a0697SVijay Khemka data[i] = (uint8_t)std::strtol(sstr.c_str(), NULL, 16); 2391d4a0697SVijay Khemka } 2401d4a0697SVijay Khemka return i; 2411d4a0697SVijay Khemka } 2421d4a0697SVijay Khemka 24310ff3d86SKarthikeyan Pasupathi int readDimmType(std::string& data, uint8_t param) 24410ff3d86SKarthikeyan Pasupathi { 24510ff3d86SKarthikeyan Pasupathi nlohmann::json dimmObj; 24610ff3d86SKarthikeyan Pasupathi /* Get dimm type names stored in json file */ 24710ff3d86SKarthikeyan Pasupathi std::ifstream file(JSON_DIMM_TYPE_FILE); 24810ff3d86SKarthikeyan Pasupathi if (file) 24910ff3d86SKarthikeyan Pasupathi { 25010ff3d86SKarthikeyan Pasupathi file >> dimmObj; 25110ff3d86SKarthikeyan Pasupathi file.close(); 25210ff3d86SKarthikeyan Pasupathi } 25310ff3d86SKarthikeyan Pasupathi else 25410ff3d86SKarthikeyan Pasupathi { 25510ff3d86SKarthikeyan Pasupathi phosphor::logging::log<phosphor::logging::level::ERR>( 25610ff3d86SKarthikeyan Pasupathi "DIMM type names file not found", 25710ff3d86SKarthikeyan Pasupathi phosphor::logging::entry("DIMM_TYPE_FILE=%s", JSON_DIMM_TYPE_FILE)); 25810ff3d86SKarthikeyan Pasupathi return -1; 25910ff3d86SKarthikeyan Pasupathi } 26010ff3d86SKarthikeyan Pasupathi 26110ff3d86SKarthikeyan Pasupathi std::string dimmKey = "dimm_type" + std::to_string(param); 26210ff3d86SKarthikeyan Pasupathi auto obj = dimmObj[dimmKey]["short_name"]; 26310ff3d86SKarthikeyan Pasupathi data = obj; 26410ff3d86SKarthikeyan Pasupathi return 0; 26510ff3d86SKarthikeyan Pasupathi } 26610ff3d86SKarthikeyan Pasupathi 2671b6fae3fSVijay Khemka ipmi_ret_t getNetworkData(uint8_t lan_param, char* data) 2681b6fae3fSVijay Khemka { 2691b6fae3fSVijay Khemka ipmi_ret_t rc = IPMI_CC_OK; 270cd315e07SPatrick Williams sdbusplus::bus_t bus(ipmid_get_sd_bus_connection()); 2711b6fae3fSVijay Khemka 2721b6fae3fSVijay Khemka const std::string ethdevice = "eth0"; 2731b6fae3fSVijay Khemka 2741b6fae3fSVijay Khemka switch (static_cast<LanParam>(lan_param)) 2751b6fae3fSVijay Khemka { 276d1194024SVijay Khemka case LanParam::IP: 277d1194024SVijay Khemka { 278a7231893SVijay Khemka auto ethIP = ethdevice + "/" + ipmi::network::IPV4_TYPE; 2791b6fae3fSVijay Khemka std::string ipaddress; 280a7231893SVijay Khemka auto ipObjectInfo = ipmi::network::getIPObject( 2811b6fae3fSVijay Khemka bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT, ethIP); 2821b6fae3fSVijay Khemka 2831b6fae3fSVijay Khemka auto properties = ipmi::getAllDbusProperties( 2841b6fae3fSVijay Khemka bus, ipObjectInfo.second, ipObjectInfo.first, 2851b6fae3fSVijay Khemka ipmi::network::IP_INTERFACE); 2861b6fae3fSVijay Khemka 287ef0efbc4SPatrick Williams ipaddress = std::get<std::string>(properties["Address"]); 2881b6fae3fSVijay Khemka 2891b6fae3fSVijay Khemka std::strcpy(data, ipaddress.c_str()); 2901b6fae3fSVijay Khemka } 2911b6fae3fSVijay Khemka break; 2921b6fae3fSVijay Khemka 293d1194024SVijay Khemka case LanParam::IPV6: 294d1194024SVijay Khemka { 295a7231893SVijay Khemka auto ethIP = ethdevice + "/" + ipmi::network::IPV6_TYPE; 2961b6fae3fSVijay Khemka std::string ipaddress; 297a7231893SVijay Khemka auto ipObjectInfo = ipmi::network::getIPObject( 2981b6fae3fSVijay Khemka bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT, ethIP); 2991b6fae3fSVijay Khemka 3001b6fae3fSVijay Khemka auto properties = ipmi::getAllDbusProperties( 3011b6fae3fSVijay Khemka bus, ipObjectInfo.second, ipObjectInfo.first, 3021b6fae3fSVijay Khemka ipmi::network::IP_INTERFACE); 3031b6fae3fSVijay Khemka 304ef0efbc4SPatrick Williams ipaddress = std::get<std::string>(properties["Address"]); 3051b6fae3fSVijay Khemka 3061b6fae3fSVijay Khemka std::strcpy(data, ipaddress.c_str()); 3071b6fae3fSVijay Khemka } 3081b6fae3fSVijay Khemka break; 3091b6fae3fSVijay Khemka 310d1194024SVijay Khemka case LanParam::MAC: 311d1194024SVijay Khemka { 3121b6fae3fSVijay Khemka std::string macAddress; 3131b6fae3fSVijay Khemka auto macObjectInfo = 3141b6fae3fSVijay Khemka ipmi::getDbusObject(bus, ipmi::network::MAC_INTERFACE, 3151b6fae3fSVijay Khemka ipmi::network::ROOT, ethdevice); 3161b6fae3fSVijay Khemka 3171b6fae3fSVijay Khemka auto variant = ipmi::getDbusProperty( 3181b6fae3fSVijay Khemka bus, macObjectInfo.second, macObjectInfo.first, 3191b6fae3fSVijay Khemka ipmi::network::MAC_INTERFACE, "MACAddress"); 3201b6fae3fSVijay Khemka 321ef0efbc4SPatrick Williams macAddress = std::get<std::string>(variant); 3221b6fae3fSVijay Khemka 3231b6fae3fSVijay Khemka sscanf(macAddress.c_str(), ipmi::network::MAC_ADDRESS_FORMAT, 3241b6fae3fSVijay Khemka (data), (data + 1), (data + 2), (data + 3), (data + 4), 3251b6fae3fSVijay Khemka (data + 5)); 3261b6fae3fSVijay Khemka std::strcpy(data, macAddress.c_str()); 3271b6fae3fSVijay Khemka } 3281b6fae3fSVijay Khemka break; 3291b6fae3fSVijay Khemka 3301b6fae3fSVijay Khemka default: 3311b6fae3fSVijay Khemka rc = IPMI_CC_PARM_OUT_OF_RANGE; 3321b6fae3fSVijay Khemka } 3331b6fae3fSVijay Khemka return rc; 3341b6fae3fSVijay Khemka } 335e7d23d0eSVijay Khemka 33639836ffaSKarthikeyan Pasupathi bool isMultiHostPlatform() 33739836ffaSKarthikeyan Pasupathi { 33839836ffaSKarthikeyan Pasupathi bool platform; 3394ec80567SJayashree Dhanapal if (hostInstances == "0") 34039836ffaSKarthikeyan Pasupathi { 34139836ffaSKarthikeyan Pasupathi platform = false; 34239836ffaSKarthikeyan Pasupathi } 34339836ffaSKarthikeyan Pasupathi else 34439836ffaSKarthikeyan Pasupathi { 34539836ffaSKarthikeyan Pasupathi platform = true; 34639836ffaSKarthikeyan Pasupathi } 34739836ffaSKarthikeyan Pasupathi return platform; 34839836ffaSKarthikeyan Pasupathi } 34939836ffaSKarthikeyan Pasupathi 350e7d23d0eSVijay Khemka // return code: 0 successful 351e7d23d0eSVijay Khemka int8_t getFruData(std::string& data, std::string& name) 352e7d23d0eSVijay Khemka { 35398aabdb1SKarthikeyan Pasupathi size_t pos; 35498aabdb1SKarthikeyan Pasupathi static constexpr const auto depth = 0; 35598aabdb1SKarthikeyan Pasupathi std::vector<std::string> paths; 35698aabdb1SKarthikeyan Pasupathi std::string machinePath; 35798aabdb1SKarthikeyan Pasupathi std::string baseBoard = "Baseboard"; 35898aabdb1SKarthikeyan Pasupathi 35998aabdb1SKarthikeyan Pasupathi bool platform = isMultiHostPlatform(); 36098aabdb1SKarthikeyan Pasupathi if (platform == true) 36198aabdb1SKarthikeyan Pasupathi { 36298aabdb1SKarthikeyan Pasupathi pos = getSelectorPosition(); 36398aabdb1SKarthikeyan Pasupathi } 36498aabdb1SKarthikeyan Pasupathi 36598aabdb1SKarthikeyan Pasupathi sd_bus* bus = NULL; 36698aabdb1SKarthikeyan Pasupathi int ret = sd_bus_default_system(&bus); 36798aabdb1SKarthikeyan Pasupathi if (ret < 0) 368e7d23d0eSVijay Khemka { 369e7d23d0eSVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 37098aabdb1SKarthikeyan Pasupathi "Failed to connect to system bus", 37198aabdb1SKarthikeyan Pasupathi phosphor::logging::entry("ERRNO=0x%X", -ret)); 37298aabdb1SKarthikeyan Pasupathi sd_bus_unref(bus); 373e7d23d0eSVijay Khemka return -1; 374e7d23d0eSVijay Khemka } 375cd315e07SPatrick Williams sdbusplus::bus_t dbus(bus); 37698aabdb1SKarthikeyan Pasupathi auto mapperCall = dbus.new_method_call("xyz.openbmc_project.ObjectMapper", 37798aabdb1SKarthikeyan Pasupathi "/xyz/openbmc_project/object_mapper", 37898aabdb1SKarthikeyan Pasupathi "xyz.openbmc_project.ObjectMapper", 37998aabdb1SKarthikeyan Pasupathi "GetSubTreePaths"); 38098aabdb1SKarthikeyan Pasupathi static constexpr std::array<const char*, 1> interface = { 38198aabdb1SKarthikeyan Pasupathi "xyz.openbmc_project.Inventory.Decorator.Asset"}; 38298aabdb1SKarthikeyan Pasupathi mapperCall.append("/xyz/openbmc_project/inventory/", depth, interface); 383e7d23d0eSVijay Khemka 384e7d23d0eSVijay Khemka try 385e7d23d0eSVijay Khemka { 38698aabdb1SKarthikeyan Pasupathi auto reply = dbus.call(mapperCall); 38798aabdb1SKarthikeyan Pasupathi reply.read(paths); 388e7d23d0eSVijay Khemka } 38998aabdb1SKarthikeyan Pasupathi catch (sdbusplus::exception_t& e) 390e7d23d0eSVijay Khemka { 391e7d23d0eSVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>(e.what()); 392e7d23d0eSVijay Khemka return -1; 393e7d23d0eSVijay Khemka } 39498aabdb1SKarthikeyan Pasupathi 39598aabdb1SKarthikeyan Pasupathi for (const auto& path : paths) 39698aabdb1SKarthikeyan Pasupathi { 39798aabdb1SKarthikeyan Pasupathi if (platform == true) 39898aabdb1SKarthikeyan Pasupathi { 39998aabdb1SKarthikeyan Pasupathi if (pos == BMC_POS) 40098aabdb1SKarthikeyan Pasupathi { 40198aabdb1SKarthikeyan Pasupathi machinePath = baseBoard; 40298aabdb1SKarthikeyan Pasupathi } 40398aabdb1SKarthikeyan Pasupathi else 40498aabdb1SKarthikeyan Pasupathi { 40598aabdb1SKarthikeyan Pasupathi machinePath = "_" + std::to_string(pos); 40698aabdb1SKarthikeyan Pasupathi } 40798aabdb1SKarthikeyan Pasupathi } 40898aabdb1SKarthikeyan Pasupathi else 40998aabdb1SKarthikeyan Pasupathi { 41098aabdb1SKarthikeyan Pasupathi machinePath = baseBoard; 41198aabdb1SKarthikeyan Pasupathi } 41298aabdb1SKarthikeyan Pasupathi 41398aabdb1SKarthikeyan Pasupathi auto found = path.find(machinePath); 414123cbcc4SPatrick Williams if (found == std::string::npos) 41598aabdb1SKarthikeyan Pasupathi { 41698aabdb1SKarthikeyan Pasupathi continue; 41798aabdb1SKarthikeyan Pasupathi } 41898aabdb1SKarthikeyan Pasupathi 41998aabdb1SKarthikeyan Pasupathi std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus(); 42098aabdb1SKarthikeyan Pasupathi std::string service = getService( 42198aabdb1SKarthikeyan Pasupathi *dbus, "xyz.openbmc_project.Inventory.Decorator.Asset", path); 42298aabdb1SKarthikeyan Pasupathi 42398aabdb1SKarthikeyan Pasupathi auto Value = ipmi::getDbusProperty( 42498aabdb1SKarthikeyan Pasupathi *dbus, service, path, 42598aabdb1SKarthikeyan Pasupathi "xyz.openbmc_project.Inventory.Decorator.Asset", name); 42698aabdb1SKarthikeyan Pasupathi 42798aabdb1SKarthikeyan Pasupathi data = std::get<std::string>(Value); 42898aabdb1SKarthikeyan Pasupathi return 0; 429e7d23d0eSVijay Khemka } 430e7d23d0eSVijay Khemka return -1; 431e7d23d0eSVijay Khemka } 432e7d23d0eSVijay Khemka 43310ff3d86SKarthikeyan Pasupathi int8_t sysConfig(std::vector<std::string>& data, size_t pos) 43410ff3d86SKarthikeyan Pasupathi { 43510ff3d86SKarthikeyan Pasupathi nlohmann::json sysObj; 43610ff3d86SKarthikeyan Pasupathi std::string dimmInfo = KEY_Q_DIMM_INFO + std::to_string(pos); 43710ff3d86SKarthikeyan Pasupathi std::string result, typeName; 43810ff3d86SKarthikeyan Pasupathi uint8_t res[MAX_BUF]; 43910ff3d86SKarthikeyan Pasupathi 44010ff3d86SKarthikeyan Pasupathi /* Get sysConfig data stored in json file */ 44110ff3d86SKarthikeyan Pasupathi std::ifstream file(JSON_OEM_DATA_FILE); 44210ff3d86SKarthikeyan Pasupathi if (file) 44310ff3d86SKarthikeyan Pasupathi { 44410ff3d86SKarthikeyan Pasupathi file >> sysObj; 44510ff3d86SKarthikeyan Pasupathi file.close(); 44610ff3d86SKarthikeyan Pasupathi } 44710ff3d86SKarthikeyan Pasupathi else 44810ff3d86SKarthikeyan Pasupathi { 44910ff3d86SKarthikeyan Pasupathi phosphor::logging::log<phosphor::logging::level::ERR>( 45010ff3d86SKarthikeyan Pasupathi "oemData file not found", 45110ff3d86SKarthikeyan Pasupathi phosphor::logging::entry("OEM_DATA_FILE=%s", JSON_OEM_DATA_FILE)); 45210ff3d86SKarthikeyan Pasupathi return -1; 45310ff3d86SKarthikeyan Pasupathi } 45410ff3d86SKarthikeyan Pasupathi 45510ff3d86SKarthikeyan Pasupathi if (sysObj.find(dimmInfo) == sysObj.end()) 45610ff3d86SKarthikeyan Pasupathi { 45710ff3d86SKarthikeyan Pasupathi phosphor::logging::log<phosphor::logging::level::ERR>( 45810ff3d86SKarthikeyan Pasupathi "sysconfig key not available", 45910ff3d86SKarthikeyan Pasupathi phosphor::logging::entry("SYS_JSON_KEY=%s", dimmInfo.c_str())); 46010ff3d86SKarthikeyan Pasupathi return -1; 46110ff3d86SKarthikeyan Pasupathi } 46210ff3d86SKarthikeyan Pasupathi /* Get dimm type names stored in json file */ 46310ff3d86SKarthikeyan Pasupathi nlohmann::json dimmObj; 46410ff3d86SKarthikeyan Pasupathi std::ifstream dimmFile(JSON_DIMM_TYPE_FILE); 46510ff3d86SKarthikeyan Pasupathi if (file) 46610ff3d86SKarthikeyan Pasupathi { 46710ff3d86SKarthikeyan Pasupathi dimmFile >> dimmObj; 46810ff3d86SKarthikeyan Pasupathi dimmFile.close(); 46910ff3d86SKarthikeyan Pasupathi } 47010ff3d86SKarthikeyan Pasupathi else 47110ff3d86SKarthikeyan Pasupathi { 47210ff3d86SKarthikeyan Pasupathi phosphor::logging::log<phosphor::logging::level::ERR>( 47310ff3d86SKarthikeyan Pasupathi "DIMM type names file not found", 47410ff3d86SKarthikeyan Pasupathi phosphor::logging::entry("DIMM_TYPE_FILE=%s", JSON_DIMM_TYPE_FILE)); 47510ff3d86SKarthikeyan Pasupathi return -1; 47610ff3d86SKarthikeyan Pasupathi } 47710ff3d86SKarthikeyan Pasupathi std::vector<std::string> a; 47810ff3d86SKarthikeyan Pasupathi for (auto& j : dimmObj.items()) 47910ff3d86SKarthikeyan Pasupathi { 48010ff3d86SKarthikeyan Pasupathi std::string name = j.key(); 48110ff3d86SKarthikeyan Pasupathi a.push_back(name); 48210ff3d86SKarthikeyan Pasupathi } 48310ff3d86SKarthikeyan Pasupathi 48410ff3d86SKarthikeyan Pasupathi uint8_t len = a.size(); 48510ff3d86SKarthikeyan Pasupathi for (uint8_t ii = 0; ii < len; ii++) 48610ff3d86SKarthikeyan Pasupathi { 48710ff3d86SKarthikeyan Pasupathi std::string indKey = std::to_string(ii); 48810ff3d86SKarthikeyan Pasupathi std::string speedSize = sysObj[dimmInfo][indKey][DIMM_SPEED]; 48910ff3d86SKarthikeyan Pasupathi strToBytes(speedSize, res); 49010ff3d86SKarthikeyan Pasupathi auto speed = (res[1] << 8 | res[0]); 49110ff3d86SKarthikeyan Pasupathi size_t dimmSize = ((res[3] << 8 | res[2]) / 1000); 49210ff3d86SKarthikeyan Pasupathi 49310ff3d86SKarthikeyan Pasupathi if (dimmSize == 0) 49410ff3d86SKarthikeyan Pasupathi { 49510ff3d86SKarthikeyan Pasupathi std::cerr << "Dimm information not available for slot_" + 49610ff3d86SKarthikeyan Pasupathi std::to_string(ii) 49710ff3d86SKarthikeyan Pasupathi << std::endl; 49810ff3d86SKarthikeyan Pasupathi continue; 49910ff3d86SKarthikeyan Pasupathi } 50010ff3d86SKarthikeyan Pasupathi std::string type = sysObj[dimmInfo][indKey][DIMM_TYPE]; 50110ff3d86SKarthikeyan Pasupathi std::string dualInlineMem = sysObj[dimmInfo][indKey][KEY_DIMM_TYPE]; 50210ff3d86SKarthikeyan Pasupathi strToBytes(type, res); 50310ff3d86SKarthikeyan Pasupathi size_t dimmType = res[0]; 50410ff3d86SKarthikeyan Pasupathi if (dimmVenMap.find(dimmType) == dimmVenMap.end()) 50510ff3d86SKarthikeyan Pasupathi { 50610ff3d86SKarthikeyan Pasupathi typeName = "unknown"; 50710ff3d86SKarthikeyan Pasupathi } 50810ff3d86SKarthikeyan Pasupathi else 50910ff3d86SKarthikeyan Pasupathi { 51010ff3d86SKarthikeyan Pasupathi typeName = dimmVenMap[dimmType]; 51110ff3d86SKarthikeyan Pasupathi } 51210ff3d86SKarthikeyan Pasupathi result = dualInlineMem + "/" + typeName + "/" + std::to_string(speed) + 51310ff3d86SKarthikeyan Pasupathi "MHz" + "/" + std::to_string(dimmSize) + "GB"; 51410ff3d86SKarthikeyan Pasupathi data.push_back(result); 51510ff3d86SKarthikeyan Pasupathi } 51610ff3d86SKarthikeyan Pasupathi return 0; 51710ff3d86SKarthikeyan Pasupathi } 51810ff3d86SKarthikeyan Pasupathi 519d532fecaSKarthikeyan Pasupathi int8_t procInfo(std::string& result, size_t pos) 520d532fecaSKarthikeyan Pasupathi { 521d532fecaSKarthikeyan Pasupathi std::vector<char> data; 522d532fecaSKarthikeyan Pasupathi uint8_t res[MAX_BUF]; 523d532fecaSKarthikeyan Pasupathi std::string procIndex = "00"; 524d532fecaSKarthikeyan Pasupathi nlohmann::json proObj; 525d532fecaSKarthikeyan Pasupathi std::string procInfo = KEY_Q_PROC_INFO + std::to_string(pos); 526d532fecaSKarthikeyan Pasupathi /* Get processor data stored in json file */ 527d532fecaSKarthikeyan Pasupathi std::ifstream file(JSON_OEM_DATA_FILE); 528d532fecaSKarthikeyan Pasupathi if (file) 529d532fecaSKarthikeyan Pasupathi { 530d532fecaSKarthikeyan Pasupathi file >> proObj; 531d532fecaSKarthikeyan Pasupathi file.close(); 532d532fecaSKarthikeyan Pasupathi } 533d532fecaSKarthikeyan Pasupathi else 534d532fecaSKarthikeyan Pasupathi { 535d532fecaSKarthikeyan Pasupathi phosphor::logging::log<phosphor::logging::level::ERR>( 536d532fecaSKarthikeyan Pasupathi "oemData file not found", 537d532fecaSKarthikeyan Pasupathi phosphor::logging::entry("OEM_DATA_FILE=%s", JSON_OEM_DATA_FILE)); 538d532fecaSKarthikeyan Pasupathi return -1; 539d532fecaSKarthikeyan Pasupathi } 540d532fecaSKarthikeyan Pasupathi if (proObj.find(procInfo) == proObj.end()) 541d532fecaSKarthikeyan Pasupathi { 542d532fecaSKarthikeyan Pasupathi phosphor::logging::log<phosphor::logging::level::ERR>( 543d532fecaSKarthikeyan Pasupathi "processor info key not available", 544d532fecaSKarthikeyan Pasupathi phosphor::logging::entry("PROC_JSON_KEY=%s", procInfo.c_str())); 545d532fecaSKarthikeyan Pasupathi return -1; 546d532fecaSKarthikeyan Pasupathi } 547d532fecaSKarthikeyan Pasupathi std::string procName = proObj[procInfo][procIndex][KEY_PROC_NAME]; 548d532fecaSKarthikeyan Pasupathi std::string basicInfo = proObj[procInfo][procIndex][KEY_BASIC_INFO]; 549d532fecaSKarthikeyan Pasupathi // Processor Product Name 550d532fecaSKarthikeyan Pasupathi strToBytes(procName, res); 551d532fecaSKarthikeyan Pasupathi data.assign(reinterpret_cast<char*>(&res), 552d532fecaSKarthikeyan Pasupathi reinterpret_cast<char*>(&res) + sizeof(res)); 553d532fecaSKarthikeyan Pasupathi 554d532fecaSKarthikeyan Pasupathi std::string s(data.begin(), data.end()); 555d532fecaSKarthikeyan Pasupathi std::regex regex(" "); 556d532fecaSKarthikeyan Pasupathi std::vector<std::string> productName( 557d532fecaSKarthikeyan Pasupathi std::sregex_token_iterator(s.begin(), s.end(), regex, -1), 558d532fecaSKarthikeyan Pasupathi std::sregex_token_iterator()); 559d532fecaSKarthikeyan Pasupathi 560d532fecaSKarthikeyan Pasupathi // Processor core and frequency 561d532fecaSKarthikeyan Pasupathi strToBytes(basicInfo, res); 562d532fecaSKarthikeyan Pasupathi uint16_t coreNum = res[0]; 563d532fecaSKarthikeyan Pasupathi double procFrequency = (float)(res[4] << 8 | res[3]) / 1000; 564d532fecaSKarthikeyan Pasupathi result = "CPU:" + productName[2] + "/" + std::to_string(procFrequency) + 565d532fecaSKarthikeyan Pasupathi "GHz" + "/" + std::to_string(coreNum) + "c"; 566d532fecaSKarthikeyan Pasupathi return 0; 567d532fecaSKarthikeyan Pasupathi } 568d532fecaSKarthikeyan Pasupathi 569e7d23d0eSVijay Khemka typedef struct 570e7d23d0eSVijay Khemka { 571e7d23d0eSVijay Khemka uint8_t cur_power_state; 572e7d23d0eSVijay Khemka uint8_t last_power_event; 573e7d23d0eSVijay Khemka uint8_t misc_power_state; 574e7d23d0eSVijay Khemka uint8_t front_panel_button_cap_status; 575e7d23d0eSVijay Khemka } ipmi_get_chassis_status_t; 576e7d23d0eSVijay Khemka 577e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 578e7d23d0eSVijay Khemka // Get Debug Frame Info 579e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 580e39f9393SWilly Tu ipmi_ret_t ipmiOemDbgGetFrameInfo(ipmi_netfn_t, ipmi_cmd_t, 581e7d23d0eSVijay Khemka ipmi_request_t request, 582e7d23d0eSVijay Khemka ipmi_response_t response, 583e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t) 584e7d23d0eSVijay Khemka { 585e7d23d0eSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 586e7d23d0eSVijay Khemka uint8_t* res = reinterpret_cast<uint8_t*>(response); 587e7d23d0eSVijay Khemka uint8_t num_frames = 3; 588e7d23d0eSVijay Khemka 589e7d23d0eSVijay Khemka std::memcpy(res, req, SIZE_IANA_ID); // IANA ID 590e7d23d0eSVijay Khemka res[SIZE_IANA_ID] = num_frames; 591e7d23d0eSVijay Khemka *data_len = SIZE_IANA_ID + 1; 592e7d23d0eSVijay Khemka 593e7d23d0eSVijay Khemka return IPMI_CC_OK; 594e7d23d0eSVijay Khemka } 595e7d23d0eSVijay Khemka 596e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 597e7d23d0eSVijay Khemka // Get Debug Updated Frames 598e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 599e39f9393SWilly Tu ipmi_ret_t ipmiOemDbgGetUpdFrames(ipmi_netfn_t, ipmi_cmd_t, 600e7d23d0eSVijay Khemka ipmi_request_t request, 601e7d23d0eSVijay Khemka ipmi_response_t response, 602e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t) 603e7d23d0eSVijay Khemka { 604e7d23d0eSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 605e7d23d0eSVijay Khemka uint8_t* res = reinterpret_cast<uint8_t*>(response); 606e7d23d0eSVijay Khemka uint8_t num_updates = 3; 607e7d23d0eSVijay Khemka *data_len = 4; 608e7d23d0eSVijay Khemka 609e7d23d0eSVijay Khemka std::memcpy(res, req, SIZE_IANA_ID); // IANA ID 610e7d23d0eSVijay Khemka res[SIZE_IANA_ID] = num_updates; 611e7d23d0eSVijay Khemka *data_len = SIZE_IANA_ID + num_updates + 1; 612e7d23d0eSVijay Khemka res[SIZE_IANA_ID + 1] = 1; // info page update 613e7d23d0eSVijay Khemka res[SIZE_IANA_ID + 2] = 2; // cri sel update 614e7d23d0eSVijay Khemka res[SIZE_IANA_ID + 3] = 3; // cri sensor update 615e7d23d0eSVijay Khemka 616e7d23d0eSVijay Khemka return IPMI_CC_OK; 617e7d23d0eSVijay Khemka } 618e7d23d0eSVijay Khemka 619e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 620e7d23d0eSVijay Khemka // Get Debug POST Description 621e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 622e39f9393SWilly Tu ipmi_ret_t ipmiOemDbgGetPostDesc(ipmi_netfn_t, ipmi_cmd_t, 623e7d23d0eSVijay Khemka ipmi_request_t request, 624e7d23d0eSVijay Khemka ipmi_response_t response, 625e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t) 626e7d23d0eSVijay Khemka { 627e7d23d0eSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 628e7d23d0eSVijay Khemka uint8_t* res = reinterpret_cast<uint8_t*>(response); 629e7d23d0eSVijay Khemka uint8_t index = 0; 630e7d23d0eSVijay Khemka uint8_t next = 0; 631e7d23d0eSVijay Khemka uint8_t end = 0; 632e7d23d0eSVijay Khemka uint8_t phase = 0; 633cc0d6d92SVijay Khemka uint8_t descLen = 0; 634e7d23d0eSVijay Khemka int ret; 635e7d23d0eSVijay Khemka 636e7d23d0eSVijay Khemka index = req[3]; 637e7d23d0eSVijay Khemka phase = req[4]; 638e7d23d0eSVijay Khemka 639cc0d6d92SVijay Khemka ret = plat_udbg_get_post_desc(index, &next, phase, &end, &descLen, &res[8]); 640e7d23d0eSVijay Khemka if (ret) 641e7d23d0eSVijay Khemka { 642e7d23d0eSVijay Khemka memcpy(res, req, SIZE_IANA_ID); // IANA ID 643e7d23d0eSVijay Khemka *data_len = SIZE_IANA_ID; 644e7d23d0eSVijay Khemka return IPMI_CC_UNSPECIFIED_ERROR; 645e7d23d0eSVijay Khemka } 646e7d23d0eSVijay Khemka 647e7d23d0eSVijay Khemka memcpy(res, req, SIZE_IANA_ID); // IANA ID 648e7d23d0eSVijay Khemka res[3] = index; 649e7d23d0eSVijay Khemka res[4] = next; 650e7d23d0eSVijay Khemka res[5] = phase; 651e7d23d0eSVijay Khemka res[6] = end; 652cc0d6d92SVijay Khemka res[7] = descLen; 653cc0d6d92SVijay Khemka *data_len = SIZE_IANA_ID + 5 + descLen; 654e7d23d0eSVijay Khemka 655e7d23d0eSVijay Khemka return IPMI_CC_OK; 656e7d23d0eSVijay Khemka } 657e7d23d0eSVijay Khemka 658e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 659e7d23d0eSVijay Khemka // Get Debug GPIO Description 660e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 661e39f9393SWilly Tu ipmi_ret_t ipmiOemDbgGetGpioDesc(ipmi_netfn_t, ipmi_cmd_t, 662e7d23d0eSVijay Khemka ipmi_request_t request, 663e7d23d0eSVijay Khemka ipmi_response_t response, 664e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t) 665e7d23d0eSVijay Khemka { 666e7d23d0eSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 667e7d23d0eSVijay Khemka uint8_t* res = reinterpret_cast<uint8_t*>(response); 668e7d23d0eSVijay Khemka 66938183d66SVijay Khemka uint8_t index = 0; 67038183d66SVijay Khemka uint8_t next = 0; 67138183d66SVijay Khemka uint8_t level = 0; 67238183d66SVijay Khemka uint8_t pinDef = 0; 67338183d66SVijay Khemka uint8_t descLen = 0; 67438183d66SVijay Khemka int ret; 675e7d23d0eSVijay Khemka 67638183d66SVijay Khemka index = req[3]; 67738183d66SVijay Khemka 67838183d66SVijay Khemka ret = plat_udbg_get_gpio_desc(index, &next, &level, &pinDef, &descLen, 67938183d66SVijay Khemka &res[8]); 68038183d66SVijay Khemka if (ret) 68138183d66SVijay Khemka { 68238183d66SVijay Khemka memcpy(res, req, SIZE_IANA_ID); // IANA ID 68338183d66SVijay Khemka *data_len = SIZE_IANA_ID; 68438183d66SVijay Khemka return IPMI_CC_UNSPECIFIED_ERROR; 68538183d66SVijay Khemka } 68638183d66SVijay Khemka 68738183d66SVijay Khemka memcpy(res, req, SIZE_IANA_ID); // IANA ID 68838183d66SVijay Khemka res[3] = index; 68938183d66SVijay Khemka res[4] = next; 69038183d66SVijay Khemka res[5] = level; 69138183d66SVijay Khemka res[6] = pinDef; 69238183d66SVijay Khemka res[7] = descLen; 69338183d66SVijay Khemka *data_len = SIZE_IANA_ID + 5 + descLen; 694e7d23d0eSVijay Khemka 695e7d23d0eSVijay Khemka return IPMI_CC_OK; 696e7d23d0eSVijay Khemka } 697e7d23d0eSVijay Khemka 698e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 699e7d23d0eSVijay Khemka // Get Debug Frame Data 700e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 701e39f9393SWilly Tu ipmi_ret_t ipmiOemDbgGetFrameData(ipmi_netfn_t, ipmi_cmd_t, 702e7d23d0eSVijay Khemka ipmi_request_t request, 703e7d23d0eSVijay Khemka ipmi_response_t response, 704e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t) 705e7d23d0eSVijay Khemka { 706e7d23d0eSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 707e7d23d0eSVijay Khemka uint8_t* res = reinterpret_cast<uint8_t*>(response); 708e7d23d0eSVijay Khemka uint8_t frame; 709e7d23d0eSVijay Khemka uint8_t page; 710e7d23d0eSVijay Khemka uint8_t next; 711e7d23d0eSVijay Khemka uint8_t count; 712e7d23d0eSVijay Khemka int ret; 713e7d23d0eSVijay Khemka 714e7d23d0eSVijay Khemka frame = req[3]; 715e7d23d0eSVijay Khemka page = req[4]; 716e7d23d0eSVijay Khemka 717e7d23d0eSVijay Khemka ret = plat_udbg_get_frame_data(frame, page, &next, &count, &res[7]); 718e7d23d0eSVijay Khemka if (ret) 719e7d23d0eSVijay Khemka { 720e7d23d0eSVijay Khemka memcpy(res, req, SIZE_IANA_ID); // IANA ID 721e7d23d0eSVijay Khemka *data_len = SIZE_IANA_ID; 722e7d23d0eSVijay Khemka return IPMI_CC_UNSPECIFIED_ERROR; 723e7d23d0eSVijay Khemka } 724e7d23d0eSVijay Khemka 725e7d23d0eSVijay Khemka memcpy(res, req, SIZE_IANA_ID); // IANA ID 726e7d23d0eSVijay Khemka res[3] = frame; 727e7d23d0eSVijay Khemka res[4] = page; 728e7d23d0eSVijay Khemka res[5] = next; 729e7d23d0eSVijay Khemka res[6] = count; 730e7d23d0eSVijay Khemka *data_len = SIZE_IANA_ID + 4 + count; 731e7d23d0eSVijay Khemka 732e7d23d0eSVijay Khemka return IPMI_CC_OK; 733e7d23d0eSVijay Khemka } 734e7d23d0eSVijay Khemka 735e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 736e7d23d0eSVijay Khemka // Get Debug Control Panel 737e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 738e39f9393SWilly Tu ipmi_ret_t ipmiOemDbgGetCtrlPanel(ipmi_netfn_t, ipmi_cmd_t, 739e7d23d0eSVijay Khemka ipmi_request_t request, 740e7d23d0eSVijay Khemka ipmi_response_t response, 741e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t) 742e7d23d0eSVijay Khemka { 743e7d23d0eSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 744e7d23d0eSVijay Khemka uint8_t* res = reinterpret_cast<uint8_t*>(response); 745e7d23d0eSVijay Khemka 746e7d23d0eSVijay Khemka uint8_t panel; 747e7d23d0eSVijay Khemka uint8_t operation; 748e7d23d0eSVijay Khemka uint8_t item; 749e7d23d0eSVijay Khemka uint8_t count; 750e7d23d0eSVijay Khemka ipmi_ret_t ret; 751e7d23d0eSVijay Khemka 752e7d23d0eSVijay Khemka panel = req[3]; 753e7d23d0eSVijay Khemka operation = req[4]; 754e7d23d0eSVijay Khemka item = req[5]; 755e7d23d0eSVijay Khemka 756e7d23d0eSVijay Khemka ret = plat_udbg_control_panel(panel, operation, item, &count, &res[3]); 757e7d23d0eSVijay Khemka 758e7d23d0eSVijay Khemka std::memcpy(res, req, SIZE_IANA_ID); // IANA ID 759e7d23d0eSVijay Khemka *data_len = SIZE_IANA_ID + count; 760e7d23d0eSVijay Khemka 761e7d23d0eSVijay Khemka return ret; 762e7d23d0eSVijay Khemka } 763e7d23d0eSVijay Khemka 764e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 765e7d23d0eSVijay Khemka // Set Dimm Info (CMD_OEM_SET_DIMM_INFO) 766e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 767e39f9393SWilly Tu ipmi_ret_t ipmiOemSetDimmInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, 768e39f9393SWilly Tu ipmi_response_t, ipmi_data_len_t data_len, 769e39f9393SWilly Tu ipmi_context_t) 770e7d23d0eSVijay Khemka { 771e7d23d0eSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 7721d4a0697SVijay Khemka 7731d4a0697SVijay Khemka uint8_t index = req[0]; 7741d4a0697SVijay Khemka uint8_t type = req[1]; 7751d4a0697SVijay Khemka uint16_t speed; 7761d4a0697SVijay Khemka uint32_t size; 7771d4a0697SVijay Khemka 7781d4a0697SVijay Khemka memcpy(&speed, &req[2], 2); 7791d4a0697SVijay Khemka memcpy(&size, &req[4], 4); 7801d4a0697SVijay Khemka 7811d4a0697SVijay Khemka std::stringstream ss; 7821d4a0697SVijay Khemka ss << std::hex; 7831d4a0697SVijay Khemka ss << std::setw(2) << std::setfill('0') << (int)index; 7841d4a0697SVijay Khemka 7851d4a0697SVijay Khemka oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_INDEX] = index; 7861d4a0697SVijay Khemka oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_TYPE] = type; 7871d4a0697SVijay Khemka oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_SPEED] = speed; 7881d4a0697SVijay Khemka oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_SIZE] = size; 7891d4a0697SVijay Khemka 7901d4a0697SVijay Khemka flushOemData(); 7911d4a0697SVijay Khemka 7921d4a0697SVijay Khemka *data_len = 0; 7931d4a0697SVijay Khemka 7941d4a0697SVijay Khemka return IPMI_CC_OK; 7951d4a0697SVijay Khemka } 7961d4a0697SVijay Khemka 7971d4a0697SVijay Khemka //---------------------------------------------------------------------- 7981d4a0697SVijay Khemka // Get Board ID (CMD_OEM_GET_BOARD_ID) 7991d4a0697SVijay Khemka //---------------------------------------------------------------------- 800e39f9393SWilly Tu ipmi_ret_t ipmiOemGetBoardID(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, 801e39f9393SWilly Tu ipmi_response_t, ipmi_data_len_t data_len, 802e39f9393SWilly Tu ipmi_context_t) 8031d4a0697SVijay Khemka { 8041d4a0697SVijay Khemka /* TODO: Needs to implement this after GPIO implementation */ 805e7d23d0eSVijay Khemka *data_len = 0; 806e7d23d0eSVijay Khemka 807e7d23d0eSVijay Khemka return IPMI_CC_OK; 808e7d23d0eSVijay Khemka } 809e7d23d0eSVijay Khemka 810877d5dd9SVijay Khemka /* Helper functions to set boot order */ 811f0cf6658SJayashree-D void setBootOrder(std::string bootObjPath, uint8_t* data, 812f0cf6658SJayashree-D std::string bootOrderKey) 813877d5dd9SVijay Khemka { 814f0cf6658SJayashree-D std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus(); 815f0cf6658SJayashree-D 816f0cf6658SJayashree-D // SETTING BOOT MODE PROPERTY 817778147daSJayashree Dhanapal uint8_t bootModeBit = data[0] & 0x06; 81877ee489fSJayashree Dhanapal auto bootValue = ipmi::boot::modeIpmiToDbus.at(bootModeBit); 819778147daSJayashree Dhanapal 820f0cf6658SJayashree-D std::string bootOption = 82177ee489fSJayashree Dhanapal sdbusplus::message::convert_to_string<boot::BootMode>(bootValue); 822f0cf6658SJayashree-D 823f0cf6658SJayashree-D std::string service = 824f0cf6658SJayashree-D getService(*dbus, ipmi::boot::bootModeIntf, bootObjPath); 825f0cf6658SJayashree-D setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootModeIntf, 826f0cf6658SJayashree-D ipmi::boot::bootModeProp, bootOption); 827f0cf6658SJayashree-D 828f0cf6658SJayashree-D // SETTING BOOT SOURCE PROPERTY 82977ee489fSJayashree Dhanapal auto bootOrder = ipmi::boot::sourceIpmiToDbus.at(data[1]); 830f0cf6658SJayashree-D std::string bootSource = 83177ee489fSJayashree Dhanapal sdbusplus::message::convert_to_string<boot::BootSource>(bootOrder); 832f0cf6658SJayashree-D 833f0cf6658SJayashree-D service = getService(*dbus, ipmi::boot::bootSourceIntf, bootObjPath); 834f0cf6658SJayashree-D setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootSourceIntf, 835f0cf6658SJayashree-D ipmi::boot::bootSourceProp, bootSource); 836f0cf6658SJayashree-D 837778147daSJayashree Dhanapal // SETTING BOOT TYPE PROPERTY 838778147daSJayashree Dhanapal uint8_t bootTypeBit = data[0] & 0x01; 83977ee489fSJayashree Dhanapal auto bootTypeVal = ipmi::boot::typeIpmiToDbus.at(bootTypeBit); 84077ee489fSJayashree Dhanapal 841778147daSJayashree Dhanapal std::string bootType = 84277ee489fSJayashree Dhanapal sdbusplus::message::convert_to_string<boot::BootType>(bootTypeVal); 843778147daSJayashree Dhanapal 844778147daSJayashree Dhanapal service = getService(*dbus, ipmi::boot::bootTypeIntf, bootObjPath); 845778147daSJayashree Dhanapal 846778147daSJayashree Dhanapal setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootTypeIntf, 847778147daSJayashree Dhanapal ipmi::boot::bootTypeProp, bootType); 848778147daSJayashree Dhanapal 849877d5dd9SVijay Khemka nlohmann::json bootMode; 850877d5dd9SVijay Khemka uint8_t mode = data[0]; 851877d5dd9SVijay Khemka int i; 852877d5dd9SVijay Khemka 853877d5dd9SVijay Khemka bootMode["UEFI"] = (mode & BOOT_MODE_UEFI ? true : false); 854877d5dd9SVijay Khemka bootMode["CMOS_CLR"] = (mode & BOOT_MODE_CMOS_CLR ? true : false); 855877d5dd9SVijay Khemka bootMode["FORCE_BOOT"] = (mode & BOOT_MODE_FORCE_BOOT ? true : false); 856877d5dd9SVijay Khemka bootMode["BOOT_FLAG"] = (mode & BOOT_MODE_BOOT_FLAG ? true : false); 857f0cf6658SJayashree-D oemData[bootOrderKey][KEY_BOOT_MODE] = bootMode; 858877d5dd9SVijay Khemka 859877d5dd9SVijay Khemka /* Initialize boot sequence array */ 860f0cf6658SJayashree-D oemData[bootOrderKey][KEY_BOOT_SEQ] = {}; 861877d5dd9SVijay Khemka for (i = 1; i < SIZE_BOOT_ORDER; i++) 862877d5dd9SVijay Khemka { 863877d5dd9SVijay Khemka if (data[i] >= BOOT_SEQ_ARRAY_SIZE) 864f0cf6658SJayashree-D oemData[bootOrderKey][KEY_BOOT_SEQ][i - 1] = "NA"; 865877d5dd9SVijay Khemka else 866f0cf6658SJayashree-D oemData[bootOrderKey][KEY_BOOT_SEQ][i - 1] = bootSeq[data[i]]; 867877d5dd9SVijay Khemka } 868877d5dd9SVijay Khemka 869877d5dd9SVijay Khemka flushOemData(); 870877d5dd9SVijay Khemka } 871877d5dd9SVijay Khemka 872e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 8731d4a0697SVijay Khemka // Set Boot Order (CMD_OEM_SET_BOOT_ORDER) 8741d4a0697SVijay Khemka //---------------------------------------------------------------------- 875f0cf6658SJayashree-D ipmi::RspType<std::vector<uint8_t>> 876f0cf6658SJayashree-D ipmiOemSetBootOrder(ipmi::Context::ptr ctx, std::vector<uint8_t> data) 8771d4a0697SVijay Khemka { 8781d4a0697SVijay Khemka 879f0cf6658SJayashree-D uint8_t bootSeq[SIZE_BOOT_ORDER]; 880f0cf6658SJayashree-D size_t len = data.size(); 8811d4a0697SVijay Khemka 8821d4a0697SVijay Khemka if (len != SIZE_BOOT_ORDER) 8831d4a0697SVijay Khemka { 8841d4a0697SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 8851d4a0697SVijay Khemka "Invalid Boot order length received"); 886f0cf6658SJayashree-D return ipmi::responseReqDataLenInvalid(); 8871d4a0697SVijay Khemka } 8881d4a0697SVijay Khemka 889f0cf6658SJayashree-D std::copy(std::begin(data), std::end(data), bootSeq); 8904ec80567SJayashree Dhanapal std::optional<size_t> hostId = findHost(ctx->hostIdx); 8911d4a0697SVijay Khemka 892f0cf6658SJayashree-D if (!hostId) 893f0cf6658SJayashree-D { 894f0cf6658SJayashree-D phosphor::logging::log<phosphor::logging::level::ERR>( 895f0cf6658SJayashree-D "Invalid Host Id received"); 896f0cf6658SJayashree-D return ipmi::responseInvalidCommand(); 897f0cf6658SJayashree-D } 898f0cf6658SJayashree-D auto [bootObjPath, hostName] = ipmi::boot::objPath(*hostId); 899f0cf6658SJayashree-D 900f0cf6658SJayashree-D setBootOrder(bootObjPath, bootSeq, hostName); 901f0cf6658SJayashree-D 902f0cf6658SJayashree-D return ipmi::responseSuccess(data); 9031d4a0697SVijay Khemka } 9041d4a0697SVijay Khemka 9051d4a0697SVijay Khemka //---------------------------------------------------------------------- 906e7d23d0eSVijay Khemka // Get Boot Order (CMD_OEM_GET_BOOT_ORDER) 907e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 908f0cf6658SJayashree-D ipmi::RspType<uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t> 909f0cf6658SJayashree-D ipmiOemGetBootOrder(ipmi::Context::ptr ctx) 910e7d23d0eSVijay Khemka { 911f0cf6658SJayashree-D uint8_t bootSeq[SIZE_BOOT_ORDER]; 9121d4a0697SVijay Khemka uint8_t mode = 0; 913e7d23d0eSVijay Khemka 9144ec80567SJayashree Dhanapal std::optional<size_t> hostId = findHost(ctx->hostIdx); 9151d4a0697SVijay Khemka 916f0cf6658SJayashree-D if (!hostId) 917f0cf6658SJayashree-D { 918f0cf6658SJayashree-D phosphor::logging::log<phosphor::logging::level::ERR>( 919f0cf6658SJayashree-D "Invalid Host Id received"); 920f0cf6658SJayashree-D return ipmi::responseInvalidCommand(); 921f0cf6658SJayashree-D } 922f0cf6658SJayashree-D auto [bootObjPath, hostName] = ipmi::boot::objPath(*hostId); 923f0cf6658SJayashree-D 924f0cf6658SJayashree-D std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus(); 925f0cf6658SJayashree-D 92677ee489fSJayashree Dhanapal // GETTING PROPERTY OF MODE INTERFACE 92777ee489fSJayashree Dhanapal 928f0cf6658SJayashree-D std::string service = 929f0cf6658SJayashree-D getService(*dbus, ipmi::boot::bootModeIntf, bootObjPath); 930f0cf6658SJayashree-D Value variant = 931f0cf6658SJayashree-D getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootModeIntf, 932f0cf6658SJayashree-D ipmi::boot::bootModeProp); 933f0cf6658SJayashree-D 93477ee489fSJayashree Dhanapal auto bootMode = sdbusplus::message::convert_from_string<boot::BootMode>( 935f0cf6658SJayashree-D std::get<std::string>(variant)); 936f0cf6658SJayashree-D 937778147daSJayashree Dhanapal uint8_t bootOption = ipmi::boot::modeDbusToIpmi.at(bootMode); 938f0cf6658SJayashree-D 939f0cf6658SJayashree-D // GETTING PROPERTY OF SOURCE INTERFACE 940f0cf6658SJayashree-D 941f0cf6658SJayashree-D service = getService(*dbus, ipmi::boot::bootSourceIntf, bootObjPath); 942f0cf6658SJayashree-D variant = 943f0cf6658SJayashree-D getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootSourceIntf, 944f0cf6658SJayashree-D ipmi::boot::bootSourceProp); 94577ee489fSJayashree Dhanapal 94677ee489fSJayashree Dhanapal auto bootSource = sdbusplus::message::convert_from_string<boot::BootSource>( 947f0cf6658SJayashree-D std::get<std::string>(variant)); 948f0cf6658SJayashree-D 949778147daSJayashree Dhanapal uint8_t bootOrder = ipmi::boot::sourceDbusToIpmi.at(bootSource); 950778147daSJayashree Dhanapal 951778147daSJayashree Dhanapal // GETTING PROPERTY OF TYPE INTERFACE 952778147daSJayashree Dhanapal 953778147daSJayashree Dhanapal service = getService(*dbus, ipmi::boot::bootTypeIntf, bootObjPath); 954778147daSJayashree Dhanapal variant = 955778147daSJayashree Dhanapal getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootTypeIntf, 956778147daSJayashree Dhanapal ipmi::boot::bootTypeProp); 95777ee489fSJayashree Dhanapal 95877ee489fSJayashree Dhanapal auto bootType = sdbusplus::message::convert_from_string<boot::BootType>( 959778147daSJayashree Dhanapal std::get<std::string>(variant)); 960778147daSJayashree Dhanapal 961778147daSJayashree Dhanapal uint8_t bootTypeVal = ipmi::boot::typeDbusToIpmi.at(bootType); 962778147daSJayashree Dhanapal 963778147daSJayashree Dhanapal uint8_t bootVal = bootOption | bootTypeVal; 964f0cf6658SJayashree-D 965f0cf6658SJayashree-D if (oemData.find(hostName) == oemData.end()) 966877d5dd9SVijay Khemka { 967877d5dd9SVijay Khemka /* Return default boot order 0100090203ff */ 968877d5dd9SVijay Khemka uint8_t defaultBoot[SIZE_BOOT_ORDER] = { 969e39f9393SWilly Tu BOOT_MODE_UEFI, 970e39f9393SWilly Tu static_cast<uint8_t>(bootMap["USB_DEV"]), 971e39f9393SWilly Tu static_cast<uint8_t>(bootMap["NET_IPV6"]), 972e39f9393SWilly Tu static_cast<uint8_t>(bootMap["SATA_HDD"]), 973e39f9393SWilly Tu static_cast<uint8_t>(bootMap["SATA_CD"]), 974e39f9393SWilly Tu 0xff}; 975877d5dd9SVijay Khemka 976f0cf6658SJayashree-D memcpy(bootSeq, defaultBoot, SIZE_BOOT_ORDER); 977877d5dd9SVijay Khemka phosphor::logging::log<phosphor::logging::level::INFO>( 978877d5dd9SVijay Khemka "Set default boot order"); 979f0cf6658SJayashree-D setBootOrder(bootObjPath, defaultBoot, hostName); 980877d5dd9SVijay Khemka } 981877d5dd9SVijay Khemka else 982877d5dd9SVijay Khemka { 983f0cf6658SJayashree-D nlohmann::json bootMode = oemData[hostName][KEY_BOOT_MODE]; 9841d4a0697SVijay Khemka if (bootMode["UEFI"]) 9851d4a0697SVijay Khemka mode |= BOOT_MODE_UEFI; 9861d4a0697SVijay Khemka if (bootMode["CMOS_CLR"]) 9871d4a0697SVijay Khemka mode |= BOOT_MODE_CMOS_CLR; 9881d4a0697SVijay Khemka if (bootMode["BOOT_FLAG"]) 9891d4a0697SVijay Khemka mode |= BOOT_MODE_BOOT_FLAG; 9901d4a0697SVijay Khemka 991f0cf6658SJayashree-D bootSeq[0] = mode; 9921d4a0697SVijay Khemka 993f0cf6658SJayashree-D for (int i = 1; i < SIZE_BOOT_ORDER; i++) 994877d5dd9SVijay Khemka { 995f0cf6658SJayashree-D std::string seqStr = oemData[hostName][KEY_BOOT_SEQ][i - 1]; 996877d5dd9SVijay Khemka if (bootMap.find(seqStr) != bootMap.end()) 997f0cf6658SJayashree-D bootSeq[i] = bootMap[seqStr]; 998877d5dd9SVijay Khemka else 999f0cf6658SJayashree-D bootSeq[i] = 0xff; 1000877d5dd9SVijay Khemka } 1001877d5dd9SVijay Khemka } 1002e7d23d0eSVijay Khemka 1003778147daSJayashree Dhanapal return ipmi::responseSuccess(bootVal, bootOrder, bootSeq[2], bootSeq[3], 1004f0cf6658SJayashree-D bootSeq[4], bootSeq[5]); 1005e7d23d0eSVijay Khemka } 1006e7d23d0eSVijay Khemka // Set Machine Config Info (CMD_OEM_SET_MACHINE_CONFIG_INFO) 1007e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1008e39f9393SWilly Tu ipmi_ret_t ipmiOemSetMachineCfgInfo(ipmi_netfn_t, ipmi_cmd_t, 1009e39f9393SWilly Tu ipmi_request_t request, ipmi_response_t, 1010e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t) 1011e7d23d0eSVijay Khemka { 10121d4a0697SVijay Khemka machineConfigInfo_t* req = reinterpret_cast<machineConfigInfo_t*>(request); 10131d4a0697SVijay Khemka uint8_t len = *data_len; 1014e7d23d0eSVijay Khemka 1015e7d23d0eSVijay Khemka *data_len = 0; 1016e7d23d0eSVijay Khemka 10171d4a0697SVijay Khemka if (len < sizeof(machineConfigInfo_t)) 10181d4a0697SVijay Khemka { 10191d4a0697SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 10201d4a0697SVijay Khemka "Invalid machine configuration length received"); 10211d4a0697SVijay Khemka return IPMI_CC_REQ_DATA_LEN_INVALID; 10221d4a0697SVijay Khemka } 10231d4a0697SVijay Khemka 10241d4a0697SVijay Khemka if (req->chassis_type >= sizeof(chassisType) / sizeof(uint8_t*)) 10251d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_CHAS_TYPE] = "UNKNOWN"; 10261d4a0697SVijay Khemka else 10271d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_CHAS_TYPE] = 10281d4a0697SVijay Khemka chassisType[req->chassis_type]; 10291d4a0697SVijay Khemka 10301d4a0697SVijay Khemka if (req->mb_type >= sizeof(mbType) / sizeof(uint8_t*)) 10311d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_MB_TYPE] = "UNKNOWN"; 10321d4a0697SVijay Khemka else 10331d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_MB_TYPE] = mbType[req->mb_type]; 10341d4a0697SVijay Khemka 10351d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_PROC_CNT] = req->proc_cnt; 10361d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_MEM_CNT] = req->mem_cnt; 10371d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_HDD35_CNT] = req->hdd35_cnt; 10381d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_HDD25_CNT] = req->hdd25_cnt; 10391d4a0697SVijay Khemka 10401d4a0697SVijay Khemka if (req->riser_type >= sizeof(riserType) / sizeof(uint8_t*)) 10411d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_RSR_TYPE] = "UNKNOWN"; 10421d4a0697SVijay Khemka else 10431d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_RSR_TYPE] = riserType[req->riser_type]; 10441d4a0697SVijay Khemka 10451d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC] = {}; 10461d4a0697SVijay Khemka int i = 0; 10471d4a0697SVijay Khemka if (req->pcie_card_loc & BIT_0) 10481d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT1"; 10491d4a0697SVijay Khemka if (req->pcie_card_loc & BIT_1) 10501d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT2"; 10511d4a0697SVijay Khemka if (req->pcie_card_loc & BIT_2) 10521d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT3"; 10531d4a0697SVijay Khemka if (req->pcie_card_loc & BIT_3) 10541d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT4"; 10551d4a0697SVijay Khemka 10561d4a0697SVijay Khemka if (req->slot1_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*)) 10571d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_SLOT1_TYPE] = "UNKNOWN"; 10581d4a0697SVijay Khemka else 10591d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_SLOT1_TYPE] = 10601d4a0697SVijay Khemka pcieType[req->slot1_pcie_type]; 10611d4a0697SVijay Khemka 10621d4a0697SVijay Khemka if (req->slot2_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*)) 10631d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_SLOT2_TYPE] = "UNKNOWN"; 10641d4a0697SVijay Khemka else 10651d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_SLOT2_TYPE] = 10661d4a0697SVijay Khemka pcieType[req->slot2_pcie_type]; 10671d4a0697SVijay Khemka 10681d4a0697SVijay Khemka if (req->slot3_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*)) 10691d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_SLOT3_TYPE] = "UNKNOWN"; 10701d4a0697SVijay Khemka else 10711d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_SLOT3_TYPE] = 10721d4a0697SVijay Khemka pcieType[req->slot3_pcie_type]; 10731d4a0697SVijay Khemka 10741d4a0697SVijay Khemka if (req->slot4_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*)) 10751d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_SLOT4_TYPE] = "UNKNOWN"; 10761d4a0697SVijay Khemka else 10771d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_SLOT4_TYPE] = 10781d4a0697SVijay Khemka pcieType[req->slot4_pcie_type]; 10791d4a0697SVijay Khemka 10801d4a0697SVijay Khemka oemData[KEY_MC_CONFIG][KEY_MC_AEP_CNT] = req->aep_mem_cnt; 10811d4a0697SVijay Khemka 10821d4a0697SVijay Khemka flushOemData(); 10831d4a0697SVijay Khemka 1084e7d23d0eSVijay Khemka return IPMI_CC_OK; 1085e7d23d0eSVijay Khemka } 1086e7d23d0eSVijay Khemka 1087e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1088e7d23d0eSVijay Khemka // Set POST start (CMD_OEM_SET_POST_START) 1089e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1090e39f9393SWilly Tu ipmi_ret_t ipmiOemSetPostStart(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, 1091e39f9393SWilly Tu ipmi_response_t, ipmi_data_len_t data_len, 1092e39f9393SWilly Tu ipmi_context_t) 1093e7d23d0eSVijay Khemka { 1094e7d23d0eSVijay Khemka phosphor::logging::log<phosphor::logging::level::INFO>("POST Start Event"); 1095e7d23d0eSVijay Khemka 10961d4a0697SVijay Khemka /* Do nothing, return success */ 1097e7d23d0eSVijay Khemka *data_len = 0; 1098e7d23d0eSVijay Khemka return IPMI_CC_OK; 1099e7d23d0eSVijay Khemka } 1100e7d23d0eSVijay Khemka 1101e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1102e7d23d0eSVijay Khemka // Set POST End (CMD_OEM_SET_POST_END) 1103e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1104e39f9393SWilly Tu ipmi_ret_t ipmiOemSetPostEnd(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, 1105e39f9393SWilly Tu ipmi_response_t, ipmi_data_len_t data_len, 1106e39f9393SWilly Tu ipmi_context_t) 1107e7d23d0eSVijay Khemka { 11081d4a0697SVijay Khemka struct timespec ts; 1109e7d23d0eSVijay Khemka 1110e7d23d0eSVijay Khemka phosphor::logging::log<phosphor::logging::level::INFO>("POST End Event"); 1111e7d23d0eSVijay Khemka 1112e7d23d0eSVijay Khemka *data_len = 0; 11131d4a0697SVijay Khemka 11141d4a0697SVijay Khemka // Timestamp post end time. 11151d4a0697SVijay Khemka clock_gettime(CLOCK_REALTIME, &ts); 11161d4a0697SVijay Khemka oemData[KEY_TS_SLED] = ts.tv_sec; 11171d4a0697SVijay Khemka flushOemData(); 11181d4a0697SVijay Khemka 11191d4a0697SVijay Khemka // Sync time with system 11201d4a0697SVijay Khemka // TODO: Add code for syncing time 11211d4a0697SVijay Khemka 11221d4a0697SVijay Khemka return IPMI_CC_OK; 11231d4a0697SVijay Khemka } 11241d4a0697SVijay Khemka 11251d4a0697SVijay Khemka //---------------------------------------------------------------------- 11261d4a0697SVijay Khemka // Set PPIN Info (CMD_OEM_SET_PPIN_INFO) 11271d4a0697SVijay Khemka //---------------------------------------------------------------------- 11281d4a0697SVijay Khemka // Inform BMC about PPIN data of 8 bytes for each CPU 11291d4a0697SVijay Khemka // 11301d4a0697SVijay Khemka // Request: 11311d4a0697SVijay Khemka // Byte 1:8 – CPU0 PPIN data 11321d4a0697SVijay Khemka // Optional: 11331d4a0697SVijay Khemka // Byte 9:16 – CPU1 PPIN data 11341d4a0697SVijay Khemka // 11351d4a0697SVijay Khemka // Response: 11361d4a0697SVijay Khemka // Byte 1 – Completion Code 1137e39f9393SWilly Tu ipmi_ret_t ipmiOemSetPPINInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, 1138e39f9393SWilly Tu ipmi_response_t, ipmi_data_len_t data_len, 1139e39f9393SWilly Tu ipmi_context_t) 11401d4a0697SVijay Khemka { 11411d4a0697SVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 11421d4a0697SVijay Khemka std::string ppinStr; 11431d4a0697SVijay Khemka int len; 11441d4a0697SVijay Khemka 11451d4a0697SVijay Khemka if (*data_len > SIZE_CPU_PPIN * 2) 11461d4a0697SVijay Khemka len = SIZE_CPU_PPIN * 2; 11471d4a0697SVijay Khemka else 11481d4a0697SVijay Khemka len = *data_len; 11491d4a0697SVijay Khemka *data_len = 0; 11501d4a0697SVijay Khemka 11511d4a0697SVijay Khemka ppinStr = bytesToStr(req, len); 11521d4a0697SVijay Khemka oemData[KEY_PPIN_INFO] = ppinStr.c_str(); 11531d4a0697SVijay Khemka flushOemData(); 11541d4a0697SVijay Khemka 11551d4a0697SVijay Khemka return IPMI_CC_OK; 11561d4a0697SVijay Khemka } 11571d4a0697SVijay Khemka 11581d4a0697SVijay Khemka //---------------------------------------------------------------------- 11591d4a0697SVijay Khemka // Set ADR Trigger (CMD_OEM_SET_ADR_TRIGGER) 11601d4a0697SVijay Khemka //---------------------------------------------------------------------- 1161e39f9393SWilly Tu ipmi_ret_t ipmiOemSetAdrTrigger(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, 1162e39f9393SWilly Tu ipmi_response_t, ipmi_data_len_t data_len, 1163e39f9393SWilly Tu ipmi_context_t) 11641d4a0697SVijay Khemka { 11651d4a0697SVijay Khemka /* Do nothing, return success */ 11661d4a0697SVijay Khemka *data_len = 0; 1167e7d23d0eSVijay Khemka return IPMI_CC_OK; 1168e7d23d0eSVijay Khemka } 1169e7d23d0eSVijay Khemka 1170f2246ce8SVijay Khemka // Helper function to set guid at offset in EEPROM 1171e39f9393SWilly Tu [[maybe_unused]] static int setGUID(off_t offset, uint8_t* guid) 1172f2246ce8SVijay Khemka { 1173f2246ce8SVijay Khemka int fd = -1; 1174f2246ce8SVijay Khemka ssize_t len; 1175f2246ce8SVijay Khemka int ret = 0; 1176f2246ce8SVijay Khemka 1177f2246ce8SVijay Khemka errno = 0; 1178f2246ce8SVijay Khemka 1179f2246ce8SVijay Khemka // Check if file is present 1180f2246ce8SVijay Khemka if (access(FRU_EEPROM, F_OK) == -1) 1181f2246ce8SVijay Khemka { 1182f2246ce8SVijay Khemka std::cerr << "Unable to access: " << FRU_EEPROM << std::endl; 1183f2246ce8SVijay Khemka return errno; 1184f2246ce8SVijay Khemka } 1185f2246ce8SVijay Khemka 1186f2246ce8SVijay Khemka // Open the file 1187f2246ce8SVijay Khemka fd = open(FRU_EEPROM, O_WRONLY); 1188f2246ce8SVijay Khemka if (fd == -1) 1189f2246ce8SVijay Khemka { 1190f2246ce8SVijay Khemka std::cerr << "Unable to open: " << FRU_EEPROM << std::endl; 1191f2246ce8SVijay Khemka return errno; 1192f2246ce8SVijay Khemka } 1193f2246ce8SVijay Khemka 1194f2246ce8SVijay Khemka // seek to the offset 1195f2246ce8SVijay Khemka lseek(fd, offset, SEEK_SET); 1196f2246ce8SVijay Khemka 1197f2246ce8SVijay Khemka // Write bytes to location 1198f2246ce8SVijay Khemka len = write(fd, guid, GUID_SIZE); 1199f2246ce8SVijay Khemka if (len != GUID_SIZE) 1200f2246ce8SVijay Khemka { 1201f2246ce8SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 1202f2246ce8SVijay Khemka "GUID write data to EEPROM failed"); 1203f2246ce8SVijay Khemka ret = errno; 1204f2246ce8SVijay Khemka } 1205f2246ce8SVijay Khemka 1206f2246ce8SVijay Khemka close(fd); 1207f2246ce8SVijay Khemka return ret; 1208f2246ce8SVijay Khemka } 1209f2246ce8SVijay Khemka 1210f2246ce8SVijay Khemka //---------------------------------------------------------------------- 1211f2246ce8SVijay Khemka // Set System GUID (CMD_OEM_SET_SYSTEM_GUID) 1212f2246ce8SVijay Khemka //---------------------------------------------------------------------- 12135f8e3435SManikandan Elumalai #if BIC_ENABLED 1214e39f9393SWilly Tu ipmi::RspType<> ipmiOemSetSystemGuid(ipmi::Context::ptr ctx, uint8_t, 12155f8e3435SManikandan Elumalai std::vector<uint8_t> reqData) 12165f8e3435SManikandan Elumalai { 12175f8e3435SManikandan Elumalai std::vector<uint8_t> respData; 12185f8e3435SManikandan Elumalai 12195f8e3435SManikandan Elumalai if (reqData.size() != GUID_SIZE) // 16bytes 12205f8e3435SManikandan Elumalai { 12215f8e3435SManikandan Elumalai 12225f8e3435SManikandan Elumalai return ipmi::responseReqDataLenInvalid(); 12235f8e3435SManikandan Elumalai } 12245f8e3435SManikandan Elumalai 12255f8e3435SManikandan Elumalai uint8_t bicAddr = (uint8_t)ctx->hostIdx << 2; 12265f8e3435SManikandan Elumalai 12275f8e3435SManikandan Elumalai if (sendBicCmd(ctx->netFn, ctx->cmd, bicAddr, reqData, respData)) 12285f8e3435SManikandan Elumalai return ipmi::responseUnspecifiedError(); 12295f8e3435SManikandan Elumalai 12305f8e3435SManikandan Elumalai return ipmi::responseSuccess(); 12315f8e3435SManikandan Elumalai } 12325f8e3435SManikandan Elumalai 12335f8e3435SManikandan Elumalai #else 1234*d5353caaSPotin Lai ipmi_ret_t ipmiOemSetSystemGuid(ipmi_netfn_t, ipmi_cmd_t, 1235*d5353caaSPotin Lai ipmi_request_t request, ipmi_response_t, 1236*d5353caaSPotin Lai ipmi_data_len_t data_len, ipmi_context_t) 1237f2246ce8SVijay Khemka { 1238f2246ce8SVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 1239f2246ce8SVijay Khemka 1240f2246ce8SVijay Khemka if (*data_len != GUID_SIZE) // 16bytes 1241f2246ce8SVijay Khemka { 1242f2246ce8SVijay Khemka *data_len = 0; 1243f2246ce8SVijay Khemka return IPMI_CC_REQ_DATA_LEN_INVALID; 1244f2246ce8SVijay Khemka } 1245f2246ce8SVijay Khemka 1246f2246ce8SVijay Khemka *data_len = 0; 1247f2246ce8SVijay Khemka 1248f2246ce8SVijay Khemka if (setGUID(OFFSET_SYS_GUID, req)) 1249f2246ce8SVijay Khemka { 1250f2246ce8SVijay Khemka return IPMI_CC_UNSPECIFIED_ERROR; 1251f2246ce8SVijay Khemka } 1252f2246ce8SVijay Khemka return IPMI_CC_OK; 1253f2246ce8SVijay Khemka } 12545f8e3435SManikandan Elumalai #endif 1255f2246ce8SVijay Khemka 1256e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1257e7d23d0eSVijay Khemka // Set Bios Flash Info (CMD_OEM_SET_BIOS_FLASH_INFO) 1258e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1259e39f9393SWilly Tu ipmi_ret_t ipmiOemSetBiosFlashInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, 1260e39f9393SWilly Tu ipmi_response_t, ipmi_data_len_t data_len, 1261e39f9393SWilly Tu ipmi_context_t) 1262e7d23d0eSVijay Khemka { 12631d4a0697SVijay Khemka /* Do nothing, return success */ 1264e7d23d0eSVijay Khemka *data_len = 0; 1265e7d23d0eSVijay Khemka return IPMI_CC_OK; 1266e7d23d0eSVijay Khemka } 1267e7d23d0eSVijay Khemka 1268e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1269e7d23d0eSVijay Khemka // Set PPR (CMD_OEM_SET_PPR) 1270e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1271e39f9393SWilly Tu ipmi_ret_t ipmiOemSetPpr(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, 1272e39f9393SWilly Tu ipmi_response_t, ipmi_data_len_t data_len, 1273e39f9393SWilly Tu ipmi_context_t) 1274e7d23d0eSVijay Khemka { 1275e7d23d0eSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 12761d4a0697SVijay Khemka uint8_t pprCnt, pprAct, pprIndex; 12771d4a0697SVijay Khemka uint8_t selParam = req[0]; 12781d4a0697SVijay Khemka uint8_t len = *data_len; 12791d4a0697SVijay Khemka std::stringstream ss; 12801d4a0697SVijay Khemka std::string str; 1281e7d23d0eSVijay Khemka 1282e7d23d0eSVijay Khemka *data_len = 0; 12831d4a0697SVijay Khemka 12841d4a0697SVijay Khemka switch (selParam) 12851d4a0697SVijay Khemka { 12861d4a0697SVijay Khemka case PPR_ACTION: 12871d4a0697SVijay Khemka if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) == 12881d4a0697SVijay Khemka oemData[KEY_PPR].end()) 12891d4a0697SVijay Khemka return CC_PARAM_NOT_SUPP_IN_CURR_STATE; 12901d4a0697SVijay Khemka 12911d4a0697SVijay Khemka pprCnt = oemData[KEY_PPR][KEY_PPR_ROW_COUNT]; 12921d4a0697SVijay Khemka if (pprCnt == 0) 12931d4a0697SVijay Khemka return CC_PARAM_NOT_SUPP_IN_CURR_STATE; 12941d4a0697SVijay Khemka 12951d4a0697SVijay Khemka pprAct = req[1]; 12961d4a0697SVijay Khemka /* Check if ppr is enabled or disabled */ 12971d4a0697SVijay Khemka if (!(pprAct & 0x80)) 12981d4a0697SVijay Khemka pprAct = 0; 12991d4a0697SVijay Khemka 13001d4a0697SVijay Khemka oemData[KEY_PPR][KEY_PPR_ACTION] = pprAct; 13011d4a0697SVijay Khemka break; 13021d4a0697SVijay Khemka case PPR_ROW_COUNT: 13031d4a0697SVijay Khemka if (req[1] > 100) 13041d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 13051d4a0697SVijay Khemka 13061d4a0697SVijay Khemka oemData[KEY_PPR][KEY_PPR_ROW_COUNT] = req[1]; 13071d4a0697SVijay Khemka break; 13081d4a0697SVijay Khemka case PPR_ROW_ADDR: 13091d4a0697SVijay Khemka pprIndex = req[1]; 13101d4a0697SVijay Khemka if (pprIndex > 100) 13111d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 13121d4a0697SVijay Khemka 13131d4a0697SVijay Khemka if (len < PPR_ROW_ADDR_LEN + 1) 13141d4a0697SVijay Khemka { 13151d4a0697SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 13161d4a0697SVijay Khemka "Invalid PPR Row Address length received"); 13171d4a0697SVijay Khemka return IPMI_CC_REQ_DATA_LEN_INVALID; 13181d4a0697SVijay Khemka } 13191d4a0697SVijay Khemka 13201d4a0697SVijay Khemka ss << std::hex; 13211d4a0697SVijay Khemka ss << std::setw(2) << std::setfill('0') << (int)pprIndex; 13221d4a0697SVijay Khemka 13231d4a0697SVijay Khemka oemData[KEY_PPR][ss.str()][KEY_PPR_INDEX] = pprIndex; 13241d4a0697SVijay Khemka 13251d4a0697SVijay Khemka str = bytesToStr(&req[1], PPR_ROW_ADDR_LEN); 13261d4a0697SVijay Khemka oemData[KEY_PPR][ss.str()][KEY_PPR_ROW_ADDR] = str.c_str(); 13271d4a0697SVijay Khemka break; 13281d4a0697SVijay Khemka case PPR_HISTORY_DATA: 13291d4a0697SVijay Khemka pprIndex = req[1]; 13301d4a0697SVijay Khemka if (pprIndex > 100) 13311d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 13321d4a0697SVijay Khemka 13331d4a0697SVijay Khemka if (len < PPR_HST_DATA_LEN + 1) 13341d4a0697SVijay Khemka { 13351d4a0697SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 13361d4a0697SVijay Khemka "Invalid PPR history data length received"); 13371d4a0697SVijay Khemka return IPMI_CC_REQ_DATA_LEN_INVALID; 13381d4a0697SVijay Khemka } 13391d4a0697SVijay Khemka 13401d4a0697SVijay Khemka ss << std::hex; 13411d4a0697SVijay Khemka ss << std::setw(2) << std::setfill('0') << (int)pprIndex; 13421d4a0697SVijay Khemka 13431d4a0697SVijay Khemka oemData[KEY_PPR][ss.str()][KEY_PPR_INDEX] = pprIndex; 13441d4a0697SVijay Khemka 13451d4a0697SVijay Khemka str = bytesToStr(&req[1], PPR_HST_DATA_LEN); 13461d4a0697SVijay Khemka oemData[KEY_PPR][ss.str()][KEY_PPR_HST_DATA] = str.c_str(); 13471d4a0697SVijay Khemka break; 13481d4a0697SVijay Khemka default: 13491d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 13501d4a0697SVijay Khemka break; 13511d4a0697SVijay Khemka } 13521d4a0697SVijay Khemka 13531d4a0697SVijay Khemka flushOemData(); 13541d4a0697SVijay Khemka 1355e7d23d0eSVijay Khemka return IPMI_CC_OK; 1356e7d23d0eSVijay Khemka } 1357e7d23d0eSVijay Khemka 1358e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1359e7d23d0eSVijay Khemka // Get PPR (CMD_OEM_GET_PPR) 1360e7d23d0eSVijay Khemka //---------------------------------------------------------------------- 1361e39f9393SWilly Tu ipmi_ret_t ipmiOemGetPpr(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, 1362e39f9393SWilly Tu ipmi_response_t response, ipmi_data_len_t data_len, 1363e39f9393SWilly Tu ipmi_context_t) 1364e7d23d0eSVijay Khemka { 1365e7d23d0eSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 1366e7d23d0eSVijay Khemka uint8_t* res = reinterpret_cast<uint8_t*>(response); 13671d4a0697SVijay Khemka uint8_t pprCnt, pprIndex; 13681d4a0697SVijay Khemka uint8_t selParam = req[0]; 13691d4a0697SVijay Khemka std::stringstream ss; 13701d4a0697SVijay Khemka std::string str; 1371e7d23d0eSVijay Khemka 13721d4a0697SVijay Khemka /* Any failure will return zero length data */ 13731d4a0697SVijay Khemka *data_len = 0; 13741d4a0697SVijay Khemka 13751d4a0697SVijay Khemka switch (selParam) 13761d4a0697SVijay Khemka { 13771d4a0697SVijay Khemka case PPR_ACTION: 13781d4a0697SVijay Khemka res[0] = 0; 1379e7d23d0eSVijay Khemka *data_len = 1; 1380e7d23d0eSVijay Khemka 13811d4a0697SVijay Khemka if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) != 13821d4a0697SVijay Khemka oemData[KEY_PPR].end()) 13831d4a0697SVijay Khemka { 13841d4a0697SVijay Khemka pprCnt = oemData[KEY_PPR][KEY_PPR_ROW_COUNT]; 13851d4a0697SVijay Khemka if (pprCnt != 0) 13861d4a0697SVijay Khemka { 13871d4a0697SVijay Khemka if (oemData[KEY_PPR].find(KEY_PPR_ACTION) != 13881d4a0697SVijay Khemka oemData[KEY_PPR].end()) 13891d4a0697SVijay Khemka { 13901d4a0697SVijay Khemka res[0] = oemData[KEY_PPR][KEY_PPR_ACTION]; 13911d4a0697SVijay Khemka } 13921d4a0697SVijay Khemka } 13931d4a0697SVijay Khemka } 13941d4a0697SVijay Khemka break; 13951d4a0697SVijay Khemka case PPR_ROW_COUNT: 13961d4a0697SVijay Khemka res[0] = 0; 13971d4a0697SVijay Khemka *data_len = 1; 13981d4a0697SVijay Khemka if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) != 13991d4a0697SVijay Khemka oemData[KEY_PPR].end()) 14001d4a0697SVijay Khemka res[0] = oemData[KEY_PPR][KEY_PPR_ROW_COUNT]; 14011d4a0697SVijay Khemka break; 14021d4a0697SVijay Khemka case PPR_ROW_ADDR: 14031d4a0697SVijay Khemka pprIndex = req[1]; 14041d4a0697SVijay Khemka if (pprIndex > 100) 14051d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 14061d4a0697SVijay Khemka 14071d4a0697SVijay Khemka ss << std::hex; 14081d4a0697SVijay Khemka ss << std::setw(2) << std::setfill('0') << (int)pprIndex; 14091d4a0697SVijay Khemka 14101d4a0697SVijay Khemka if (oemData[KEY_PPR].find(ss.str()) == oemData[KEY_PPR].end()) 14111d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 14121d4a0697SVijay Khemka 14131d4a0697SVijay Khemka if (oemData[KEY_PPR][ss.str()].find(KEY_PPR_ROW_ADDR) == 14141d4a0697SVijay Khemka oemData[KEY_PPR][ss.str()].end()) 14151d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 14161d4a0697SVijay Khemka 14171d4a0697SVijay Khemka str = oemData[KEY_PPR][ss.str()][KEY_PPR_ROW_ADDR]; 14181d4a0697SVijay Khemka *data_len = strToBytes(str, res); 14191d4a0697SVijay Khemka break; 14201d4a0697SVijay Khemka case PPR_HISTORY_DATA: 14211d4a0697SVijay Khemka pprIndex = req[1]; 14221d4a0697SVijay Khemka if (pprIndex > 100) 14231d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 14241d4a0697SVijay Khemka 14251d4a0697SVijay Khemka ss << std::hex; 14261d4a0697SVijay Khemka ss << std::setw(2) << std::setfill('0') << (int)pprIndex; 14271d4a0697SVijay Khemka 14281d4a0697SVijay Khemka if (oemData[KEY_PPR].find(ss.str()) == oemData[KEY_PPR].end()) 14291d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 14301d4a0697SVijay Khemka 14311d4a0697SVijay Khemka if (oemData[KEY_PPR][ss.str()].find(KEY_PPR_HST_DATA) == 14321d4a0697SVijay Khemka oemData[KEY_PPR][ss.str()].end()) 14331d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 14341d4a0697SVijay Khemka 14351d4a0697SVijay Khemka str = oemData[KEY_PPR][ss.str()][KEY_PPR_HST_DATA]; 14361d4a0697SVijay Khemka *data_len = strToBytes(str, res); 14371d4a0697SVijay Khemka break; 14381d4a0697SVijay Khemka default: 14391d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 14401d4a0697SVijay Khemka break; 14411d4a0697SVijay Khemka } 14421d4a0697SVijay Khemka 14431d4a0697SVijay Khemka return IPMI_CC_OK; 14441d4a0697SVijay Khemka } 14451d4a0697SVijay Khemka 14461d4a0697SVijay Khemka /* FB OEM QC Commands */ 14471d4a0697SVijay Khemka 14481d4a0697SVijay Khemka //---------------------------------------------------------------------- 14491d4a0697SVijay Khemka // Set Proc Info (CMD_OEM_Q_SET_PROC_INFO) 14501d4a0697SVijay Khemka //---------------------------------------------------------------------- 14511d4a0697SVijay Khemka //"Request: 14521d4a0697SVijay Khemka // Byte 1:3 – Manufacturer ID – XXYYZZ h, LSB first 14531d4a0697SVijay Khemka // Byte 4 – Processor Index, 0 base 14541d4a0697SVijay Khemka // Byte 5 – Parameter Selector 14551d4a0697SVijay Khemka // Byte 6..N – Configuration parameter data (see below for Parameters 14561d4a0697SVijay Khemka // of Processor Information) 14571d4a0697SVijay Khemka // Response: 14581d4a0697SVijay Khemka // Byte 1 – Completion code 14591d4a0697SVijay Khemka // 14601d4a0697SVijay Khemka // Parameter#1: (Processor Product Name) 14611d4a0697SVijay Khemka // 14621d4a0697SVijay Khemka // Byte 1..48 –Product name(ASCII code) 14631d4a0697SVijay Khemka // Ex. Intel(R) Xeon(R) CPU E5-2685 v3 @ 2.60GHz 14641d4a0697SVijay Khemka // 14651d4a0697SVijay Khemka // Param#2: Processor Basic Information 14661d4a0697SVijay Khemka // Byte 1 – Core Number 14671d4a0697SVijay Khemka // Byte 2 – Thread Number (LSB) 14681d4a0697SVijay Khemka // Byte 3 – Thread Number (MSB) 14691d4a0697SVijay Khemka // Byte 4 – Processor frequency in MHz (LSB) 14701d4a0697SVijay Khemka // Byte 5 – Processor frequency in MHz (MSB) 14711d4a0697SVijay Khemka // Byte 6..7 – Revision 14721d4a0697SVijay Khemka // 1473d532fecaSKarthikeyan Pasupathi 1474d532fecaSKarthikeyan Pasupathi ipmi::RspType<> ipmiOemQSetProcInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t, 1475d532fecaSKarthikeyan Pasupathi uint8_t, uint8_t procIndex, 1476d532fecaSKarthikeyan Pasupathi uint8_t paramSel, 1477d532fecaSKarthikeyan Pasupathi std::vector<uint8_t> request) 14781d4a0697SVijay Khemka { 14791d4a0697SVijay Khemka uint8_t numParam = sizeof(cpuInfoKey) / sizeof(uint8_t*); 14801d4a0697SVijay Khemka std::stringstream ss; 14811d4a0697SVijay Khemka std::string str; 1482d532fecaSKarthikeyan Pasupathi uint8_t len = request.size(); 1483d532fecaSKarthikeyan Pasupathi auto hostId = findHost(ctx->hostIdx); 1484d532fecaSKarthikeyan Pasupathi if (!hostId) 1485d532fecaSKarthikeyan Pasupathi { 1486d532fecaSKarthikeyan Pasupathi phosphor::logging::log<phosphor::logging::level::ERR>( 1487d532fecaSKarthikeyan Pasupathi "Invalid Host Id received"); 1488d532fecaSKarthikeyan Pasupathi return ipmi::responseInvalidCommand(); 1489d532fecaSKarthikeyan Pasupathi } 1490d532fecaSKarthikeyan Pasupathi std::string procInfo = KEY_Q_PROC_INFO + std::to_string(*hostId); 14911d4a0697SVijay Khemka /* check for requested data params */ 1492d532fecaSKarthikeyan Pasupathi if (len < 5 || paramSel < 1 || paramSel >= numParam) 14931d4a0697SVijay Khemka { 14941d4a0697SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 14951d4a0697SVijay Khemka "Invalid parameter received"); 1496d532fecaSKarthikeyan Pasupathi return ipmi::responseParmOutOfRange(); 14971d4a0697SVijay Khemka } 14981d4a0697SVijay Khemka ss << std::hex; 1499d532fecaSKarthikeyan Pasupathi ss << std::setw(2) << std::setfill('0') << (int)procIndex; 1500d532fecaSKarthikeyan Pasupathi oemData[procInfo][ss.str()][KEY_PROC_INDEX] = procIndex; 1501d532fecaSKarthikeyan Pasupathi str = bytesToStr(request.data(), len); 1502d532fecaSKarthikeyan Pasupathi oemData[procInfo][ss.str()][cpuInfoKey[paramSel]] = str.c_str(); 15031d4a0697SVijay Khemka flushOemData(); 1504d532fecaSKarthikeyan Pasupathi return ipmi::responseSuccess(); 15051d4a0697SVijay Khemka } 15061d4a0697SVijay Khemka 15071d4a0697SVijay Khemka //---------------------------------------------------------------------- 15081d4a0697SVijay Khemka // Get Proc Info (CMD_OEM_Q_GET_PROC_INFO) 15091d4a0697SVijay Khemka //---------------------------------------------------------------------- 15101d4a0697SVijay Khemka // Request: 15111d4a0697SVijay Khemka // Byte 1:3 – Manufacturer ID – XXYYZZ h, LSB first 15121d4a0697SVijay Khemka // Byte 4 – Processor Index, 0 base 15131d4a0697SVijay Khemka // Byte 5 – Parameter Selector 15141d4a0697SVijay Khemka // Response: 15151d4a0697SVijay Khemka // Byte 1 – Completion code 15161d4a0697SVijay Khemka // Byte 2..N – Configuration Parameter Data (see below for Parameters 15171d4a0697SVijay Khemka // of Processor Information) 15181d4a0697SVijay Khemka // 15191d4a0697SVijay Khemka // Parameter#1: (Processor Product Name) 15201d4a0697SVijay Khemka // 15211d4a0697SVijay Khemka // Byte 1..48 –Product name(ASCII code) 15221d4a0697SVijay Khemka // Ex. Intel(R) Xeon(R) CPU E5-2685 v3 @ 2.60GHz 15231d4a0697SVijay Khemka // 15241d4a0697SVijay Khemka // Param#2: Processor Basic Information 15251d4a0697SVijay Khemka // Byte 1 – Core Number 15261d4a0697SVijay Khemka // Byte 2 – Thread Number (LSB) 15271d4a0697SVijay Khemka // Byte 3 – Thread Number (MSB) 15281d4a0697SVijay Khemka // Byte 4 – Processor frequency in MHz (LSB) 15291d4a0697SVijay Khemka // Byte 5 – Processor frequency in MHz (MSB) 15301d4a0697SVijay Khemka // Byte 6..7 – Revision 15311d4a0697SVijay Khemka // 1532d532fecaSKarthikeyan Pasupathi 1533d532fecaSKarthikeyan Pasupathi ipmi::RspType<std::vector<uint8_t>> 1534d532fecaSKarthikeyan Pasupathi ipmiOemQGetProcInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t, uint8_t, 1535d532fecaSKarthikeyan Pasupathi uint8_t procIndex, uint8_t paramSel) 15361d4a0697SVijay Khemka { 15371d4a0697SVijay Khemka uint8_t numParam = sizeof(cpuInfoKey) / sizeof(uint8_t*); 15381d4a0697SVijay Khemka std::stringstream ss; 15391d4a0697SVijay Khemka std::string str; 1540d532fecaSKarthikeyan Pasupathi uint8_t res[MAX_BUF]; 1541d532fecaSKarthikeyan Pasupathi auto hostId = findHost(ctx->hostIdx); 1542d532fecaSKarthikeyan Pasupathi if (!hostId) 1543d532fecaSKarthikeyan Pasupathi { 1544d532fecaSKarthikeyan Pasupathi phosphor::logging::log<phosphor::logging::level::ERR>( 1545d532fecaSKarthikeyan Pasupathi "Invalid Host Id received"); 1546d532fecaSKarthikeyan Pasupathi return ipmi::responseInvalidCommand(); 1547d532fecaSKarthikeyan Pasupathi } 1548d532fecaSKarthikeyan Pasupathi std::string procInfo = KEY_Q_PROC_INFO + std::to_string(*hostId); 1549d532fecaSKarthikeyan Pasupathi if (paramSel < 1 || paramSel >= numParam) 15501d4a0697SVijay Khemka { 15511d4a0697SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 15521d4a0697SVijay Khemka "Invalid parameter received"); 1553d532fecaSKarthikeyan Pasupathi return ipmi::responseParmOutOfRange(); 15541d4a0697SVijay Khemka } 15551d4a0697SVijay Khemka ss << std::hex; 1556d532fecaSKarthikeyan Pasupathi ss << std::setw(2) << std::setfill('0') << (int)procIndex; 1557d532fecaSKarthikeyan Pasupathi if (oemData[procInfo].find(ss.str()) == oemData[procInfo].end()) 1558d532fecaSKarthikeyan Pasupathi return ipmi::responseCommandNotAvailable(); 1559d532fecaSKarthikeyan Pasupathi if (oemData[procInfo][ss.str()].find(cpuInfoKey[paramSel]) == 1560d532fecaSKarthikeyan Pasupathi oemData[procInfo][ss.str()].end()) 1561d532fecaSKarthikeyan Pasupathi return ipmi::responseCommandNotAvailable(); 1562d532fecaSKarthikeyan Pasupathi str = oemData[procInfo][ss.str()][cpuInfoKey[paramSel]]; 1563d532fecaSKarthikeyan Pasupathi int dataLen = strToBytes(str, res); 1564d532fecaSKarthikeyan Pasupathi std::vector<uint8_t> response(&res[0], &res[dataLen]); 1565d532fecaSKarthikeyan Pasupathi return ipmi::responseSuccess(response); 15661d4a0697SVijay Khemka } 15671d4a0697SVijay Khemka 15681d4a0697SVijay Khemka //---------------------------------------------------------------------- 15691d4a0697SVijay Khemka // Set Dimm Info (CMD_OEM_Q_SET_DIMM_INFO) 15701d4a0697SVijay Khemka //---------------------------------------------------------------------- 15711d4a0697SVijay Khemka // Request: 15721d4a0697SVijay Khemka // Byte 1:3 – Manufacturer ID – XXYYZZh, LSB first 15731d4a0697SVijay Khemka // Byte 4 – DIMM Index, 0 base 15741d4a0697SVijay Khemka // Byte 5 – Parameter Selector 15751d4a0697SVijay Khemka // Byte 6..N – Configuration parameter data (see below for Parameters 15761d4a0697SVijay Khemka // of DIMM Information) 15771d4a0697SVijay Khemka // Response: 15781d4a0697SVijay Khemka // Byte 1 – Completion code 15791d4a0697SVijay Khemka // 15801d4a0697SVijay Khemka // Param#1 (DIMM Location): 15811d4a0697SVijay Khemka // Byte 1 – DIMM Present 15821d4a0697SVijay Khemka // Byte 1 – DIMM Present 15831d4a0697SVijay Khemka // 01h – Present 15841d4a0697SVijay Khemka // FFh – Not Present 15851d4a0697SVijay Khemka // Byte 2 – Node Number, 0 base 15861d4a0697SVijay Khemka // Byte 3 – Channel Number , 0 base 15871d4a0697SVijay Khemka // Byte 4 – DIMM Number , 0 base 15881d4a0697SVijay Khemka // 15891d4a0697SVijay Khemka // Param#2 (DIMM Type): 15901d4a0697SVijay Khemka // Byte 1 – DIMM Type 15911d4a0697SVijay Khemka // Bit [7:6] 15921d4a0697SVijay Khemka // For DDR3 15931d4a0697SVijay Khemka // 00 – Normal Voltage (1.5V) 15941d4a0697SVijay Khemka // 01 – Ultra Low Voltage (1.25V) 15951d4a0697SVijay Khemka // 10 – Low Voltage (1.35V) 15961d4a0697SVijay Khemka // 11 – Reserved 15971d4a0697SVijay Khemka // For DDR4 15981d4a0697SVijay Khemka // 00 – Reserved 15991d4a0697SVijay Khemka // 01 – Reserved 16001d4a0697SVijay Khemka // 10 – Reserved 16011d4a0697SVijay Khemka // 11 – Normal Voltage (1.2V) 16021d4a0697SVijay Khemka // Bit [5:0] 16031d4a0697SVijay Khemka // 0x00 – SDRAM 16041d4a0697SVijay Khemka // 0x01 – DDR-1 RAM 16051d4a0697SVijay Khemka // 0x02 – Rambus 16061d4a0697SVijay Khemka // 0x03 – DDR-2 RAM 16071d4a0697SVijay Khemka // 0x04 – FBDIMM 16081d4a0697SVijay Khemka // 0x05 – DDR-3 RAM 16091d4a0697SVijay Khemka // 0x06 – DDR-4 RAM 16101d4a0697SVijay Khemka // 16111d4a0697SVijay Khemka // Param#3 (DIMM Speed): 16121d4a0697SVijay Khemka // Byte 1..2 – DIMM speed in MHz, LSB 16131d4a0697SVijay Khemka // Byte 3..6 – DIMM size in Mbytes, LSB 16141d4a0697SVijay Khemka // 16151d4a0697SVijay Khemka // Param#4 (Module Part Number): 16161d4a0697SVijay Khemka // Byte 1..20 –Module Part Number (JEDEC Standard No. 21-C) 16171d4a0697SVijay Khemka // 16181d4a0697SVijay Khemka // Param#5 (Module Serial Number): 16191d4a0697SVijay Khemka // Byte 1..4 –Module Serial Number (JEDEC Standard No. 21-C) 16201d4a0697SVijay Khemka // 16211d4a0697SVijay Khemka // Param#6 (Module Manufacturer ID): 16221d4a0697SVijay Khemka // Byte 1 - Module Manufacturer ID, LSB 16231d4a0697SVijay Khemka // Byte 2 - Module Manufacturer ID, MSB 16241d4a0697SVijay Khemka // 162510ff3d86SKarthikeyan Pasupathi ipmi::RspType<> ipmiOemQSetDimmInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t, 162610ff3d86SKarthikeyan Pasupathi uint8_t, uint8_t dimmIndex, 162710ff3d86SKarthikeyan Pasupathi uint8_t paramSel, 162810ff3d86SKarthikeyan Pasupathi std::vector<uint8_t> request) 16291d4a0697SVijay Khemka { 16301d4a0697SVijay Khemka uint8_t numParam = sizeof(dimmInfoKey) / sizeof(uint8_t*); 16311d4a0697SVijay Khemka std::stringstream ss; 16321d4a0697SVijay Khemka std::string str; 163310ff3d86SKarthikeyan Pasupathi uint8_t len = request.size(); 163410ff3d86SKarthikeyan Pasupathi std::string dimmType; 163510ff3d86SKarthikeyan Pasupathi readDimmType(dimmType, dimmIndex); 16366d9e9a75SPatrick Williams auto hostId = findHost(ctx->hostIdx); 163710ff3d86SKarthikeyan Pasupathi if (!hostId) 163810ff3d86SKarthikeyan Pasupathi { 163910ff3d86SKarthikeyan Pasupathi phosphor::logging::log<phosphor::logging::level::ERR>( 164010ff3d86SKarthikeyan Pasupathi "Invalid Host Id received"); 164110ff3d86SKarthikeyan Pasupathi return ipmi::responseInvalidCommand(); 164210ff3d86SKarthikeyan Pasupathi } 16431d4a0697SVijay Khemka 164410ff3d86SKarthikeyan Pasupathi std::string dimmInfo = KEY_Q_DIMM_INFO + std::to_string(*hostId); 16451d4a0697SVijay Khemka 164610ff3d86SKarthikeyan Pasupathi if (len < 3 || paramSel < 1 || paramSel >= numParam) 16471d4a0697SVijay Khemka { 16481d4a0697SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 16491d4a0697SVijay Khemka "Invalid parameter received"); 165010ff3d86SKarthikeyan Pasupathi return ipmi::responseParmOutOfRange(); 16511d4a0697SVijay Khemka } 16521d4a0697SVijay Khemka 16531d4a0697SVijay Khemka ss << std::hex; 165410ff3d86SKarthikeyan Pasupathi ss << (int)dimmIndex; 165510ff3d86SKarthikeyan Pasupathi oemData[dimmInfo][ss.str()][KEY_DIMM_INDEX] = dimmIndex; 165610ff3d86SKarthikeyan Pasupathi oemData[dimmInfo][ss.str()][KEY_DIMM_TYPE] = dimmType; 165710ff3d86SKarthikeyan Pasupathi str = bytesToStr(request.data(), len); 165810ff3d86SKarthikeyan Pasupathi oemData[dimmInfo][ss.str()][dimmInfoKey[paramSel]] = str.c_str(); 16591d4a0697SVijay Khemka flushOemData(); 166010ff3d86SKarthikeyan Pasupathi return ipmi::responseSuccess(); 16611d4a0697SVijay Khemka } 16621d4a0697SVijay Khemka 16631d4a0697SVijay Khemka // Get Dimm Info (CMD_OEM_Q_GET_DIMM_INFO) 16641d4a0697SVijay Khemka //---------------------------------------------------------------------- 16651d4a0697SVijay Khemka // Request: 16661d4a0697SVijay Khemka // Byte 1:3 – Manufacturer ID – XXYYZZh, LSB first 16671d4a0697SVijay Khemka // Byte 4 – DIMM Index, 0 base 16681d4a0697SVijay Khemka // Byte 5 – Parameter Selector 16691d4a0697SVijay Khemka // Byte 6..N – Configuration parameter data (see below for Parameters 16701d4a0697SVijay Khemka // of DIMM Information) 16711d4a0697SVijay Khemka // Response: 16721d4a0697SVijay Khemka // Byte 1 – Completion code 16731d4a0697SVijay Khemka // Byte 2..N – Configuration Parameter Data (see Table_1213h Parameters 16741d4a0697SVijay Khemka // of DIMM Information) 16751d4a0697SVijay Khemka // 16761d4a0697SVijay Khemka // Param#1 (DIMM Location): 16771d4a0697SVijay Khemka // Byte 1 – DIMM Present 16781d4a0697SVijay Khemka // Byte 1 – DIMM Present 16791d4a0697SVijay Khemka // 01h – Present 16801d4a0697SVijay Khemka // FFh – Not Present 16811d4a0697SVijay Khemka // Byte 2 – Node Number, 0 base 16821d4a0697SVijay Khemka // Byte 3 – Channel Number , 0 base 16831d4a0697SVijay Khemka // Byte 4 – DIMM Number , 0 base 16841d4a0697SVijay Khemka // 16851d4a0697SVijay Khemka // Param#2 (DIMM Type): 16861d4a0697SVijay Khemka // Byte 1 – DIMM Type 16871d4a0697SVijay Khemka // Bit [7:6] 16881d4a0697SVijay Khemka // For DDR3 16891d4a0697SVijay Khemka // 00 – Normal Voltage (1.5V) 16901d4a0697SVijay Khemka // 01 – Ultra Low Voltage (1.25V) 16911d4a0697SVijay Khemka // 10 – Low Voltage (1.35V) 16921d4a0697SVijay Khemka // 11 – Reserved 16931d4a0697SVijay Khemka // For DDR4 16941d4a0697SVijay Khemka // 00 – Reserved 16951d4a0697SVijay Khemka // 01 – Reserved 16961d4a0697SVijay Khemka // 10 – Reserved 16971d4a0697SVijay Khemka // 11 – Normal Voltage (1.2V) 16981d4a0697SVijay Khemka // Bit [5:0] 16991d4a0697SVijay Khemka // 0x00 – SDRAM 17001d4a0697SVijay Khemka // 0x01 – DDR-1 RAM 17011d4a0697SVijay Khemka // 0x02 – Rambus 17021d4a0697SVijay Khemka // 0x03 – DDR-2 RAM 17031d4a0697SVijay Khemka // 0x04 – FBDIMM 17041d4a0697SVijay Khemka // 0x05 – DDR-3 RAM 17051d4a0697SVijay Khemka // 0x06 – DDR-4 RAM 17061d4a0697SVijay Khemka // 17071d4a0697SVijay Khemka // Param#3 (DIMM Speed): 17081d4a0697SVijay Khemka // Byte 1..2 – DIMM speed in MHz, LSB 17091d4a0697SVijay Khemka // Byte 3..6 – DIMM size in Mbytes, LSB 17101d4a0697SVijay Khemka // 17111d4a0697SVijay Khemka // Param#4 (Module Part Number): 17121d4a0697SVijay Khemka // Byte 1..20 –Module Part Number (JEDEC Standard No. 21-C) 17131d4a0697SVijay Khemka // 17141d4a0697SVijay Khemka // Param#5 (Module Serial Number): 17151d4a0697SVijay Khemka // Byte 1..4 –Module Serial Number (JEDEC Standard No. 21-C) 17161d4a0697SVijay Khemka // 17171d4a0697SVijay Khemka // Param#6 (Module Manufacturer ID): 17181d4a0697SVijay Khemka // Byte 1 - Module Manufacturer ID, LSB 17191d4a0697SVijay Khemka // Byte 2 - Module Manufacturer ID, MSB 17201d4a0697SVijay Khemka // 172110ff3d86SKarthikeyan Pasupathi ipmi::RspType<std::vector<uint8_t>> 172210ff3d86SKarthikeyan Pasupathi ipmiOemQGetDimmInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t, uint8_t, 172310ff3d86SKarthikeyan Pasupathi uint8_t dimmIndex, uint8_t paramSel) 17241d4a0697SVijay Khemka { 17251d4a0697SVijay Khemka uint8_t numParam = sizeof(dimmInfoKey) / sizeof(uint8_t*); 172610ff3d86SKarthikeyan Pasupathi uint8_t res[MAX_BUF]; 17271d4a0697SVijay Khemka std::stringstream ss; 17281d4a0697SVijay Khemka std::string str; 172910ff3d86SKarthikeyan Pasupathi std::string dimmType; 173010ff3d86SKarthikeyan Pasupathi readDimmType(dimmType, dimmIndex); 17316d9e9a75SPatrick Williams auto hostId = findHost(ctx->hostIdx); 173210ff3d86SKarthikeyan Pasupathi if (!hostId) 173310ff3d86SKarthikeyan Pasupathi { 173410ff3d86SKarthikeyan Pasupathi phosphor::logging::log<phosphor::logging::level::ERR>( 173510ff3d86SKarthikeyan Pasupathi "Invalid Host Id received"); 173610ff3d86SKarthikeyan Pasupathi return ipmi::responseInvalidCommand(); 173710ff3d86SKarthikeyan Pasupathi } 173810ff3d86SKarthikeyan Pasupathi std::string dimmInfo = KEY_Q_DIMM_INFO + std::to_string(*hostId); 17391d4a0697SVijay Khemka 174010ff3d86SKarthikeyan Pasupathi if (paramSel < 1 || paramSel >= numParam) 17411d4a0697SVijay Khemka { 17421d4a0697SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 17431d4a0697SVijay Khemka "Invalid parameter received"); 174410ff3d86SKarthikeyan Pasupathi return ipmi::responseParmOutOfRange(); 17451d4a0697SVijay Khemka } 17461d4a0697SVijay Khemka ss << std::hex; 174710ff3d86SKarthikeyan Pasupathi ss << (int)dimmIndex; 174810ff3d86SKarthikeyan Pasupathi oemData[dimmInfo][ss.str()][KEY_DIMM_TYPE] = dimmType; 174910ff3d86SKarthikeyan Pasupathi if (oemData[dimmInfo].find(ss.str()) == oemData[dimmInfo].end()) 175010ff3d86SKarthikeyan Pasupathi return ipmi::responseCommandNotAvailable(); 175110ff3d86SKarthikeyan Pasupathi if (oemData[dimmInfo][ss.str()].find(dimmInfoKey[paramSel]) == 175210ff3d86SKarthikeyan Pasupathi oemData[dimmInfo][ss.str()].end()) 175310ff3d86SKarthikeyan Pasupathi return ipmi::responseCommandNotAvailable(); 175410ff3d86SKarthikeyan Pasupathi str = oemData[dimmInfo][ss.str()][dimmInfoKey[paramSel]]; 175510ff3d86SKarthikeyan Pasupathi int data_length = strToBytes(str, res); 175610ff3d86SKarthikeyan Pasupathi std::vector<uint8_t> response(&res[0], &res[data_length]); 175710ff3d86SKarthikeyan Pasupathi return ipmi::responseSuccess(response); 17581d4a0697SVijay Khemka } 17591d4a0697SVijay Khemka 17601d4a0697SVijay Khemka //---------------------------------------------------------------------- 17611d4a0697SVijay Khemka // Set Drive Info (CMD_OEM_Q_SET_DRIVE_INFO) 17621d4a0697SVijay Khemka //---------------------------------------------------------------------- 17631d4a0697SVijay Khemka // BIOS issue this command to provide HDD information to BMC. 17641d4a0697SVijay Khemka // 17651d4a0697SVijay Khemka // BIOS just can get information by standard ATA / SMART command for 17661d4a0697SVijay Khemka // OB SATA controller. 17671d4a0697SVijay Khemka // BIOS can get 17681d4a0697SVijay Khemka // 1. Serial Number 17691d4a0697SVijay Khemka // 2. Model Name 17701d4a0697SVijay Khemka // 3. HDD FW Version 17711d4a0697SVijay Khemka // 4. HDD Capacity 17721d4a0697SVijay Khemka // 5. HDD WWN 17731d4a0697SVijay Khemka // 17741d4a0697SVijay Khemka // Use Get HDD info Param #5 to know the MAX HDD info index. 17751d4a0697SVijay Khemka // 17761d4a0697SVijay Khemka // Request: 17771d4a0697SVijay Khemka // Byte 1:3 – Quanta Manufacturer ID – 001C4Ch, LSB first 17781d4a0697SVijay Khemka // Byte 4 – 17791d4a0697SVijay Khemka // [7:4] Reserved 17801d4a0697SVijay Khemka // [3:0] HDD Controller Type 17811d4a0697SVijay Khemka // 0x00 – BIOS 17821d4a0697SVijay Khemka // 0x01 – Expander 17831d4a0697SVijay Khemka // 0x02 – LSI 17841d4a0697SVijay Khemka // Byte 5 – HDD Info Index, 0 base 17851d4a0697SVijay Khemka // Byte 6 – Parameter Selector 17861d4a0697SVijay Khemka // Byte 7..N – Configuration parameter data (see Table_1415h Parameters of HDD 17871d4a0697SVijay Khemka // Information) 17881d4a0697SVijay Khemka // 17891d4a0697SVijay Khemka // Response: 17901d4a0697SVijay Khemka // Byte 1 – Completion Code 17911d4a0697SVijay Khemka // 17921d4a0697SVijay Khemka // Param#0 (HDD Location): 17931d4a0697SVijay Khemka // Byte 1 – Controller 17941d4a0697SVijay Khemka // [7:3] Device Number 17951d4a0697SVijay Khemka // [2:0] Function Number 17961d4a0697SVijay Khemka // For Intel C610 series (Wellsburg) 17971d4a0697SVijay Khemka // D31:F2 (0xFA) – SATA control 1 17981d4a0697SVijay Khemka // D31:F5 (0xFD) – SATA control 2 17991d4a0697SVijay Khemka // D17:F4 (0x8C) – sSata control 18001d4a0697SVijay Khemka // Byte 2 – Port Number 18011d4a0697SVijay Khemka // Byte 3 – Location (0xFF: No HDD Present) 18021d4a0697SVijay Khemka // BIOS default set Byte 3 to 0xFF, if No HDD Present. And then skip send param 18031d4a0697SVijay Khemka // #1~4, #6, #7 to BMC (still send param #5) BIOS default set Byte 3 to 0, if 18041d4a0697SVijay Khemka // the HDD present. BMC or other people who know the HDD location has 18051d4a0697SVijay Khemka // responsibility for update Location info 18061d4a0697SVijay Khemka // 18071d4a0697SVijay Khemka // Param#1 (Serial Number): 18081d4a0697SVijay Khemka // Bytes 1..33: HDD Serial Number 18091d4a0697SVijay Khemka // 18101d4a0697SVijay Khemka // Param#2 (Model Name): 18111d4a0697SVijay Khemka // Byte 1..33 – HDD Model Name 18121d4a0697SVijay Khemka // 18131d4a0697SVijay Khemka // Param#3 (HDD FW Version): 18141d4a0697SVijay Khemka // Byte 1..17 –HDD FW version 18151d4a0697SVijay Khemka // 18161d4a0697SVijay Khemka // Param#4 (Capacity): 18171d4a0697SVijay Khemka // Byte 1..4 –HDD Block Size, LSB 18181d4a0697SVijay Khemka // Byte 5..12 - HDD Block Number, LSB 18191d4a0697SVijay Khemka // HDD Capacity = HDD Block size * HDD BLock number (Unit Byte) 18201d4a0697SVijay Khemka // 18211d4a0697SVijay Khemka // Param#5 (Max HDD Quantity): 18221d4a0697SVijay Khemka // Byte 1 - Max HDD Quantity 18231d4a0697SVijay Khemka // Max supported port numbers in this PCH 18241d4a0697SVijay Khemka // 18251d4a0697SVijay Khemka // Param#6 (HDD Type) 18261d4a0697SVijay Khemka // Byte 1 – HDD Type 18271d4a0697SVijay Khemka // 0h – Reserved 18281d4a0697SVijay Khemka // 1h – SAS 18291d4a0697SVijay Khemka // 2h – SATA 18301d4a0697SVijay Khemka // 3h – PCIE SSD (NVME) 18311d4a0697SVijay Khemka // 18321d4a0697SVijay Khemka // Param#7 (HDD WWN) 18331d4a0697SVijay Khemka // Data 1...8: HDD World Wide Name, LSB 18341d4a0697SVijay Khemka // 1835e39f9393SWilly Tu ipmi_ret_t ipmiOemQSetDriveInfo(ipmi_netfn_t, ipmi_cmd_t, 1836e39f9393SWilly Tu ipmi_request_t request, ipmi_response_t, 1837e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t) 18381d4a0697SVijay Khemka { 18391d4a0697SVijay Khemka qDriveInfo_t* req = reinterpret_cast<qDriveInfo_t*>(request); 18401d4a0697SVijay Khemka uint8_t numParam = sizeof(driveInfoKey) / sizeof(uint8_t*); 18411d4a0697SVijay Khemka uint8_t ctrlType = req->hddCtrlType & 0x0f; 18421d4a0697SVijay Khemka std::stringstream ss; 18431d4a0697SVijay Khemka std::string str; 18441d4a0697SVijay Khemka uint8_t len = *data_len; 18451d4a0697SVijay Khemka 18461d4a0697SVijay Khemka *data_len = 0; 18471d4a0697SVijay Khemka 18481d4a0697SVijay Khemka /* check for requested data params */ 18491d4a0697SVijay Khemka if (len < 6 || req->paramSel < 1 || req->paramSel >= numParam || 18501d4a0697SVijay Khemka ctrlType > 2) 18511d4a0697SVijay Khemka { 18521d4a0697SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 18531d4a0697SVijay Khemka "Invalid parameter received"); 18541d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 18551d4a0697SVijay Khemka } 18561d4a0697SVijay Khemka 18571d4a0697SVijay Khemka len = len - 6; // Get Actual data length 18581d4a0697SVijay Khemka 18591d4a0697SVijay Khemka ss << std::hex; 18601d4a0697SVijay Khemka ss << std::setw(2) << std::setfill('0') << (int)req->hddIndex; 18611d4a0697SVijay Khemka oemData[KEY_Q_DRIVE_INFO][KEY_HDD_CTRL_TYPE] = req->hddCtrlType; 18621d4a0697SVijay Khemka oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()][KEY_HDD_INDEX] = 18631d4a0697SVijay Khemka req->hddIndex; 18641d4a0697SVijay Khemka 18651d4a0697SVijay Khemka str = bytesToStr(req->data, len); 18661d4a0697SVijay Khemka oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()] 18671d4a0697SVijay Khemka [driveInfoKey[req->paramSel]] = str.c_str(); 18681d4a0697SVijay Khemka flushOemData(); 18691d4a0697SVijay Khemka 18701d4a0697SVijay Khemka return IPMI_CC_OK; 18711d4a0697SVijay Khemka } 18721d4a0697SVijay Khemka 18731d4a0697SVijay Khemka //---------------------------------------------------------------------- 18741d4a0697SVijay Khemka // Get Drive Info (CMD_OEM_Q_GET_DRIVE_INFO) 18751d4a0697SVijay Khemka //---------------------------------------------------------------------- 18761d4a0697SVijay Khemka // BMC needs to check HDD presented or not first. If NOT presented, return 18771d4a0697SVijay Khemka // completion code 0xD5. 18781d4a0697SVijay Khemka // 18791d4a0697SVijay Khemka // Request: 18801d4a0697SVijay Khemka // Byte 1:3 – Quanta Manufacturer ID – 001C4Ch, LSB first 18811d4a0697SVijay Khemka // Byte 4 – 18821d4a0697SVijay Khemka //[7:4] Reserved 18831d4a0697SVijay Khemka //[3:0] HDD Controller Type 18841d4a0697SVijay Khemka // 0x00 – BIOS 18851d4a0697SVijay Khemka // 0x01 – Expander 18861d4a0697SVijay Khemka // 0x02 – LSI 18871d4a0697SVijay Khemka // Byte 5 – HDD Index, 0 base 18881d4a0697SVijay Khemka // Byte 6 – Parameter Selector (See Above Set HDD Information) 18891d4a0697SVijay Khemka // Response: 18901d4a0697SVijay Khemka // Byte 1 – Completion Code 18911d4a0697SVijay Khemka // 0xD5 – Not support in current status (HDD Not Present) 18921d4a0697SVijay Khemka // Byte 2..N – Configuration parameter data (see Table_1415h Parameters of HDD 18931d4a0697SVijay Khemka // Information) 18941d4a0697SVijay Khemka // 1895e39f9393SWilly Tu ipmi_ret_t ipmiOemQGetDriveInfo(ipmi_netfn_t, ipmi_cmd_t, 18961d4a0697SVijay Khemka ipmi_request_t request, 18971d4a0697SVijay Khemka ipmi_response_t response, 1898e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t) 18991d4a0697SVijay Khemka { 19001d4a0697SVijay Khemka qDriveInfo_t* req = reinterpret_cast<qDriveInfo_t*>(request); 19011d4a0697SVijay Khemka uint8_t numParam = sizeof(driveInfoKey) / sizeof(uint8_t*); 19021d4a0697SVijay Khemka uint8_t* res = reinterpret_cast<uint8_t*>(response); 19031d4a0697SVijay Khemka uint8_t ctrlType = req->hddCtrlType & 0x0f; 19041d4a0697SVijay Khemka std::stringstream ss; 19051d4a0697SVijay Khemka std::string str; 19061d4a0697SVijay Khemka 19071d4a0697SVijay Khemka *data_len = 0; 19081d4a0697SVijay Khemka 19091d4a0697SVijay Khemka /* check for requested data params */ 19101d4a0697SVijay Khemka if (req->paramSel < 1 || req->paramSel >= numParam || ctrlType > 2) 19111d4a0697SVijay Khemka { 19121d4a0697SVijay Khemka phosphor::logging::log<phosphor::logging::level::ERR>( 19131d4a0697SVijay Khemka "Invalid parameter received"); 19141d4a0697SVijay Khemka return IPMI_CC_PARM_OUT_OF_RANGE; 19151d4a0697SVijay Khemka } 19161d4a0697SVijay Khemka 19171d4a0697SVijay Khemka if (oemData[KEY_Q_DRIVE_INFO].find(ctrlTypeKey[ctrlType]) == 19181d4a0697SVijay Khemka oemData[KEY_Q_DRIVE_INFO].end()) 19191d4a0697SVijay Khemka return CC_PARAM_NOT_SUPP_IN_CURR_STATE; 19201d4a0697SVijay Khemka 19211d4a0697SVijay Khemka ss << std::hex; 19221d4a0697SVijay Khemka ss << std::setw(2) << std::setfill('0') << (int)req->hddIndex; 19231d4a0697SVijay Khemka 19241d4a0697SVijay Khemka if (oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]].find(ss.str()) == 19251d4a0697SVijay Khemka oemData[KEY_Q_DRIVE_INFO].end()) 19261d4a0697SVijay Khemka return CC_PARAM_NOT_SUPP_IN_CURR_STATE; 19271d4a0697SVijay Khemka 19281d4a0697SVijay Khemka if (oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()].find( 19291d4a0697SVijay Khemka dimmInfoKey[req->paramSel]) == 19301d4a0697SVijay Khemka oemData[KEY_Q_DRIVE_INFO][ss.str()].end()) 19311d4a0697SVijay Khemka return CC_PARAM_NOT_SUPP_IN_CURR_STATE; 19321d4a0697SVijay Khemka 19331d4a0697SVijay Khemka str = oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()] 19341d4a0697SVijay Khemka [dimmInfoKey[req->paramSel]]; 19351d4a0697SVijay Khemka *data_len = strToBytes(str, res); 19361d4a0697SVijay Khemka 1937e7d23d0eSVijay Khemka return IPMI_CC_OK; 1938e7d23d0eSVijay Khemka } 1939e7d23d0eSVijay Khemka 1940dd14c0f7SVijay Khemka /* Helper function for sending DCMI commands to ME and getting response back */ 1941dd14c0f7SVijay Khemka ipmi::RspType<std::vector<uint8_t>> sendDCMICmd(uint8_t cmd, 1942dd14c0f7SVijay Khemka std::vector<uint8_t>& cmdData) 1943dd14c0f7SVijay Khemka { 1944dd14c0f7SVijay Khemka std::vector<uint8_t> respData; 1945dd14c0f7SVijay Khemka 1946dd14c0f7SVijay Khemka /* Add group id as first byte to request for ME command */ 1947dd14c0f7SVijay Khemka cmdData.insert(cmdData.begin(), groupDCMI); 1948dd14c0f7SVijay Khemka 1949dd14c0f7SVijay Khemka if (sendMeCmd(ipmi::netFnGroup, cmd, cmdData, respData)) 1950dd14c0f7SVijay Khemka return ipmi::responseUnspecifiedError(); 1951dd14c0f7SVijay Khemka 1952dd14c0f7SVijay Khemka /* Remove group id as first byte as it will be added by IPMID */ 1953dd14c0f7SVijay Khemka respData.erase(respData.begin()); 1954dd14c0f7SVijay Khemka 1955dd14c0f7SVijay Khemka return ipmi::responseSuccess(std::move(respData)); 1956dd14c0f7SVijay Khemka } 1957dd14c0f7SVijay Khemka 1958dd14c0f7SVijay Khemka /* DCMI Command handellers. */ 1959dd14c0f7SVijay Khemka 1960dd14c0f7SVijay Khemka ipmi::RspType<std::vector<uint8_t>> 1961dd14c0f7SVijay Khemka ipmiOemDCMIGetPowerReading(std::vector<uint8_t> reqData) 1962dd14c0f7SVijay Khemka { 1963dd14c0f7SVijay Khemka return sendDCMICmd(ipmi::dcmi::cmdGetPowerReading, reqData); 1964dd14c0f7SVijay Khemka } 1965dd14c0f7SVijay Khemka 1966dd14c0f7SVijay Khemka ipmi::RspType<std::vector<uint8_t>> 1967dd14c0f7SVijay Khemka ipmiOemDCMIGetPowerLimit(std::vector<uint8_t> reqData) 1968dd14c0f7SVijay Khemka { 1969dd14c0f7SVijay Khemka return sendDCMICmd(ipmi::dcmi::cmdGetPowerLimit, reqData); 1970dd14c0f7SVijay Khemka } 1971dd14c0f7SVijay Khemka 1972dd14c0f7SVijay Khemka ipmi::RspType<std::vector<uint8_t>> 1973dd14c0f7SVijay Khemka ipmiOemDCMISetPowerLimit(std::vector<uint8_t> reqData) 1974dd14c0f7SVijay Khemka { 1975dd14c0f7SVijay Khemka return sendDCMICmd(ipmi::dcmi::cmdSetPowerLimit, reqData); 1976dd14c0f7SVijay Khemka } 1977dd14c0f7SVijay Khemka 1978dd14c0f7SVijay Khemka ipmi::RspType<std::vector<uint8_t>> 1979dd14c0f7SVijay Khemka ipmiOemDCMIApplyPowerLimit(std::vector<uint8_t> reqData) 1980dd14c0f7SVijay Khemka { 1981dd14c0f7SVijay Khemka return sendDCMICmd(ipmi::dcmi::cmdActDeactivatePwrLimit, reqData); 1982dd14c0f7SVijay Khemka } 1983dd14c0f7SVijay Khemka 1984e7d23d0eSVijay Khemka static void registerOEMFunctions(void) 1985e7d23d0eSVijay Khemka { 19861d4a0697SVijay Khemka /* Get OEM data from json file */ 19871d4a0697SVijay Khemka std::ifstream file(JSON_OEM_DATA_FILE); 19881d4a0697SVijay Khemka if (file) 1989feaa9811SVijay Khemka { 19901d4a0697SVijay Khemka file >> oemData; 1991feaa9811SVijay Khemka file.close(); 1992feaa9811SVijay Khemka } 19931d4a0697SVijay Khemka 1994e7d23d0eSVijay Khemka phosphor::logging::log<phosphor::logging::level::INFO>( 1995e7d23d0eSVijay Khemka "Registering OEM commands"); 19967c0aea49SVijay Khemka 1997e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_INFO, 1998e7d23d0eSVijay Khemka NULL, ipmiOemDbgGetFrameInfo, 1999e7d23d0eSVijay Khemka PRIVILEGE_USER); // get debug frame info 2000e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, 2001e7d23d0eSVijay Khemka CMD_OEM_USB_DBG_GET_UPDATED_FRAMES, NULL, 2002e7d23d0eSVijay Khemka ipmiOemDbgGetUpdFrames, 2003e7d23d0eSVijay Khemka PRIVILEGE_USER); // get debug updated frames 2004e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_POST_DESC, 2005e7d23d0eSVijay Khemka NULL, ipmiOemDbgGetPostDesc, 2006e7d23d0eSVijay Khemka PRIVILEGE_USER); // get debug post description 2007e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_GPIO_DESC, 2008e7d23d0eSVijay Khemka NULL, ipmiOemDbgGetGpioDesc, 2009e7d23d0eSVijay Khemka PRIVILEGE_USER); // get debug gpio description 2010e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_DATA, 2011e7d23d0eSVijay Khemka NULL, ipmiOemDbgGetFrameData, 2012e7d23d0eSVijay Khemka PRIVILEGE_USER); // get debug frame data 2013e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_CTRL_PANEL, 2014e7d23d0eSVijay Khemka NULL, ipmiOemDbgGetCtrlPanel, 2015e7d23d0eSVijay Khemka PRIVILEGE_USER); // get debug control panel 2016e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_DIMM_INFO, NULL, 2017e7d23d0eSVijay Khemka ipmiOemSetDimmInfo, 2018e7d23d0eSVijay Khemka PRIVILEGE_USER); // Set Dimm Info 20191d4a0697SVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_BOARD_ID, NULL, 20201d4a0697SVijay Khemka ipmiOemGetBoardID, 20211d4a0697SVijay Khemka PRIVILEGE_USER); // Get Board ID 2022e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_MACHINE_CONFIG_INFO, NULL, 2023e7d23d0eSVijay Khemka ipmiOemSetMachineCfgInfo, 2024e7d23d0eSVijay Khemka PRIVILEGE_USER); // Set Machine Config Info 2025e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_START, NULL, 2026e7d23d0eSVijay Khemka ipmiOemSetPostStart, 2027e7d23d0eSVijay Khemka PRIVILEGE_USER); // Set POST start 2028e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_END, NULL, 2029e7d23d0eSVijay Khemka ipmiOemSetPostEnd, 2030e7d23d0eSVijay Khemka PRIVILEGE_USER); // Set POST End 20311d4a0697SVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPIN_INFO, NULL, 20321d4a0697SVijay Khemka ipmiOemSetPPINInfo, 20331d4a0697SVijay Khemka PRIVILEGE_USER); // Set PPIN Info 20345f8e3435SManikandan Elumalai #if BIC_ENABLED 20355f8e3435SManikandan Elumalai 20365f8e3435SManikandan Elumalai ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne, 20375f8e3435SManikandan Elumalai ipmi::cmdSetSystemGuid, ipmi::Privilege::User, 20385f8e3435SManikandan Elumalai ipmiOemSetSystemGuid); 20395f8e3435SManikandan Elumalai #else 20405f8e3435SManikandan Elumalai 2041f2246ce8SVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_SYSTEM_GUID, NULL, 2042f2246ce8SVijay Khemka ipmiOemSetSystemGuid, 2043f2246ce8SVijay Khemka PRIVILEGE_USER); // Set System GUID 20445f8e3435SManikandan Elumalai #endif 20451d4a0697SVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_ADR_TRIGGER, NULL, 20461d4a0697SVijay Khemka ipmiOemSetAdrTrigger, 20471d4a0697SVijay Khemka PRIVILEGE_USER); // Set ADR Trigger 2048e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_BIOS_FLASH_INFO, NULL, 2049e7d23d0eSVijay Khemka ipmiOemSetBiosFlashInfo, 2050e7d23d0eSVijay Khemka PRIVILEGE_USER); // Set Bios Flash Info 2051e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPR, NULL, ipmiOemSetPpr, 2052e7d23d0eSVijay Khemka PRIVILEGE_USER); // Set PPR 2053e7d23d0eSVijay Khemka ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_PPR, NULL, ipmiOemGetPpr, 2054e7d23d0eSVijay Khemka PRIVILEGE_USER); // Get PPR 20551d4a0697SVijay Khemka /* FB OEM QC Commands */ 2056d532fecaSKarthikeyan Pasupathi ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour, 2057d532fecaSKarthikeyan Pasupathi CMD_OEM_Q_SET_PROC_INFO, ipmi::Privilege::User, 2058d532fecaSKarthikeyan Pasupathi ipmiOemQSetProcInfo); // Set Proc Info 2059d532fecaSKarthikeyan Pasupathi ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour, 2060d532fecaSKarthikeyan Pasupathi CMD_OEM_Q_GET_PROC_INFO, ipmi::Privilege::User, 2061d532fecaSKarthikeyan Pasupathi ipmiOemQGetProcInfo); // Get Proc Info 206210ff3d86SKarthikeyan Pasupathi ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour, 206310ff3d86SKarthikeyan Pasupathi ipmi::cmdSetQDimmInfo, ipmi::Privilege::User, 206410ff3d86SKarthikeyan Pasupathi ipmiOemQSetDimmInfo); // Set Dimm Info 206510ff3d86SKarthikeyan Pasupathi ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour, 206610ff3d86SKarthikeyan Pasupathi ipmi::cmdGetQDimmInfo, ipmi::Privilege::User, 206710ff3d86SKarthikeyan Pasupathi ipmiOemQGetDimmInfo); // Get Dimm Info 20681d4a0697SVijay Khemka ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_SET_DRIVE_INFO, NULL, 20691d4a0697SVijay Khemka ipmiOemQSetDriveInfo, 20701d4a0697SVijay Khemka PRIVILEGE_USER); // Set Drive Info 20711d4a0697SVijay Khemka ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_GET_DRIVE_INFO, NULL, 20721d4a0697SVijay Khemka ipmiOemQGetDriveInfo, 20731d4a0697SVijay Khemka PRIVILEGE_USER); // Get Drive Info 2074dd14c0f7SVijay Khemka 2075dd14c0f7SVijay Khemka /* FB OEM DCMI Commands as per DCMI spec 1.5 Section 6 */ 2076dd14c0f7SVijay Khemka ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI, 2077dd14c0f7SVijay Khemka ipmi::dcmi::cmdGetPowerReading, 2078dd14c0f7SVijay Khemka ipmi::Privilege::User, 2079dd14c0f7SVijay Khemka ipmiOemDCMIGetPowerReading); // Get Power Reading 2080dd14c0f7SVijay Khemka 2081dd14c0f7SVijay Khemka ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI, 2082dd14c0f7SVijay Khemka ipmi::dcmi::cmdGetPowerLimit, 2083dd14c0f7SVijay Khemka ipmi::Privilege::User, 2084dd14c0f7SVijay Khemka ipmiOemDCMIGetPowerLimit); // Get Power Limit 2085dd14c0f7SVijay Khemka 2086dd14c0f7SVijay Khemka ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI, 2087dd14c0f7SVijay Khemka ipmi::dcmi::cmdSetPowerLimit, 2088dd14c0f7SVijay Khemka ipmi::Privilege::Operator, 2089dd14c0f7SVijay Khemka ipmiOemDCMISetPowerLimit); // Set Power Limit 2090dd14c0f7SVijay Khemka 2091dd14c0f7SVijay Khemka ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI, 2092dd14c0f7SVijay Khemka ipmi::dcmi::cmdActDeactivatePwrLimit, 2093dd14c0f7SVijay Khemka ipmi::Privilege::Operator, 2094dd14c0f7SVijay Khemka ipmiOemDCMIApplyPowerLimit); // Apply Power Limit 2095dd14c0f7SVijay Khemka 2096f0cf6658SJayashree-D /* FB OEM BOOT ORDER COMMANDS */ 2097f0cf6658SJayashree-D ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne, 2098f0cf6658SJayashree-D CMD_OEM_GET_BOOT_ORDER, ipmi::Privilege::User, 2099f0cf6658SJayashree-D ipmiOemGetBootOrder); // Get Boot Order 2100f0cf6658SJayashree-D 2101f0cf6658SJayashree-D ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne, 2102f0cf6658SJayashree-D CMD_OEM_SET_BOOT_ORDER, ipmi::Privilege::User, 2103f0cf6658SJayashree-D ipmiOemSetBootOrder); // Set Boot Order 2104f0cf6658SJayashree-D 2105e7d23d0eSVijay Khemka return; 2106e7d23d0eSVijay Khemka } 2107e7d23d0eSVijay Khemka 2108e7d23d0eSVijay Khemka } // namespace ipmi 2109