Add DCMI command
Added DCMI command support for get power reading, get power limit,
set power limit and apply power limit.
Tested: Verified by running ipmi raw command.
ipmitool raw 0x2c 0x2 0xdc 0x1 0x0 0x0
dc 0d 00 0c 00 0e 00 0d 00 a8 96 72 5e 18 51 3b 1a 40
Change-Id: I59a61b795d4c2ffec5d10d3f27fcf5e8d1bef6fc
Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
diff --git a/src/usb-dbg.cpp b/src/usb-dbg.cpp
index 19e7914..501d8cb 100644
--- a/src/usb-dbg.cpp
+++ b/src/usb-dbg.cpp
@@ -880,6 +880,54 @@
return -1;
}
+int sendMeCmd(uint8_t netFn, uint8_t cmd, std::vector<uint8_t> &cmdData,
+ std::vector<uint8_t> &respData)
+{
+ auto bus = getSdBus();
+
+ if (DEBUG)
+ {
+ std::cout << "ME NetFn:cmd " << (int)netFn << ":" << (int)cmd << "\n";
+ std::cout << "ME req data: ";
+ for (auto d : cmdData)
+ {
+ std::cout << d << " ";
+ }
+ std::cout << "\n";
+ }
+
+ auto method = bus->new_method_call("xyz.openbmc_project.Ipmi.Channel.Ipmb",
+ "/xyz/openbmc_project/Ipmi/Channel/Ipmb",
+ "org.openbmc.Ipmb", "sendRequest");
+ method.append(meAddress, netFn, lun, cmd, cmdData);
+
+ auto reply = bus->call(method);
+ if (reply.is_method_error())
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Error reading from ME");
+ return -1;
+ }
+
+ IpmbMethodType resp;
+ reply.read(resp);
+
+ respData =
+ std::move(std::get<std::remove_reference_t<decltype(respData)>>(resp));
+
+ if (DEBUG)
+ {
+ std::cout << "ME resp data: ";
+ for (auto d : respData)
+ {
+ std::cout << d << " ";
+ }
+ std::cout << "\n";
+ }
+
+ return 0;
+}
+
static int getMeStatus(std::string &status)
{
uint8_t cmd = 0x01; // Get Device id command