blob: cdb0a025b38791feada3cf739abddb2f3156b179 [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"
Vijay Khemkadd14c0f2020-03-18 14:48:13 -070019#include <ipmid/api.hpp>
Vijay Khemkae7d23d02019-03-08 13:13:40 -080020
Vijay Khemka1d4a0692019-04-09 15:20:28 -070021#include <nlohmann/json.hpp>
Vijay Khemkae7d23d02019-03-08 13:13:40 -080022#include <array>
23#include <commandutils.hpp>
24#include <cstring>
25#include <iostream>
Vijay Khemka1d4a0692019-04-09 15:20:28 -070026#include <iomanip>
27#include <sstream>
28#include <fstream>
Vijay Khemkae7d23d02019-03-08 13:13:40 -080029#include <oemcommands.hpp>
Vijay Khemka1b6fae32019-03-25 17:43:01 -070030#include <ipmid/utils.hpp>
Vijay Khemkae7d23d02019-03-08 13:13:40 -080031#include <phosphor-logging/log.hpp>
32#include <sdbusplus/bus.hpp>
33#include <string>
34#include <vector>
35
36#define SIZE_IANA_ID 3
37
38namespace ipmi
39{
Vijay Khemkaa7231892019-10-11 11:35:05 -070040
41using namespace phosphor::logging;
42
Vijay Khemkae7d23d02019-03-08 13:13:40 -080043static void registerOEMFunctions() __attribute__((constructor));
44sdbusplus::bus::bus dbus(ipmid_get_sd_bus_connection()); // from ipmid/api.h
45static constexpr size_t maxFRUStringLength = 0x3F;
46
Vijay Khemkacc0d6d92019-08-27 14:51:17 -070047int plat_udbg_get_post_desc(uint8_t, uint8_t *, uint8_t, uint8_t *, uint8_t *,
48 uint8_t *);
Vijay Khemka38183d62019-08-28 16:19:33 -070049int plat_udbg_get_gpio_desc(uint8_t, uint8_t *, uint8_t *, uint8_t *, uint8_t *,
50 uint8_t *);
Vijay Khemkae7d23d02019-03-08 13:13:40 -080051ipmi_ret_t plat_udbg_get_frame_data(uint8_t, uint8_t, uint8_t *, uint8_t *,
52 uint8_t *);
53ipmi_ret_t plat_udbg_control_panel(uint8_t, uint8_t, uint8_t, uint8_t *,
54 uint8_t *);
Vijay Khemkadd14c0f2020-03-18 14:48:13 -070055int sendMeCmd(uint8_t, uint8_t, std::vector<uint8_t> &, std::vector<uint8_t> &);
56
Vijay Khemka1b6fae32019-03-25 17:43:01 -070057namespace variant_ns = sdbusplus::message::variant_ns;
Vijay Khemkafeaa9812019-08-27 15:08:08 -070058nlohmann::json oemData __attribute__((init_priority(101)));
Vijay Khemka1b6fae32019-03-25 17:43:01 -070059
60enum class LanParam : uint8_t
61{
62 INPROGRESS = 0,
63 AUTHSUPPORT = 1,
64 AUTHENABLES = 2,
65 IP = 3,
66 IPSRC = 4,
67 MAC = 5,
68 SUBNET = 6,
69 GATEWAY = 12,
70 VLAN = 20,
71 CIPHER_SUITE_COUNT = 22,
72 CIPHER_SUITE_ENTRIES = 23,
73 IPV6 = 59,
74};
75
Vijay Khemkaa7231892019-10-11 11:35:05 -070076namespace network
77{
78
79constexpr auto ROOT = "/xyz/openbmc_project/network";
80constexpr auto SERVICE = "xyz.openbmc_project.Network";
81constexpr auto IPV4_TYPE = "ipv4";
82constexpr auto IPV6_TYPE = "ipv6";
83constexpr auto IPV4_PREFIX = "169.254";
84constexpr auto IPV6_PREFIX = "fe80";
85constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP";
86constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress";
87
88bool isLinkLocalIP(const std::string &address)
89{
90 return address.find(IPV4_PREFIX) == 0 || address.find(IPV6_PREFIX) == 0;
91}
92
93DbusObjectInfo getIPObject(sdbusplus::bus::bus &bus,
94 const std::string &interface,
95 const std::string &serviceRoot,
96 const std::string &match)
97{
98 auto objectTree = getAllDbusObjects(bus, serviceRoot, interface, match);
99
100 if (objectTree.empty())
101 {
102 log<level::ERR>("No Object has implemented the IP interface",
103 entry("INTERFACE=%s", interface.c_str()));
104 }
105
106 DbusObjectInfo objectInfo;
107
108 for (auto &object : objectTree)
109 {
110 auto variant =
111 ipmi::getDbusProperty(bus, object.second.begin()->first,
112 object.first, IP_INTERFACE, "Address");
113
114 objectInfo = std::make_pair(object.first, object.second.begin()->first);
115
116 // if LinkLocalIP found look for Non-LinkLocalIP
117 if (isLinkLocalIP(std::get<std::string>(variant)))
118 {
119 continue;
120 }
121 else
122 {
123 break;
124 }
125 }
126 return objectInfo;
127}
128
129} // namespace network
130
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700131//----------------------------------------------------------------------
132// Helper functions for storing oem data
133//----------------------------------------------------------------------
134
135void flushOemData()
136{
137 std::ofstream file(JSON_OEM_DATA_FILE);
138 file << oemData;
Vijay Khemkafeaa9812019-08-27 15:08:08 -0700139 file.close();
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700140 return;
141}
142
143std::string bytesToStr(uint8_t *byte, int len)
144{
145 std::stringstream ss;
146 int i;
147
148 ss << std::hex;
149 for (i = 0; i < len; i++)
150 {
151 ss << std::setw(2) << std::setfill('0') << (int)byte[i];
152 }
153
154 return ss.str();
155}
156
157int strToBytes(std::string &str, uint8_t *data)
158{
159 std::string sstr;
160 int i;
161
162 for (i = 0; i < (str.length()) / 2; i++)
163 {
164 sstr = str.substr(i * 2, 2);
165 data[i] = (uint8_t)std::strtol(sstr.c_str(), NULL, 16);
166 }
167 return i;
168}
169
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700170ipmi_ret_t getNetworkData(uint8_t lan_param, char *data)
171{
172 ipmi_ret_t rc = IPMI_CC_OK;
173 sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection());
174
175 const std::string ethdevice = "eth0";
176
177 switch (static_cast<LanParam>(lan_param))
178 {
179 case LanParam::IP:
180 {
Vijay Khemkaa7231892019-10-11 11:35:05 -0700181 auto ethIP = ethdevice + "/" + ipmi::network::IPV4_TYPE;
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700182 std::string ipaddress;
Vijay Khemkaa7231892019-10-11 11:35:05 -0700183 auto ipObjectInfo = ipmi::network::getIPObject(
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700184 bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT, ethIP);
185
186 auto properties = ipmi::getAllDbusProperties(
187 bus, ipObjectInfo.second, ipObjectInfo.first,
188 ipmi::network::IP_INTERFACE);
189
190 ipaddress = variant_ns::get<std::string>(properties["Address"]);
191
192 std::strcpy(data, ipaddress.c_str());
193 }
194 break;
195
196 case LanParam::IPV6:
197 {
Vijay Khemkaa7231892019-10-11 11:35:05 -0700198 auto ethIP = ethdevice + "/" + ipmi::network::IPV6_TYPE;
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700199 std::string ipaddress;
Vijay Khemkaa7231892019-10-11 11:35:05 -0700200 auto ipObjectInfo = ipmi::network::getIPObject(
Vijay Khemka1b6fae32019-03-25 17:43:01 -0700201 bus, ipmi::network::IP_INTERFACE, ipmi::network::ROOT, ethIP);
202
203 auto properties = ipmi::getAllDbusProperties(
204 bus, ipObjectInfo.second, ipObjectInfo.first,
205 ipmi::network::IP_INTERFACE);
206
207 ipaddress = variant_ns::get<std::string>(properties["Address"]);
208
209 std::strcpy(data, ipaddress.c_str());
210 }
211 break;
212
213 case LanParam::MAC:
214 {
215 std::string macAddress;
216 auto macObjectInfo =
217 ipmi::getDbusObject(bus, ipmi::network::MAC_INTERFACE,
218 ipmi::network::ROOT, ethdevice);
219
220 auto variant = ipmi::getDbusProperty(
221 bus, macObjectInfo.second, macObjectInfo.first,
222 ipmi::network::MAC_INTERFACE, "MACAddress");
223
224 macAddress = variant_ns::get<std::string>(variant);
225
226 sscanf(macAddress.c_str(), ipmi::network::MAC_ADDRESS_FORMAT,
227 (data), (data + 1), (data + 2), (data + 3), (data + 4),
228 (data + 5));
229 std::strcpy(data, macAddress.c_str());
230 }
231 break;
232
233 default:
234 rc = IPMI_CC_PARM_OUT_OF_RANGE;
235 }
236 return rc;
237}
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800238
239// return code: 0 successful
240int8_t getFruData(std::string &data, std::string &name)
241{
242 std::string objpath = "/xyz/openbmc_project/FruDevice";
243 std::string intf = "xyz.openbmc_project.FruDeviceManager";
244 std::string service = getService(dbus, intf, objpath);
245 ObjectValueTree valueTree = getManagedObjects(dbus, service, "/");
246 if (valueTree.empty())
247 {
248 phosphor::logging::log<phosphor::logging::level::ERR>(
249 "No object implements interface",
250 phosphor::logging::entry("INTF=%s", intf.c_str()));
251 return -1;
252 }
253
254 for (const auto &item : valueTree)
255 {
256 auto interface = item.second.find("xyz.openbmc_project.FruDevice");
257 if (interface == item.second.end())
258 {
259 continue;
260 }
261
262 auto property = interface->second.find(name.c_str());
263 if (property == interface->second.end())
264 {
265 continue;
266 }
267
268 try
269 {
270 Value variant = property->second;
271 std::string &result =
272 sdbusplus::message::variant_ns::get<std::string>(variant);
273 if (result.size() > maxFRUStringLength)
274 {
275 phosphor::logging::log<phosphor::logging::level::ERR>(
276 "FRU serial number exceed maximum length");
277 return -1;
278 }
279 data = result;
280 return 0;
281 }
282 catch (sdbusplus::message::variant_ns::bad_variant_access &e)
283 {
284 phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
285 return -1;
286 }
287 }
288 return -1;
289}
290
291typedef struct
292{
293 uint8_t cur_power_state;
294 uint8_t last_power_event;
295 uint8_t misc_power_state;
296 uint8_t front_panel_button_cap_status;
297} ipmi_get_chassis_status_t;
298
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800299//----------------------------------------------------------------------
300// Get Debug Frame Info
301//----------------------------------------------------------------------
302ipmi_ret_t ipmiOemDbgGetFrameInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
303 ipmi_request_t request,
304 ipmi_response_t response,
305 ipmi_data_len_t data_len,
306 ipmi_context_t context)
307{
308 uint8_t *req = reinterpret_cast<uint8_t *>(request);
309 uint8_t *res = reinterpret_cast<uint8_t *>(response);
310 uint8_t num_frames = 3;
311
312 std::memcpy(res, req, SIZE_IANA_ID); // IANA ID
313 res[SIZE_IANA_ID] = num_frames;
314 *data_len = SIZE_IANA_ID + 1;
315
316 return IPMI_CC_OK;
317}
318
319//----------------------------------------------------------------------
320// Get Debug Updated Frames
321//----------------------------------------------------------------------
322ipmi_ret_t ipmiOemDbgGetUpdFrames(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
323 ipmi_request_t request,
324 ipmi_response_t response,
325 ipmi_data_len_t data_len,
326 ipmi_context_t context)
327{
328 uint8_t *req = reinterpret_cast<uint8_t *>(request);
329 uint8_t *res = reinterpret_cast<uint8_t *>(response);
330 uint8_t num_updates = 3;
331 *data_len = 4;
332
333 std::memcpy(res, req, SIZE_IANA_ID); // IANA ID
334 res[SIZE_IANA_ID] = num_updates;
335 *data_len = SIZE_IANA_ID + num_updates + 1;
336 res[SIZE_IANA_ID + 1] = 1; // info page update
337 res[SIZE_IANA_ID + 2] = 2; // cri sel update
338 res[SIZE_IANA_ID + 3] = 3; // cri sensor update
339
340 return IPMI_CC_OK;
341}
342
343//----------------------------------------------------------------------
344// Get Debug POST Description
345//----------------------------------------------------------------------
346ipmi_ret_t ipmiOemDbgGetPostDesc(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
347 ipmi_request_t request,
348 ipmi_response_t response,
349 ipmi_data_len_t data_len,
350 ipmi_context_t context)
351{
352 uint8_t *req = reinterpret_cast<uint8_t *>(request);
353 uint8_t *res = reinterpret_cast<uint8_t *>(response);
354 uint8_t index = 0;
355 uint8_t next = 0;
356 uint8_t end = 0;
357 uint8_t phase = 0;
Vijay Khemkacc0d6d92019-08-27 14:51:17 -0700358 uint8_t descLen = 0;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800359 int ret;
360
361 index = req[3];
362 phase = req[4];
363
Vijay Khemkacc0d6d92019-08-27 14:51:17 -0700364 ret = plat_udbg_get_post_desc(index, &next, phase, &end, &descLen, &res[8]);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800365 if (ret)
366 {
367 memcpy(res, req, SIZE_IANA_ID); // IANA ID
368 *data_len = SIZE_IANA_ID;
369 return IPMI_CC_UNSPECIFIED_ERROR;
370 }
371
372 memcpy(res, req, SIZE_IANA_ID); // IANA ID
373 res[3] = index;
374 res[4] = next;
375 res[5] = phase;
376 res[6] = end;
Vijay Khemkacc0d6d92019-08-27 14:51:17 -0700377 res[7] = descLen;
378 *data_len = SIZE_IANA_ID + 5 + descLen;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800379
380 return IPMI_CC_OK;
381}
382
383//----------------------------------------------------------------------
384// Get Debug GPIO Description
385//----------------------------------------------------------------------
386ipmi_ret_t ipmiOemDbgGetGpioDesc(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
387 ipmi_request_t request,
388 ipmi_response_t response,
389 ipmi_data_len_t data_len,
390 ipmi_context_t context)
391{
392 uint8_t *req = reinterpret_cast<uint8_t *>(request);
393 uint8_t *res = reinterpret_cast<uint8_t *>(response);
394
Vijay Khemka38183d62019-08-28 16:19:33 -0700395 uint8_t index = 0;
396 uint8_t next = 0;
397 uint8_t level = 0;
398 uint8_t pinDef = 0;
399 uint8_t descLen = 0;
400 int ret;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800401
Vijay Khemka38183d62019-08-28 16:19:33 -0700402 index = req[3];
403
404 ret = plat_udbg_get_gpio_desc(index, &next, &level, &pinDef, &descLen,
405 &res[8]);
406 if (ret)
407 {
408 memcpy(res, req, SIZE_IANA_ID); // IANA ID
409 *data_len = SIZE_IANA_ID;
410 return IPMI_CC_UNSPECIFIED_ERROR;
411 }
412
413 memcpy(res, req, SIZE_IANA_ID); // IANA ID
414 res[3] = index;
415 res[4] = next;
416 res[5] = level;
417 res[6] = pinDef;
418 res[7] = descLen;
419 *data_len = SIZE_IANA_ID + 5 + descLen;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800420
421 return IPMI_CC_OK;
422}
423
424//----------------------------------------------------------------------
425// Get Debug Frame Data
426//----------------------------------------------------------------------
427ipmi_ret_t ipmiOemDbgGetFrameData(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
428 ipmi_request_t request,
429 ipmi_response_t response,
430 ipmi_data_len_t data_len,
431 ipmi_context_t context)
432{
433 uint8_t *req = reinterpret_cast<uint8_t *>(request);
434 uint8_t *res = reinterpret_cast<uint8_t *>(response);
435 uint8_t frame;
436 uint8_t page;
437 uint8_t next;
438 uint8_t count;
439 int ret;
440
441 frame = req[3];
442 page = req[4];
443 int fr = frame;
444 int pg = page;
445
446 ret = plat_udbg_get_frame_data(frame, page, &next, &count, &res[7]);
447 if (ret)
448 {
449 memcpy(res, req, SIZE_IANA_ID); // IANA ID
450 *data_len = SIZE_IANA_ID;
451 return IPMI_CC_UNSPECIFIED_ERROR;
452 }
453
454 memcpy(res, req, SIZE_IANA_ID); // IANA ID
455 res[3] = frame;
456 res[4] = page;
457 res[5] = next;
458 res[6] = count;
459 *data_len = SIZE_IANA_ID + 4 + count;
460
461 return IPMI_CC_OK;
462}
463
464//----------------------------------------------------------------------
465// Get Debug Control Panel
466//----------------------------------------------------------------------
467ipmi_ret_t ipmiOemDbgGetCtrlPanel(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
468 ipmi_request_t request,
469 ipmi_response_t response,
470 ipmi_data_len_t data_len,
471 ipmi_context_t context)
472{
473 uint8_t *req = reinterpret_cast<uint8_t *>(request);
474 uint8_t *res = reinterpret_cast<uint8_t *>(response);
475
476 uint8_t panel;
477 uint8_t operation;
478 uint8_t item;
479 uint8_t count;
480 ipmi_ret_t ret;
481
482 panel = req[3];
483 operation = req[4];
484 item = req[5];
485
486 ret = plat_udbg_control_panel(panel, operation, item, &count, &res[3]);
487
488 std::memcpy(res, req, SIZE_IANA_ID); // IANA ID
489 *data_len = SIZE_IANA_ID + count;
490
491 return ret;
492}
493
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800494//----------------------------------------------------------------------
495// Set Dimm Info (CMD_OEM_SET_DIMM_INFO)
496//----------------------------------------------------------------------
497ipmi_ret_t ipmiOemSetDimmInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
498 ipmi_request_t request, ipmi_response_t response,
499 ipmi_data_len_t data_len, ipmi_context_t context)
500{
501 uint8_t *req = reinterpret_cast<uint8_t *>(request);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700502
503 uint8_t index = req[0];
504 uint8_t type = req[1];
505 uint16_t speed;
506 uint32_t size;
507
508 memcpy(&speed, &req[2], 2);
509 memcpy(&size, &req[4], 4);
510
511 std::stringstream ss;
512 ss << std::hex;
513 ss << std::setw(2) << std::setfill('0') << (int)index;
514
515 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_INDEX] = index;
516 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_TYPE] = type;
517 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_SPEED] = speed;
518 oemData[KEY_SYS_CONFIG][ss.str()][KEY_DIMM_SIZE] = size;
519
520 flushOemData();
521
522 *data_len = 0;
523
524 return IPMI_CC_OK;
525}
526
527//----------------------------------------------------------------------
528// Get Board ID (CMD_OEM_GET_BOARD_ID)
529//----------------------------------------------------------------------
530ipmi_ret_t ipmiOemGetBoardID(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
531 ipmi_request_t request, ipmi_response_t response,
532 ipmi_data_len_t data_len, ipmi_context_t context)
533{
534 uint8_t *req = reinterpret_cast<uint8_t *>(request);
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800535 uint8_t *res = reinterpret_cast<uint8_t *>(response);
536
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700537 /* TODO: Needs to implement this after GPIO implementation */
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800538 *data_len = 0;
539
540 return IPMI_CC_OK;
541}
542
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800543/* Helper functions to set boot order */
544void setBootOrder(uint8_t *data)
545{
546 nlohmann::json bootMode;
547 uint8_t mode = data[0];
548 int i;
549
550 bootMode["UEFI"] = (mode & BOOT_MODE_UEFI ? true : false);
551 bootMode["CMOS_CLR"] = (mode & BOOT_MODE_CMOS_CLR ? true : false);
552 bootMode["FORCE_BOOT"] = (mode & BOOT_MODE_FORCE_BOOT ? true : false);
553 bootMode["BOOT_FLAG"] = (mode & BOOT_MODE_BOOT_FLAG ? true : false);
554 oemData[KEY_BOOT_ORDER][KEY_BOOT_MODE] = bootMode;
555
556 /* Initialize boot sequence array */
557 oemData[KEY_BOOT_ORDER][KEY_BOOT_SEQ] = {};
558 for (i = 1; i < SIZE_BOOT_ORDER; i++)
559 {
560 if (data[i] >= BOOT_SEQ_ARRAY_SIZE)
561 oemData[KEY_BOOT_ORDER][KEY_BOOT_SEQ][i - 1] = "NA";
562 else
563 oemData[KEY_BOOT_ORDER][KEY_BOOT_SEQ][i - 1] = bootSeq[data[i]];
564 }
565
566 flushOemData();
567}
568
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800569//----------------------------------------------------------------------
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700570// Set Boot Order (CMD_OEM_SET_BOOT_ORDER)
571//----------------------------------------------------------------------
572ipmi_ret_t ipmiOemSetBootOrder(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
573 ipmi_request_t request, ipmi_response_t response,
574 ipmi_data_len_t data_len, ipmi_context_t context)
575{
576 uint8_t *req = reinterpret_cast<uint8_t *>(request);
577 uint8_t len = *data_len;
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700578
579 *data_len = 0;
580
581 if (len != SIZE_BOOT_ORDER)
582 {
583 phosphor::logging::log<phosphor::logging::level::ERR>(
584 "Invalid Boot order length received");
585 return IPMI_CC_REQ_DATA_LEN_INVALID;
586 }
587
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800588 setBootOrder(req);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700589
590 return IPMI_CC_OK;
591}
592
593//----------------------------------------------------------------------
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800594// Get Boot Order (CMD_OEM_GET_BOOT_ORDER)
595//----------------------------------------------------------------------
596ipmi_ret_t ipmiOemGetBootOrder(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
597 ipmi_request_t request, ipmi_response_t response,
598 ipmi_data_len_t data_len, ipmi_context_t context)
599{
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800600 uint8_t *res = reinterpret_cast<uint8_t *>(response);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700601 uint8_t mode = 0;
602 int i;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800603
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700604 *data_len = SIZE_BOOT_ORDER;
605
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800606 if (oemData.find(KEY_BOOT_ORDER) == oemData.end())
607 {
608 /* Return default boot order 0100090203ff */
609 uint8_t defaultBoot[SIZE_BOOT_ORDER] = {
610 BOOT_MODE_UEFI, bootMap["USB_DEV"], bootMap["NET_IPV6"],
611 bootMap["SATA_HDD"], bootMap["SATA_CD"], 0xff};
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700612
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800613 memcpy(res, defaultBoot, SIZE_BOOT_ORDER);
614 phosphor::logging::log<phosphor::logging::level::INFO>(
615 "Set default boot order");
616 setBootOrder(defaultBoot);
617 }
618 else
619 {
620 nlohmann::json bootMode = oemData[KEY_BOOT_ORDER][KEY_BOOT_MODE];
621 if (bootMode["UEFI"])
622 mode |= BOOT_MODE_UEFI;
623 if (bootMode["CMOS_CLR"])
624 mode |= BOOT_MODE_CMOS_CLR;
625 if (bootMode["BOOT_FLAG"])
626 mode |= BOOT_MODE_BOOT_FLAG;
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700627
Vijay Khemka877d5dd2019-12-16 14:46:21 -0800628 res[0] = mode;
629
630 for (i = 1; i < SIZE_BOOT_ORDER; i++)
631 {
632 std::string seqStr = oemData[KEY_BOOT_ORDER][KEY_BOOT_SEQ][i - 1];
633 if (bootMap.find(seqStr) != bootMap.end())
634 res[i] = bootMap[seqStr];
635 else
636 res[i] = 0xff;
637 }
638 }
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800639
640 return IPMI_CC_OK;
641}
642
643//----------------------------------------------------------------------
644// Set Machine Config Info (CMD_OEM_SET_MACHINE_CONFIG_INFO)
645//----------------------------------------------------------------------
646ipmi_ret_t ipmiOemSetMachineCfgInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
647 ipmi_request_t request,
648 ipmi_response_t response,
649 ipmi_data_len_t data_len,
650 ipmi_context_t context)
651{
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700652 machineConfigInfo_t *req = reinterpret_cast<machineConfigInfo_t *>(request);
653 uint8_t len = *data_len;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800654
655 *data_len = 0;
656
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700657 if (len < sizeof(machineConfigInfo_t))
658 {
659 phosphor::logging::log<phosphor::logging::level::ERR>(
660 "Invalid machine configuration length received");
661 return IPMI_CC_REQ_DATA_LEN_INVALID;
662 }
663
664 if (req->chassis_type >= sizeof(chassisType) / sizeof(uint8_t *))
665 oemData[KEY_MC_CONFIG][KEY_MC_CHAS_TYPE] = "UNKNOWN";
666 else
667 oemData[KEY_MC_CONFIG][KEY_MC_CHAS_TYPE] =
668 chassisType[req->chassis_type];
669
670 if (req->mb_type >= sizeof(mbType) / sizeof(uint8_t *))
671 oemData[KEY_MC_CONFIG][KEY_MC_MB_TYPE] = "UNKNOWN";
672 else
673 oemData[KEY_MC_CONFIG][KEY_MC_MB_TYPE] = mbType[req->mb_type];
674
675 oemData[KEY_MC_CONFIG][KEY_MC_PROC_CNT] = req->proc_cnt;
676 oemData[KEY_MC_CONFIG][KEY_MC_MEM_CNT] = req->mem_cnt;
677 oemData[KEY_MC_CONFIG][KEY_MC_HDD35_CNT] = req->hdd35_cnt;
678 oemData[KEY_MC_CONFIG][KEY_MC_HDD25_CNT] = req->hdd25_cnt;
679
680 if (req->riser_type >= sizeof(riserType) / sizeof(uint8_t *))
681 oemData[KEY_MC_CONFIG][KEY_MC_RSR_TYPE] = "UNKNOWN";
682 else
683 oemData[KEY_MC_CONFIG][KEY_MC_RSR_TYPE] = riserType[req->riser_type];
684
685 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC] = {};
686 int i = 0;
687 if (req->pcie_card_loc & BIT_0)
688 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT1";
689 if (req->pcie_card_loc & BIT_1)
690 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT2";
691 if (req->pcie_card_loc & BIT_2)
692 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT3";
693 if (req->pcie_card_loc & BIT_3)
694 oemData[KEY_MC_CONFIG][KEY_MC_PCIE_LOC][i++] = "SLOT4";
695
696 if (req->slot1_pcie_type >= sizeof(pcieType) / sizeof(uint8_t *))
697 oemData[KEY_MC_CONFIG][KEY_MC_SLOT1_TYPE] = "UNKNOWN";
698 else
699 oemData[KEY_MC_CONFIG][KEY_MC_SLOT1_TYPE] =
700 pcieType[req->slot1_pcie_type];
701
702 if (req->slot2_pcie_type >= sizeof(pcieType) / sizeof(uint8_t *))
703 oemData[KEY_MC_CONFIG][KEY_MC_SLOT2_TYPE] = "UNKNOWN";
704 else
705 oemData[KEY_MC_CONFIG][KEY_MC_SLOT2_TYPE] =
706 pcieType[req->slot2_pcie_type];
707
708 if (req->slot3_pcie_type >= sizeof(pcieType) / sizeof(uint8_t *))
709 oemData[KEY_MC_CONFIG][KEY_MC_SLOT3_TYPE] = "UNKNOWN";
710 else
711 oemData[KEY_MC_CONFIG][KEY_MC_SLOT3_TYPE] =
712 pcieType[req->slot3_pcie_type];
713
714 if (req->slot4_pcie_type >= sizeof(pcieType) / sizeof(uint8_t *))
715 oemData[KEY_MC_CONFIG][KEY_MC_SLOT4_TYPE] = "UNKNOWN";
716 else
717 oemData[KEY_MC_CONFIG][KEY_MC_SLOT4_TYPE] =
718 pcieType[req->slot4_pcie_type];
719
720 oemData[KEY_MC_CONFIG][KEY_MC_AEP_CNT] = req->aep_mem_cnt;
721
722 flushOemData();
723
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800724 return IPMI_CC_OK;
725}
726
727//----------------------------------------------------------------------
728// Set POST start (CMD_OEM_SET_POST_START)
729//----------------------------------------------------------------------
730ipmi_ret_t ipmiOemSetPostStart(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
731 ipmi_request_t request, ipmi_response_t response,
732 ipmi_data_len_t data_len, ipmi_context_t context)
733{
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800734 phosphor::logging::log<phosphor::logging::level::INFO>("POST Start Event");
735
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700736 /* Do nothing, return success */
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800737 *data_len = 0;
738 return IPMI_CC_OK;
739}
740
741//----------------------------------------------------------------------
742// Set POST End (CMD_OEM_SET_POST_END)
743//----------------------------------------------------------------------
744ipmi_ret_t ipmiOemSetPostEnd(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
745 ipmi_request_t request, ipmi_response_t response,
746 ipmi_data_len_t data_len, ipmi_context_t context)
747{
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700748 struct timespec ts;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800749
750 phosphor::logging::log<phosphor::logging::level::INFO>("POST End Event");
751
752 *data_len = 0;
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700753
754 // Timestamp post end time.
755 clock_gettime(CLOCK_REALTIME, &ts);
756 oemData[KEY_TS_SLED] = ts.tv_sec;
757 flushOemData();
758
759 // Sync time with system
760 // TODO: Add code for syncing time
761
762 return IPMI_CC_OK;
763}
764
765//----------------------------------------------------------------------
766// Set PPIN Info (CMD_OEM_SET_PPIN_INFO)
767//----------------------------------------------------------------------
768// Inform BMC about PPIN data of 8 bytes for each CPU
769//
770// Request:
771// Byte 1:8 – CPU0 PPIN data
772// Optional:
773// Byte 9:16 – CPU1 PPIN data
774//
775// Response:
776// Byte 1 – Completion Code
777ipmi_ret_t ipmiOemSetPPINInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
778 ipmi_request_t request, ipmi_response_t response,
779 ipmi_data_len_t data_len, ipmi_context_t context)
780{
781 uint8_t *req = reinterpret_cast<uint8_t *>(request);
782 std::string ppinStr;
783 int len;
784
785 if (*data_len > SIZE_CPU_PPIN * 2)
786 len = SIZE_CPU_PPIN * 2;
787 else
788 len = *data_len;
789 *data_len = 0;
790
791 ppinStr = bytesToStr(req, len);
792 oemData[KEY_PPIN_INFO] = ppinStr.c_str();
793 flushOemData();
794
795 return IPMI_CC_OK;
796}
797
798//----------------------------------------------------------------------
799// Set ADR Trigger (CMD_OEM_SET_ADR_TRIGGER)
800//----------------------------------------------------------------------
801ipmi_ret_t ipmiOemSetAdrTrigger(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
802 ipmi_request_t request,
803 ipmi_response_t response,
804 ipmi_data_len_t data_len,
805 ipmi_context_t context)
806{
807 /* Do nothing, return success */
808 *data_len = 0;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800809 return IPMI_CC_OK;
810}
811
812//----------------------------------------------------------------------
813// Set Bios Flash Info (CMD_OEM_SET_BIOS_FLASH_INFO)
814//----------------------------------------------------------------------
815ipmi_ret_t ipmiOemSetBiosFlashInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
816 ipmi_request_t request,
817 ipmi_response_t response,
818 ipmi_data_len_t data_len,
819 ipmi_context_t context)
820{
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700821 /* Do nothing, return success */
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800822 *data_len = 0;
823 return IPMI_CC_OK;
824}
825
826//----------------------------------------------------------------------
827// Set PPR (CMD_OEM_SET_PPR)
828//----------------------------------------------------------------------
829ipmi_ret_t ipmiOemSetPpr(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
830 ipmi_request_t request, ipmi_response_t response,
831 ipmi_data_len_t data_len, ipmi_context_t context)
832{
833 uint8_t *req = reinterpret_cast<uint8_t *>(request);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700834 uint8_t pprCnt, pprAct, pprIndex;
835 uint8_t selParam = req[0];
836 uint8_t len = *data_len;
837 std::stringstream ss;
838 std::string str;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800839
840 *data_len = 0;
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700841
842 switch (selParam)
843 {
844 case PPR_ACTION:
845 if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) ==
846 oemData[KEY_PPR].end())
847 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
848
849 pprCnt = oemData[KEY_PPR][KEY_PPR_ROW_COUNT];
850 if (pprCnt == 0)
851 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
852
853 pprAct = req[1];
854 /* Check if ppr is enabled or disabled */
855 if (!(pprAct & 0x80))
856 pprAct = 0;
857
858 oemData[KEY_PPR][KEY_PPR_ACTION] = pprAct;
859 break;
860 case PPR_ROW_COUNT:
861 if (req[1] > 100)
862 return IPMI_CC_PARM_OUT_OF_RANGE;
863
864 oemData[KEY_PPR][KEY_PPR_ROW_COUNT] = req[1];
865 break;
866 case PPR_ROW_ADDR:
867 pprIndex = req[1];
868 if (pprIndex > 100)
869 return IPMI_CC_PARM_OUT_OF_RANGE;
870
871 if (len < PPR_ROW_ADDR_LEN + 1)
872 {
873 phosphor::logging::log<phosphor::logging::level::ERR>(
874 "Invalid PPR Row Address length received");
875 return IPMI_CC_REQ_DATA_LEN_INVALID;
876 }
877
878 ss << std::hex;
879 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
880
881 oemData[KEY_PPR][ss.str()][KEY_PPR_INDEX] = pprIndex;
882
883 str = bytesToStr(&req[1], PPR_ROW_ADDR_LEN);
884 oemData[KEY_PPR][ss.str()][KEY_PPR_ROW_ADDR] = str.c_str();
885 break;
886 case PPR_HISTORY_DATA:
887 pprIndex = req[1];
888 if (pprIndex > 100)
889 return IPMI_CC_PARM_OUT_OF_RANGE;
890
891 if (len < PPR_HST_DATA_LEN + 1)
892 {
893 phosphor::logging::log<phosphor::logging::level::ERR>(
894 "Invalid PPR history data length received");
895 return IPMI_CC_REQ_DATA_LEN_INVALID;
896 }
897
898 ss << std::hex;
899 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
900
901 oemData[KEY_PPR][ss.str()][KEY_PPR_INDEX] = pprIndex;
902
903 str = bytesToStr(&req[1], PPR_HST_DATA_LEN);
904 oemData[KEY_PPR][ss.str()][KEY_PPR_HST_DATA] = str.c_str();
905 break;
906 default:
907 return IPMI_CC_PARM_OUT_OF_RANGE;
908 break;
909 }
910
911 flushOemData();
912
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800913 return IPMI_CC_OK;
914}
915
916//----------------------------------------------------------------------
917// Get PPR (CMD_OEM_GET_PPR)
918//----------------------------------------------------------------------
919ipmi_ret_t ipmiOemGetPpr(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
920 ipmi_request_t request, ipmi_response_t response,
921 ipmi_data_len_t data_len, ipmi_context_t context)
922{
923 uint8_t *req = reinterpret_cast<uint8_t *>(request);
924 uint8_t *res = reinterpret_cast<uint8_t *>(response);
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700925 uint8_t pprCnt, pprIndex;
926 uint8_t selParam = req[0];
927 std::stringstream ss;
928 std::string str;
Vijay Khemkae7d23d02019-03-08 13:13:40 -0800929
Vijay Khemka1d4a0692019-04-09 15:20:28 -0700930 /* Any failure will return zero length data */
931 *data_len = 0;
932
933 switch (selParam)
934 {
935 case PPR_ACTION:
936 res[0] = 0;
937 *data_len = 1;
938
939 if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) !=
940 oemData[KEY_PPR].end())
941 {
942 pprCnt = oemData[KEY_PPR][KEY_PPR_ROW_COUNT];
943 if (pprCnt != 0)
944 {
945 if (oemData[KEY_PPR].find(KEY_PPR_ACTION) !=
946 oemData[KEY_PPR].end())
947 {
948 res[0] = oemData[KEY_PPR][KEY_PPR_ACTION];
949 }
950 }
951 }
952 break;
953 case PPR_ROW_COUNT:
954 res[0] = 0;
955 *data_len = 1;
956 if (oemData[KEY_PPR].find(KEY_PPR_ROW_COUNT) !=
957 oemData[KEY_PPR].end())
958 res[0] = oemData[KEY_PPR][KEY_PPR_ROW_COUNT];
959 break;
960 case PPR_ROW_ADDR:
961 pprIndex = req[1];
962 if (pprIndex > 100)
963 return IPMI_CC_PARM_OUT_OF_RANGE;
964
965 ss << std::hex;
966 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
967
968 if (oemData[KEY_PPR].find(ss.str()) == oemData[KEY_PPR].end())
969 return IPMI_CC_PARM_OUT_OF_RANGE;
970
971 if (oemData[KEY_PPR][ss.str()].find(KEY_PPR_ROW_ADDR) ==
972 oemData[KEY_PPR][ss.str()].end())
973 return IPMI_CC_PARM_OUT_OF_RANGE;
974
975 str = oemData[KEY_PPR][ss.str()][KEY_PPR_ROW_ADDR];
976 *data_len = strToBytes(str, res);
977 break;
978 case PPR_HISTORY_DATA:
979 pprIndex = req[1];
980 if (pprIndex > 100)
981 return IPMI_CC_PARM_OUT_OF_RANGE;
982
983 ss << std::hex;
984 ss << std::setw(2) << std::setfill('0') << (int)pprIndex;
985
986 if (oemData[KEY_PPR].find(ss.str()) == oemData[KEY_PPR].end())
987 return IPMI_CC_PARM_OUT_OF_RANGE;
988
989 if (oemData[KEY_PPR][ss.str()].find(KEY_PPR_HST_DATA) ==
990 oemData[KEY_PPR][ss.str()].end())
991 return IPMI_CC_PARM_OUT_OF_RANGE;
992
993 str = oemData[KEY_PPR][ss.str()][KEY_PPR_HST_DATA];
994 *data_len = strToBytes(str, res);
995 break;
996 default:
997 return IPMI_CC_PARM_OUT_OF_RANGE;
998 break;
999 }
1000
1001 return IPMI_CC_OK;
1002}
1003
1004/* FB OEM QC Commands */
1005
1006//----------------------------------------------------------------------
1007// Set Proc Info (CMD_OEM_Q_SET_PROC_INFO)
1008//----------------------------------------------------------------------
1009//"Request:
1010// Byte 1:3 – Manufacturer ID – XXYYZZ h, LSB first
1011// Byte 4 – Processor Index, 0 base
1012// Byte 5 – Parameter Selector
1013// Byte 6..N – Configuration parameter data (see below for Parameters
1014// of Processor Information)
1015// Response:
1016// Byte 1 – Completion code
1017//
1018// Parameter#1: (Processor Product Name)
1019//
1020// Byte 1..48 –Product name(ASCII code)
1021// Ex. Intel(R) Xeon(R) CPU E5-2685 v3 @ 2.60GHz
1022//
1023// Param#2: Processor Basic Information
1024// Byte 1 – Core Number
1025// Byte 2 – Thread Number (LSB)
1026// Byte 3 – Thread Number (MSB)
1027// Byte 4 – Processor frequency in MHz (LSB)
1028// Byte 5 – Processor frequency in MHz (MSB)
1029// Byte 6..7 – Revision
1030//
1031ipmi_ret_t ipmiOemQSetProcInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
1032 ipmi_request_t request, ipmi_response_t response,
1033 ipmi_data_len_t data_len, ipmi_context_t context)
1034{
1035 qProcInfo_t *req = reinterpret_cast<qProcInfo_t *>(request);
1036 uint8_t numParam = sizeof(cpuInfoKey) / sizeof(uint8_t *);
1037 std::stringstream ss;
1038 std::string str;
1039 uint8_t len = *data_len;
1040
1041 *data_len = 0;
1042
1043 /* check for requested data params */
1044 if (len < 5 || req->paramSel < 1 || req->paramSel >= numParam)
1045 {
1046 phosphor::logging::log<phosphor::logging::level::ERR>(
1047 "Invalid parameter received");
1048 return IPMI_CC_PARM_OUT_OF_RANGE;
1049 }
1050
1051 len = len - 5; // Get Actual data length
1052
1053 ss << std::hex;
1054 ss << std::setw(2) << std::setfill('0') << (int)req->procIndex;
1055 oemData[KEY_Q_PROC_INFO][ss.str()][KEY_PROC_INDEX] = req->procIndex;
1056
1057 str = bytesToStr(req->data, len);
1058 oemData[KEY_Q_PROC_INFO][ss.str()][cpuInfoKey[req->paramSel]] = str.c_str();
1059 flushOemData();
1060
1061 return IPMI_CC_OK;
1062}
1063
1064//----------------------------------------------------------------------
1065// Get Proc Info (CMD_OEM_Q_GET_PROC_INFO)
1066//----------------------------------------------------------------------
1067// Request:
1068// Byte 1:3 – Manufacturer ID – XXYYZZ h, LSB first
1069// Byte 4 – Processor Index, 0 base
1070// Byte 5 – Parameter Selector
1071// Response:
1072// Byte 1 – Completion code
1073// Byte 2..N – Configuration Parameter Data (see below for Parameters
1074// of Processor Information)
1075//
1076// Parameter#1: (Processor Product Name)
1077//
1078// Byte 1..48 –Product name(ASCII code)
1079// Ex. Intel(R) Xeon(R) CPU E5-2685 v3 @ 2.60GHz
1080//
1081// Param#2: Processor Basic Information
1082// Byte 1 – Core Number
1083// Byte 2 – Thread Number (LSB)
1084// Byte 3 – Thread Number (MSB)
1085// Byte 4 – Processor frequency in MHz (LSB)
1086// Byte 5 – Processor frequency in MHz (MSB)
1087// Byte 6..7 – Revision
1088//
1089ipmi_ret_t ipmiOemQGetProcInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
1090 ipmi_request_t request, ipmi_response_t response,
1091 ipmi_data_len_t data_len, ipmi_context_t context)
1092{
1093 qProcInfo_t *req = reinterpret_cast<qProcInfo_t *>(request);
1094 uint8_t numParam = sizeof(cpuInfoKey) / sizeof(uint8_t *);
1095 uint8_t *res = reinterpret_cast<uint8_t *>(response);
1096 std::stringstream ss;
1097 std::string str;
1098
1099 *data_len = 0;
1100
1101 /* check for requested data params */
1102 if (req->paramSel < 1 || req->paramSel >= numParam)
1103 {
1104 phosphor::logging::log<phosphor::logging::level::ERR>(
1105 "Invalid parameter received");
1106 return IPMI_CC_PARM_OUT_OF_RANGE;
1107 }
1108
1109 ss << std::hex;
1110 ss << std::setw(2) << std::setfill('0') << (int)req->procIndex;
1111
1112 if (oemData[KEY_Q_PROC_INFO].find(ss.str()) ==
1113 oemData[KEY_Q_PROC_INFO].end())
1114 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1115
1116 if (oemData[KEY_Q_PROC_INFO][ss.str()].find(cpuInfoKey[req->paramSel]) ==
1117 oemData[KEY_Q_PROC_INFO][ss.str()].end())
1118 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1119
1120 str = oemData[KEY_Q_PROC_INFO][ss.str()][cpuInfoKey[req->paramSel]];
1121 *data_len = strToBytes(str, res);
1122
1123 return IPMI_CC_OK;
1124}
1125
1126//----------------------------------------------------------------------
1127// Set Dimm Info (CMD_OEM_Q_SET_DIMM_INFO)
1128//----------------------------------------------------------------------
1129// Request:
1130// Byte 1:3 – Manufacturer ID – XXYYZZh, LSB first
1131// Byte 4 – DIMM Index, 0 base
1132// Byte 5 – Parameter Selector
1133// Byte 6..N – Configuration parameter data (see below for Parameters
1134// of DIMM Information)
1135// Response:
1136// Byte 1 – Completion code
1137//
1138// Param#1 (DIMM Location):
1139// Byte 1 – DIMM Present
1140// Byte 1 – DIMM Present
1141// 01h – Present
1142// FFh – Not Present
1143// Byte 2 – Node Number, 0 base
1144// Byte 3 – Channel Number , 0 base
1145// Byte 4 – DIMM Number , 0 base
1146//
1147// Param#2 (DIMM Type):
1148// Byte 1 – DIMM Type
1149// Bit [7:6]
1150// For DDR3
1151// 00 – Normal Voltage (1.5V)
1152// 01 – Ultra Low Voltage (1.25V)
1153// 10 – Low Voltage (1.35V)
1154// 11 – Reserved
1155// For DDR4
1156// 00 – Reserved
1157// 01 – Reserved
1158// 10 – Reserved
1159// 11 – Normal Voltage (1.2V)
1160// Bit [5:0]
1161// 0x00 – SDRAM
1162// 0x01 – DDR-1 RAM
1163// 0x02 – Rambus
1164// 0x03 – DDR-2 RAM
1165// 0x04 – FBDIMM
1166// 0x05 – DDR-3 RAM
1167// 0x06 – DDR-4 RAM
1168//
1169// Param#3 (DIMM Speed):
1170// Byte 1..2 – DIMM speed in MHz, LSB
1171// Byte 3..6 – DIMM size in Mbytes, LSB
1172//
1173// Param#4 (Module Part Number):
1174// Byte 1..20 –Module Part Number (JEDEC Standard No. 21-C)
1175//
1176// Param#5 (Module Serial Number):
1177// Byte 1..4 –Module Serial Number (JEDEC Standard No. 21-C)
1178//
1179// Param#6 (Module Manufacturer ID):
1180// Byte 1 - Module Manufacturer ID, LSB
1181// Byte 2 - Module Manufacturer ID, MSB
1182//
1183ipmi_ret_t ipmiOemQSetDimmInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
1184 ipmi_request_t request, ipmi_response_t response,
1185 ipmi_data_len_t data_len, ipmi_context_t context)
1186{
1187 qDimmInfo_t *req = reinterpret_cast<qDimmInfo_t *>(request);
1188 uint8_t numParam = sizeof(dimmInfoKey) / sizeof(uint8_t *);
1189 std::stringstream ss;
1190 std::string str;
1191 uint8_t len = *data_len;
1192
1193 *data_len = 0;
1194
1195 /* check for requested data params */
1196 if (len < 5 || req->paramSel < 1 || req->paramSel >= numParam)
1197 {
1198 phosphor::logging::log<phosphor::logging::level::ERR>(
1199 "Invalid parameter received");
1200 return IPMI_CC_PARM_OUT_OF_RANGE;
1201 }
1202
1203 len = len - 5; // Get Actual data length
1204
1205 ss << std::hex;
1206 ss << std::setw(2) << std::setfill('0') << (int)req->dimmIndex;
1207 oemData[KEY_Q_DIMM_INFO][ss.str()][KEY_DIMM_INDEX] = req->dimmIndex;
1208
1209 str = bytesToStr(req->data, len);
1210 oemData[KEY_Q_DIMM_INFO][ss.str()][dimmInfoKey[req->paramSel]] =
1211 str.c_str();
1212 flushOemData();
1213
1214 return IPMI_CC_OK;
1215}
1216
1217//----------------------------------------------------------------------
1218// Get Dimm Info (CMD_OEM_Q_GET_DIMM_INFO)
1219//----------------------------------------------------------------------
1220// Request:
1221// Byte 1:3 – Manufacturer ID – XXYYZZh, LSB first
1222// Byte 4 – DIMM Index, 0 base
1223// Byte 5 – Parameter Selector
1224// Byte 6..N – Configuration parameter data (see below for Parameters
1225// of DIMM Information)
1226// Response:
1227// Byte 1 – Completion code
1228// Byte 2..N – Configuration Parameter Data (see Table_1213h Parameters
1229// of DIMM Information)
1230//
1231// Param#1 (DIMM Location):
1232// Byte 1 – DIMM Present
1233// Byte 1 – DIMM Present
1234// 01h – Present
1235// FFh – Not Present
1236// Byte 2 – Node Number, 0 base
1237// Byte 3 – Channel Number , 0 base
1238// Byte 4 – DIMM Number , 0 base
1239//
1240// Param#2 (DIMM Type):
1241// Byte 1 – DIMM Type
1242// Bit [7:6]
1243// For DDR3
1244// 00 – Normal Voltage (1.5V)
1245// 01 – Ultra Low Voltage (1.25V)
1246// 10 – Low Voltage (1.35V)
1247// 11 – Reserved
1248// For DDR4
1249// 00 – Reserved
1250// 01 – Reserved
1251// 10 – Reserved
1252// 11 – Normal Voltage (1.2V)
1253// Bit [5:0]
1254// 0x00 – SDRAM
1255// 0x01 – DDR-1 RAM
1256// 0x02 – Rambus
1257// 0x03 – DDR-2 RAM
1258// 0x04 – FBDIMM
1259// 0x05 – DDR-3 RAM
1260// 0x06 – DDR-4 RAM
1261//
1262// Param#3 (DIMM Speed):
1263// Byte 1..2 – DIMM speed in MHz, LSB
1264// Byte 3..6 – DIMM size in Mbytes, LSB
1265//
1266// Param#4 (Module Part Number):
1267// Byte 1..20 –Module Part Number (JEDEC Standard No. 21-C)
1268//
1269// Param#5 (Module Serial Number):
1270// Byte 1..4 –Module Serial Number (JEDEC Standard No. 21-C)
1271//
1272// Param#6 (Module Manufacturer ID):
1273// Byte 1 - Module Manufacturer ID, LSB
1274// Byte 2 - Module Manufacturer ID, MSB
1275//
1276ipmi_ret_t ipmiOemQGetDimmInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
1277 ipmi_request_t request, ipmi_response_t response,
1278 ipmi_data_len_t data_len, ipmi_context_t context)
1279{
1280 qDimmInfo_t *req = reinterpret_cast<qDimmInfo_t *>(request);
1281 uint8_t numParam = sizeof(dimmInfoKey) / sizeof(uint8_t *);
1282 uint8_t *res = reinterpret_cast<uint8_t *>(response);
1283 std::stringstream ss;
1284 std::string str;
1285
1286 *data_len = 0;
1287
1288 /* check for requested data params */
1289 if (req->paramSel < 1 || req->paramSel >= numParam)
1290 {
1291 phosphor::logging::log<phosphor::logging::level::ERR>(
1292 "Invalid parameter received");
1293 return IPMI_CC_PARM_OUT_OF_RANGE;
1294 }
1295
1296 ss << std::hex;
1297 ss << std::setw(2) << std::setfill('0') << (int)req->dimmIndex;
1298
1299 if (oemData[KEY_Q_DIMM_INFO].find(ss.str()) ==
1300 oemData[KEY_Q_DIMM_INFO].end())
1301 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1302
1303 if (oemData[KEY_Q_DIMM_INFO][ss.str()].find(dimmInfoKey[req->paramSel]) ==
1304 oemData[KEY_Q_DIMM_INFO][ss.str()].end())
1305 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1306
1307 str = oemData[KEY_Q_DIMM_INFO][ss.str()][dimmInfoKey[req->paramSel]];
1308 *data_len = strToBytes(str, res);
1309
1310 return IPMI_CC_OK;
1311}
1312
1313//----------------------------------------------------------------------
1314// Set Drive Info (CMD_OEM_Q_SET_DRIVE_INFO)
1315//----------------------------------------------------------------------
1316// BIOS issue this command to provide HDD information to BMC.
1317//
1318// BIOS just can get information by standard ATA / SMART command for
1319// OB SATA controller.
1320// BIOS can get
1321// 1. Serial Number
1322// 2. Model Name
1323// 3. HDD FW Version
1324// 4. HDD Capacity
1325// 5. HDD WWN
1326//
1327// Use Get HDD info Param #5 to know the MAX HDD info index.
1328//
1329// Request:
1330// Byte 1:3 – Quanta Manufacturer ID – 001C4Ch, LSB first
1331// Byte 4 –
1332// [7:4] Reserved
1333// [3:0] HDD Controller Type
1334// 0x00 – BIOS
1335// 0x01 – Expander
1336// 0x02 – LSI
1337// Byte 5 – HDD Info Index, 0 base
1338// Byte 6 – Parameter Selector
1339// Byte 7..N – Configuration parameter data (see Table_1415h Parameters of HDD
1340// Information)
1341//
1342// Response:
1343// Byte 1 – Completion Code
1344//
1345// Param#0 (HDD Location):
1346// Byte 1 – Controller
1347// [7:3] Device Number
1348// [2:0] Function Number
1349// For Intel C610 series (Wellsburg)
1350// D31:F2 (0xFA) – SATA control 1
1351// D31:F5 (0xFD) – SATA control 2
1352// D17:F4 (0x8C) – sSata control
1353// Byte 2 – Port Number
1354// Byte 3 – Location (0xFF: No HDD Present)
1355// BIOS default set Byte 3 to 0xFF, if No HDD Present. And then skip send param
1356// #1~4, #6, #7 to BMC (still send param #5) BIOS default set Byte 3 to 0, if
1357// the HDD present. BMC or other people who know the HDD location has
1358// responsibility for update Location info
1359//
1360// Param#1 (Serial Number):
1361// Bytes 1..33: HDD Serial Number
1362//
1363// Param#2 (Model Name):
1364// Byte 1..33 – HDD Model Name
1365//
1366// Param#3 (HDD FW Version):
1367// Byte 1..17 –HDD FW version
1368//
1369// Param#4 (Capacity):
1370// Byte 1..4 –HDD Block Size, LSB
1371// Byte 5..12 - HDD Block Number, LSB
1372// HDD Capacity = HDD Block size * HDD BLock number (Unit Byte)
1373//
1374// Param#5 (Max HDD Quantity):
1375// Byte 1 - Max HDD Quantity
1376// Max supported port numbers in this PCH
1377//
1378// Param#6 (HDD Type)
1379// Byte 1 – HDD Type
1380// 0h – Reserved
1381// 1h – SAS
1382// 2h – SATA
1383// 3h – PCIE SSD (NVME)
1384//
1385// Param#7 (HDD WWN)
1386// Data 1...8: HDD World Wide Name, LSB
1387//
1388ipmi_ret_t ipmiOemQSetDriveInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
1389 ipmi_request_t request,
1390 ipmi_response_t response,
1391 ipmi_data_len_t data_len,
1392 ipmi_context_t context)
1393{
1394 qDriveInfo_t *req = reinterpret_cast<qDriveInfo_t *>(request);
1395 uint8_t numParam = sizeof(driveInfoKey) / sizeof(uint8_t *);
1396 uint8_t ctrlType = req->hddCtrlType & 0x0f;
1397 std::stringstream ss;
1398 std::string str;
1399 uint8_t len = *data_len;
1400
1401 *data_len = 0;
1402
1403 /* check for requested data params */
1404 if (len < 6 || req->paramSel < 1 || req->paramSel >= numParam ||
1405 ctrlType > 2)
1406 {
1407 phosphor::logging::log<phosphor::logging::level::ERR>(
1408 "Invalid parameter received");
1409 return IPMI_CC_PARM_OUT_OF_RANGE;
1410 }
1411
1412 len = len - 6; // Get Actual data length
1413
1414 ss << std::hex;
1415 ss << std::setw(2) << std::setfill('0') << (int)req->hddIndex;
1416 oemData[KEY_Q_DRIVE_INFO][KEY_HDD_CTRL_TYPE] = req->hddCtrlType;
1417 oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()][KEY_HDD_INDEX] =
1418 req->hddIndex;
1419
1420 str = bytesToStr(req->data, len);
1421 oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()]
1422 [driveInfoKey[req->paramSel]] = str.c_str();
1423 flushOemData();
1424
1425 return IPMI_CC_OK;
1426}
1427
1428//----------------------------------------------------------------------
1429// Get Drive Info (CMD_OEM_Q_GET_DRIVE_INFO)
1430//----------------------------------------------------------------------
1431// BMC needs to check HDD presented or not first. If NOT presented, return
1432// completion code 0xD5.
1433//
1434// Request:
1435// Byte 1:3 – Quanta Manufacturer ID – 001C4Ch, LSB first
1436// Byte 4 –
1437//[7:4] Reserved
1438//[3:0] HDD Controller Type
1439// 0x00 – BIOS
1440// 0x01 – Expander
1441// 0x02 – LSI
1442// Byte 5 – HDD Index, 0 base
1443// Byte 6 – Parameter Selector (See Above Set HDD Information)
1444// Response:
1445// Byte 1 – Completion Code
1446// 0xD5 – Not support in current status (HDD Not Present)
1447// Byte 2..N – Configuration parameter data (see Table_1415h Parameters of HDD
1448// Information)
1449//
1450ipmi_ret_t ipmiOemQGetDriveInfo(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
1451 ipmi_request_t request,
1452 ipmi_response_t response,
1453 ipmi_data_len_t data_len,
1454 ipmi_context_t context)
1455{
1456 qDriveInfo_t *req = reinterpret_cast<qDriveInfo_t *>(request);
1457 uint8_t numParam = sizeof(driveInfoKey) / sizeof(uint8_t *);
1458 uint8_t *res = reinterpret_cast<uint8_t *>(response);
1459 uint8_t ctrlType = req->hddCtrlType & 0x0f;
1460 std::stringstream ss;
1461 std::string str;
1462
1463 *data_len = 0;
1464
1465 /* check for requested data params */
1466 if (req->paramSel < 1 || req->paramSel >= numParam || ctrlType > 2)
1467 {
1468 phosphor::logging::log<phosphor::logging::level::ERR>(
1469 "Invalid parameter received");
1470 return IPMI_CC_PARM_OUT_OF_RANGE;
1471 }
1472
1473 if (oemData[KEY_Q_DRIVE_INFO].find(ctrlTypeKey[ctrlType]) ==
1474 oemData[KEY_Q_DRIVE_INFO].end())
1475 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1476
1477 ss << std::hex;
1478 ss << std::setw(2) << std::setfill('0') << (int)req->hddIndex;
1479
1480 if (oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]].find(ss.str()) ==
1481 oemData[KEY_Q_DRIVE_INFO].end())
1482 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1483
1484 if (oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()].find(
1485 dimmInfoKey[req->paramSel]) ==
1486 oemData[KEY_Q_DRIVE_INFO][ss.str()].end())
1487 return CC_PARAM_NOT_SUPP_IN_CURR_STATE;
1488
1489 str = oemData[KEY_Q_DRIVE_INFO][ctrlTypeKey[ctrlType]][ss.str()]
1490 [dimmInfoKey[req->paramSel]];
1491 *data_len = strToBytes(str, res);
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001492
1493 return IPMI_CC_OK;
1494}
1495
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07001496/* Helper function for sending DCMI commands to ME and getting response back */
1497ipmi::RspType<std::vector<uint8_t>> sendDCMICmd(uint8_t cmd,
1498 std::vector<uint8_t> &cmdData)
1499{
1500 std::vector<uint8_t> respData;
1501
1502 /* Add group id as first byte to request for ME command */
1503 cmdData.insert(cmdData.begin(), groupDCMI);
1504
1505 if (sendMeCmd(ipmi::netFnGroup, cmd, cmdData, respData))
1506 return ipmi::responseUnspecifiedError();
1507
1508 /* Remove group id as first byte as it will be added by IPMID */
1509 respData.erase(respData.begin());
1510
1511 return ipmi::responseSuccess(std::move(respData));
1512}
1513
1514/* DCMI Command handellers. */
1515
1516ipmi::RspType<std::vector<uint8_t>>
1517 ipmiOemDCMIGetPowerReading(std::vector<uint8_t> reqData)
1518{
1519 return sendDCMICmd(ipmi::dcmi::cmdGetPowerReading, reqData);
1520}
1521
1522ipmi::RspType<std::vector<uint8_t>>
1523 ipmiOemDCMIGetPowerLimit(std::vector<uint8_t> reqData)
1524{
1525 return sendDCMICmd(ipmi::dcmi::cmdGetPowerLimit, reqData);
1526}
1527
1528ipmi::RspType<std::vector<uint8_t>>
1529 ipmiOemDCMISetPowerLimit(std::vector<uint8_t> reqData)
1530{
1531 return sendDCMICmd(ipmi::dcmi::cmdSetPowerLimit, reqData);
1532}
1533
1534ipmi::RspType<std::vector<uint8_t>>
1535 ipmiOemDCMIApplyPowerLimit(std::vector<uint8_t> reqData)
1536{
1537 return sendDCMICmd(ipmi::dcmi::cmdActDeactivatePwrLimit, reqData);
1538}
1539
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001540static void registerOEMFunctions(void)
1541{
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001542 /* Get OEM data from json file */
1543 std::ifstream file(JSON_OEM_DATA_FILE);
1544 if (file)
Vijay Khemkafeaa9812019-08-27 15:08:08 -07001545 {
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001546 file >> oemData;
Vijay Khemkafeaa9812019-08-27 15:08:08 -07001547 file.close();
1548 }
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001549
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001550 phosphor::logging::log<phosphor::logging::level::INFO>(
1551 "Registering OEM commands");
Vijay Khemka7c0aea42020-03-05 13:31:53 -08001552
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001553 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_INFO,
1554 NULL, ipmiOemDbgGetFrameInfo,
1555 PRIVILEGE_USER); // get debug frame info
1556 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ,
1557 CMD_OEM_USB_DBG_GET_UPDATED_FRAMES, NULL,
1558 ipmiOemDbgGetUpdFrames,
1559 PRIVILEGE_USER); // get debug updated frames
1560 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_POST_DESC,
1561 NULL, ipmiOemDbgGetPostDesc,
1562 PRIVILEGE_USER); // get debug post description
1563 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_GPIO_DESC,
1564 NULL, ipmiOemDbgGetGpioDesc,
1565 PRIVILEGE_USER); // get debug gpio description
1566 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_GET_FRAME_DATA,
1567 NULL, ipmiOemDbgGetFrameData,
1568 PRIVILEGE_USER); // get debug frame data
1569 ipmiPrintAndRegister(NETFN_OEM_USB_DBG_REQ, CMD_OEM_USB_DBG_CTRL_PANEL,
1570 NULL, ipmiOemDbgGetCtrlPanel,
1571 PRIVILEGE_USER); // get debug control panel
1572 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_DIMM_INFO, NULL,
1573 ipmiOemSetDimmInfo,
1574 PRIVILEGE_USER); // Set Dimm Info
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001575 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_BOARD_ID, NULL,
1576 ipmiOemGetBoardID,
1577 PRIVILEGE_USER); // Get Board ID
1578 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_BOOT_ORDER, NULL,
1579 ipmiOemSetBootOrder,
1580 PRIVILEGE_USER); // Set Boot Order
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001581 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_BOOT_ORDER, NULL,
1582 ipmiOemGetBootOrder,
1583 PRIVILEGE_USER); // Get Boot Order
1584 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_MACHINE_CONFIG_INFO, NULL,
1585 ipmiOemSetMachineCfgInfo,
1586 PRIVILEGE_USER); // Set Machine Config Info
1587 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_START, NULL,
1588 ipmiOemSetPostStart,
1589 PRIVILEGE_USER); // Set POST start
1590 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_POST_END, NULL,
1591 ipmiOemSetPostEnd,
1592 PRIVILEGE_USER); // Set POST End
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001593 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPIN_INFO, NULL,
1594 ipmiOemSetPPINInfo,
1595 PRIVILEGE_USER); // Set PPIN Info
1596 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_ADR_TRIGGER, NULL,
1597 ipmiOemSetAdrTrigger,
1598 PRIVILEGE_USER); // Set ADR Trigger
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001599 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_BIOS_FLASH_INFO, NULL,
1600 ipmiOemSetBiosFlashInfo,
1601 PRIVILEGE_USER); // Set Bios Flash Info
1602 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_SET_PPR, NULL, ipmiOemSetPpr,
1603 PRIVILEGE_USER); // Set PPR
1604 ipmiPrintAndRegister(NETFUN_NONE, CMD_OEM_GET_PPR, NULL, ipmiOemGetPpr,
1605 PRIVILEGE_USER); // Get PPR
Vijay Khemka1d4a0692019-04-09 15:20:28 -07001606 /* FB OEM QC Commands */
1607 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_SET_PROC_INFO, NULL,
1608 ipmiOemQSetProcInfo,
1609 PRIVILEGE_USER); // Set Proc Info
1610 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_GET_PROC_INFO, NULL,
1611 ipmiOemQGetProcInfo,
1612 PRIVILEGE_USER); // Get Proc Info
1613 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_SET_DIMM_INFO, NULL,
1614 ipmiOemQSetDimmInfo,
1615 PRIVILEGE_USER); // Set Dimm Info
1616 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_GET_DIMM_INFO, NULL,
1617 ipmiOemQGetDimmInfo,
1618 PRIVILEGE_USER); // Get Dimm Info
1619 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_SET_DRIVE_INFO, NULL,
1620 ipmiOemQSetDriveInfo,
1621 PRIVILEGE_USER); // Set Drive Info
1622 ipmiPrintAndRegister(NETFUN_FB_OEM_QC, CMD_OEM_Q_GET_DRIVE_INFO, NULL,
1623 ipmiOemQGetDriveInfo,
1624 PRIVILEGE_USER); // Get Drive Info
Vijay Khemkadd14c0f2020-03-18 14:48:13 -07001625
1626 /* FB OEM DCMI Commands as per DCMI spec 1.5 Section 6 */
1627 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
1628 ipmi::dcmi::cmdGetPowerReading,
1629 ipmi::Privilege::User,
1630 ipmiOemDCMIGetPowerReading); // Get Power Reading
1631
1632 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
1633 ipmi::dcmi::cmdGetPowerLimit,
1634 ipmi::Privilege::User,
1635 ipmiOemDCMIGetPowerLimit); // Get Power Limit
1636
1637 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
1638 ipmi::dcmi::cmdSetPowerLimit,
1639 ipmi::Privilege::Operator,
1640 ipmiOemDCMISetPowerLimit); // Set Power Limit
1641
1642 ipmi::registerGroupHandler(ipmi::prioOpenBmcBase, groupDCMI,
1643 ipmi::dcmi::cmdActDeactivatePwrLimit,
1644 ipmi::Privilege::Operator,
1645 ipmiOemDCMIApplyPowerLimit); // Apply Power Limit
1646
Vijay Khemkae7d23d02019-03-08 13:13:40 -08001647 return;
1648}
1649
1650} // namespace ipmi