blob: d781964888f648024b7798ffccd0e925d396343c [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>
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +053042#include <regex>
Vijay Khemkae7d23d02019-03-08 13:13:40 -080043
44#define SIZE_IANA_ID 3
45
46namespace ipmi
47{
Vijay Khemkaa7231892019-10-11 11:35:05 -070048
49using namespace phosphor::logging;
50
Karthikeyan Pasupathie1ff81f2022-11-21 17:54:46 +053051void getSelectorPosition(size_t& position);
Vijay Khemkae7d23d02019-03-08 13:13:40 -080052static void registerOEMFunctions() __attribute__((constructor));
Patrick Williamscd315e02022-07-22 19:26:52 -050053sdbusplus::bus_t dbus(ipmid_get_sd_bus_connection()); // from ipmid/api.h
Vijay Khemkae7d23d02019-03-08 13:13:40 -080054static constexpr size_t maxFRUStringLength = 0x3F;
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +053055constexpr uint8_t cmdSetSystemGuid = 0xEF;
Vijay Khemkae7d23d02019-03-08 13:13:40 -080056
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +053057constexpr uint8_t cmdSetQDimmInfo = 0x12;
58constexpr uint8_t cmdGetQDimmInfo = 0x13;
59
Vijay Khemka63c99be2020-05-27 19:14:35 -070060int plat_udbg_get_post_desc(uint8_t, uint8_t*, uint8_t, uint8_t*, uint8_t*,
61 uint8_t*);
62int plat_udbg_get_gpio_desc(uint8_t, uint8_t*, uint8_t*, uint8_t*, uint8_t*,
63 uint8_t*);
64ipmi_ret_t plat_udbg_get_frame_data(uint8_t, uint8_t, uint8_t*, uint8_t*,
65 uint8_t*);
66ipmi_ret_t plat_udbg_control_panel(uint8_t, uint8_t, uint8_t, uint8_t*,
67 uint8_t*);
68int sendMeCmd(uint8_t, uint8_t, std::vector<uint8_t>&, std::vector<uint8_t>&);
Vijay Khemkadd14c0f2020-03-18 14:48:13 -070069
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +053070int sendBicCmd(uint8_t, uint8_t, uint8_t, std::vector<uint8_t>&,
71 std::vector<uint8_t>&);
72
Vijay Khemkafeaa9812019-08-27 15:08:08 -070073nlohmann::json oemData __attribute__((init_priority(101)));
Vijay Khemka1b6fae32019-03-25 17:43:01 -070074
Vijay Khemkaf2246ce2020-05-27 14:26:35 -070075static constexpr size_t GUID_SIZE = 16;
76// TODO Make offset and location runtime configurable to ensure we
77// can make each define their own locations.
78static constexpr off_t OFFSET_SYS_GUID = 0x17F0;
79static constexpr const char* FRU_EEPROM = "/sys/bus/i2c/devices/6-0054/eeprom";
80
Vijay Khemka1b6fae32019-03-25 17:43:01 -070081enum class LanParam : uint8_t
82{
83 INPROGRESS = 0,
84 AUTHSUPPORT = 1,
85 AUTHENABLES = 2,
86 IP = 3,
87 IPSRC = 4,
88 MAC = 5,
89 SUBNET = 6,
90 GATEWAY = 12,
91 VLAN = 20,
92 CIPHER_SUITE_COUNT = 22,
93 CIPHER_SUITE_ENTRIES = 23,
94 IPV6 = 59,
95};
96
Vijay Khemkaa7231892019-10-11 11:35:05 -070097namespace network
98{
99
100constexpr auto ROOT = "/xyz/openbmc_project/network";
101constexpr auto SERVICE = "xyz.openbmc_project.Network";
102constexpr auto IPV4_TYPE = "ipv4";
103constexpr auto IPV6_TYPE = "ipv6";
104constexpr auto IPV4_PREFIX = "169.254";
105constexpr auto IPV6_PREFIX = "fe80";
106constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP";
107constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress";
Potin Lai8d1a81e2022-12-20 11:13:45 +0800108constexpr auto IPV4_PROTOCOL = "xyz.openbmc_project.Network.IP.Protocol.IPv4";
109constexpr auto IPV6_PROTOCOL = "xyz.openbmc_project.Network.IP.Protocol.IPv6";
Vijay Khemkaa7231892019-10-11 11:35:05 -0700110
Vijay Khemka63c99be2020-05-27 19:14:35 -0700111bool isLinkLocalIP(const std::string& address)
Vijay Khemkaa7231892019-10-11 11:35:05 -0700112{
113 return address.find(IPV4_PREFIX) == 0 || address.find(IPV6_PREFIX) == 0;
114}
115
Patrick Williamscd315e02022-07-22 19:26:52 -0500116DbusObjectInfo getIPObject(sdbusplus::bus_t& bus, const std::string& interface,
Vijay Khemka63c99be2020-05-27 19:14:35 -0700117 const std::string& serviceRoot,
Potin Lai8d1a81e2022-12-20 11:13:45 +0800118 const std::string& protocol,
119 const std::string& ethdev)
Vijay Khemkaa7231892019-10-11 11:35:05 -0700120{
Potin Lai8d1a81e2022-12-20 11:13:45 +0800121 auto objectTree = getAllDbusObjects(bus, serviceRoot, interface, ethdev);
Vijay Khemkaa7231892019-10-11 11:35:05 -0700122
123 if (objectTree.empty())
124 {
125 log<level::ERR>("No Object has implemented the IP interface",
126 entry("INTERFACE=%s", interface.c_str()));
127 }
128
129 DbusObjectInfo objectInfo;
130
Vijay Khemka63c99be2020-05-27 19:14:35 -0700131 for (auto& object : objectTree)
Vijay Khemkaa7231892019-10-11 11:35:05 -0700132 {
133 auto variant =
134 ipmi::getDbusProperty(bus, object.second.begin()->first,
Potin Lai8d1a81e2022-12-20 11:13:45 +0800135 object.first, IP_INTERFACE, "Type");
136 if (std::get<std::string>(variant) != protocol)
137 {
138 continue;
139 }
140
141 variant = ipmi::getDbusProperty(bus, object.second.begin()->first,
142 object.first, IP_INTERFACE, "Address");
Vijay Khemkaa7231892019-10-11 11:35:05 -0700143
144 objectInfo = std::make_pair(object.first, object.second.begin()->first);
145
146 // if LinkLocalIP found look for Non-LinkLocalIP
147 if (isLinkLocalIP(std::get<std::string>(variant)))
148 {
149 continue;
150 }
151 else
152 {
153 break;
154 }
155 }
156 return objectInfo;
157}
158
159} // namespace network
160
Jayashree-Df0cf6652020-11-30 11:03:30 +0530161namespace boot
162{
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530163using BootSource =
164 sdbusplus::xyz::openbmc_project::Control::Boot::server::Source::Sources;
165using BootMode =
166 sdbusplus::xyz::openbmc_project::Control::Boot::server::Mode::Modes;
167using BootType =
168 sdbusplus::xyz::openbmc_project::Control::Boot::server::Type::Types;
Jayashree-Df0cf6652020-11-30 11:03:30 +0530169
Jayashree-Df0cf6652020-11-30 11:03:30 +0530170using IpmiValue = uint8_t;
171
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530172std::map<IpmiValue, BootSource> sourceIpmiToDbus = {
173 {0x0f, BootSource::Default}, {0x00, BootSource::RemovableMedia},
174 {0x01, BootSource::Network}, {0x02, BootSource::Disk},
175 {0x03, BootSource::ExternalMedia}, {0x09, BootSource::Network}};
Jayashree-Df0cf6652020-11-30 11:03:30 +0530176
Delphine CC Chiuc0f918b2023-03-22 14:48:04 +0800177std::map<IpmiValue, BootMode> modeIpmiToDbus = {{0x04, BootMode::Setup},
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530178 {0x00, BootMode::Regular}};
Jayashree-Df0cf6652020-11-30 11:03:30 +0530179
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530180std::map<IpmiValue, BootType> typeIpmiToDbus = {{0x00, BootType::Legacy},
181 {0x01, BootType::EFI}};
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530182
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530183std::map<std::optional<BootSource>, IpmiValue> sourceDbusToIpmi = {
184 {BootSource::Default, 0x0f},
185 {BootSource::RemovableMedia, 0x00},
186 {BootSource::Network, 0x01},
187 {BootSource::Disk, 0x02},
188 {BootSource::ExternalMedia, 0x03}};
Jayashree-Df0cf6652020-11-30 11:03:30 +0530189
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530190std::map<std::optional<BootMode>, IpmiValue> modeDbusToIpmi = {
Delphine CC Chiuc0f918b2023-03-22 14:48:04 +0800191 {BootMode::Setup, 0x04}, {BootMode::Regular, 0x00}};
Jayashree-Df0cf6652020-11-30 11:03:30 +0530192
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530193std::map<std::optional<BootType>, IpmiValue> typeDbusToIpmi = {
194 {BootType::Legacy, 0x00}, {BootType::EFI, 0x01}};
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530195
Delphine CC Chiuc0f918b2023-03-22 14:48:04 +0800196static constexpr auto bootEnableIntf = "xyz.openbmc_project.Object.Enable";
Jayashree-Df0cf6652020-11-30 11:03:30 +0530197static constexpr auto bootModeIntf = "xyz.openbmc_project.Control.Boot.Mode";
198static constexpr auto bootSourceIntf =
199 "xyz.openbmc_project.Control.Boot.Source";
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530200static constexpr auto bootTypeIntf = "xyz.openbmc_project.Control.Boot.Type";
Jayashree-Df0cf6652020-11-30 11:03:30 +0530201static constexpr auto bootSourceProp = "BootSource";
202static constexpr auto bootModeProp = "BootMode";
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530203static constexpr auto bootTypeProp = "BootType";
Delphine CC Chiuc0f918b2023-03-22 14:48:04 +0800204static constexpr auto bootEnableProp = "Enabled";
Jayashree-Df0cf6652020-11-30 11:03:30 +0530205
Jayashree-Df0cf6652020-11-30 11:03:30 +0530206std::tuple<std::string, std::string> objPath(size_t id)
207{
208 std::string hostName = "host" + std::to_string(id);
209 std::string bootObjPath =
210 "/xyz/openbmc_project/control/" + hostName + "/boot";
211 return std::make_tuple(std::move(bootObjPath), std::move(hostName));
212}
213
214} // namespace boot
215
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700216//----------------------------------------------------------------------
217// Helper functions for storing oem data
218//----------------------------------------------------------------------
219
220void flushOemData()
221{
222 std::ofstream file(JSON_OEM_DATA_FILE);
223 file << oemData;
Vijay Khemkafeaa9812019-08-27 15:08:08 -0700224 file.close();
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700225 return;
226}
227
Vijay Khemka63c99be2020-05-27 19:14:35 -0700228std::string bytesToStr(uint8_t* byte, int len)
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700229{
230 std::stringstream ss;
231 int i;
232
233 ss << std::hex;
234 for (i = 0; i < len; i++)
235 {
236 ss << std::setw(2) << std::setfill('0') << (int)byte[i];
237 }
238
239 return ss.str();
240}
241
Vijay Khemka63c99be2020-05-27 19:14:35 -0700242int strToBytes(std::string& str, uint8_t* data)
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700243{
244 std::string sstr;
Willy Tue39f9392022-06-15 13:24:20 -0700245 size_t i;
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700246
247 for (i = 0; i < (str.length()) / 2; i++)
248 {
249 sstr = str.substr(i * 2, 2);
250 data[i] = (uint8_t)std::strtol(sstr.c_str(), NULL, 16);
251 }
252 return i;
253}
254
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +0530255int readDimmType(std::string& data, uint8_t param)
256{
257 nlohmann::json dimmObj;
258 /* Get dimm type names stored in json file */
259 std::ifstream file(JSON_DIMM_TYPE_FILE);
260 if (file)
261 {
262 file >> dimmObj;
263 file.close();
264 }
265 else
266 {
267 phosphor::logging::log<phosphor::logging::level::ERR>(
268 "DIMM type names file not found",
269 phosphor::logging::entry("DIMM_TYPE_FILE=%s", JSON_DIMM_TYPE_FILE));
270 return -1;
271 }
272
273 std::string dimmKey = "dimm_type" + std::to_string(param);
274 auto obj = dimmObj[dimmKey]["short_name"];
275 data = obj;
276 return 0;
277}
278
Vijay Khemka63c99be2020-05-27 19:14:35 -0700279ipmi_ret_t getNetworkData(uint8_t lan_param, char* data)
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700280{
281 ipmi_ret_t rc = IPMI_CC_OK;
Patrick Williamscd315e02022-07-22 19:26:52 -0500282 sdbusplus::bus_t bus(ipmid_get_sd_bus_connection());
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700283
284 const std::string ethdevice = "eth0";
285
286 switch (static_cast<LanParam>(lan_param))
287 {
Vijay Khemkad1194022020-05-27 18:58:33 -0700288 case LanParam::IP:
289 {
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700290 std::string ipaddress;
Vijay Khemkaa7231892019-10-11 11:35:05 -0700291 auto ipObjectInfo = ipmi::network::getIPObject(
Potin Lai8d1a81e2022-12-20 11:13:45 +0800292 bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT,
293 ipmi::network::IPV4_PROTOCOL, ethdevice);
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700294
295 auto properties = ipmi::getAllDbusProperties(
296 bus, ipObjectInfo.second, ipObjectInfo.first,
297 ipmi::network::IP_INTERFACE);
298
Patrick Williamsef0efbc2020-05-13 11:26:51 -0500299 ipaddress = std::get<std::string>(properties["Address"]);
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700300
301 std::strcpy(data, ipaddress.c_str());
302 }
303 break;
304
Vijay Khemkad1194022020-05-27 18:58:33 -0700305 case LanParam::IPV6:
306 {
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700307 std::string ipaddress;
Vijay Khemkaa7231892019-10-11 11:35:05 -0700308 auto ipObjectInfo = ipmi::network::getIPObject(
Potin Lai8d1a81e2022-12-20 11:13:45 +0800309 bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT,
310 ipmi::network::IPV6_PROTOCOL, ethdevice);
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700311
312 auto properties = ipmi::getAllDbusProperties(
313 bus, ipObjectInfo.second, ipObjectInfo.first,
314 ipmi::network::IP_INTERFACE);
315
Patrick Williamsef0efbc2020-05-13 11:26:51 -0500316 ipaddress = std::get<std::string>(properties["Address"]);
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700317
318 std::strcpy(data, ipaddress.c_str());
319 }
320 break;
321
Vijay Khemkad1194022020-05-27 18:58:33 -0700322 case LanParam::MAC:
323 {
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700324 std::string macAddress;
325 auto macObjectInfo =
326 ipmi::getDbusObject(bus, ipmi::network::MAC_INTERFACE,
327 ipmi::network::ROOT, ethdevice);
328
329 auto variant = ipmi::getDbusProperty(
330 bus, macObjectInfo.second, macObjectInfo.first,
331 ipmi::network::MAC_INTERFACE, "MACAddress");
332
Patrick Williamsef0efbc2020-05-13 11:26:51 -0500333 macAddress = std::get<std::string>(variant);
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700334
335 sscanf(macAddress.c_str(), ipmi::network::MAC_ADDRESS_FORMAT,
336 (data), (data + 1), (data + 2), (data + 3), (data + 4),
337 (data + 5));
338 std::strcpy(data, macAddress.c_str());
339 }
340 break;
341
342 default:
343 rc = IPMI_CC_PARM_OUT_OF_RANGE;
344 }
345 return rc;
346}
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800347
Karthikeyan Pasupathi39836ff2022-01-17 12:20:06 +0530348bool isMultiHostPlatform()
349{
350 bool platform;
Jayashree Dhanapal4ec80562022-06-28 15:41:47 +0530351 if (hostInstances == "0")
Karthikeyan Pasupathi39836ff2022-01-17 12:20:06 +0530352 {
353 platform = false;
354 }
355 else
356 {
357 platform = true;
358 }
359 return platform;
360}
361
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800362// return code: 0 successful
Vijay Khemka63c99be2020-05-27 19:14:35 -0700363int8_t getFruData(std::string& data, std::string& name)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800364{
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530365 size_t pos;
366 static constexpr const auto depth = 0;
367 std::vector<std::string> paths;
368 std::string machinePath;
369 std::string baseBoard = "Baseboard";
370
371 bool platform = isMultiHostPlatform();
372 if (platform == true)
373 {
Karthikeyan Pasupathie1ff81f2022-11-21 17:54:46 +0530374 getSelectorPosition(pos);
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530375 }
376
377 sd_bus* bus = NULL;
378 int ret = sd_bus_default_system(&bus);
379 if (ret < 0)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800380 {
381 phosphor::logging::log<phosphor::logging::level::ERR>(
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530382 "Failed to connect to system bus",
383 phosphor::logging::entry("ERRNO=0x%X", -ret));
384 sd_bus_unref(bus);
385 return -1;
386 }
Patrick Williamscd315e02022-07-22 19:26:52 -0500387 sdbusplus::bus_t dbus(bus);
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530388 auto mapperCall = dbus.new_method_call("xyz.openbmc_project.ObjectMapper",
389 "/xyz/openbmc_project/object_mapper",
390 "xyz.openbmc_project.ObjectMapper",
391 "GetSubTreePaths");
392 static constexpr std::array<const char*, 1> interface = {
393 "xyz.openbmc_project.Inventory.Decorator.Asset"};
394 mapperCall.append("/xyz/openbmc_project/inventory/", depth, interface);
395
396 try
397 {
398 auto reply = dbus.call(mapperCall);
399 reply.read(paths);
400 }
401 catch (sdbusplus::exception_t& e)
402 {
403 phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800404 return -1;
405 }
406
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530407 for (const auto& path : paths)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800408 {
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530409 if (platform == true)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800410 {
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530411 if (pos == BMC_POS)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800412 {
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530413 machinePath = baseBoard;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800414 }
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530415 else
416 {
417 machinePath = "_" + std::to_string(pos);
418 }
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800419 }
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530420 else
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800421 {
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530422 machinePath = baseBoard;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800423 }
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530424
425 auto found = path.find(machinePath);
Patrick Williams123cbcc2022-06-24 06:13:59 -0500426 if (found == std::string::npos)
Karthikeyan Pasupathi98aabdb2022-04-06 17:18:51 +0530427 {
428 continue;
429 }
430
431 std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
432 std::string service = getService(
433 *dbus, "xyz.openbmc_project.Inventory.Decorator.Asset", path);
434
435 auto Value = ipmi::getDbusProperty(
436 *dbus, service, path,
437 "xyz.openbmc_project.Inventory.Decorator.Asset", name);
438
439 data = std::get<std::string>(Value);
440 return 0;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800441 }
442 return -1;
443}
444
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +0530445int8_t sysConfig(std::vector<std::string>& data, size_t pos)
446{
447 nlohmann::json sysObj;
448 std::string dimmInfo = KEY_Q_DIMM_INFO + std::to_string(pos);
449 std::string result, typeName;
450 uint8_t res[MAX_BUF];
451
452 /* Get sysConfig data stored in json file */
453 std::ifstream file(JSON_OEM_DATA_FILE);
454 if (file)
455 {
456 file >> sysObj;
457 file.close();
458 }
459 else
460 {
461 phosphor::logging::log<phosphor::logging::level::ERR>(
462 "oemData file not found",
463 phosphor::logging::entry("OEM_DATA_FILE=%s", JSON_OEM_DATA_FILE));
464 return -1;
465 }
466
467 if (sysObj.find(dimmInfo) == sysObj.end())
468 {
469 phosphor::logging::log<phosphor::logging::level::ERR>(
470 "sysconfig key not available",
471 phosphor::logging::entry("SYS_JSON_KEY=%s", dimmInfo.c_str()));
472 return -1;
473 }
474 /* Get dimm type names stored in json file */
475 nlohmann::json dimmObj;
476 std::ifstream dimmFile(JSON_DIMM_TYPE_FILE);
477 if (file)
478 {
479 dimmFile >> dimmObj;
480 dimmFile.close();
481 }
482 else
483 {
484 phosphor::logging::log<phosphor::logging::level::ERR>(
485 "DIMM type names file not found",
486 phosphor::logging::entry("DIMM_TYPE_FILE=%s", JSON_DIMM_TYPE_FILE));
487 return -1;
488 }
489 std::vector<std::string> a;
490 for (auto& j : dimmObj.items())
491 {
492 std::string name = j.key();
493 a.push_back(name);
494 }
495
496 uint8_t len = a.size();
497 for (uint8_t ii = 0; ii < len; ii++)
498 {
499 std::string indKey = std::to_string(ii);
500 std::string speedSize = sysObj[dimmInfo][indKey][DIMM_SPEED];
501 strToBytes(speedSize, res);
502 auto speed = (res[1] << 8 | res[0]);
503 size_t dimmSize = ((res[3] << 8 | res[2]) / 1000);
504
505 if (dimmSize == 0)
506 {
507 std::cerr << "Dimm information not available for slot_" +
508 std::to_string(ii)
509 << std::endl;
510 continue;
511 }
512 std::string type = sysObj[dimmInfo][indKey][DIMM_TYPE];
513 std::string dualInlineMem = sysObj[dimmInfo][indKey][KEY_DIMM_TYPE];
514 strToBytes(type, res);
515 size_t dimmType = res[0];
516 if (dimmVenMap.find(dimmType) == dimmVenMap.end())
517 {
518 typeName = "unknown";
519 }
520 else
521 {
522 typeName = dimmVenMap[dimmType];
523 }
524 result = dualInlineMem + "/" + typeName + "/" + std::to_string(speed) +
525 "MHz" + "/" + std::to_string(dimmSize) + "GB";
526 data.push_back(result);
527 }
528 return 0;
529}
530
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +0530531int8_t procInfo(std::string& result, size_t pos)
532{
533 std::vector<char> data;
534 uint8_t res[MAX_BUF];
535 std::string procIndex = "00";
536 nlohmann::json proObj;
537 std::string procInfo = KEY_Q_PROC_INFO + std::to_string(pos);
538 /* Get processor data stored in json file */
539 std::ifstream file(JSON_OEM_DATA_FILE);
540 if (file)
541 {
542 file >> proObj;
543 file.close();
544 }
545 else
546 {
547 phosphor::logging::log<phosphor::logging::level::ERR>(
548 "oemData file not found",
549 phosphor::logging::entry("OEM_DATA_FILE=%s", JSON_OEM_DATA_FILE));
550 return -1;
551 }
552 if (proObj.find(procInfo) == proObj.end())
553 {
554 phosphor::logging::log<phosphor::logging::level::ERR>(
555 "processor info key not available",
556 phosphor::logging::entry("PROC_JSON_KEY=%s", procInfo.c_str()));
557 return -1;
558 }
559 std::string procName = proObj[procInfo][procIndex][KEY_PROC_NAME];
560 std::string basicInfo = proObj[procInfo][procIndex][KEY_BASIC_INFO];
561 // Processor Product Name
562 strToBytes(procName, res);
563 data.assign(reinterpret_cast<char*>(&res),
564 reinterpret_cast<char*>(&res) + sizeof(res));
565
566 std::string s(data.begin(), data.end());
567 std::regex regex(" ");
568 std::vector<std::string> productName(
569 std::sregex_token_iterator(s.begin(), s.end(), regex, -1),
570 std::sregex_token_iterator());
571
572 // Processor core and frequency
573 strToBytes(basicInfo, res);
574 uint16_t coreNum = res[0];
575 double procFrequency = (float)(res[4] << 8 | res[3]) / 1000;
576 result = "CPU:" + productName[2] + "/" + std::to_string(procFrequency) +
577 "GHz" + "/" + std::to_string(coreNum) + "c";
578 return 0;
579}
580
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800581typedef struct
582{
583 uint8_t cur_power_state;
584 uint8_t last_power_event;
585 uint8_t misc_power_state;
586 uint8_t front_panel_button_cap_status;
587} ipmi_get_chassis_status_t;
588
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800589//----------------------------------------------------------------------
590// Get Debug Frame Info
591//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700592ipmi_ret_t ipmiOemDbgGetFrameInfo(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800593 ipmi_request_t request,
594 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700595 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800596{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700597 uint8_t* req = reinterpret_cast<uint8_t*>(request);
598 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800599 uint8_t num_frames = 3;
600
601 std::memcpy(res, req, SIZE_IANA_ID); // IANA ID
602 res[SIZE_IANA_ID] = num_frames;
603 *data_len = SIZE_IANA_ID + 1;
604
605 return IPMI_CC_OK;
606}
607
608//----------------------------------------------------------------------
609// Get Debug Updated Frames
610//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700611ipmi_ret_t ipmiOemDbgGetUpdFrames(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800612 ipmi_request_t request,
613 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700614 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800615{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700616 uint8_t* req = reinterpret_cast<uint8_t*>(request);
617 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800618 uint8_t num_updates = 3;
619 *data_len = 4;
620
621 std::memcpy(res, req, SIZE_IANA_ID); // IANA ID
622 res[SIZE_IANA_ID] = num_updates;
623 *data_len = SIZE_IANA_ID + num_updates + 1;
624 res[SIZE_IANA_ID + 1] = 1; // info page update
625 res[SIZE_IANA_ID + 2] = 2; // cri sel update
626 res[SIZE_IANA_ID + 3] = 3; // cri sensor update
627
628 return IPMI_CC_OK;
629}
630
631//----------------------------------------------------------------------
632// Get Debug POST Description
633//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700634ipmi_ret_t ipmiOemDbgGetPostDesc(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800635 ipmi_request_t request,
636 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700637 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800638{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700639 uint8_t* req = reinterpret_cast<uint8_t*>(request);
640 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800641 uint8_t index = 0;
642 uint8_t next = 0;
643 uint8_t end = 0;
644 uint8_t phase = 0;
Vijay Khemkacc0d6d92019-08-27 14:51:17 -0700645 uint8_t descLen = 0;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800646 int ret;
647
648 index = req[3];
649 phase = req[4];
650
Vijay Khemkacc0d6d92019-08-27 14:51:17 -0700651 ret = plat_udbg_get_post_desc(index, &next, phase, &end, &descLen, &res[8]);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800652 if (ret)
653 {
654 memcpy(res, req, SIZE_IANA_ID); // IANA ID
655 *data_len = SIZE_IANA_ID;
656 return IPMI_CC_UNSPECIFIED_ERROR;
657 }
658
659 memcpy(res, req, SIZE_IANA_ID); // IANA ID
660 res[3] = index;
661 res[4] = next;
662 res[5] = phase;
663 res[6] = end;
Vijay Khemkacc0d6d92019-08-27 14:51:17 -0700664 res[7] = descLen;
665 *data_len = SIZE_IANA_ID + 5 + descLen;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800666
667 return IPMI_CC_OK;
668}
669
670//----------------------------------------------------------------------
671// Get Debug GPIO Description
672//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700673ipmi_ret_t ipmiOemDbgGetGpioDesc(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800674 ipmi_request_t request,
675 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700676 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800677{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700678 uint8_t* req = reinterpret_cast<uint8_t*>(request);
679 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800680
Vijay Khemka38183d62019-08-28 16:19:33 -0700681 uint8_t index = 0;
682 uint8_t next = 0;
683 uint8_t level = 0;
684 uint8_t pinDef = 0;
685 uint8_t descLen = 0;
686 int ret;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800687
Vijay Khemka38183d62019-08-28 16:19:33 -0700688 index = req[3];
689
690 ret = plat_udbg_get_gpio_desc(index, &next, &level, &pinDef, &descLen,
691 &res[8]);
692 if (ret)
693 {
694 memcpy(res, req, SIZE_IANA_ID); // IANA ID
695 *data_len = SIZE_IANA_ID;
696 return IPMI_CC_UNSPECIFIED_ERROR;
697 }
698
699 memcpy(res, req, SIZE_IANA_ID); // IANA ID
700 res[3] = index;
701 res[4] = next;
702 res[5] = level;
703 res[6] = pinDef;
704 res[7] = descLen;
705 *data_len = SIZE_IANA_ID + 5 + descLen;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800706
707 return IPMI_CC_OK;
708}
709
710//----------------------------------------------------------------------
711// Get Debug Frame Data
712//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700713ipmi_ret_t ipmiOemDbgGetFrameData(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800714 ipmi_request_t request,
715 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700716 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800717{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700718 uint8_t* req = reinterpret_cast<uint8_t*>(request);
719 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800720 uint8_t frame;
721 uint8_t page;
722 uint8_t next;
723 uint8_t count;
724 int ret;
725
726 frame = req[3];
727 page = req[4];
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800728
729 ret = plat_udbg_get_frame_data(frame, page, &next, &count, &res[7]);
730 if (ret)
731 {
732 memcpy(res, req, SIZE_IANA_ID); // IANA ID
733 *data_len = SIZE_IANA_ID;
734 return IPMI_CC_UNSPECIFIED_ERROR;
735 }
736
737 memcpy(res, req, SIZE_IANA_ID); // IANA ID
738 res[3] = frame;
739 res[4] = page;
740 res[5] = next;
741 res[6] = count;
742 *data_len = SIZE_IANA_ID + 4 + count;
743
744 return IPMI_CC_OK;
745}
746
747//----------------------------------------------------------------------
748// Get Debug Control Panel
749//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700750ipmi_ret_t ipmiOemDbgGetCtrlPanel(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800751 ipmi_request_t request,
752 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -0700753 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800754{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700755 uint8_t* req = reinterpret_cast<uint8_t*>(request);
756 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800757
758 uint8_t panel;
759 uint8_t operation;
760 uint8_t item;
761 uint8_t count;
762 ipmi_ret_t ret;
763
764 panel = req[3];
765 operation = req[4];
766 item = req[5];
767
768 ret = plat_udbg_control_panel(panel, operation, item, &count, &res[3]);
769
770 std::memcpy(res, req, SIZE_IANA_ID); // IANA ID
771 *data_len = SIZE_IANA_ID + count;
772
773 return ret;
774}
775
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800776//----------------------------------------------------------------------
777// Set Dimm Info (CMD_OEM_SET_DIMM_INFO)
778//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700779ipmi_ret_t ipmiOemSetDimmInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
780 ipmi_response_t, ipmi_data_len_t data_len,
781 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800782{
Vijay Khemka63c99be2020-05-27 19:14:35 -0700783 uint8_t* req = reinterpret_cast<uint8_t*>(request);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700784
785 uint8_t index = req[0];
786 uint8_t type = req[1];
787 uint16_t speed;
788 uint32_t size;
789
790 memcpy(&speed, &req[2], 2);
791 memcpy(&size, &req[4], 4);
792
793 std::stringstream ss;
794 ss << std::hex;
795 ss << std::setw(2) << std::setfill('0') << (int)index;
796
797 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_INDEX] = index;
798 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_TYPE] = type;
799 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_SPEED] = speed;
800 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_SIZE] = size;
801
802 flushOemData();
803
804 *data_len = 0;
805
806 return IPMI_CC_OK;
807}
808
809//----------------------------------------------------------------------
810// Get Board ID (CMD_OEM_GET_BOARD_ID)
811//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -0700812ipmi_ret_t ipmiOemGetBoardID(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
813 ipmi_response_t, ipmi_data_len_t data_len,
814 ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700815{
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700816 /* TODO: Needs to implement this after GPIO implementation */
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800817 *data_len = 0;
818
819 return IPMI_CC_OK;
820}
821
Bonnie Lo4ae63e72023-02-09 15:27:54 +0800822//----------------------------------------------------------------------
823// Get port 80 record (CMD_OEM_GET_80PORT_RECORD)
824//----------------------------------------------------------------------
825ipmi::RspType<std::vector<uint8_t>>
826 ipmiOemGet80PortRecord(ipmi::Context::ptr ctx)
827{
828 auto postCodeService = "xyz.openbmc_project.State.Boot.PostCode" +
829 std::to_string(ctx->hostIdx + 1);
830 auto postCodeObjPath = "/xyz/openbmc_project/State/Boot/PostCode" +
831 std::to_string(ctx->hostIdx + 1);
832 constexpr auto postCodeInterface =
833 "xyz.openbmc_project.State.Boot.PostCode";
834 const static uint16_t lastestPostCodeIndex = 1;
835 constexpr const auto maxPostCodeLen =
836 224; // The length must be lower than IPMB limitation
837 size_t startIndex = 0;
838
839 std::vector<std::tuple<uint64_t, std::vector<uint8_t>>> postCodes;
840 std::vector<uint8_t> resData;
841
842 auto conn = getSdBus();
843 /* Get the post codes by calling GetPostCodes method */
844 auto msg =
845 conn->new_method_call(postCodeService.c_str(), postCodeObjPath.c_str(),
846 postCodeInterface, "GetPostCodes");
847 msg.append(lastestPostCodeIndex);
848
849 try
850 {
851 auto reply = conn->call(msg);
852 reply.read(postCodes);
853 }
854 catch (const sdbusplus::exception::SdBusError& e)
855 {
856 phosphor::logging::log<phosphor::logging::level::ERR>(
857 "IPMI Get80PortRecord Failed in call method",
858 phosphor::logging::entry("ERROR=%s", e.what()));
859 return ipmi::responseUnspecifiedError();
860 }
861
862 /* Get post code data */
863 for (size_t i = 0; i < postCodes.size(); ++i)
864 {
865 uint64_t primaryPostCode = std::get<uint64_t>(postCodes[i]);
866 for (int j = postCodeSize - 1; j >= 0; --j)
867 {
868 uint8_t postCode =
869 ((primaryPostCode >> (sizeof(uint64_t) * j)) & 0xFF);
870 resData.emplace_back(postCode);
871 }
872 }
873
874 std::vector<uint8_t> response;
875 if (resData.size() > maxPostCodeLen)
876 {
877 startIndex = resData.size() - maxPostCodeLen;
878 }
879
880 response.assign(resData.begin() + startIndex, resData.end());
881
882 return ipmi::responseSuccess(response);
883}
884
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800885/* Helper functions to set boot order */
Jayashree-Df0cf6652020-11-30 11:03:30 +0530886void setBootOrder(std::string bootObjPath, uint8_t* data,
887 std::string bootOrderKey)
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800888{
Jayashree-Df0cf6652020-11-30 11:03:30 +0530889 std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
890
891 // SETTING BOOT MODE PROPERTY
Delphine CC Chiuc0f918b2023-03-22 14:48:04 +0800892 uint8_t bootModeBit = data[0] & 0x04;
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530893 auto bootValue = ipmi::boot::modeIpmiToDbus.at(bootModeBit);
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530894
Jayashree-Df0cf6652020-11-30 11:03:30 +0530895 std::string bootOption =
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530896 sdbusplus::message::convert_to_string<boot::BootMode>(bootValue);
Jayashree-Df0cf6652020-11-30 11:03:30 +0530897
898 std::string service =
899 getService(*dbus, ipmi::boot::bootModeIntf, bootObjPath);
900 setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootModeIntf,
901 ipmi::boot::bootModeProp, bootOption);
902
903 // SETTING BOOT SOURCE PROPERTY
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530904 auto bootOrder = ipmi::boot::sourceIpmiToDbus.at(data[1]);
Jayashree-Df0cf6652020-11-30 11:03:30 +0530905 std::string bootSource =
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530906 sdbusplus::message::convert_to_string<boot::BootSource>(bootOrder);
Jayashree-Df0cf6652020-11-30 11:03:30 +0530907
908 service = getService(*dbus, ipmi::boot::bootSourceIntf, bootObjPath);
909 setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootSourceIntf,
910 ipmi::boot::bootSourceProp, bootSource);
911
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530912 // SETTING BOOT TYPE PROPERTY
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530913 uint8_t bootTypeBit = data[0] & 0x01;
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530914 auto bootTypeVal = ipmi::boot::typeIpmiToDbus.at(bootTypeBit);
915
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530916 std::string bootType =
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +0530917 sdbusplus::message::convert_to_string<boot::BootType>(bootTypeVal);
Jayashree Dhanapal778147d2022-03-30 16:48:53 +0530918
919 service = getService(*dbus, ipmi::boot::bootTypeIntf, bootObjPath);
920
921 setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootTypeIntf,
922 ipmi::boot::bootTypeProp, bootType);
923
Delphine CC Chiuc0f918b2023-03-22 14:48:04 +0800924 // Set the valid bit to boot enabled property
925 service = getService(*dbus, ipmi::boot::bootEnableIntf, bootObjPath);
926
927 setDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootEnableIntf,
928 ipmi::boot::bootEnableProp,
929 (data[0] & BOOT_MODE_BOOT_FLAG) ? true : false);
930
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800931 nlohmann::json bootMode;
932 uint8_t mode = data[0];
933 int i;
934
935 bootMode["UEFI"] = (mode & BOOT_MODE_UEFI ? true : false);
936 bootMode["CMOS_CLR"] = (mode & BOOT_MODE_CMOS_CLR ? true : false);
937 bootMode["FORCE_BOOT"] = (mode & BOOT_MODE_FORCE_BOOT ? true : false);
938 bootMode["BOOT_FLAG"] = (mode & BOOT_MODE_BOOT_FLAG ? true : false);
Jayashree-Df0cf6652020-11-30 11:03:30 +0530939 oemData[bootOrderKey][KEY_BOOT_MODE] = bootMode;
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800940
941 /* Initialize boot sequence array */
Jayashree-Df0cf6652020-11-30 11:03:30 +0530942 oemData[bootOrderKey][KEY_BOOT_SEQ] = {};
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800943 for (i = 1; i < SIZE_BOOT_ORDER; i++)
944 {
945 if (data[i] >= BOOT_SEQ_ARRAY_SIZE)
Jayashree-Df0cf6652020-11-30 11:03:30 +0530946 oemData[bootOrderKey][KEY_BOOT_SEQ][i - 1] = "NA";
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800947 else
Jayashree-Df0cf6652020-11-30 11:03:30 +0530948 oemData[bootOrderKey][KEY_BOOT_SEQ][i - 1] = bootSeq[data[i]];
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800949 }
950
951 flushOemData();
952}
953
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800954//----------------------------------------------------------------------
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700955// Set Boot Order (CMD_OEM_SET_BOOT_ORDER)
956//----------------------------------------------------------------------
Jayashree-Df0cf6652020-11-30 11:03:30 +0530957ipmi::RspType<std::vector<uint8_t>>
958 ipmiOemSetBootOrder(ipmi::Context::ptr ctx, std::vector<uint8_t> data)
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700959{
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700960
Jayashree-Df0cf6652020-11-30 11:03:30 +0530961 uint8_t bootSeq[SIZE_BOOT_ORDER];
962 size_t len = data.size();
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700963
964 if (len != SIZE_BOOT_ORDER)
965 {
966 phosphor::logging::log<phosphor::logging::level::ERR>(
967 "Invalid Boot order length received");
Jayashree-Df0cf6652020-11-30 11:03:30 +0530968 return ipmi::responseReqDataLenInvalid();
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700969 }
970
Jayashree-Df0cf6652020-11-30 11:03:30 +0530971 std::copy(std::begin(data), std::end(data), bootSeq);
Jayashree Dhanapal4ec80562022-06-28 15:41:47 +0530972 std::optional<size_t> hostId = findHost(ctx->hostIdx);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700973
Jayashree-Df0cf6652020-11-30 11:03:30 +0530974 if (!hostId)
975 {
976 phosphor::logging::log<phosphor::logging::level::ERR>(
977 "Invalid Host Id received");
978 return ipmi::responseInvalidCommand();
979 }
980 auto [bootObjPath, hostName] = ipmi::boot::objPath(*hostId);
981
982 setBootOrder(bootObjPath, bootSeq, hostName);
983
984 return ipmi::responseSuccess(data);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700985}
986
987//----------------------------------------------------------------------
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800988// Get Boot Order (CMD_OEM_GET_BOOT_ORDER)
989//----------------------------------------------------------------------
Jayashree-Df0cf6652020-11-30 11:03:30 +0530990ipmi::RspType<uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t>
991 ipmiOemGetBootOrder(ipmi::Context::ptr ctx)
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800992{
Jayashree-Df0cf6652020-11-30 11:03:30 +0530993 uint8_t bootSeq[SIZE_BOOT_ORDER];
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700994 uint8_t mode = 0;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800995
Jayashree Dhanapal4ec80562022-06-28 15:41:47 +0530996 std::optional<size_t> hostId = findHost(ctx->hostIdx);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700997
Jayashree-Df0cf6652020-11-30 11:03:30 +0530998 if (!hostId)
999 {
1000 phosphor::logging::log<phosphor::logging::level::ERR>(
1001 "Invalid Host Id received");
1002 return ipmi::responseInvalidCommand();
1003 }
1004 auto [bootObjPath, hostName] = ipmi::boot::objPath(*hostId);
1005
Jayashree-Df0cf6652020-11-30 11:03:30 +05301006 std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
1007
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +05301008 // GETTING PROPERTY OF MODE INTERFACE
1009
Jayashree-Df0cf6652020-11-30 11:03:30 +05301010 std::string service =
1011 getService(*dbus, ipmi::boot::bootModeIntf, bootObjPath);
1012 Value variant =
1013 getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootModeIntf,
1014 ipmi::boot::bootModeProp);
1015
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +05301016 auto bootMode = sdbusplus::message::convert_from_string<boot::BootMode>(
Jayashree-Df0cf6652020-11-30 11:03:30 +05301017 std::get<std::string>(variant));
1018
Jayashree Dhanapal778147d2022-03-30 16:48:53 +05301019 uint8_t bootOption = ipmi::boot::modeDbusToIpmi.at(bootMode);
Jayashree-Df0cf6652020-11-30 11:03:30 +05301020
Jayashree Dhanapal778147d2022-03-30 16:48:53 +05301021 // GETTING PROPERTY OF TYPE INTERFACE
1022
1023 service = getService(*dbus, ipmi::boot::bootTypeIntf, bootObjPath);
1024 variant =
1025 getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootTypeIntf,
1026 ipmi::boot::bootTypeProp);
Jayashree Dhanapal77ee4892022-04-08 16:53:51 +05301027
1028 auto bootType = sdbusplus::message::convert_from_string<boot::BootType>(
Jayashree Dhanapal778147d2022-03-30 16:48:53 +05301029 std::get<std::string>(variant));
1030
Delphine CC Chiuc0f918b2023-03-22 14:48:04 +08001031 // Get the valid bit from boot enabled property
1032 service = getService(*dbus, ipmi::boot::bootEnableIntf, bootObjPath);
1033 variant =
1034 getDbusProperty(*dbus, service, bootObjPath, ipmi::boot::bootEnableIntf,
1035 ipmi::boot::bootEnableProp);
1036
1037 bool validFlag = std::get<bool>(variant);
1038
Jayashree Dhanapal778147d2022-03-30 16:48:53 +05301039 uint8_t bootTypeVal = ipmi::boot::typeDbusToIpmi.at(bootType);
1040
1041 uint8_t bootVal = bootOption | bootTypeVal;
Jayashree-Df0cf6652020-11-30 11:03:30 +05301042
Delphine CC Chiuc0f918b2023-03-22 14:48:04 +08001043 if (validFlag)
1044 {
1045 bootVal |= BOOT_MODE_BOOT_FLAG;
1046 }
1047
Jayashree-Df0cf6652020-11-30 11:03:30 +05301048 if (oemData.find(hostName) == oemData.end())
Vijay Khemka877d5dd2019-12-16 14:46:21 -08001049 {
1050 /* Return default boot order 0100090203ff */
1051 uint8_t defaultBoot[SIZE_BOOT_ORDER] = {
Willy Tue39f9392022-06-15 13:24:20 -07001052 BOOT_MODE_UEFI,
1053 static_cast<uint8_t>(bootMap["USB_DEV"]),
1054 static_cast<uint8_t>(bootMap["NET_IPV6"]),
1055 static_cast<uint8_t>(bootMap["SATA_HDD"]),
1056 static_cast<uint8_t>(bootMap["SATA_CD"]),
1057 0xff};
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001058
Jayashree-Df0cf6652020-11-30 11:03:30 +05301059 memcpy(bootSeq, defaultBoot, SIZE_BOOT_ORDER);
Vijay Khemka877d5dd2019-12-16 14:46:21 -08001060 phosphor::logging::log<phosphor::logging::level::INFO>(
1061 "Set default boot order");
Jayashree-Df0cf6652020-11-30 11:03:30 +05301062 setBootOrder(bootObjPath, defaultBoot, hostName);
Vijay Khemka877d5dd2019-12-16 14:46:21 -08001063 }
1064 else
1065 {
Jayashree-Df0cf6652020-11-30 11:03:30 +05301066 nlohmann::json bootMode = oemData[hostName][KEY_BOOT_MODE];
Vijay Khemka877d5dd2019-12-16 14:46:21 -08001067 if (bootMode["CMOS_CLR"])
Delphine CC Chiuc0f918b2023-03-22 14:48:04 +08001068 bootVal |= BOOT_MODE_CMOS_CLR;
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001069
Jayashree-Df0cf6652020-11-30 11:03:30 +05301070 bootSeq[0] = mode;
Vijay Khemka877d5dd2019-12-16 14:46:21 -08001071
Jayashree-Df0cf6652020-11-30 11:03:30 +05301072 for (int i = 1; i < SIZE_BOOT_ORDER; i++)
Vijay Khemka877d5dd2019-12-16 14:46:21 -08001073 {
Jayashree-Df0cf6652020-11-30 11:03:30 +05301074 std::string seqStr = oemData[hostName][KEY_BOOT_SEQ][i - 1];
Vijay Khemka877d5dd2019-12-16 14:46:21 -08001075 if (bootMap.find(seqStr) != bootMap.end())
Jayashree-Df0cf6652020-11-30 11:03:30 +05301076 bootSeq[i] = bootMap[seqStr];
Vijay Khemka877d5dd2019-12-16 14:46:21 -08001077 else
Jayashree-Df0cf6652020-11-30 11:03:30 +05301078 bootSeq[i] = 0xff;
Vijay Khemka877d5dd2019-12-16 14:46:21 -08001079 }
1080 }
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001081
Delphine CC Chiuc0f918b2023-03-22 14:48:04 +08001082 return ipmi::responseSuccess(bootVal, bootSeq[1], bootSeq[2], bootSeq[3],
Jayashree-Df0cf6652020-11-30 11:03:30 +05301083 bootSeq[4], bootSeq[5]);
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001084}
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001085// Set Machine Config Info (CMD_OEM_SET_MACHINE_CONFIG_INFO)
1086//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -07001087ipmi_ret_t ipmiOemSetMachineCfgInfo(ipmi_netfn_t, ipmi_cmd_t,
1088 ipmi_request_t request, ipmi_response_t,
1089 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001090{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001091 machineConfigInfo_t* req = reinterpret_cast<machineConfigInfo_t*>(request);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001092 uint8_t len = *data_len;
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001093
1094 *data_len = 0;
1095
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001096 if (len < sizeof(machineConfigInfo_t))
1097 {
1098 phosphor::logging::log<phosphor::logging::level::ERR>(
1099 "Invalid machine configuration length received");
1100 return IPMI_CC_REQ_DATA_LEN_INVALID;
1101 }
1102
Vijay Khemka63c99be2020-05-27 19:14:35 -07001103 if (req->chassis_type >= sizeof(chassisType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001104 oemData[KEY_MC_CONFIG][KEY_MC_CHAS_TYPE] = "UNKNOWN";
1105 else
1106 oemData[KEY_MC_CONFIG][KEY_MC_CHAS_TYPE] =
1107 chassisType[req->chassis_type];
1108
Vijay Khemka63c99be2020-05-27 19:14:35 -07001109 if (req->mb_type >= sizeof(mbType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001110 oemData[KEY_MC_CONFIG][KEY_MC_MB_TYPE] = "UNKNOWN";
1111 else
1112 oemData[KEY_MC_CONFIG][KEY_MC_MB_TYPE] = mbType[req->mb_type];
1113
1114 oemData[KEY_MC_CONFIG][KEY_MC_PROC_CNT] = req->proc_cnt;
1115 oemData[KEY_MC_CONFIG][KEY_MC_MEM_CNT] = req->mem_cnt;
1116 oemData[KEY_MC_CONFIG][KEY_MC_HDD35_CNT] = req->hdd35_cnt;
1117 oemData[KEY_MC_CONFIG][KEY_MC_HDD25_CNT] = req->hdd25_cnt;
1118
Vijay Khemka63c99be2020-05-27 19:14:35 -07001119 if (req->riser_type >= sizeof(riserType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001120 oemData[KEY_MC_CONFIG][KEY_MC_RSR_TYPE] = "UNKNOWN";
1121 else
1122 oemData[KEY_MC_CONFIG][KEY_MC_RSR_TYPE] = riserType[req->riser_type];
1123
1124 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC] = {};
1125 int i = 0;
1126 if (req->pcie_card_loc & BIT_0)
1127 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT1";
1128 if (req->pcie_card_loc & BIT_1)
1129 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT2";
1130 if (req->pcie_card_loc & BIT_2)
1131 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT3";
1132 if (req->pcie_card_loc & BIT_3)
1133 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT4";
1134
Vijay Khemka63c99be2020-05-27 19:14:35 -07001135 if (req->slot1_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001136 oemData[KEY_MC_CONFIG][KEY_MC_SLOT1_TYPE] = "UNKNOWN";
1137 else
1138 oemData[KEY_MC_CONFIG][KEY_MC_SLOT1_TYPE] =
1139 pcieType[req->slot1_pcie_type];
1140
Vijay Khemka63c99be2020-05-27 19:14:35 -07001141 if (req->slot2_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001142 oemData[KEY_MC_CONFIG][KEY_MC_SLOT2_TYPE] = "UNKNOWN";
1143 else
1144 oemData[KEY_MC_CONFIG][KEY_MC_SLOT2_TYPE] =
1145 pcieType[req->slot2_pcie_type];
1146
Vijay Khemka63c99be2020-05-27 19:14:35 -07001147 if (req->slot3_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001148 oemData[KEY_MC_CONFIG][KEY_MC_SLOT3_TYPE] = "UNKNOWN";
1149 else
1150 oemData[KEY_MC_CONFIG][KEY_MC_SLOT3_TYPE] =
1151 pcieType[req->slot3_pcie_type];
1152
Vijay Khemka63c99be2020-05-27 19:14:35 -07001153 if (req->slot4_pcie_type >= sizeof(pcieType) / sizeof(uint8_t*))
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001154 oemData[KEY_MC_CONFIG][KEY_MC_SLOT4_TYPE] = "UNKNOWN";
1155 else
1156 oemData[KEY_MC_CONFIG][KEY_MC_SLOT4_TYPE] =
1157 pcieType[req->slot4_pcie_type];
1158
1159 oemData[KEY_MC_CONFIG][KEY_MC_AEP_CNT] = req->aep_mem_cnt;
1160
1161 flushOemData();
1162
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001163 return IPMI_CC_OK;
1164}
1165
1166//----------------------------------------------------------------------
1167// Set POST start (CMD_OEM_SET_POST_START)
1168//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -07001169ipmi_ret_t ipmiOemSetPostStart(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
1170 ipmi_response_t, ipmi_data_len_t data_len,
1171 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001172{
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001173 phosphor::logging::log<phosphor::logging::level::INFO>("POST Start Event");
1174
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001175 /* Do nothing, return success */
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001176 *data_len = 0;
1177 return IPMI_CC_OK;
1178}
1179
1180//----------------------------------------------------------------------
1181// Set POST End (CMD_OEM_SET_POST_END)
1182//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -07001183ipmi_ret_t ipmiOemSetPostEnd(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
1184 ipmi_response_t, ipmi_data_len_t data_len,
1185 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001186{
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001187 struct timespec ts;
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001188
1189 phosphor::logging::log<phosphor::logging::level::INFO>("POST End Event");
1190
1191 *data_len = 0;
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001192
1193 // Timestamp post end time.
1194 clock_gettime(CLOCK_REALTIME, &ts);
1195 oemData[KEY_TS_SLED] = ts.tv_sec;
1196 flushOemData();
1197
1198 // Sync time with system
1199 // TODO: Add code for syncing time
1200
1201 return IPMI_CC_OK;
1202}
1203
1204//----------------------------------------------------------------------
1205// Set PPIN Info (CMD_OEM_SET_PPIN_INFO)
1206//----------------------------------------------------------------------
1207// Inform BMC about PPIN data of 8 bytes for each CPU
1208//
1209// Request:
1210// Byte 1:8 – CPU0 PPIN data
1211// Optional:
1212// Byte 9:16 – CPU1 PPIN data
1213//
1214// Response:
1215// Byte 1 – Completion Code
Willy Tue39f9392022-06-15 13:24:20 -07001216ipmi_ret_t ipmiOemSetPPINInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
1217 ipmi_response_t, ipmi_data_len_t data_len,
1218 ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001219{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001220 uint8_t* req = reinterpret_cast<uint8_t*>(request);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001221 std::string ppinStr;
1222 int len;
1223
1224 if (*data_len > SIZE_CPU_PPIN * 2)
1225 len = SIZE_CPU_PPIN * 2;
1226 else
1227 len = *data_len;
1228 *data_len = 0;
1229
1230 ppinStr = bytesToStr(req, len);
1231 oemData[KEY_PPIN_INFO] = ppinStr.c_str();
1232 flushOemData();
1233
1234 return IPMI_CC_OK;
1235}
1236
1237//----------------------------------------------------------------------
1238// Set ADR Trigger (CMD_OEM_SET_ADR_TRIGGER)
1239//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -07001240ipmi_ret_t ipmiOemSetAdrTrigger(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
1241 ipmi_response_t, ipmi_data_len_t data_len,
1242 ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001243{
1244 /* Do nothing, return success */
1245 *data_len = 0;
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001246 return IPMI_CC_OK;
1247}
1248
Vijay Khemkaf2246ce2020-05-27 14:26:35 -07001249// Helper function to set guid at offset in EEPROM
Willy Tue39f9392022-06-15 13:24:20 -07001250[[maybe_unused]] static int setGUID(off_t offset, uint8_t* guid)
Vijay Khemkaf2246ce2020-05-27 14:26:35 -07001251{
1252 int fd = -1;
1253 ssize_t len;
1254 int ret = 0;
1255
1256 errno = 0;
1257
1258 // Check if file is present
1259 if (access(FRU_EEPROM, F_OK) == -1)
1260 {
1261 std::cerr << "Unable to access: " << FRU_EEPROM << std::endl;
1262 return errno;
1263 }
1264
1265 // Open the file
1266 fd = open(FRU_EEPROM, O_WRONLY);
1267 if (fd == -1)
1268 {
1269 std::cerr << "Unable to open: " << FRU_EEPROM << std::endl;
1270 return errno;
1271 }
1272
1273 // seek to the offset
1274 lseek(fd, offset, SEEK_SET);
1275
1276 // Write bytes to location
1277 len = write(fd, guid, GUID_SIZE);
1278 if (len != GUID_SIZE)
1279 {
1280 phosphor::logging::log<phosphor::logging::level::ERR>(
1281 "GUID write data to EEPROM failed");
1282 ret = errno;
1283 }
1284
1285 close(fd);
1286 return ret;
1287}
1288
1289//----------------------------------------------------------------------
1290// Set System GUID (CMD_OEM_SET_SYSTEM_GUID)
1291//----------------------------------------------------------------------
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05301292#if BIC_ENABLED
Bonnie Lo3f671272022-10-12 15:46:45 +08001293ipmi::RspType<> ipmiOemSetSystemGuid(ipmi::Context::ptr ctx,
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05301294 std::vector<uint8_t> reqData)
1295{
1296 std::vector<uint8_t> respData;
1297
1298 if (reqData.size() != GUID_SIZE) // 16bytes
1299 {
1300
1301 return ipmi::responseReqDataLenInvalid();
1302 }
1303
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05301304 uint8_t bicAddr = (uint8_t)ctx->hostIdx << 2;
1305
1306 if (sendBicCmd(ctx->netFn, ctx->cmd, bicAddr, reqData, respData))
1307 return ipmi::responseUnspecifiedError();
1308
1309 return ipmi::responseSuccess();
1310}
1311
1312#else
Potin Laid5353ca2022-08-11 04:52:11 +00001313ipmi_ret_t ipmiOemSetSystemGuid(ipmi_netfn_t, ipmi_cmd_t,
1314 ipmi_request_t request, ipmi_response_t,
1315 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemkaf2246ce2020-05-27 14:26:35 -07001316{
1317 uint8_t* req = reinterpret_cast<uint8_t*>(request);
1318
1319 if (*data_len != GUID_SIZE) // 16bytes
1320 {
1321 *data_len = 0;
1322 return IPMI_CC_REQ_DATA_LEN_INVALID;
1323 }
1324
1325 *data_len = 0;
1326
1327 if (setGUID(OFFSET_SYS_GUID, req))
1328 {
1329 return IPMI_CC_UNSPECIFIED_ERROR;
1330 }
1331 return IPMI_CC_OK;
1332}
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05301333#endif
Vijay Khemkaf2246ce2020-05-27 14:26:35 -07001334
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001335//----------------------------------------------------------------------
1336// Set Bios Flash Info (CMD_OEM_SET_BIOS_FLASH_INFO)
1337//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -07001338ipmi_ret_t ipmiOemSetBiosFlashInfo(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
1339 ipmi_response_t, ipmi_data_len_t data_len,
1340 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001341{
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001342 /* Do nothing, return success */
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001343 *data_len = 0;
1344 return IPMI_CC_OK;
1345}
1346
1347//----------------------------------------------------------------------
1348// Set PPR (CMD_OEM_SET_PPR)
1349//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -07001350ipmi_ret_t ipmiOemSetPpr(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
1351 ipmi_response_t, ipmi_data_len_t data_len,
1352 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001353{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001354 uint8_t* req = reinterpret_cast<uint8_t*>(request);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001355 uint8_t pprCnt, pprAct, pprIndex;
1356 uint8_t selParam = req[0];
1357 uint8_t len = *data_len;
1358 std::stringstream ss;
1359 std::string str;
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001360
1361 *data_len = 0;
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001362
1363 switch (selParam)
1364 {
1365 case PPR_ACTION:
1366 if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) ==
1367 oemData[KEY_PPR].end())
1368 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1369
1370 pprCnt = oemData[KEY_PPR][KEY_PPR_ROW_COUNT];
1371 if (pprCnt == 0)
1372 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1373
1374 pprAct = req[1];
1375 /* Check if ppr is enabled or disabled */
1376 if (!(pprAct & 0x80))
1377 pprAct = 0;
1378
1379 oemData[KEY_PPR][KEY_PPR_ACTION] = pprAct;
1380 break;
1381 case PPR_ROW_COUNT:
1382 if (req[1] > 100)
1383 return IPMI_CC_PARM_OUT_OF_RANGE;
1384
1385 oemData[KEY_PPR][KEY_PPR_ROW_COUNT] = req[1];
1386 break;
1387 case PPR_ROW_ADDR:
1388 pprIndex = req[1];
1389 if (pprIndex > 100)
1390 return IPMI_CC_PARM_OUT_OF_RANGE;
1391
1392 if (len < PPR_ROW_ADDR_LEN + 1)
1393 {
1394 phosphor::logging::log<phosphor::logging::level::ERR>(
1395 "Invalid PPR Row Address length received");
1396 return IPMI_CC_REQ_DATA_LEN_INVALID;
1397 }
1398
1399 ss << std::hex;
1400 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
1401
1402 oemData[KEY_PPR][ss.str()][KEY_PPR_INDEX] = pprIndex;
1403
1404 str = bytesToStr(&req[1], PPR_ROW_ADDR_LEN);
1405 oemData[KEY_PPR][ss.str()][KEY_PPR_ROW_ADDR] = str.c_str();
1406 break;
1407 case PPR_HISTORY_DATA:
1408 pprIndex = req[1];
1409 if (pprIndex > 100)
1410 return IPMI_CC_PARM_OUT_OF_RANGE;
1411
1412 if (len < PPR_HST_DATA_LEN + 1)
1413 {
1414 phosphor::logging::log<phosphor::logging::level::ERR>(
1415 "Invalid PPR history data length received");
1416 return IPMI_CC_REQ_DATA_LEN_INVALID;
1417 }
1418
1419 ss << std::hex;
1420 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
1421
1422 oemData[KEY_PPR][ss.str()][KEY_PPR_INDEX] = pprIndex;
1423
1424 str = bytesToStr(&req[1], PPR_HST_DATA_LEN);
1425 oemData[KEY_PPR][ss.str()][KEY_PPR_HST_DATA] = str.c_str();
1426 break;
1427 default:
1428 return IPMI_CC_PARM_OUT_OF_RANGE;
1429 break;
1430 }
1431
1432 flushOemData();
1433
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001434 return IPMI_CC_OK;
1435}
1436
1437//----------------------------------------------------------------------
1438// Get PPR (CMD_OEM_GET_PPR)
1439//----------------------------------------------------------------------
Willy Tue39f9392022-06-15 13:24:20 -07001440ipmi_ret_t ipmiOemGetPpr(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request,
1441 ipmi_response_t response, ipmi_data_len_t data_len,
1442 ipmi_context_t)
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001443{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001444 uint8_t* req = reinterpret_cast<uint8_t*>(request);
1445 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001446 uint8_t pprCnt, pprIndex;
1447 uint8_t selParam = req[0];
1448 std::stringstream ss;
1449 std::string str;
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001450
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001451 /* Any failure will return zero length data */
1452 *data_len = 0;
1453
1454 switch (selParam)
1455 {
1456 case PPR_ACTION:
1457 res[0] = 0;
1458 *data_len = 1;
1459
1460 if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) !=
1461 oemData[KEY_PPR].end())
1462 {
1463 pprCnt = oemData[KEY_PPR][KEY_PPR_ROW_COUNT];
1464 if (pprCnt != 0)
1465 {
1466 if (oemData[KEY_PPR].find(KEY_PPR_ACTION) !=
1467 oemData[KEY_PPR].end())
1468 {
1469 res[0] = oemData[KEY_PPR][KEY_PPR_ACTION];
1470 }
1471 }
1472 }
1473 break;
1474 case PPR_ROW_COUNT:
1475 res[0] = 0;
1476 *data_len = 1;
1477 if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) !=
1478 oemData[KEY_PPR].end())
1479 res[0] = oemData[KEY_PPR][KEY_PPR_ROW_COUNT];
1480 break;
1481 case PPR_ROW_ADDR:
1482 pprIndex = req[1];
1483 if (pprIndex > 100)
1484 return IPMI_CC_PARM_OUT_OF_RANGE;
1485
1486 ss << std::hex;
1487 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
1488
1489 if (oemData[KEY_PPR].find(ss.str()) == oemData[KEY_PPR].end())
1490 return IPMI_CC_PARM_OUT_OF_RANGE;
1491
1492 if (oemData[KEY_PPR][ss.str()].find(KEY_PPR_ROW_ADDR) ==
1493 oemData[KEY_PPR][ss.str()].end())
1494 return IPMI_CC_PARM_OUT_OF_RANGE;
1495
1496 str = oemData[KEY_PPR][ss.str()][KEY_PPR_ROW_ADDR];
1497 *data_len = strToBytes(str, res);
1498 break;
1499 case PPR_HISTORY_DATA:
1500 pprIndex = req[1];
1501 if (pprIndex > 100)
1502 return IPMI_CC_PARM_OUT_OF_RANGE;
1503
1504 ss << std::hex;
1505 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
1506
1507 if (oemData[KEY_PPR].find(ss.str()) == oemData[KEY_PPR].end())
1508 return IPMI_CC_PARM_OUT_OF_RANGE;
1509
1510 if (oemData[KEY_PPR][ss.str()].find(KEY_PPR_HST_DATA) ==
1511 oemData[KEY_PPR][ss.str()].end())
1512 return IPMI_CC_PARM_OUT_OF_RANGE;
1513
1514 str = oemData[KEY_PPR][ss.str()][KEY_PPR_HST_DATA];
1515 *data_len = strToBytes(str, res);
1516 break;
1517 default:
1518 return IPMI_CC_PARM_OUT_OF_RANGE;
1519 break;
1520 }
1521
1522 return IPMI_CC_OK;
1523}
1524
1525/* FB OEM QC Commands */
1526
1527//----------------------------------------------------------------------
1528// Set Proc Info (CMD_OEM_Q_SET_PROC_INFO)
1529//----------------------------------------------------------------------
1530//"Request:
1531// Byte 1:3 – Manufacturer ID – XXYYZZ h, LSB first
1532// Byte 4 – Processor Index, 0 base
1533// Byte 5 – Parameter Selector
1534// Byte 6..N – Configuration parameter data (see below for Parameters
1535// of Processor Information)
1536// Response:
1537// Byte 1 – Completion code
1538//
1539// Parameter#1: (Processor Product Name)
1540//
1541// Byte 1..48 –Product name(ASCII code)
1542// Ex. Intel(R) Xeon(R) CPU E5-2685 v3 @ 2.60GHz
1543//
1544// Param#2: Processor Basic Information
1545// Byte 1 – Core Number
1546// Byte 2 – Thread Number (LSB)
1547// Byte 3 – Thread Number (MSB)
1548// Byte 4 – Processor frequency in MHz (LSB)
1549// Byte 5 – Processor frequency in MHz (MSB)
1550// Byte 6..7 – Revision
1551//
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05301552
1553ipmi::RspType<> ipmiOemQSetProcInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t,
1554 uint8_t, uint8_t procIndex,
1555 uint8_t paramSel,
1556 std::vector<uint8_t> request)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001557{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001558 uint8_t numParam = sizeof(cpuInfoKey) / sizeof(uint8_t*);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001559 std::stringstream ss;
1560 std::string str;
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05301561 uint8_t len = request.size();
1562 auto hostId = findHost(ctx->hostIdx);
1563 if (!hostId)
1564 {
1565 phosphor::logging::log<phosphor::logging::level::ERR>(
1566 "Invalid Host Id received");
1567 return ipmi::responseInvalidCommand();
1568 }
1569 std::string procInfo = KEY_Q_PROC_INFO + std::to_string(*hostId);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001570 /* check for requested data params */
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05301571 if (len < 5 || paramSel < 1 || paramSel >= numParam)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001572 {
1573 phosphor::logging::log<phosphor::logging::level::ERR>(
1574 "Invalid parameter received");
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05301575 return ipmi::responseParmOutOfRange();
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001576 }
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001577 ss << std::hex;
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05301578 ss << std::setw(2) << std::setfill('0') << (int)procIndex;
1579 oemData[procInfo][ss.str()][KEY_PROC_INDEX] = procIndex;
1580 str = bytesToStr(request.data(), len);
1581 oemData[procInfo][ss.str()][cpuInfoKey[paramSel]] = str.c_str();
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001582 flushOemData();
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05301583 return ipmi::responseSuccess();
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001584}
1585
1586//----------------------------------------------------------------------
1587// Get Proc Info (CMD_OEM_Q_GET_PROC_INFO)
1588//----------------------------------------------------------------------
1589// Request:
1590// Byte 1:3 – Manufacturer ID – XXYYZZ h, LSB first
1591// Byte 4 – Processor Index, 0 base
1592// Byte 5 – Parameter Selector
1593// Response:
1594// Byte 1 – Completion code
1595// Byte 2..N – Configuration Parameter Data (see below for Parameters
1596// of Processor Information)
1597//
1598// Parameter#1: (Processor Product Name)
1599//
1600// Byte 1..48 –Product name(ASCII code)
1601// Ex. Intel(R) Xeon(R) CPU E5-2685 v3 @ 2.60GHz
1602//
1603// Param#2: Processor Basic Information
1604// Byte 1 – Core Number
1605// Byte 2 – Thread Number (LSB)
1606// Byte 3 – Thread Number (MSB)
1607// Byte 4 – Processor frequency in MHz (LSB)
1608// Byte 5 – Processor frequency in MHz (MSB)
1609// Byte 6..7 – Revision
1610//
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05301611
1612ipmi::RspType<std::vector<uint8_t>>
1613 ipmiOemQGetProcInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t, uint8_t,
1614 uint8_t procIndex, uint8_t paramSel)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001615{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001616 uint8_t numParam = sizeof(cpuInfoKey) / sizeof(uint8_t*);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001617 std::stringstream ss;
1618 std::string str;
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05301619 uint8_t res[MAX_BUF];
1620 auto hostId = findHost(ctx->hostIdx);
1621 if (!hostId)
1622 {
1623 phosphor::logging::log<phosphor::logging::level::ERR>(
1624 "Invalid Host Id received");
1625 return ipmi::responseInvalidCommand();
1626 }
1627 std::string procInfo = KEY_Q_PROC_INFO + std::to_string(*hostId);
1628 if (paramSel < 1 || paramSel >= numParam)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001629 {
1630 phosphor::logging::log<phosphor::logging::level::ERR>(
1631 "Invalid parameter received");
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05301632 return ipmi::responseParmOutOfRange();
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001633 }
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001634 ss << std::hex;
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05301635 ss << std::setw(2) << std::setfill('0') << (int)procIndex;
1636 if (oemData[procInfo].find(ss.str()) == oemData[procInfo].end())
1637 return ipmi::responseCommandNotAvailable();
1638 if (oemData[procInfo][ss.str()].find(cpuInfoKey[paramSel]) ==
1639 oemData[procInfo][ss.str()].end())
1640 return ipmi::responseCommandNotAvailable();
1641 str = oemData[procInfo][ss.str()][cpuInfoKey[paramSel]];
1642 int dataLen = strToBytes(str, res);
1643 std::vector<uint8_t> response(&res[0], &res[dataLen]);
1644 return ipmi::responseSuccess(response);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001645}
1646
1647//----------------------------------------------------------------------
1648// Set Dimm Info (CMD_OEM_Q_SET_DIMM_INFO)
1649//----------------------------------------------------------------------
1650// Request:
1651// Byte 1:3 – Manufacturer ID – XXYYZZh, LSB first
1652// Byte 4 – DIMM Index, 0 base
1653// Byte 5 – Parameter Selector
1654// Byte 6..N – Configuration parameter data (see below for Parameters
1655// of DIMM Information)
1656// Response:
1657// Byte 1 – Completion code
1658//
1659// Param#1 (DIMM Location):
1660// Byte 1 – DIMM Present
1661// Byte 1 – DIMM Present
1662// 01h – Present
1663// FFh – Not Present
1664// Byte 2 – Node Number, 0 base
1665// Byte 3 – Channel Number , 0 base
1666// Byte 4 – DIMM Number , 0 base
1667//
1668// Param#2 (DIMM Type):
1669// Byte 1 – DIMM Type
1670// Bit [7:6]
1671// For DDR3
1672// 00 – Normal Voltage (1.5V)
1673// 01 – Ultra Low Voltage (1.25V)
1674// 10 – Low Voltage (1.35V)
1675// 11 – Reserved
1676// For DDR4
1677// 00 – Reserved
1678// 01 – Reserved
1679// 10 – Reserved
1680// 11 – Normal Voltage (1.2V)
1681// Bit [5:0]
1682// 0x00 – SDRAM
1683// 0x01 – DDR-1 RAM
1684// 0x02 – Rambus
1685// 0x03 – DDR-2 RAM
1686// 0x04 – FBDIMM
1687// 0x05 – DDR-3 RAM
1688// 0x06 – DDR-4 RAM
1689//
1690// Param#3 (DIMM Speed):
1691// Byte 1..2 – DIMM speed in MHz, LSB
1692// Byte 3..6 – DIMM size in Mbytes, LSB
1693//
1694// Param#4 (Module Part Number):
1695// Byte 1..20 –Module Part Number (JEDEC Standard No. 21-C)
1696//
1697// Param#5 (Module Serial Number):
1698// Byte 1..4 –Module Serial Number (JEDEC Standard No. 21-C)
1699//
1700// Param#6 (Module Manufacturer ID):
1701// Byte 1 - Module Manufacturer ID, LSB
1702// Byte 2 - Module Manufacturer ID, MSB
1703//
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301704ipmi::RspType<> ipmiOemQSetDimmInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t,
1705 uint8_t, uint8_t dimmIndex,
1706 uint8_t paramSel,
1707 std::vector<uint8_t> request)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001708{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001709 uint8_t numParam = sizeof(dimmInfoKey) / sizeof(uint8_t*);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001710 std::stringstream ss;
1711 std::string str;
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301712 uint8_t len = request.size();
1713 std::string dimmType;
1714 readDimmType(dimmType, dimmIndex);
Patrick Williams6d9e9a72022-07-18 10:30:50 -05001715 auto hostId = findHost(ctx->hostIdx);
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301716 if (!hostId)
1717 {
1718 phosphor::logging::log<phosphor::logging::level::ERR>(
1719 "Invalid Host Id received");
1720 return ipmi::responseInvalidCommand();
1721 }
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001722
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301723 std::string dimmInfo = KEY_Q_DIMM_INFO + std::to_string(*hostId);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001724
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301725 if (len < 3 || paramSel < 1 || paramSel >= numParam)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001726 {
1727 phosphor::logging::log<phosphor::logging::level::ERR>(
1728 "Invalid parameter received");
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301729 return ipmi::responseParmOutOfRange();
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001730 }
1731
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001732 ss << std::hex;
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301733 ss << (int)dimmIndex;
1734 oemData[dimmInfo][ss.str()][KEY_DIMM_INDEX] = dimmIndex;
1735 oemData[dimmInfo][ss.str()][KEY_DIMM_TYPE] = dimmType;
1736 str = bytesToStr(request.data(), len);
1737 oemData[dimmInfo][ss.str()][dimmInfoKey[paramSel]] = str.c_str();
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001738 flushOemData();
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301739 return ipmi::responseSuccess();
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001740}
1741
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001742// Get Dimm Info (CMD_OEM_Q_GET_DIMM_INFO)
1743//----------------------------------------------------------------------
1744// Request:
1745// Byte 1:3 – Manufacturer ID – XXYYZZh, LSB first
1746// Byte 4 – DIMM Index, 0 base
1747// Byte 5 – Parameter Selector
1748// Byte 6..N – Configuration parameter data (see below for Parameters
1749// of DIMM Information)
1750// Response:
1751// Byte 1 – Completion code
1752// Byte 2..N – Configuration Parameter Data (see Table_1213h Parameters
1753// of DIMM Information)
1754//
1755// Param#1 (DIMM Location):
1756// Byte 1 – DIMM Present
1757// Byte 1 – DIMM Present
1758// 01h – Present
1759// FFh – Not Present
1760// Byte 2 – Node Number, 0 base
1761// Byte 3 – Channel Number , 0 base
1762// Byte 4 – DIMM Number , 0 base
1763//
1764// Param#2 (DIMM Type):
1765// Byte 1 – DIMM Type
1766// Bit [7:6]
1767// For DDR3
1768// 00 – Normal Voltage (1.5V)
1769// 01 – Ultra Low Voltage (1.25V)
1770// 10 – Low Voltage (1.35V)
1771// 11 – Reserved
1772// For DDR4
1773// 00 – Reserved
1774// 01 – Reserved
1775// 10 – Reserved
1776// 11 – Normal Voltage (1.2V)
1777// Bit [5:0]
1778// 0x00 – SDRAM
1779// 0x01 – DDR-1 RAM
1780// 0x02 – Rambus
1781// 0x03 – DDR-2 RAM
1782// 0x04 – FBDIMM
1783// 0x05 – DDR-3 RAM
1784// 0x06 – DDR-4 RAM
1785//
1786// Param#3 (DIMM Speed):
1787// Byte 1..2 – DIMM speed in MHz, LSB
1788// Byte 3..6 – DIMM size in Mbytes, LSB
1789//
1790// Param#4 (Module Part Number):
1791// Byte 1..20 –Module Part Number (JEDEC Standard No. 21-C)
1792//
1793// Param#5 (Module Serial Number):
1794// Byte 1..4 –Module Serial Number (JEDEC Standard No. 21-C)
1795//
1796// Param#6 (Module Manufacturer ID):
1797// Byte 1 - Module Manufacturer ID, LSB
1798// Byte 2 - Module Manufacturer ID, MSB
1799//
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301800ipmi::RspType<std::vector<uint8_t>>
1801 ipmiOemQGetDimmInfo(ipmi::Context::ptr ctx, uint8_t, uint8_t, uint8_t,
1802 uint8_t dimmIndex, uint8_t paramSel)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001803{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001804 uint8_t numParam = sizeof(dimmInfoKey) / sizeof(uint8_t*);
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301805 uint8_t res[MAX_BUF];
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001806 std::stringstream ss;
1807 std::string str;
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301808 std::string dimmType;
1809 readDimmType(dimmType, dimmIndex);
Patrick Williams6d9e9a72022-07-18 10:30:50 -05001810 auto hostId = findHost(ctx->hostIdx);
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301811 if (!hostId)
1812 {
1813 phosphor::logging::log<phosphor::logging::level::ERR>(
1814 "Invalid Host Id received");
1815 return ipmi::responseInvalidCommand();
1816 }
1817 std::string dimmInfo = KEY_Q_DIMM_INFO + std::to_string(*hostId);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001818
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301819 if (paramSel < 1 || paramSel >= numParam)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001820 {
1821 phosphor::logging::log<phosphor::logging::level::ERR>(
1822 "Invalid parameter received");
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301823 return ipmi::responseParmOutOfRange();
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001824 }
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001825 ss << std::hex;
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05301826 ss << (int)dimmIndex;
1827 oemData[dimmInfo][ss.str()][KEY_DIMM_TYPE] = dimmType;
1828 if (oemData[dimmInfo].find(ss.str()) == oemData[dimmInfo].end())
1829 return ipmi::responseCommandNotAvailable();
1830 if (oemData[dimmInfo][ss.str()].find(dimmInfoKey[paramSel]) ==
1831 oemData[dimmInfo][ss.str()].end())
1832 return ipmi::responseCommandNotAvailable();
1833 str = oemData[dimmInfo][ss.str()][dimmInfoKey[paramSel]];
1834 int data_length = strToBytes(str, res);
1835 std::vector<uint8_t> response(&res[0], &res[data_length]);
1836 return ipmi::responseSuccess(response);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001837}
1838
1839//----------------------------------------------------------------------
1840// Set Drive Info (CMD_OEM_Q_SET_DRIVE_INFO)
1841//----------------------------------------------------------------------
1842// BIOS issue this command to provide HDD information to BMC.
1843//
1844// BIOS just can get information by standard ATA / SMART command for
1845// OB SATA controller.
1846// BIOS can get
1847// 1. Serial Number
1848// 2. Model Name
1849// 3. HDD FW Version
1850// 4. HDD Capacity
1851// 5. HDD WWN
1852//
1853// Use Get HDD info Param #5 to know the MAX HDD info index.
1854//
1855// Request:
1856// Byte 1:3 – Quanta Manufacturer ID – 001C4Ch, LSB first
1857// Byte 4 –
1858// [7:4] Reserved
1859// [3:0] HDD Controller Type
1860// 0x00 – BIOS
1861// 0x01 – Expander
1862// 0x02 – LSI
1863// Byte 5 – HDD Info Index, 0 base
1864// Byte 6 – Parameter Selector
1865// Byte 7..N – Configuration parameter data (see Table_1415h Parameters of HDD
1866// Information)
1867//
1868// Response:
1869// Byte 1 – Completion Code
1870//
1871// Param#0 (HDD Location):
1872// Byte 1 – Controller
1873// [7:3] Device Number
1874// [2:0] Function Number
1875// For Intel C610 series (Wellsburg)
1876// D31:F2 (0xFA) – SATA control 1
1877// D31:F5 (0xFD) – SATA control 2
1878// D17:F4 (0x8C) – sSata control
1879// Byte 2 – Port Number
1880// Byte 3 – Location (0xFF: No HDD Present)
1881// BIOS default set Byte 3 to 0xFF, if No HDD Present. And then skip send param
1882// #1~4, #6, #7 to BMC (still send param #5) BIOS default set Byte 3 to 0, if
1883// the HDD present. BMC or other people who know the HDD location has
1884// responsibility for update Location info
1885//
1886// Param#1 (Serial Number):
1887// Bytes 1..33: HDD Serial Number
1888//
1889// Param#2 (Model Name):
1890// Byte 1..33 – HDD Model Name
1891//
1892// Param#3 (HDD FW Version):
1893// Byte 1..17 –HDD FW version
1894//
1895// Param#4 (Capacity):
1896// Byte 1..4 –HDD Block Size, LSB
1897// Byte 5..12 - HDD Block Number, LSB
1898// HDD Capacity = HDD Block size * HDD BLock number (Unit Byte)
1899//
1900// Param#5 (Max HDD Quantity):
1901// Byte 1 - Max HDD Quantity
1902// Max supported port numbers in this PCH
1903//
1904// Param#6 (HDD Type)
1905// Byte 1 – HDD Type
1906// 0h – Reserved
1907// 1h – SAS
1908// 2h – SATA
1909// 3h – PCIE SSD (NVME)
1910//
1911// Param#7 (HDD WWN)
1912// Data 1...8: HDD World Wide Name, LSB
1913//
Willy Tue39f9392022-06-15 13:24:20 -07001914ipmi_ret_t ipmiOemQSetDriveInfo(ipmi_netfn_t, ipmi_cmd_t,
1915 ipmi_request_t request, ipmi_response_t,
1916 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001917{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001918 qDriveInfo_t* req = reinterpret_cast<qDriveInfo_t*>(request);
1919 uint8_t numParam = sizeof(driveInfoKey) / sizeof(uint8_t*);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001920 uint8_t ctrlType = req->hddCtrlType & 0x0f;
1921 std::stringstream ss;
1922 std::string str;
1923 uint8_t len = *data_len;
1924
1925 *data_len = 0;
1926
1927 /* check for requested data params */
1928 if (len < 6 || req->paramSel < 1 || req->paramSel >= numParam ||
1929 ctrlType > 2)
1930 {
1931 phosphor::logging::log<phosphor::logging::level::ERR>(
1932 "Invalid parameter received");
1933 return IPMI_CC_PARM_OUT_OF_RANGE;
1934 }
1935
1936 len = len - 6; // Get Actual data length
1937
1938 ss << std::hex;
1939 ss << std::setw(2) << std::setfill('0') << (int)req->hddIndex;
1940 oemData[KEY_Q_DRIVE_INFO][KEY_HDD_CTRL_TYPE] = req->hddCtrlType;
1941 oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()][KEY_HDD_INDEX] =
1942 req->hddIndex;
1943
1944 str = bytesToStr(req->data, len);
1945 oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()]
1946 [driveInfoKey[req->paramSel]] = str.c_str();
1947 flushOemData();
1948
1949 return IPMI_CC_OK;
1950}
1951
1952//----------------------------------------------------------------------
1953// Get Drive Info (CMD_OEM_Q_GET_DRIVE_INFO)
1954//----------------------------------------------------------------------
1955// BMC needs to check HDD presented or not first. If NOT presented, return
1956// completion code 0xD5.
1957//
1958// Request:
1959// Byte 1:3 – Quanta Manufacturer ID – 001C4Ch, LSB first
1960// Byte 4 –
1961//[7:4] Reserved
1962//[3:0] HDD Controller Type
1963// 0x00 – BIOS
1964// 0x01 – Expander
1965// 0x02 – LSI
1966// Byte 5 – HDD Index, 0 base
1967// Byte 6 – Parameter Selector (See Above Set HDD Information)
1968// Response:
1969// Byte 1 – Completion Code
1970// 0xD5 – Not support in current status (HDD Not Present)
1971// Byte 2..N – Configuration parameter data (see Table_1415h Parameters of HDD
1972// Information)
1973//
Willy Tue39f9392022-06-15 13:24:20 -07001974ipmi_ret_t ipmiOemQGetDriveInfo(ipmi_netfn_t, ipmi_cmd_t,
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001975 ipmi_request_t request,
1976 ipmi_response_t response,
Willy Tue39f9392022-06-15 13:24:20 -07001977 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001978{
Vijay Khemka63c99be2020-05-27 19:14:35 -07001979 qDriveInfo_t* req = reinterpret_cast<qDriveInfo_t*>(request);
1980 uint8_t numParam = sizeof(driveInfoKey) / sizeof(uint8_t*);
1981 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001982 uint8_t ctrlType = req->hddCtrlType & 0x0f;
1983 std::stringstream ss;
1984 std::string str;
1985
1986 *data_len = 0;
1987
1988 /* check for requested data params */
1989 if (req->paramSel < 1 || req->paramSel >= numParam || ctrlType > 2)
1990 {
1991 phosphor::logging::log<phosphor::logging::level::ERR>(
1992 "Invalid parameter received");
1993 return IPMI_CC_PARM_OUT_OF_RANGE;
1994 }
1995
1996 if (oemData[KEY_Q_DRIVE_INFO].find(ctrlTypeKey[ctrlType]) ==
1997 oemData[KEY_Q_DRIVE_INFO].end())
1998 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1999
2000 ss << std::hex;
2001 ss << std::setw(2) << std::setfill('0') << (int)req->hddIndex;
2002
2003 if (oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]].find(ss.str()) ==
2004 oemData[KEY_Q_DRIVE_INFO].end())
2005 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
2006
2007 if (oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()].find(
2008 dimmInfoKey[req->paramSel]) ==
2009 oemData[KEY_Q_DRIVE_INFO][ss.str()].end())
2010 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
2011
2012 str = oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()]
2013 [dimmInfoKey[req->paramSel]];
2014 *data_len = strToBytes(str, res);
Vijay Khemkae7d23d02019-03-08 13:13:40 -08002015
2016 return IPMI_CC_OK;
2017}
2018
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302019/* Helper function for sending DCMI commands to ME/BIC and
2020 * getting response back
2021 */
2022ipmi::RspType<std::vector<uint8_t>>
2023 sendDCMICmd([[maybe_unused]] ipmi::Context::ptr ctx,
2024 [[maybe_unused]] uint8_t cmd, std::vector<uint8_t>& cmdData)
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002025{
2026 std::vector<uint8_t> respData;
2027
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302028#if BIC_ENABLED
2029
2030 uint8_t bicAddr = (uint8_t)ctx->hostIdx << 2;
2031
2032 if (sendBicCmd(ctx->netFn, ctx->cmd, bicAddr, cmdData, respData))
2033 {
2034 return ipmi::responseUnspecifiedError();
2035 }
2036
2037#else
2038
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002039 /* Add group id as first byte to request for ME command */
2040 cmdData.insert(cmdData.begin(), groupDCMI);
2041
2042 if (sendMeCmd(ipmi::netFnGroup, cmd, cmdData, respData))
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302043 {
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002044 return ipmi::responseUnspecifiedError();
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302045 }
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002046
2047 /* Remove group id as first byte as it will be added by IPMID */
2048 respData.erase(respData.begin());
2049
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302050#endif
2051
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002052 return ipmi::responseSuccess(std::move(respData));
2053}
2054
2055/* DCMI Command handellers. */
2056
2057ipmi::RspType<std::vector<uint8_t>>
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302058 ipmiOemDCMIGetPowerReading(ipmi::Context::ptr ctx,
2059 std::vector<uint8_t> reqData)
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002060{
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302061 return sendDCMICmd(ctx, ipmi::dcmi::cmdGetPowerReading, reqData);
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002062}
2063
2064ipmi::RspType<std::vector<uint8_t>>
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302065 ipmiOemDCMIGetPowerLimit(ipmi::Context::ptr ctx,
2066 std::vector<uint8_t> reqData)
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002067{
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302068 return sendDCMICmd(ctx, ipmi::dcmi::cmdGetPowerLimit, reqData);
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002069}
2070
2071ipmi::RspType<std::vector<uint8_t>>
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302072 ipmiOemDCMISetPowerLimit(ipmi::Context::ptr ctx,
2073 std::vector<uint8_t> reqData)
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002074{
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302075 return sendDCMICmd(ctx, ipmi::dcmi::cmdSetPowerLimit, reqData);
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002076}
2077
2078ipmi::RspType<std::vector<uint8_t>>
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302079 ipmiOemDCMIApplyPowerLimit(ipmi::Context::ptr ctx,
2080 std::vector<uint8_t> reqData)
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002081{
Logananth Sundararaje4d6fe72022-08-23 20:36:31 +05302082 return sendDCMICmd(ctx, ipmi::dcmi::cmdActDeactivatePwrLimit, reqData);
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002083}
2084
Vijay Khemkae7d23d02019-03-08 13:13:40 -08002085static void registerOEMFunctions(void)
2086{
Vijay Khemka1d4a0692019-04-09 15:20:28 -07002087 /* Get OEM data from json file */
2088 std::ifstream file(JSON_OEM_DATA_FILE);
2089 if (file)
Vijay Khemkafeaa9812019-08-27 15:08:08 -07002090 {
Vijay Khemka1d4a0692019-04-09 15:20:28 -07002091 file >> oemData;
Vijay Khemkafeaa9812019-08-27 15:08:08 -07002092 file.close();
2093 }
Vijay Khemka1d4a0692019-04-09 15:20:28 -07002094
Vijay Khemkae7d23d02019-03-08 13:13:40 -08002095 phosphor::logging::log<phosphor::logging::level::INFO>(
2096 "Registering OEM commands");
Vijay Khemka7c0aea42020-03-05 13:31:53 -08002097
Vijay Khemkae7d23d02019-03-08 13:13:40 -08002098 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_INFO,
2099 NULL, ipmiOemDbgGetFrameInfo,
2100 PRIVILEGE_USER); // get debug frame info
2101 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ,
2102 CMD_OEM_USB_DBG_GET_UPDATED_FRAMES, NULL,
2103 ipmiOemDbgGetUpdFrames,
2104 PRIVILEGE_USER); // get debug updated frames
2105 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_POST_DESC,
2106 NULL, ipmiOemDbgGetPostDesc,
2107 PRIVILEGE_USER); // get debug post description
2108 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_GPIO_DESC,
2109 NULL, ipmiOemDbgGetGpioDesc,
2110 PRIVILEGE_USER); // get debug gpio description
2111 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_DATA,
2112 NULL, ipmiOemDbgGetFrameData,
2113 PRIVILEGE_USER); // get debug frame data
2114 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_CTRL_PANEL,
2115 NULL, ipmiOemDbgGetCtrlPanel,
2116 PRIVILEGE_USER); // get debug control panel
2117 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_DIMM_INFO, NULL,
2118 ipmiOemSetDimmInfo,
2119 PRIVILEGE_USER); // Set Dimm Info
Vijay Khemka1d4a0692019-04-09 15:20:28 -07002120 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_BOARD_ID, NULL,
2121 ipmiOemGetBoardID,
2122 PRIVILEGE_USER); // Get Board ID
Bonnie Lo4ae63e72023-02-09 15:27:54 +08002123 ipmi::registerHandler(ipmi::prioOemBase, ipmi::netFnOemOne,
2124 CMD_OEM_GET_80PORT_RECORD, ipmi::Privilege::User,
2125 ipmiOemGet80PortRecord); // Get 80 Port Record
Vijay Khemkae7d23d02019-03-08 13:13:40 -08002126 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_MACHINE_CONFIG_INFO, NULL,
2127 ipmiOemSetMachineCfgInfo,
2128 PRIVILEGE_USER); // Set Machine Config Info
2129 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_START, NULL,
2130 ipmiOemSetPostStart,
2131 PRIVILEGE_USER); // Set POST start
2132 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_END, NULL,
2133 ipmiOemSetPostEnd,
2134 PRIVILEGE_USER); // Set POST End
Vijay Khemka1d4a0692019-04-09 15:20:28 -07002135 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPIN_INFO, NULL,
2136 ipmiOemSetPPINInfo,
2137 PRIVILEGE_USER); // Set PPIN Info
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05302138#if BIC_ENABLED
2139
2140 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne,
2141 ipmi::cmdSetSystemGuid, ipmi::Privilege::User,
2142 ipmiOemSetSystemGuid);
2143#else
2144
Vijay Khemkaf2246ce2020-05-27 14:26:35 -07002145 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_SYSTEM_GUID, NULL,
2146 ipmiOemSetSystemGuid,
2147 PRIVILEGE_USER); // Set System GUID
Manikandan Elumalai5f8e3432020-12-02 03:46:55 +05302148#endif
Vijay Khemka1d4a0692019-04-09 15:20:28 -07002149 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_ADR_TRIGGER, NULL,
2150 ipmiOemSetAdrTrigger,
2151 PRIVILEGE_USER); // Set ADR Trigger
Vijay Khemkae7d23d02019-03-08 13:13:40 -08002152 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_BIOS_FLASH_INFO, NULL,
2153 ipmiOemSetBiosFlashInfo,
2154 PRIVILEGE_USER); // Set Bios Flash Info
2155 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPR, NULL, ipmiOemSetPpr,
2156 PRIVILEGE_USER); // Set PPR
2157 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_PPR, NULL, ipmiOemGetPpr,
2158 PRIVILEGE_USER); // Get PPR
Vijay Khemka1d4a0692019-04-09 15:20:28 -07002159 /* FB OEM QC Commands */
Karthikeyan Pasupathid532fec2022-07-14 14:43:42 +05302160 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour,
2161 CMD_OEM_Q_SET_PROC_INFO, ipmi::Privilege::User,
2162 ipmiOemQSetProcInfo); // Set Proc Info
2163 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour,
2164 CMD_OEM_Q_GET_PROC_INFO, ipmi::Privilege::User,
2165 ipmiOemQGetProcInfo); // Get Proc Info
Karthikeyan Pasupathi10ff3d82022-04-06 16:27:25 +05302166 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour,
2167 ipmi::cmdSetQDimmInfo, ipmi::Privilege::User,
2168 ipmiOemQSetDimmInfo); // Set Dimm Info
2169 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemFour,
2170 ipmi::cmdGetQDimmInfo, ipmi::Privilege::User,
2171 ipmiOemQGetDimmInfo); // Get Dimm Info
Vijay Khemka1d4a0692019-04-09 15:20:28 -07002172 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_SET_DRIVE_INFO, NULL,
2173 ipmiOemQSetDriveInfo,
2174 PRIVILEGE_USER); // Set Drive Info
2175 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_GET_DRIVE_INFO, NULL,
2176 ipmiOemQGetDriveInfo,
2177 PRIVILEGE_USER); // Get Drive Info
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07002178
2179 /* FB OEM DCMI Commands as per DCMI spec 1.5 Section 6 */
2180 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
2181 ipmi::dcmi::cmdGetPowerReading,
2182 ipmi::Privilege::User,
2183 ipmiOemDCMIGetPowerReading); // Get Power Reading
2184
2185 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
2186 ipmi::dcmi::cmdGetPowerLimit,
2187 ipmi::Privilege::User,
2188 ipmiOemDCMIGetPowerLimit); // Get Power Limit
2189
2190 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
2191 ipmi::dcmi::cmdSetPowerLimit,
2192 ipmi::Privilege::Operator,
2193 ipmiOemDCMISetPowerLimit); // Set Power Limit
2194
2195 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
2196 ipmi::dcmi::cmdActDeactivatePwrLimit,
2197 ipmi::Privilege::Operator,
2198 ipmiOemDCMIApplyPowerLimit); // Apply Power Limit
2199
Jayashree-Df0cf6652020-11-30 11:03:30 +05302200 /* FB OEM BOOT ORDER COMMANDS */
2201 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne,
2202 CMD_OEM_GET_BOOT_ORDER, ipmi::Privilege::User,
2203 ipmiOemGetBootOrder); // Get Boot Order
2204
2205 ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnOemOne,
2206 CMD_OEM_SET_BOOT_ORDER, ipmi::Privilege::User,
2207 ipmiOemSetBootOrder); // Set Boot Order
2208
Vijay Khemkae7d23d02019-03-08 13:13:40 -08002209 return;
2210}
2211
2212} // namespace ipmi