blob: 50b7a71c1d374a0793e0fed7b02115c2e7679c19 [file] [log] [blame]
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001/*
2 * Copyright (c) 2018 Intel Corporation.
3 * Copyright (c) 2018-present Facebook.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#include "xyz/openbmc_project/Common/error.hpp"
Jayashree-Df0cf6652020-11-30 11:03:30 +053019#include <xyz/openbmc_project/Control/Boot/Mode/server.hpp>
20#include <xyz/openbmc_project/Control/Boot/Source/server.hpp>
Jayashree Dhanapal778147d2022-03-30 16:48:53 +053021#include <xyz/openbmc_project/Control/Boot/Type/server.hpp>
Vijay Khemkae7d23d02019-03-08 13:13:40 -080022
Vijay Khemka63c99be2020-05-27 19:14:35 -070023#include <ipmid/api.hpp>
Vijay Khemka1b6fae32019-03-25 17:43:01 -070024#include <ipmid/utils.hpp>
Vijay Khemka63c99be2020-05-27 19:14:35 -070025#include <commandutils.hpp>
26#include <nlohmann/json.hpp>
27#include <oemcommands.hpp>
Vijay Khemkae7d23d02019-03-08 13:13:40 -080028#include <phosphor-logging/log.hpp>
29#include <sdbusplus/bus.hpp>
Vijay Khemka63c99be2020-05-27 19:14:35 -070030
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +053031#include <ipmid/api.hpp>
32#include <ipmid/api-types.hpp>
33
Vijay Khemka63c99be2020-05-27 19:14:35 -070034#include <array>
35#include <cstring>
36#include <fstream>
37#include <iomanip>
38#include <iostream>
39#include <sstream>
Vijay Khemkae7d23d02019-03-08 13:13:40 -080040#include <string>
41#include <vector>
42
43#define SIZE_IANA_ID 3
44
45namespace ipmi
46{
Vijay Khemkaa7231892019-10-11 11:35:05 -070047
48using namespace phosphor::logging;
49
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +053050size_t getSelectorPosition();
Vijay Khemkae7d23d02019-03-08 13:13:40 -080051static void registerOEMFunctions() __attribute__((constructor));
52sdbusplus::bus::bus dbus(ipmid_get_sd_bus_connection()); // from ipmid/api.h
53static constexpr size_t maxFRUStringLength = 0x3F;
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +053054constexpr uint8_t cmdSetSystemGuid = 0xEF;
Vijay Khemkae7d23d02019-03-08 13:13:40 -080055
Vijay Khemka63c99be2020-05-27 19:14:35 -070056int plat_udbg_get_post_desc(uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t*,
57 uint8_t*);
58int plat_udbg_get_gpio_desc(uint8_t, uint8_t*, uint8_t*, uint8_t*, uint8_t*,
59 uint8_t*);
60ipmi_ret_t plat_udbg_get_frame_data(uint8_t, uint8_t, uint8_t*, uint8_t*,
61 uint8_t*);
62ipmi_ret_t plat_udbg_control_panel(uint8_t, uint8_t, uint8_t, uint8_t*,
63 uint8_t*);
64int sendMeCmd(uint8_t, uint8_t, std::vector<uint8_t>&, std::vector<uint8_t>&);
Vijay Khemkadd14c0f2020-03-18 14:48:13 -070065
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +053066int sendBicCmd(uint8_t, uint8_t, uint8_t, std::vector<uint8_t>&,
67 std::vector<uint8_t>&);
68
Vijay Khemkafeaa9812019-08-27 15:08:08 -070069nlohmann::json oemData __attribute__((init_priority(101)));
Vijay Khemka1b6fae32019-03-25 17:43:01 -070070
Vijay Khemkaf2246ce2020-05-27 14:26:35 -070071static constexpr size_t GUID_SIZE = 16;
72// TODO Make offset and location runtime configurable to ensure we
73// can make each define their own locations.
74static constexpr off_t OFFSET_SYS_GUID = 0x17F0;
75static constexpr const char* FRU_EEPROM = "/sys/bus/i2c/devices/6-0054/eeprom";
76
Vijay Khemka1b6fae32019-03-25 17:43:01 -070077enum class LanParam : uint8_t
78{
79 INPROGRESS = 0,
80 AUTHSUPPORT = 1,
81 AUTHENABLES = 2,
82 IP = 3,
83 IPSRC = 4,
84 MAC = 5,
85 SUBNET = 6,
86 GATEWAY = 12,
87 VLAN = 20,
88 CIPHER_SUITE_COUNT = 22,
89 CIPHER_SUITE_ENTRIES = 23,
90 IPV6 = 59,
91};
92
Vijay Khemkaa7231892019-10-11 11:35:05 -070093namespace network
94{
95
96constexpr auto ROOT = "/xyz/openbmc_project/network";
97constexpr auto SERVICE = "xyz.openbmc_project.Network";
98constexpr auto IPV4_TYPE = "ipv4";
99constexpr auto IPV6_TYPE = "ipv6";
100constexpr auto IPV4_PREFIX = "169.254";
101constexpr auto IPV6_PREFIX = "fe80";
102constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP";
103constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress";
104
Vijay Khemka63c99be2020-05-27 19:14:35 -0700105bool isLinkLocalIP(const std::string& address)
Vijay Khemkaa7231892019-10-11 11:35:05 -0700106{
107 return address.find(IPV4_PREFIX) == 0 || address.find(IPV6_PREFIX) == 0;
108}
109
Vijay Khemka63c99be2020-05-27 19:14:35 -0700110DbusObjectInfo getIPObject(sdbusplus::bus::bus& bus,
111 const std::string& interface,
112 const std::string& serviceRoot,
113 const std::string& match)
Vijay Khemkaa7231892019-10-11 11:35:05 -0700114{
115 auto objectTree = getAllDbusObjects(bus, serviceRoot, interface, match);
116
117 if (objectTree.empty())
118 {
119 log<level::ERR>("No Object has implemented the IP interface",
120 entry("INTERFACE=%s", interface.c_str()));
121 }
122
123 DbusObjectInfo objectInfo;
124
Vijay Khemka63c99be2020-05-27 19:14:35 -0700125 for (auto& object : objectTree)
Vijay Khemkaa7231892019-10-11 11:35:05 -0700126 {
127 auto variant =
128 ipmi::getDbusProperty(bus, object.second.begin()->first,
129 object.first, IP_INTERFACE, "Address");
130
131 objectInfo = std::make_pair(object.first, object.second.begin()->first);
132
133 // if LinkLocalIP found look for Non-LinkLocalIP
134 if (isLinkLocalIP(std::get<std::string>(variant)))
135 {
136 continue;
137 }
138 else
139 {
140 break;
141 }
142 }
143 return objectInfo;
144}
145
146} // namespace network
147
Jayashree-Df0cf6652020-11-30 11:03:30 +0530148namespace boot
149{
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530150using BootSource =
151 sdbusplus::xyz::openbmc_project::Control::Boot::server::Source::Sources;
152using BootMode =
153 sdbusplus::xyz::openbmc_project::Control::Boot::server::Mode::Modes;
154using BootType =
155 sdbusplus::xyz::openbmc_project::Control::Boot::server::Type::Types;
Jayashree-Df0cf6652020-11-30 11:03:30 +0530156
Jayashree-Df0cf6652020-11-30 11:03:30 +0530157using IpmiValue = uint8_t;
158
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530159std::map<IpmiValue, BootSource> sourceIpmiToDbus = {
160 {0x0f, BootSource::Default}, {0x00, BootSource::RemovableMedia},
161 {0x01, BootSource::Network}, {0x02, BootSource::Disk},
162 {0x03, BootSource::ExternalMedia}, {0x09, BootSource::Network}};
Jayashree-Df0cf6652020-11-30 11:03:30 +0530163
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530164std::map<IpmiValue, BootMode> modeIpmiToDbus = {{0x06, BootMode::Setup},
165 {0x00, BootMode::Regular}};
Jayashree-Df0cf6652020-11-30 11:03:30 +0530166
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530167std::map<IpmiValue, BootType> typeIpmiToDbus = {{0x00, BootType::Legacy},
168 {0x01, BootType::EFI}};
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530169
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530170std::map<std::optional<BootSource>, IpmiValue> sourceDbusToIpmi = {
171 {BootSource::Default, 0x0f},
172 {BootSource::RemovableMedia, 0x00},
173 {BootSource::Network, 0x01},
174 {BootSource::Disk, 0x02},
175 {BootSource::ExternalMedia, 0x03}};
Jayashree-Df0cf6652020-11-30 11:03:30 +0530176
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530177std::map<std::optional<BootMode>, IpmiValue> modeDbusToIpmi = {
178 {BootMode::Setup, 0x06}, {BootMode::Regular, 0x00}};
Jayashree-Df0cf6652020-11-30 11:03:30 +0530179
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530180std::map<std::optional<BootType>, IpmiValue> typeDbusToIpmi = {
181 {BootType::Legacy, 0x00}, {BootType::EFI, 0x01}};
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530182
Jayashree-Df0cf6652020-11-30 11:03:30 +0530183static constexpr auto bootModeIntf = "xyz.openbmc_project.Control.Boot.Mode";
184static constexpr auto bootSourceIntf =
185 "xyz.openbmc_project.Control.Boot.Source";
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530186static constexpr auto bootTypeIntf = "xyz.openbmc_project.Control.Boot.Type";
Jayashree-Df0cf6652020-11-30 11:03:30 +0530187static constexpr auto bootSourceProp = "BootSource";
188static constexpr auto bootModeProp = "BootMode";
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530189static constexpr auto bootTypeProp = "BootType";
Jayashree-Df0cf6652020-11-30 11:03:30 +0530190
Jayashree-Df0cf6652020-11-30 11:03:30 +0530191std::tuple<std::string, std::string> objPath(size_t id)
192{
193 std::string hostName = "host" + std::to_string(id);
194 std::string bootObjPath =
195 "/xyz/openbmc_project/control/" + hostName + "/boot";
196 return std::make_tuple(std::move(bootObjPath), std::move(hostName));
197}
198
199} // namespace boot
200
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700201//----------------------------------------------------------------------
202// Helper functions for storing oem data
203//----------------------------------------------------------------------
204
205void flushOemData()
206{
207 std::ofstream file(JSON_OEM_DATA_FILE);
208 file << oemData;
Vijay Khemkafeaa9812019-08-27 15:08:08 -0700209 file.close();
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700210 return;
211}
212
Vijay Khemka63c99be2020-05-27 19:14:35 -0700213std::string bytesToStr(uint8_t* byte, int len)
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700214{
215 std::stringstream ss;
216 int i;
217
218 ss << std::hex;
219 for (i = 0; i < len; i++)
220 {
221 ss << std::setw(2) << std::setfill('0') << (int)byte[i];
222 }
223
224 return ss.str();
225}
226
Vijay Khemka63c99be2020-05-27 19:14:35 -0700227int strToBytes(std::string& str, uint8_t* data)
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700228{
229 std::string sstr;
Willy Tue39f9392022-06-15 13:24:20 -0700230 size_t i;
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700231
232 for (i = 0; i < (str.length()) / 2; i++)
233 {
234 sstr = str.substr(i * 2, 2);
235 data[i] = (uint8_t)std::strtol(sstr.c_str(), NULL, 16);
236 }
237 return i;
238}
239
Vijay Khemka63c99be2020-05-27 19:14:35 -0700240ipmi_ret_t getNetworkData(uint8_t lan_param, char* data)
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700241{
242 ipmi_ret_t rc = IPMI_CC_OK;
243 sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection());
244
245 const std::string ethdevice = "eth0";
246
247 switch (static_cast<LanParam>(lan_param))
248 {
Vijay Khemkad1194022020-05-27 18:58:33 -0700249 case LanParam::IP:
250 {
Vijay Khemkaa7231892019-10-11 11:35:05 -0700251 auto ethIP = ethdevice + "/" + ipmi::network::IPV4_TYPE;
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700252 std::string ipaddress;
Vijay Khemkaa7231892019-10-11 11:35:05 -0700253 auto ipObjectInfo = ipmi::network::getIPObject(
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700254 bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT, ethIP);
255
256 auto properties = ipmi::getAllDbusProperties(
257 bus, ipObjectInfo.second, ipObjectInfo.first,
258 ipmi::network::IP_INTERFACE);
259
Patrick Williamsef0efbc2020-05-13 11:26:51 -0500260 ipaddress = std::get<std::string>(properties["Address"]);
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700261
262 std::strcpy(data, ipaddress.c_str());
263 }
264 break;
265
Vijay Khemkad1194022020-05-27 18:58:33 -0700266 case LanParam::IPV6:
267 {
Vijay Khemkaa7231892019-10-11 11:35:05 -0700268 auto ethIP = ethdevice + "/" + ipmi::network::IPV6_TYPE;
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700269 std::string ipaddress;
Vijay Khemkaa7231892019-10-11 11:35:05 -0700270 auto ipObjectInfo = ipmi::network::getIPObject(
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700271 bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT, ethIP);
272
273 auto properties = ipmi::getAllDbusProperties(
274 bus, ipObjectInfo.second, ipObjectInfo.first,
275 ipmi::network::IP_INTERFACE);
276
Patrick Williamsef0efbc2020-05-13 11:26:51 -0500277 ipaddress = std::get<std::string>(properties["Address"]);
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700278
279 std::strcpy(data, ipaddress.c_str());
280 }
281 break;
282
Vijay Khemkad1194022020-05-27 18:58:33 -0700283 case LanParam::MAC:
284 {
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700285 std::string macAddress;
286 auto macObjectInfo =
287 ipmi::getDbusObject(bus, ipmi::network::MAC_INTERFACE,
288 ipmi::network::ROOT, ethdevice);
289
290 auto variant = ipmi::getDbusProperty(
291 bus, macObjectInfo.second, macObjectInfo.first,
292 ipmi::network::MAC_INTERFACE, "MACAddress");
293
Patrick Williamsef0efbc2020-05-13 11:26:51 -0500294 macAddress = std::get<std::string>(variant);
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700295
296 sscanf(macAddress.c_str(), ipmi::network::MAC_ADDRESS_FORMAT,
297 (data), (data + 1), (data + 2), (data + 3), (data + 4),
298 (data + 5));
299 std::strcpy(data, macAddress.c_str());
300 }
301 break;
302
303 default:
304 rc = IPMI_CC_PARM_OUT_OF_RANGE;
305 }
306 return rc;
307}
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800308
Karthikeyan Pasupathi39836ff2022-01-17 12:20:06 +0530309bool isMultiHostPlatform()
310{
311 bool platform;
Jayashree Dhanapal4ec80562022-06-28 15:41:47 +0530312 if (hostInstances == "0")
Karthikeyan Pasupathi39836ff2022-01-17 12:20:06 +0530313 {
314 platform = false;
315 }
316 else
317 {
318 platform = true;
319 }
320 return platform;
321}
322
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800323// return code: 0 successful
Vijay Khemka63c99be2020-05-27 19:14:35 -0700324int8_t getFruData(std::string& data, std::string& name)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800325{
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530326 size_t pos;
327 static constexpr const auto depth = 0;
328 std::vector<std::string> paths;
329 std::string machinePath;
330 std::string baseBoard = "Baseboard";
331
332 bool platform = isMultiHostPlatform();
333 if (platform == true)
334 {
335 pos = getSelectorPosition();
336 }
337
338 sd_bus* bus = NULL;
339 int ret = sd_bus_default_system(&bus);
340 if (ret < 0)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800341 {
342 phosphor::logging::log<phosphor::logging::level::ERR>(
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530343 "Failed to connect to system bus",
344 phosphor::logging::entry("ERRNO=0x%X", -ret));
345 sd_bus_unref(bus);
346 return -1;
347 }
348 sdbusplus::bus::bus dbus(bus);
349 auto mapperCall = dbus.new_method_call("xyz.openbmc_project.ObjectMapper",
350 "/xyz/openbmc_project/object_mapper",
351 "xyz.openbmc_project.ObjectMapper",
352 "GetSubTreePaths");
353 static constexpr std::array<const char*, 1> interface = {
354 "xyz.openbmc_project.Inventory.Decorator.Asset"};
355 mapperCall.append("/xyz/openbmc_project/inventory/", depth, interface);
356
357 try
358 {
359 auto reply = dbus.call(mapperCall);
360 reply.read(paths);
361 }
362 catch (sdbusplus::exception_t& e)
363 {
364 phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800365 return -1;
366 }
367
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530368 for (const auto& path : paths)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800369 {
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530370 if (platform == true)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800371 {
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530372 if (pos == BMC_POS)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800373 {
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530374 machinePath = baseBoard;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800375 }
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530376 else
377 {
378 machinePath = "_" + std::to_string(pos);
379 }
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800380 }
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530381 else
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800382 {
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530383 machinePath = baseBoard;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800384 }
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530385
386 auto found = path.find(machinePath);
Patrick Williams123cbcc2022-06-24 06:13:59 -0500387 if (found == std::string::npos)
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530388 {
389 continue;
390 }
391
392 std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
393 std::string service = getService(
394 *dbus, "xyz.openbmc_project.Inventory.Decorator.Asset", path);
395
396 auto Value = ipmi::getDbusProperty(
397 *dbus, service, path,
398 "xyz.openbmc_project.Inventory.Decorator.Asset", name);
399
400 data = std::get<std::string>(Value);
401 return 0;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800402 }
403 return -1;
404}
405
406typedef struct
407{
408 uint8_t cur_power_state;
409 uint8_t last_power_event;
410 uint8_t misc_power_state;
411 uint8_t front_panel_button_cap_status;
412} ipmi_get_chassis_status_t;
413
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800414//----------------------------------------------------------------------
415// Get Debug Frame Info
416//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700417ipmi_ret_t ipmiOemDbgGetFrameInfo(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800418 ipmi_request_t request,
419 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700420 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800421{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700422 uint8_t* req = reinterpret_cast<uint8_t*>(request);
423 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800424 uint8_t num_frames = 3;
425
426 std::memcpy(res, req, SIZE_IANA_ID); // IANA ID
427 res[SIZE_IANA_ID] = num_frames;
428 *data_len = SIZE_IANA_ID + 1;
429
430 return IPMI_CC_OK;
431}
432
433//----------------------------------------------------------------------
434// Get Debug Updated Frames
435//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700436ipmi_ret_t ipmiOemDbgGetUpdFrames(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800437 ipmi_request_t request,
438 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700439 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800440{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700441 uint8_t* req = reinterpret_cast<uint8_t*>(request);
442 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800443 uint8_t num_updates = 3;
444 *data_len = 4;
445
446 std::memcpy(res, req, SIZE_IANA_ID); // IANA ID
447 res[SIZE_IANA_ID] = num_updates;
448 *data_len = SIZE_IANA_ID + num_updates + 1;
449 res[SIZE_IANA_ID + 1] = 1; // info page update
450 res[SIZE_IANA_ID + 2] = 2; // cri sel update
451 res[SIZE_IANA_ID + 3] = 3; // cri sensor update
452
453 return IPMI_CC_OK;
454}
455
456//----------------------------------------------------------------------
457// Get Debug POST Description
458//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700459ipmi_ret_t ipmiOemDbgGetPostDesc(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800460 ipmi_request_t request,
461 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700462 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800463{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700464 uint8_t* req = reinterpret_cast<uint8_t*>(request);
465 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800466 uint8_t index = 0;
467 uint8_t next = 0;
468 uint8_t end = 0;
469 uint8_t phase = 0;
Vijay Khemkacc0d6d92019-08-27 14:51:17 -0700470 uint8_t descLen = 0;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800471 int ret;
472
473 index = req[3];
474 phase = req[4];
475
Vijay Khemkacc0d6d92019-08-27 14:51:17 -0700476 ret = plat_udbg_get_post_desc(index, &next, phase, &end, &descLen, &res[8]);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800477 if (ret)
478 {
479 memcpy(res, req, SIZE_IANA_ID); // IANA ID
480 *data_len = SIZE_IANA_ID;
481 return IPMI_CC_UNSPECIFIED_ERROR;
482 }
483
484 memcpy(res, req, SIZE_IANA_ID); // IANA ID
485 res[3] = index;
486 res[4] = next;
487 res[5] = phase;
488 res[6] = end;
Vijay Khemkacc0d6d92019-08-27 14:51:17 -0700489 res[7] = descLen;
490 *data_len = SIZE_IANA_ID + 5 + descLen;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800491
492 return IPMI_CC_OK;
493}
494
495//----------------------------------------------------------------------
496// Get Debug GPIO Description
497//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700498ipmi_ret_t ipmiOemDbgGetGpioDesc(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800499 ipmi_request_t request,
500 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700501 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800502{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700503 uint8_t* req = reinterpret_cast<uint8_t*>(request);
504 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800505
Vijay Khemka38183d62019-08-28 16:19:33 -0700506 uint8_t index = 0;
507 uint8_t next = 0;
508 uint8_t level = 0;
509 uint8_t pinDef = 0;
510 uint8_t descLen = 0;
511 int ret;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800512
Vijay Khemka38183d62019-08-28 16:19:33 -0700513 index = req[3];
514
515 ret = plat_udbg_get_gpio_desc(index, &next, &level, &pinDef, &descLen,
516 &res[8]);
517 if (ret)
518 {
519 memcpy(res, req, SIZE_IANA_ID); // IANA ID
520 *data_len = SIZE_IANA_ID;
521 return IPMI_CC_UNSPECIFIED_ERROR;
522 }
523
524 memcpy(res, req, SIZE_IANA_ID); // IANA ID
525 res[3] = index;
526 res[4] = next;
527 res[5] = level;
528 res[6] = pinDef;
529 res[7] = descLen;
530 *data_len = SIZE_IANA_ID + 5 + descLen;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800531
532 return IPMI_CC_OK;
533}
534
535//----------------------------------------------------------------------
536// Get Debug Frame Data
537//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700538ipmi_ret_t ipmiOemDbgGetFrameData(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800539 ipmi_request_t request,
540 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700541 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800542{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700543 uint8_t* req = reinterpret_cast<uint8_t*>(request);
544 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800545 uint8_t frame;
546 uint8_t page;
547 uint8_t next;
548 uint8_t count;
549 int ret;
550
551 frame = req[3];
552 page = req[4];
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800553
554 ret = plat_udbg_get_frame_data(frame, page, &next, &count, &res[7]);
555 if (ret)
556 {
557 memcpy(res, req, SIZE_IANA_ID); // IANA ID
558 *data_len = SIZE_IANA_ID;
559 return IPMI_CC_UNSPECIFIED_ERROR;
560 }
561
562 memcpy(res, req, SIZE_IANA_ID); // IANA ID
563 res[3] = frame;
564 res[4] = page;
565 res[5] = next;
566 res[6] = count;
567 *data_len = SIZE_IANA_ID + 4 + count;
568
569 return IPMI_CC_OK;
570}
571
572//----------------------------------------------------------------------
573// Get Debug Control Panel
574//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700575ipmi_ret_t ipmiOemDbgGetCtrlPanel(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800576 ipmi_request_t request,
577 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700578 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800579{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700580 uint8_t* req = reinterpret_cast<uint8_t*>(request);
581 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800582
583 uint8_t panel;
584 uint8_t operation;
585 uint8_t item;
586 uint8_t count;
587 ipmi_ret_t ret;
588
589 panel = req[3];
590 operation = req[4];
591 item = req[5];
592
593 ret = plat_udbg_control_panel(panel, operation, item, &count, &res[3]);
594
595 std::memcpy(res, req, SIZE_IANA_ID); // IANA ID
596 *data_len = SIZE_IANA_ID + count;
597
598 return ret;
599}
600
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800601//----------------------------------------------------------------------
602// Set Dimm Info (CMD_OEM_SET_DIMM_INFO)
603//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700604ipmi_ret_t ipmiOemSetDimmInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
605 ipmi_response_t, ipmi_data_len_t data_len,
606 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800607{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700608 uint8_t* req = reinterpret_cast<uint8_t*>(request);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700609
610 uint8_t index = req[0];
611 uint8_t type = req[1];
612 uint16_t speed;
613 uint32_t size;
614
615 memcpy(&speed, &req[2], 2);
616 memcpy(&size, &req[4], 4);
617
618 std::stringstream ss;
619 ss << std::hex;
620 ss << std::setw(2) << std::setfill('0') << (int)index;
621
622 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_INDEX] = index;
623 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_TYPE] = type;
624 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_SPEED] = speed;
625 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_SIZE] = size;
626
627 flushOemData();
628
629 *data_len = 0;
630
631 return IPMI_CC_OK;
632}
633
634//----------------------------------------------------------------------
635// Get Board ID (CMD_OEM_GET_BOARD_ID)
636//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700637ipmi_ret_t ipmiOemGetBoardID(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
638 ipmi_response_t, ipmi_data_len_t data_len,
639 ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700640{
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700641 /* TODO: Needs to implement this after GPIO implementation */
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800642 *data_len = 0;
643
644 return IPMI_CC_OK;
645}
646
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800647/* Helper functions to set boot order */
Jayashree-Df0cf6652020-11-30 11:03:30 +0530648void setBootOrder(std::string bootObjPath, uint8_t* data,
649 std::string bootOrderKey)
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800650{
Jayashree-Df0cf6652020-11-30 11:03:30 +0530651 std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
652
653 // SETTING BOOT MODE PROPERTY
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530654 uint8_t bootModeBit = data[0] & 0x06;
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530655 auto bootValue = ipmi::boot::modeIpmiToDbus.at(bootModeBit);
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530656
Jayashree-Df0cf6652020-11-30 11:03:30 +0530657 std::string bootOption =
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530658 sdbusplus::message::convert_to_string<boot::BootMode>(bootValue);
Jayashree-Df0cf6652020-11-30 11:03:30 +0530659
660 std::string service =
661 getService(*dbus, ipmi::boot::bootModeIntf, bootObjPath);
662 setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootModeIntf,
663 ipmi::boot::bootModeProp, bootOption);
664
665 // SETTING BOOT SOURCE PROPERTY
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530666 auto bootOrder = ipmi::boot::sourceIpmiToDbus.at(data[1]);
Jayashree-Df0cf6652020-11-30 11:03:30 +0530667 std::string bootSource =
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530668 sdbusplus::message::convert_to_string<boot::BootSource>(bootOrder);
Jayashree-Df0cf6652020-11-30 11:03:30 +0530669
670 service = getService(*dbus, ipmi::boot::bootSourceIntf, bootObjPath);
671 setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootSourceIntf,
672 ipmi::boot::bootSourceProp, bootSource);
673
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530674 // SETTING BOOT TYPE PROPERTY
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530675 uint8_t bootTypeBit = data[0] & 0x01;
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530676 auto bootTypeVal = ipmi::boot::typeIpmiToDbus.at(bootTypeBit);
677
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530678 std::string bootType =
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530679 sdbusplus::message::convert_to_string<boot::BootType>(bootTypeVal);
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530680
681 service = getService(*dbus, ipmi::boot::bootTypeIntf, bootObjPath);
682
683 setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootTypeIntf,
684 ipmi::boot::bootTypeProp, bootType);
685
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800686 nlohmann::json bootMode;
687 uint8_t mode = data[0];
688 int i;
689
690 bootMode["UEFI"] = (mode & BOOT_MODE_UEFI ? true : false);
691 bootMode["CMOS_CLR"] = (mode & BOOT_MODE_CMOS_CLR ? true : false);
692 bootMode["FORCE_BOOT"] = (mode & BOOT_MODE_FORCE_BOOT ? true : false);
693 bootMode["BOOT_FLAG"] = (mode & BOOT_MODE_BOOT_FLAG ? true : false);
Jayashree-Df0cf6652020-11-30 11:03:30 +0530694 oemData[bootOrderKey][KEY_BOOT_MODE] = bootMode;
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800695
696 /* Initialize boot sequence array */
Jayashree-Df0cf6652020-11-30 11:03:30 +0530697 oemData[bootOrderKey][KEY_BOOT_SEQ] = {};
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800698 for (i = 1; i < SIZE_BOOT_ORDER; i++)
699 {
700 if (data[i] >= BOOT_SEQ_ARRAY_SIZE)
Jayashree-Df0cf6652020-11-30 11:03:30 +0530701 oemData[bootOrderKey][KEY_BOOT_SEQ][i - 1] = "NA";
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800702 else
Jayashree-Df0cf6652020-11-30 11:03:30 +0530703 oemData[bootOrderKey][KEY_BOOT_SEQ][i - 1] = bootSeq[data[i]];
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800704 }
705
706 flushOemData();
707}
708
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800709//----------------------------------------------------------------------
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700710// Set Boot Order (CMD_OEM_SET_BOOT_ORDER)
711//----------------------------------------------------------------------
Jayashree-Df0cf6652020-11-30 11:03:30 +0530712ipmi::RspType<std::vector<uint8_t>>
713 ipmiOemSetBootOrder(ipmi::Context::ptr ctx, std::vector<uint8_t> data)
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700714{
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700715
Jayashree-Df0cf6652020-11-30 11:03:30 +0530716 uint8_t bootSeq[SIZE_BOOT_ORDER];
717 size_t len = data.size();
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700718
719 if (len != SIZE_BOOT_ORDER)
720 {
721 phosphor::logging::log<phosphor::logging::level::ERR>(
722 "Invalid Boot order length received");
Jayashree-Df0cf6652020-11-30 11:03:30 +0530723 return ipmi::responseReqDataLenInvalid();
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700724 }
725
Jayashree-Df0cf6652020-11-30 11:03:30 +0530726 std::copy(std::begin(data), std::end(data), bootSeq);
Jayashree Dhanapal4ec80562022-06-28 15:41:47 +0530727 std::optional<size_t> hostId = findHost(ctx->hostIdx);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700728
Jayashree-Df0cf6652020-11-30 11:03:30 +0530729 if (!hostId)
730 {
731 phosphor::logging::log<phosphor::logging::level::ERR>(
732 "Invalid Host Id received");
733 return ipmi::responseInvalidCommand();
734 }
735 auto [bootObjPath, hostName] = ipmi::boot::objPath(*hostId);
736
737 setBootOrder(bootObjPath, bootSeq, hostName);
738
739 return ipmi::responseSuccess(data);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700740}
741
742//----------------------------------------------------------------------
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800743// Get Boot Order (CMD_OEM_GET_BOOT_ORDER)
744//----------------------------------------------------------------------
Jayashree-Df0cf6652020-11-30 11:03:30 +0530745ipmi::RspType<uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t>
746 ipmiOemGetBootOrder(ipmi::Context::ptr ctx)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800747{
Jayashree-Df0cf6652020-11-30 11:03:30 +0530748 uint8_t bootSeq[SIZE_BOOT_ORDER];
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700749 uint8_t mode = 0;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800750
Jayashree Dhanapal4ec80562022-06-28 15:41:47 +0530751 std::optional<size_t> hostId = findHost(ctx->hostIdx);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700752
Jayashree-Df0cf6652020-11-30 11:03:30 +0530753 if (!hostId)
754 {
755 phosphor::logging::log<phosphor::logging::level::ERR>(
756 "Invalid Host Id received");
757 return ipmi::responseInvalidCommand();
758 }
759 auto [bootObjPath, hostName] = ipmi::boot::objPath(*hostId);
760
Jayashree-Df0cf6652020-11-30 11:03:30 +0530761 std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
762
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530763 // GETTING PROPERTY OF MODE INTERFACE
764
Jayashree-Df0cf6652020-11-30 11:03:30 +0530765 std::string service =
766 getService(*dbus, ipmi::boot::bootModeIntf, bootObjPath);
767 Value variant =
768 getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootModeIntf,
769 ipmi::boot::bootModeProp);
770
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530771 auto bootMode = sdbusplus::message::convert_from_string<boot::BootMode>(
Jayashree-Df0cf6652020-11-30 11:03:30 +0530772 std::get<std::string>(variant));
773
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530774 uint8_t bootOption = ipmi::boot::modeDbusToIpmi.at(bootMode);
Jayashree-Df0cf6652020-11-30 11:03:30 +0530775
776 // GETTING PROPERTY OF SOURCE INTERFACE
777
778 service = getService(*dbus, ipmi::boot::bootSourceIntf, bootObjPath);
779 variant =
780 getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootSourceIntf,
781 ipmi::boot::bootSourceProp);
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530782
783 auto bootSource = sdbusplus::message::convert_from_string<boot::BootSource>(
Jayashree-Df0cf6652020-11-30 11:03:30 +0530784 std::get<std::string>(variant));
785
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530786 uint8_t bootOrder = ipmi::boot::sourceDbusToIpmi.at(bootSource);
787
788 // GETTING PROPERTY OF TYPE INTERFACE
789
790 service = getService(*dbus, ipmi::boot::bootTypeIntf, bootObjPath);
791 variant =
792 getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootTypeIntf,
793 ipmi::boot::bootTypeProp);
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530794
795 auto bootType = sdbusplus::message::convert_from_string<boot::BootType>(
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530796 std::get<std::string>(variant));
797
798 uint8_t bootTypeVal = ipmi::boot::typeDbusToIpmi.at(bootType);
799
800 uint8_t bootVal = bootOption | bootTypeVal;
Jayashree-Df0cf6652020-11-30 11:03:30 +0530801
802 if (oemData.find(hostName) == oemData.end())
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800803 {
804 /* Return default boot order 0100090203ff */
805 uint8_t defaultBoot[SIZE_BOOT_ORDER] = {
Willy Tue39f9392022-06-15 13:24:20 -0700806 BOOT_MODE_UEFI,
807 static_cast<uint8_t>(bootMap["USB_DEV"]),
808 static_cast<uint8_t>(bootMap["NET_IPV6"]),
809 static_cast<uint8_t>(bootMap["SATA_HDD"]),
810 static_cast<uint8_t>(bootMap["SATA_CD"]),
811 0xff};
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700812
Jayashree-Df0cf6652020-11-30 11:03:30 +0530813 memcpy(bootSeq, defaultBoot, SIZE_BOOT_ORDER);
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800814 phosphor::logging::log<phosphor::logging::level::INFO>(
815 "Set default boot order");
Jayashree-Df0cf6652020-11-30 11:03:30 +0530816 setBootOrder(bootObjPath, defaultBoot, hostName);
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800817 }
818 else
819 {
Jayashree-Df0cf6652020-11-30 11:03:30 +0530820 nlohmann::json bootMode = oemData[hostName][KEY_BOOT_MODE];
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800821 if (bootMode["UEFI"])
822 mode |= BOOT_MODE_UEFI;
823 if (bootMode["CMOS_CLR"])
824 mode |= BOOT_MODE_CMOS_CLR;
825 if (bootMode["BOOT_FLAG"])
826 mode |= BOOT_MODE_BOOT_FLAG;
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700827
Jayashree-Df0cf6652020-11-30 11:03:30 +0530828 bootSeq[0] = mode;
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800829
Jayashree-Df0cf6652020-11-30 11:03:30 +0530830 for (int i = 1; i < SIZE_BOOT_ORDER; i++)
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800831 {
Jayashree-Df0cf6652020-11-30 11:03:30 +0530832 std::string seqStr = oemData[hostName][KEY_BOOT_SEQ][i - 1];
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800833 if (bootMap.find(seqStr) != bootMap.end())
Jayashree-Df0cf6652020-11-30 11:03:30 +0530834 bootSeq[i] = bootMap[seqStr];
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800835 else
Jayashree-Df0cf6652020-11-30 11:03:30 +0530836 bootSeq[i] = 0xff;
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800837 }
838 }
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800839
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530840 return ipmi::responseSuccess(bootVal, bootOrder, bootSeq[2], bootSeq[3],
Jayashree-Df0cf6652020-11-30 11:03:30 +0530841 bootSeq[4], bootSeq[5]);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800842}
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800843// Set Machine Config Info (CMD_OEM_SET_MACHINE_CONFIG_INFO)
844//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700845ipmi_ret_t ipmiOemSetMachineCfgInfo(ipmi_netfn_t, ipmi_cmd_t,
846 ipmi_request_t request, ipmi_response_t,
847 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800848{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700849 machineConfigInfo_t* req = reinterpret_cast<machineConfigInfo_t*>(request);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700850 uint8_t len = *data_len;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800851
852 *data_len = 0;
853
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700854 if (len < sizeof(machineConfigInfo_t))
855 {
856 phosphor::logging::log<phosphor::logging::level::ERR>(
857 "Invalid machine configuration length received");
858 return IPMI_CC_REQ_DATA_LEN_INVALID;
859 }
860
Vijay Khemka63c99be2020-05-27 19:14:35 -0700861 if (req->chassis_type >= sizeof(chassisType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700862 oemData[KEY_MC_CONFIG][KEY_MC_CHAS_TYPE] = "UNKNOWN";
863 else
864 oemData[KEY_MC_CONFIG][KEY_MC_CHAS_TYPE] =
865 chassisType[req->chassis_type];
866
Vijay Khemka63c99be2020-05-27 19:14:35 -0700867 if (req->mb_type >= sizeof(mbType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700868 oemData[KEY_MC_CONFIG][KEY_MC_MB_TYPE] = "UNKNOWN";
869 else
870 oemData[KEY_MC_CONFIG][KEY_MC_MB_TYPE] = mbType[req->mb_type];
871
872 oemData[KEY_MC_CONFIG][KEY_MC_PROC_CNT] = req->proc_cnt;
873 oemData[KEY_MC_CONFIG][KEY_MC_MEM_CNT] = req->mem_cnt;
874 oemData[KEY_MC_CONFIG][KEY_MC_HDD35_CNT] = req->hdd35_cnt;
875 oemData[KEY_MC_CONFIG][KEY_MC_HDD25_CNT] = req->hdd25_cnt;
876
Vijay Khemka63c99be2020-05-27 19:14:35 -0700877 if (req->riser_type >= sizeof(riserType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700878 oemData[KEY_MC_CONFIG][KEY_MC_RSR_TYPE] = "UNKNOWN";
879 else
880 oemData[KEY_MC_CONFIG][KEY_MC_RSR_TYPE] = riserType[req->riser_type];
881
882 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC] = {};
883 int i = 0;
884 if (req->pcie_card_loc & BIT_0)
885 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT1";
886 if (req->pcie_card_loc & BIT_1)
887 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT2";
888 if (req->pcie_card_loc & BIT_2)
889 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT3";
890 if (req->pcie_card_loc & BIT_3)
891 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT4";
892
Vijay Khemka63c99be2020-05-27 19:14:35 -0700893 if (req->slot1_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700894 oemData[KEY_MC_CONFIG][KEY_MC_SLOT1_TYPE] = "UNKNOWN";
895 else
896 oemData[KEY_MC_CONFIG][KEY_MC_SLOT1_TYPE] =
897 pcieType[req->slot1_pcie_type];
898
Vijay Khemka63c99be2020-05-27 19:14:35 -0700899 if (req->slot2_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700900 oemData[KEY_MC_CONFIG][KEY_MC_SLOT2_TYPE] = "UNKNOWN";
901 else
902 oemData[KEY_MC_CONFIG][KEY_MC_SLOT2_TYPE] =
903 pcieType[req->slot2_pcie_type];
904
Vijay Khemka63c99be2020-05-27 19:14:35 -0700905 if (req->slot3_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700906 oemData[KEY_MC_CONFIG][KEY_MC_SLOT3_TYPE] = "UNKNOWN";
907 else
908 oemData[KEY_MC_CONFIG][KEY_MC_SLOT3_TYPE] =
909 pcieType[req->slot3_pcie_type];
910
Vijay Khemka63c99be2020-05-27 19:14:35 -0700911 if (req->slot4_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700912 oemData[KEY_MC_CONFIG][KEY_MC_SLOT4_TYPE] = "UNKNOWN";
913 else
914 oemData[KEY_MC_CONFIG][KEY_MC_SLOT4_TYPE] =
915 pcieType[req->slot4_pcie_type];
916
917 oemData[KEY_MC_CONFIG][KEY_MC_AEP_CNT] = req->aep_mem_cnt;
918
919 flushOemData();
920
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800921 return IPMI_CC_OK;
922}
923
924//----------------------------------------------------------------------
925// Set POST start (CMD_OEM_SET_POST_START)
926//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700927ipmi_ret_t ipmiOemSetPostStart(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
928 ipmi_response_t, ipmi_data_len_t data_len,
929 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800930{
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800931 phosphor::logging::log<phosphor::logging::level::INFO>("POST Start Event");
932
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700933 /* Do nothing, return success */
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800934 *data_len = 0;
935 return IPMI_CC_OK;
936}
937
938//----------------------------------------------------------------------
939// Set POST End (CMD_OEM_SET_POST_END)
940//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700941ipmi_ret_t ipmiOemSetPostEnd(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
942 ipmi_response_t, ipmi_data_len_t data_len,
943 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800944{
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700945 struct timespec ts;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800946
947 phosphor::logging::log<phosphor::logging::level::INFO>("POST End Event");
948
949 *data_len = 0;
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700950
951 // Timestamp post end time.
952 clock_gettime(CLOCK_REALTIME, &ts);
953 oemData[KEY_TS_SLED] = ts.tv_sec;
954 flushOemData();
955
956 // Sync time with system
957 // TODO: Add code for syncing time
958
959 return IPMI_CC_OK;
960}
961
962//----------------------------------------------------------------------
963// Set PPIN Info (CMD_OEM_SET_PPIN_INFO)
964//----------------------------------------------------------------------
965// Inform BMC about PPIN data of 8 bytes for each CPU
966//
967// Request:
968// Byte 1:8 – CPU0 PPIN data
969// Optional:
970// Byte 9:16 – CPU1 PPIN data
971//
972// Response:
973// Byte 1 – Completion Code
Willy Tue39f9392022-06-15 13:24:20 -0700974ipmi_ret_t ipmiOemSetPPINInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
975 ipmi_response_t, ipmi_data_len_t data_len,
976 ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700977{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700978 uint8_t* req = reinterpret_cast<uint8_t*>(request);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700979 std::string ppinStr;
980 int len;
981
982 if (*data_len > SIZE_CPU_PPIN * 2)
983 len = SIZE_CPU_PPIN * 2;
984 else
985 len = *data_len;
986 *data_len = 0;
987
988 ppinStr = bytesToStr(req, len);
989 oemData[KEY_PPIN_INFO] = ppinStr.c_str();
990 flushOemData();
991
992 return IPMI_CC_OK;
993}
994
995//----------------------------------------------------------------------
996// Set ADR Trigger (CMD_OEM_SET_ADR_TRIGGER)
997//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700998ipmi_ret_t ipmiOemSetAdrTrigger(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
999 ipmi_response_t, ipmi_data_len_t data_len,
1000 ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001001{
1002 /* Do nothing, return success */
1003 *data_len = 0;
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001004 return IPMI_CC_OK;
1005}
1006
Vijay Khemkaf2246ce2020-05-27 14:26:35 -07001007// Helper function to set guid at offset in EEPROM
Willy Tue39f9392022-06-15 13:24:20 -07001008[[maybe_unused]] static int setGUID(off_t offset, uint8_t* guid)
Vijay Khemkaf2246ce2020-05-27 14:26:35 -07001009{
1010 int fd = -1;
1011 ssize_t len;
1012 int ret = 0;
1013
1014 errno = 0;
1015
1016 // Check if file is present
1017 if (access(FRU_EEPROM, F_OK) == -1)
1018 {
1019 std::cerr << "Unable to access: " << FRU_EEPROM << std::endl;
1020 return errno;
1021 }
1022
1023 // Open the file
1024 fd = open(FRU_EEPROM, O_WRONLY);
1025 if (fd == -1)
1026 {
1027 std::cerr << "Unable to open: " << FRU_EEPROM << std::endl;
1028 return errno;
1029 }
1030
1031 // seek to the offset
1032 lseek(fd, offset, SEEK_SET);
1033
1034 // Write bytes to location
1035 len = write(fd, guid, GUID_SIZE);
1036 if (len != GUID_SIZE)
1037 {
1038 phosphor::logging::log<phosphor::logging::level::ERR>(
1039 "GUID write data to EEPROM failed");
1040 ret = errno;
1041 }
1042
1043 close(fd);
1044 return ret;
1045}
1046
1047//----------------------------------------------------------------------
1048// Set System GUID (CMD_OEM_SET_SYSTEM_GUID)
1049//----------------------------------------------------------------------
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05301050#if BIC_ENABLED
Willy Tue39f9392022-06-15 13:24:20 -07001051ipmi::RspType<> ipmiOemSetSystemGuid(ipmi::Context::ptr ctx, uint8_t,
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05301052 std::vector<uint8_t> reqData)
1053{
1054 std::vector<uint8_t> respData;
1055
1056 if (reqData.size() != GUID_SIZE) // 16bytes
1057 {
1058
1059 return ipmi::responseReqDataLenInvalid();
1060 }
1061
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05301062 uint8_t bicAddr = (uint8_t)ctx->hostIdx << 2;
1063
1064 if (sendBicCmd(ctx->netFn, ctx->cmd, bicAddr, reqData, respData))
1065 return ipmi::responseUnspecifiedError();
1066
1067 return ipmi::responseSuccess();
1068}
1069
1070#else
Vijay Khemkaf2246ce2020-05-27 14:26:35 -07001071ipmi_ret_t ipmiOemSetSystemGuid(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
1072 ipmi_request_t request,
1073 ipmi_response_t response,
1074 ipmi_data_len_t data_len,
1075 ipmi_context_t context)
1076{
1077 uint8_t* req = reinterpret_cast<uint8_t*>(request);
1078
1079 if (*data_len != GUID_SIZE) // 16bytes
1080 {
1081 *data_len = 0;
1082 return IPMI_CC_REQ_DATA_LEN_INVALID;
1083 }
1084
1085 *data_len = 0;
1086
1087 if (setGUID(OFFSET_SYS_GUID, req))
1088 {
1089 return IPMI_CC_UNSPECIFIED_ERROR;
1090 }
1091 return IPMI_CC_OK;
1092}
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05301093#endif
Vijay Khemkaf2246ce2020-05-27 14:26:35 -07001094
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001095//----------------------------------------------------------------------
1096// Set Bios Flash Info (CMD_OEM_SET_BIOS_FLASH_INFO)
1097//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -07001098ipmi_ret_t ipmiOemSetBiosFlashInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
1099 ipmi_response_t, ipmi_data_len_t data_len,
1100 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001101{
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001102 /* Do nothing, return success */
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001103 *data_len = 0;
1104 return IPMI_CC_OK;
1105}
1106
1107//----------------------------------------------------------------------
1108// Set PPR (CMD_OEM_SET_PPR)
1109//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -07001110ipmi_ret_t ipmiOemSetPpr(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
1111 ipmi_response_t, ipmi_data_len_t data_len,
1112 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001113{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001114 uint8_t* req = reinterpret_cast<uint8_t*>(request);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001115 uint8_t pprCnt, pprAct, pprIndex;
1116 uint8_t selParam = req[0];
1117 uint8_t len = *data_len;
1118 std::stringstream ss;
1119 std::string str;
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001120
1121 *data_len = 0;
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001122
1123 switch (selParam)
1124 {
1125 case PPR_ACTION:
1126 if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) ==
1127 oemData[KEY_PPR].end())
1128 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1129
1130 pprCnt = oemData[KEY_PPR][KEY_PPR_ROW_COUNT];
1131 if (pprCnt == 0)
1132 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1133
1134 pprAct = req[1];
1135 /* Check if ppr is enabled or disabled */
1136 if (!(pprAct & 0x80))
1137 pprAct = 0;
1138
1139 oemData[KEY_PPR][KEY_PPR_ACTION] = pprAct;
1140 break;
1141 case PPR_ROW_COUNT:
1142 if (req[1] > 100)
1143 return IPMI_CC_PARM_OUT_OF_RANGE;
1144
1145 oemData[KEY_PPR][KEY_PPR_ROW_COUNT] = req[1];
1146 break;
1147 case PPR_ROW_ADDR:
1148 pprIndex = req[1];
1149 if (pprIndex > 100)
1150 return IPMI_CC_PARM_OUT_OF_RANGE;
1151
1152 if (len < PPR_ROW_ADDR_LEN + 1)
1153 {
1154 phosphor::logging::log<phosphor::logging::level::ERR>(
1155 "Invalid PPR Row Address length received");
1156 return IPMI_CC_REQ_DATA_LEN_INVALID;
1157 }
1158
1159 ss << std::hex;
1160 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
1161
1162 oemData[KEY_PPR][ss.str()][KEY_PPR_INDEX] = pprIndex;
1163
1164 str = bytesToStr(&req[1], PPR_ROW_ADDR_LEN);
1165 oemData[KEY_PPR][ss.str()][KEY_PPR_ROW_ADDR] = str.c_str();
1166 break;
1167 case PPR_HISTORY_DATA:
1168 pprIndex = req[1];
1169 if (pprIndex > 100)
1170 return IPMI_CC_PARM_OUT_OF_RANGE;
1171
1172 if (len < PPR_HST_DATA_LEN + 1)
1173 {
1174 phosphor::logging::log<phosphor::logging::level::ERR>(
1175 "Invalid PPR history data length received");
1176 return IPMI_CC_REQ_DATA_LEN_INVALID;
1177 }
1178
1179 ss << std::hex;
1180 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
1181
1182 oemData[KEY_PPR][ss.str()][KEY_PPR_INDEX] = pprIndex;
1183
1184 str = bytesToStr(&req[1], PPR_HST_DATA_LEN);
1185 oemData[KEY_PPR][ss.str()][KEY_PPR_HST_DATA] = str.c_str();
1186 break;
1187 default:
1188 return IPMI_CC_PARM_OUT_OF_RANGE;
1189 break;
1190 }
1191
1192 flushOemData();
1193
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001194 return IPMI_CC_OK;
1195}
1196
1197//----------------------------------------------------------------------
1198// Get PPR (CMD_OEM_GET_PPR)
1199//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -07001200ipmi_ret_t ipmiOemGetPpr(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
1201 ipmi_response_t response, ipmi_data_len_t data_len,
1202 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001203{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001204 uint8_t* req = reinterpret_cast<uint8_t*>(request);
1205 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001206 uint8_t pprCnt, pprIndex;
1207 uint8_t selParam = req[0];
1208 std::stringstream ss;
1209 std::string str;
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001210
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001211 /* Any failure will return zero length data */
1212 *data_len = 0;
1213
1214 switch (selParam)
1215 {
1216 case PPR_ACTION:
1217 res[0] = 0;
1218 *data_len = 1;
1219
1220 if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) !=
1221 oemData[KEY_PPR].end())
1222 {
1223 pprCnt = oemData[KEY_PPR][KEY_PPR_ROW_COUNT];
1224 if (pprCnt != 0)
1225 {
1226 if (oemData[KEY_PPR].find(KEY_PPR_ACTION) !=
1227 oemData[KEY_PPR].end())
1228 {
1229 res[0] = oemData[KEY_PPR][KEY_PPR_ACTION];
1230 }
1231 }
1232 }
1233 break;
1234 case PPR_ROW_COUNT:
1235 res[0] = 0;
1236 *data_len = 1;
1237 if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) !=
1238 oemData[KEY_PPR].end())
1239 res[0] = oemData[KEY_PPR][KEY_PPR_ROW_COUNT];
1240 break;
1241 case PPR_ROW_ADDR:
1242 pprIndex = req[1];
1243 if (pprIndex > 100)
1244 return IPMI_CC_PARM_OUT_OF_RANGE;
1245
1246 ss << std::hex;
1247 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
1248
1249 if (oemData[KEY_PPR].find(ss.str()) == oemData[KEY_PPR].end())
1250 return IPMI_CC_PARM_OUT_OF_RANGE;
1251
1252 if (oemData[KEY_PPR][ss.str()].find(KEY_PPR_ROW_ADDR) ==
1253 oemData[KEY_PPR][ss.str()].end())
1254 return IPMI_CC_PARM_OUT_OF_RANGE;
1255
1256 str = oemData[KEY_PPR][ss.str()][KEY_PPR_ROW_ADDR];
1257 *data_len = strToBytes(str, res);
1258 break;
1259 case PPR_HISTORY_DATA:
1260 pprIndex = req[1];
1261 if (pprIndex > 100)
1262 return IPMI_CC_PARM_OUT_OF_RANGE;
1263
1264 ss << std::hex;
1265 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
1266
1267 if (oemData[KEY_PPR].find(ss.str()) == oemData[KEY_PPR].end())
1268 return IPMI_CC_PARM_OUT_OF_RANGE;
1269
1270 if (oemData[KEY_PPR][ss.str()].find(KEY_PPR_HST_DATA) ==
1271 oemData[KEY_PPR][ss.str()].end())
1272 return IPMI_CC_PARM_OUT_OF_RANGE;
1273
1274 str = oemData[KEY_PPR][ss.str()][KEY_PPR_HST_DATA];
1275 *data_len = strToBytes(str, res);
1276 break;
1277 default:
1278 return IPMI_CC_PARM_OUT_OF_RANGE;
1279 break;
1280 }
1281
1282 return IPMI_CC_OK;
1283}
1284
1285/* FB OEM QC Commands */
1286
1287//----------------------------------------------------------------------
1288// Set Proc Info (CMD_OEM_Q_SET_PROC_INFO)
1289//----------------------------------------------------------------------
1290//"Request:
1291// Byte 1:3 – Manufacturer ID – XXYYZZ h, LSB first
1292// Byte 4 – Processor Index, 0 base
1293// Byte 5 – Parameter Selector
1294// Byte 6..N – Configuration parameter data (see below for Parameters
1295// of Processor Information)
1296// Response:
1297// Byte 1 – Completion code
1298//
1299// Parameter#1: (Processor Product Name)
1300//
1301// Byte 1..48 –Product name(ASCII code)
1302// Ex. Intel(R) Xeon(R) CPU E5-2685 v3 @ 2.60GHz
1303//
1304// Param#2: Processor Basic Information
1305// Byte 1 – Core Number
1306// Byte 2 – Thread Number (LSB)
1307// Byte 3 – Thread Number (MSB)
1308// Byte 4 – Processor frequency in MHz (LSB)
1309// Byte 5 – Processor frequency in MHz (MSB)
1310// Byte 6..7 – Revision
1311//
Willy Tue39f9392022-06-15 13:24:20 -07001312ipmi_ret_t ipmiOemQSetProcInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
1313 ipmi_response_t, ipmi_data_len_t data_len,
1314 ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001315{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001316 qProcInfo_t* req = reinterpret_cast<qProcInfo_t*>(request);
1317 uint8_t numParam = sizeof(cpuInfoKey) / sizeof(uint8_t*);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001318 std::stringstream ss;
1319 std::string str;
1320 uint8_t len = *data_len;
1321
1322 *data_len = 0;
1323
1324 /* check for requested data params */
1325 if (len < 5 || req->paramSel < 1 || req->paramSel >= numParam)
1326 {
1327 phosphor::logging::log<phosphor::logging::level::ERR>(
1328 "Invalid parameter received");
1329 return IPMI_CC_PARM_OUT_OF_RANGE;
1330 }
1331
1332 len = len - 5; // Get Actual data length
1333
1334 ss << std::hex;
1335 ss << std::setw(2) << std::setfill('0') << (int)req->procIndex;
1336 oemData[KEY_Q_PROC_INFO][ss.str()][KEY_PROC_INDEX] = req->procIndex;
1337
1338 str = bytesToStr(req->data, len);
1339 oemData[KEY_Q_PROC_INFO][ss.str()][cpuInfoKey[req->paramSel]] = str.c_str();
1340 flushOemData();
1341
1342 return IPMI_CC_OK;
1343}
1344
1345//----------------------------------------------------------------------
1346// Get Proc Info (CMD_OEM_Q_GET_PROC_INFO)
1347//----------------------------------------------------------------------
1348// Request:
1349// Byte 1:3 – Manufacturer ID – XXYYZZ h, LSB first
1350// Byte 4 – Processor Index, 0 base
1351// Byte 5 – Parameter Selector
1352// Response:
1353// Byte 1 – Completion code
1354// Byte 2..N – Configuration Parameter Data (see below for Parameters
1355// of Processor Information)
1356//
1357// Parameter#1: (Processor Product Name)
1358//
1359// Byte 1..48 –Product name(ASCII code)
1360// Ex. Intel(R) Xeon(R) CPU E5-2685 v3 @ 2.60GHz
1361//
1362// Param#2: Processor Basic Information
1363// Byte 1 – Core Number
1364// Byte 2 – Thread Number (LSB)
1365// Byte 3 – Thread Number (MSB)
1366// Byte 4 – Processor frequency in MHz (LSB)
1367// Byte 5 – Processor frequency in MHz (MSB)
1368// Byte 6..7 – Revision
1369//
Willy Tue39f9392022-06-15 13:24:20 -07001370ipmi_ret_t ipmiOemQGetProcInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
1371 ipmi_response_t response,
1372 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001373{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001374 qProcInfo_t* req = reinterpret_cast<qProcInfo_t*>(request);
1375 uint8_t numParam = sizeof(cpuInfoKey) / sizeof(uint8_t*);
1376 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001377 std::stringstream ss;
1378 std::string str;
1379
1380 *data_len = 0;
1381
1382 /* check for requested data params */
1383 if (req->paramSel < 1 || req->paramSel >= numParam)
1384 {
1385 phosphor::logging::log<phosphor::logging::level::ERR>(
1386 "Invalid parameter received");
1387 return IPMI_CC_PARM_OUT_OF_RANGE;
1388 }
1389
1390 ss << std::hex;
1391 ss << std::setw(2) << std::setfill('0') << (int)req->procIndex;
1392
1393 if (oemData[KEY_Q_PROC_INFO].find(ss.str()) ==
1394 oemData[KEY_Q_PROC_INFO].end())
1395 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1396
1397 if (oemData[KEY_Q_PROC_INFO][ss.str()].find(cpuInfoKey[req->paramSel]) ==
1398 oemData[KEY_Q_PROC_INFO][ss.str()].end())
1399 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1400
1401 str = oemData[KEY_Q_PROC_INFO][ss.str()][cpuInfoKey[req->paramSel]];
1402 *data_len = strToBytes(str, res);
1403
1404 return IPMI_CC_OK;
1405}
1406
1407//----------------------------------------------------------------------
1408// Set Dimm Info (CMD_OEM_Q_SET_DIMM_INFO)
1409//----------------------------------------------------------------------
1410// Request:
1411// Byte 1:3 – Manufacturer ID – XXYYZZh, LSB first
1412// Byte 4 – DIMM Index, 0 base
1413// Byte 5 – Parameter Selector
1414// Byte 6..N – Configuration parameter data (see below for Parameters
1415// of DIMM Information)
1416// Response:
1417// Byte 1 – Completion code
1418//
1419// Param#1 (DIMM Location):
1420// Byte 1 – DIMM Present
1421// Byte 1 – DIMM Present
1422// 01h – Present
1423// FFh – Not Present
1424// Byte 2 – Node Number, 0 base
1425// Byte 3 – Channel Number , 0 base
1426// Byte 4 – DIMM Number , 0 base
1427//
1428// Param#2 (DIMM Type):
1429// Byte 1 – DIMM Type
1430// Bit [7:6]
1431// For DDR3
1432// 00 – Normal Voltage (1.5V)
1433// 01 – Ultra Low Voltage (1.25V)
1434// 10 – Low Voltage (1.35V)
1435// 11 – Reserved
1436// For DDR4
1437// 00 – Reserved
1438// 01 – Reserved
1439// 10 – Reserved
1440// 11 – Normal Voltage (1.2V)
1441// Bit [5:0]
1442// 0x00 – SDRAM
1443// 0x01 – DDR-1 RAM
1444// 0x02 – Rambus
1445// 0x03 – DDR-2 RAM
1446// 0x04 – FBDIMM
1447// 0x05 – DDR-3 RAM
1448// 0x06 – DDR-4 RAM
1449//
1450// Param#3 (DIMM Speed):
1451// Byte 1..2 – DIMM speed in MHz, LSB
1452// Byte 3..6 – DIMM size in Mbytes, LSB
1453//
1454// Param#4 (Module Part Number):
1455// Byte 1..20 –Module Part Number (JEDEC Standard No. 21-C)
1456//
1457// Param#5 (Module Serial Number):
1458// Byte 1..4 –Module Serial Number (JEDEC Standard No. 21-C)
1459//
1460// Param#6 (Module Manufacturer ID):
1461// Byte 1 - Module Manufacturer ID, LSB
1462// Byte 2 - Module Manufacturer ID, MSB
1463//
Willy Tue39f9392022-06-15 13:24:20 -07001464ipmi_ret_t ipmiOemQSetDimmInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
1465 ipmi_response_t, ipmi_data_len_t data_len,
1466 ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001467{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001468 qDimmInfo_t* req = reinterpret_cast<qDimmInfo_t*>(request);
1469 uint8_t numParam = sizeof(dimmInfoKey) / sizeof(uint8_t*);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001470 std::stringstream ss;
1471 std::string str;
1472 uint8_t len = *data_len;
1473
1474 *data_len = 0;
1475
1476 /* check for requested data params */
1477 if (len < 5 || req->paramSel < 1 || req->paramSel >= numParam)
1478 {
1479 phosphor::logging::log<phosphor::logging::level::ERR>(
1480 "Invalid parameter received");
1481 return IPMI_CC_PARM_OUT_OF_RANGE;
1482 }
1483
1484 len = len - 5; // Get Actual data length
1485
1486 ss << std::hex;
1487 ss << std::setw(2) << std::setfill('0') << (int)req->dimmIndex;
1488 oemData[KEY_Q_DIMM_INFO][ss.str()][KEY_DIMM_INDEX] = req->dimmIndex;
1489
1490 str = bytesToStr(req->data, len);
1491 oemData[KEY_Q_DIMM_INFO][ss.str()][dimmInfoKey[req->paramSel]] =
1492 str.c_str();
1493 flushOemData();
1494
1495 return IPMI_CC_OK;
1496}
1497
1498//----------------------------------------------------------------------
1499// Get Dimm Info (CMD_OEM_Q_GET_DIMM_INFO)
1500//----------------------------------------------------------------------
1501// Request:
1502// Byte 1:3 – Manufacturer ID – XXYYZZh, LSB first
1503// Byte 4 – DIMM Index, 0 base
1504// Byte 5 – Parameter Selector
1505// Byte 6..N – Configuration parameter data (see below for Parameters
1506// of DIMM Information)
1507// Response:
1508// Byte 1 – Completion code
1509// Byte 2..N – Configuration Parameter Data (see Table_1213h Parameters
1510// of DIMM Information)
1511//
1512// Param#1 (DIMM Location):
1513// Byte 1 – DIMM Present
1514// Byte 1 – DIMM Present
1515// 01h – Present
1516// FFh – Not Present
1517// Byte 2 – Node Number, 0 base
1518// Byte 3 – Channel Number , 0 base
1519// Byte 4 – DIMM Number , 0 base
1520//
1521// Param#2 (DIMM Type):
1522// Byte 1 – DIMM Type
1523// Bit [7:6]
1524// For DDR3
1525// 00 – Normal Voltage (1.5V)
1526// 01 – Ultra Low Voltage (1.25V)
1527// 10 – Low Voltage (1.35V)
1528// 11 – Reserved
1529// For DDR4
1530// 00 – Reserved
1531// 01 – Reserved
1532// 10 – Reserved
1533// 11 – Normal Voltage (1.2V)
1534// Bit [5:0]
1535// 0x00 – SDRAM
1536// 0x01 – DDR-1 RAM
1537// 0x02 – Rambus
1538// 0x03 – DDR-2 RAM
1539// 0x04 – FBDIMM
1540// 0x05 – DDR-3 RAM
1541// 0x06 – DDR-4 RAM
1542//
1543// Param#3 (DIMM Speed):
1544// Byte 1..2 – DIMM speed in MHz, LSB
1545// Byte 3..6 – DIMM size in Mbytes, LSB
1546//
1547// Param#4 (Module Part Number):
1548// Byte 1..20 –Module Part Number (JEDEC Standard No. 21-C)
1549//
1550// Param#5 (Module Serial Number):
1551// Byte 1..4 –Module Serial Number (JEDEC Standard No. 21-C)
1552//
1553// Param#6 (Module Manufacturer ID):
1554// Byte 1 - Module Manufacturer ID, LSB
1555// Byte 2 - Module Manufacturer ID, MSB
1556//
Willy Tue39f9392022-06-15 13:24:20 -07001557ipmi_ret_t ipmiOemQGetDimmInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
1558 ipmi_response_t response,
1559 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001560{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001561 qDimmInfo_t* req = reinterpret_cast<qDimmInfo_t*>(request);
1562 uint8_t numParam = sizeof(dimmInfoKey) / sizeof(uint8_t*);
1563 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001564 std::stringstream ss;
1565 std::string str;
1566
1567 *data_len = 0;
1568
1569 /* check for requested data params */
1570 if (req->paramSel < 1 || req->paramSel >= numParam)
1571 {
1572 phosphor::logging::log<phosphor::logging::level::ERR>(
1573 "Invalid parameter received");
1574 return IPMI_CC_PARM_OUT_OF_RANGE;
1575 }
1576
1577 ss << std::hex;
1578 ss << std::setw(2) << std::setfill('0') << (int)req->dimmIndex;
1579
1580 if (oemData[KEY_Q_DIMM_INFO].find(ss.str()) ==
1581 oemData[KEY_Q_DIMM_INFO].end())
1582 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1583
1584 if (oemData[KEY_Q_DIMM_INFO][ss.str()].find(dimmInfoKey[req->paramSel]) ==
1585 oemData[KEY_Q_DIMM_INFO][ss.str()].end())
1586 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1587
1588 str = oemData[KEY_Q_DIMM_INFO][ss.str()][dimmInfoKey[req->paramSel]];
1589 *data_len = strToBytes(str, res);
1590
1591 return IPMI_CC_OK;
1592}
1593
1594//----------------------------------------------------------------------
1595// Set Drive Info (CMD_OEM_Q_SET_DRIVE_INFO)
1596//----------------------------------------------------------------------
1597// BIOS issue this command to provide HDD information to BMC.
1598//
1599// BIOS just can get information by standard ATA / SMART command for
1600// OB SATA controller.
1601// BIOS can get
1602// 1. Serial Number
1603// 2. Model Name
1604// 3. HDD FW Version
1605// 4. HDD Capacity
1606// 5. HDD WWN
1607//
1608// Use Get HDD info Param #5 to know the MAX HDD info index.
1609//
1610// Request:
1611// Byte 1:3 – Quanta Manufacturer ID – 001C4Ch, LSB first
1612// Byte 4 –
1613// [7:4] Reserved
1614// [3:0] HDD Controller Type
1615// 0x00 – BIOS
1616// 0x01 – Expander
1617// 0x02 – LSI
1618// Byte 5 – HDD Info Index, 0 base
1619// Byte 6 – Parameter Selector
1620// Byte 7..N – Configuration parameter data (see Table_1415h Parameters of HDD
1621// Information)
1622//
1623// Response:
1624// Byte 1 – Completion Code
1625//
1626// Param#0 (HDD Location):
1627// Byte 1 – Controller
1628// [7:3] Device Number
1629// [2:0] Function Number
1630// For Intel C610 series (Wellsburg)
1631// D31:F2 (0xFA) – SATA control 1
1632// D31:F5 (0xFD) – SATA control 2
1633// D17:F4 (0x8C) – sSata control
1634// Byte 2 – Port Number
1635// Byte 3 – Location (0xFF: No HDD Present)
1636// BIOS default set Byte 3 to 0xFF, if No HDD Present. And then skip send param
1637// #1~4, #6, #7 to BMC (still send param #5) BIOS default set Byte 3 to 0, if
1638// the HDD present. BMC or other people who know the HDD location has
1639// responsibility for update Location info
1640//
1641// Param#1 (Serial Number):
1642// Bytes 1..33: HDD Serial Number
1643//
1644// Param#2 (Model Name):
1645// Byte 1..33 – HDD Model Name
1646//
1647// Param#3 (HDD FW Version):
1648// Byte 1..17 –HDD FW version
1649//
1650// Param#4 (Capacity):
1651// Byte 1..4 –HDD Block Size, LSB
1652// Byte 5..12 - HDD Block Number, LSB
1653// HDD Capacity = HDD Block size * HDD BLock number (Unit Byte)
1654//
1655// Param#5 (Max HDD Quantity):
1656// Byte 1 - Max HDD Quantity
1657// Max supported port numbers in this PCH
1658//
1659// Param#6 (HDD Type)
1660// Byte 1 – HDD Type
1661// 0h – Reserved
1662// 1h – SAS
1663// 2h – SATA
1664// 3h – PCIE SSD (NVME)
1665//
1666// Param#7 (HDD WWN)
1667// Data 1...8: HDD World Wide Name, LSB
1668//
Willy Tue39f9392022-06-15 13:24:20 -07001669ipmi_ret_t ipmiOemQSetDriveInfo(ipmi_netfn_t, ipmi_cmd_t,
1670 ipmi_request_t request, ipmi_response_t,
1671 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001672{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001673 qDriveInfo_t* req = reinterpret_cast<qDriveInfo_t*>(request);
1674 uint8_t numParam = sizeof(driveInfoKey) / sizeof(uint8_t*);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001675 uint8_t ctrlType = req->hddCtrlType & 0x0f;
1676 std::stringstream ss;
1677 std::string str;
1678 uint8_t len = *data_len;
1679
1680 *data_len = 0;
1681
1682 /* check for requested data params */
1683 if (len < 6 || req->paramSel < 1 || req->paramSel >= numParam ||
1684 ctrlType > 2)
1685 {
1686 phosphor::logging::log<phosphor::logging::level::ERR>(
1687 "Invalid parameter received");
1688 return IPMI_CC_PARM_OUT_OF_RANGE;
1689 }
1690
1691 len = len - 6; // Get Actual data length
1692
1693 ss << std::hex;
1694 ss << std::setw(2) << std::setfill('0') << (int)req->hddIndex;
1695 oemData[KEY_Q_DRIVE_INFO][KEY_HDD_CTRL_TYPE] = req->hddCtrlType;
1696 oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()][KEY_HDD_INDEX] =
1697 req->hddIndex;
1698
1699 str = bytesToStr(req->data, len);
1700 oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()]
1701 [driveInfoKey[req->paramSel]] = str.c_str();
1702 flushOemData();
1703
1704 return IPMI_CC_OK;
1705}
1706
1707//----------------------------------------------------------------------
1708// Get Drive Info (CMD_OEM_Q_GET_DRIVE_INFO)
1709//----------------------------------------------------------------------
1710// BMC needs to check HDD presented or not first. If NOT presented, return
1711// completion code 0xD5.
1712//
1713// Request:
1714// Byte 1:3 – Quanta Manufacturer ID – 001C4Ch, LSB first
1715// Byte 4 –
1716//[7:4] Reserved
1717//[3:0] HDD Controller Type
1718// 0x00 – BIOS
1719// 0x01 – Expander
1720// 0x02 – LSI
1721// Byte 5 – HDD Index, 0 base
1722// Byte 6 – Parameter Selector (See Above Set HDD Information)
1723// Response:
1724// Byte 1 – Completion Code
1725// 0xD5 – Not support in current status (HDD Not Present)
1726// Byte 2..N – Configuration parameter data (see Table_1415h Parameters of HDD
1727// Information)
1728//
Willy Tue39f9392022-06-15 13:24:20 -07001729ipmi_ret_t ipmiOemQGetDriveInfo(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001730 ipmi_request_t request,
1731 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -07001732 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001733{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001734 qDriveInfo_t* req = reinterpret_cast<qDriveInfo_t*>(request);
1735 uint8_t numParam = sizeof(driveInfoKey) / sizeof(uint8_t*);
1736 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001737 uint8_t ctrlType = req->hddCtrlType & 0x0f;
1738 std::stringstream ss;
1739 std::string str;
1740
1741 *data_len = 0;
1742
1743 /* check for requested data params */
1744 if (req->paramSel < 1 || req->paramSel >= numParam || ctrlType > 2)
1745 {
1746 phosphor::logging::log<phosphor::logging::level::ERR>(
1747 "Invalid parameter received");
1748 return IPMI_CC_PARM_OUT_OF_RANGE;
1749 }
1750
1751 if (oemData[KEY_Q_DRIVE_INFO].find(ctrlTypeKey[ctrlType]) ==
1752 oemData[KEY_Q_DRIVE_INFO].end())
1753 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1754
1755 ss << std::hex;
1756 ss << std::setw(2) << std::setfill('0') << (int)req->hddIndex;
1757
1758 if (oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]].find(ss.str()) ==
1759 oemData[KEY_Q_DRIVE_INFO].end())
1760 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1761
1762 if (oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()].find(
1763 dimmInfoKey[req->paramSel]) ==
1764 oemData[KEY_Q_DRIVE_INFO][ss.str()].end())
1765 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1766
1767 str = oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()]
1768 [dimmInfoKey[req->paramSel]];
1769 *data_len = strToBytes(str, res);
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001770
1771 return IPMI_CC_OK;
1772}
1773
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07001774/* Helper function for sending DCMI commands to ME and getting response back */
1775ipmi::RspType<std::vector<uint8_t>> sendDCMICmd(uint8_t cmd,
Vijay Khemka63c99be2020-05-27 19:14:35 -07001776 std::vector<uint8_t>& cmdData)
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07001777{
1778 std::vector<uint8_t> respData;
1779
1780 /* Add group id as first byte to request for ME command */
1781 cmdData.insert(cmdData.begin(), groupDCMI);
1782
1783 if (sendMeCmd(ipmi::netFnGroup, cmd, cmdData, respData))
1784 return ipmi::responseUnspecifiedError();
1785
1786 /* Remove group id as first byte as it will be added by IPMID */
1787 respData.erase(respData.begin());
1788
1789 return ipmi::responseSuccess(std::move(respData));
1790}
1791
1792/* DCMI Command handellers. */
1793
1794ipmi::RspType<std::vector<uint8_t>>
1795 ipmiOemDCMIGetPowerReading(std::vector<uint8_t> reqData)
1796{
1797 return sendDCMICmd(ipmi::dcmi::cmdGetPowerReading, reqData);
1798}
1799
1800ipmi::RspType<std::vector<uint8_t>>
1801 ipmiOemDCMIGetPowerLimit(std::vector<uint8_t> reqData)
1802{
1803 return sendDCMICmd(ipmi::dcmi::cmdGetPowerLimit, reqData);
1804}
1805
1806ipmi::RspType<std::vector<uint8_t>>
1807 ipmiOemDCMISetPowerLimit(std::vector<uint8_t> reqData)
1808{
1809 return sendDCMICmd(ipmi::dcmi::cmdSetPowerLimit, reqData);
1810}
1811
1812ipmi::RspType<std::vector<uint8_t>>
1813 ipmiOemDCMIApplyPowerLimit(std::vector<uint8_t> reqData)
1814{
1815 return sendDCMICmd(ipmi::dcmi::cmdActDeactivatePwrLimit, reqData);
1816}
1817
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001818static void registerOEMFunctions(void)
1819{
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001820 /* Get OEM data from json file */
1821 std::ifstream file(JSON_OEM_DATA_FILE);
1822 if (file)
Vijay Khemkafeaa9812019-08-27 15:08:08 -07001823 {
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001824 file >> oemData;
Vijay Khemkafeaa9812019-08-27 15:08:08 -07001825 file.close();
1826 }
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001827
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001828 phosphor::logging::log<phosphor::logging::level::INFO>(
1829 "Registering OEM commands");
Vijay Khemka7c0aea42020-03-05 13:31:53 -08001830
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001831 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_INFO,
1832 NULL, ipmiOemDbgGetFrameInfo,
1833 PRIVILEGE_USER); // get debug frame info
1834 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ,
1835 CMD_OEM_USB_DBG_GET_UPDATED_FRAMES, NULL,
1836 ipmiOemDbgGetUpdFrames,
1837 PRIVILEGE_USER); // get debug updated frames
1838 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_POST_DESC,
1839 NULL, ipmiOemDbgGetPostDesc,
1840 PRIVILEGE_USER); // get debug post description
1841 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_GPIO_DESC,
1842 NULL, ipmiOemDbgGetGpioDesc,
1843 PRIVILEGE_USER); // get debug gpio description
1844 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_DATA,
1845 NULL, ipmiOemDbgGetFrameData,
1846 PRIVILEGE_USER); // get debug frame data
1847 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_CTRL_PANEL,
1848 NULL, ipmiOemDbgGetCtrlPanel,
1849 PRIVILEGE_USER); // get debug control panel
1850 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_DIMM_INFO, NULL,
1851 ipmiOemSetDimmInfo,
1852 PRIVILEGE_USER); // Set Dimm Info
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001853 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_BOARD_ID, NULL,
1854 ipmiOemGetBoardID,
1855 PRIVILEGE_USER); // Get Board ID
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001856 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_MACHINE_CONFIG_INFO, NULL,
1857 ipmiOemSetMachineCfgInfo,
1858 PRIVILEGE_USER); // Set Machine Config Info
1859 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_START, NULL,
1860 ipmiOemSetPostStart,
1861 PRIVILEGE_USER); // Set POST start
1862 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_END, NULL,
1863 ipmiOemSetPostEnd,
1864 PRIVILEGE_USER); // Set POST End
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001865 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPIN_INFO, NULL,
1866 ipmiOemSetPPINInfo,
1867 PRIVILEGE_USER); // Set PPIN Info
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05301868#if BIC_ENABLED
1869
1870 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne,
1871 ipmi::cmdSetSystemGuid, ipmi::Privilege::User,
1872 ipmiOemSetSystemGuid);
1873#else
1874
Vijay Khemkaf2246ce2020-05-27 14:26:35 -07001875 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_SYSTEM_GUID, NULL,
1876 ipmiOemSetSystemGuid,
1877 PRIVILEGE_USER); // Set System GUID
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05301878#endif
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001879 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_ADR_TRIGGER, NULL,
1880 ipmiOemSetAdrTrigger,
1881 PRIVILEGE_USER); // Set ADR Trigger
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001882 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_BIOS_FLASH_INFO, NULL,
1883 ipmiOemSetBiosFlashInfo,
1884 PRIVILEGE_USER); // Set Bios Flash Info
1885 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPR, NULL, ipmiOemSetPpr,
1886 PRIVILEGE_USER); // Set PPR
1887 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_PPR, NULL, ipmiOemGetPpr,
1888 PRIVILEGE_USER); // Get PPR
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001889 /* FB OEM QC Commands */
1890 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_SET_PROC_INFO, NULL,
1891 ipmiOemQSetProcInfo,
1892 PRIVILEGE_USER); // Set Proc Info
1893 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_GET_PROC_INFO, NULL,
1894 ipmiOemQGetProcInfo,
1895 PRIVILEGE_USER); // Get Proc Info
1896 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_SET_DIMM_INFO, NULL,
1897 ipmiOemQSetDimmInfo,
1898 PRIVILEGE_USER); // Set Dimm Info
1899 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_GET_DIMM_INFO, NULL,
1900 ipmiOemQGetDimmInfo,
1901 PRIVILEGE_USER); // Get Dimm Info
1902 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_SET_DRIVE_INFO, NULL,
1903 ipmiOemQSetDriveInfo,
1904 PRIVILEGE_USER); // Set Drive Info
1905 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_GET_DRIVE_INFO, NULL,
1906 ipmiOemQGetDriveInfo,
1907 PRIVILEGE_USER); // Get Drive Info
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07001908
1909 /* FB OEM DCMI Commands as per DCMI spec 1.5 Section 6 */
1910 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
1911 ipmi::dcmi::cmdGetPowerReading,
1912 ipmi::Privilege::User,
1913 ipmiOemDCMIGetPowerReading); // Get Power Reading
1914
1915 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
1916 ipmi::dcmi::cmdGetPowerLimit,
1917 ipmi::Privilege::User,
1918 ipmiOemDCMIGetPowerLimit); // Get Power Limit
1919
1920 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
1921 ipmi::dcmi::cmdSetPowerLimit,
1922 ipmi::Privilege::Operator,
1923 ipmiOemDCMISetPowerLimit); // Set Power Limit
1924
1925 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
1926 ipmi::dcmi::cmdActDeactivatePwrLimit,
1927 ipmi::Privilege::Operator,
1928 ipmiOemDCMIApplyPowerLimit); // Apply Power Limit
1929
Jayashree-Df0cf6652020-11-30 11:03:30 +05301930 /* FB OEM BOOT ORDER COMMANDS */
1931 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne,
1932 CMD_OEM_GET_BOOT_ORDER, ipmi::Privilege::User,
1933 ipmiOemGetBootOrder); // Get Boot Order
1934
1935 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne,
1936 CMD_OEM_SET_BOOT_ORDER, ipmi::Privilege::User,
1937 ipmiOemSetBootOrder); // Set Boot Order
1938
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001939 return;
1940}
1941
1942} // namespace ipmi