summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dcmihandler.cpp35
-rw-r--r--dcmihandler.hpp9
2 files changed, 44 insertions, 0 deletions
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index 7a4db9f..e9cc39a 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -65,6 +65,13 @@ static const std::map<uint8_t, std::string> entityIdToName{
{0x40, "inlet"}, {0x37, "inlet"}, {0x41, "cpu"},
{0x03, "cpu"}, {0x42, "baseboard"}, {0x07, "baseboard"}};
+bool isDCMIPowerMgmtSupported()
+{
+ auto data = parseJSONConfig(gDCMICapabilitiesConfig);
+
+ return (gDCMIPowerMgmtSupported == data.value(gDCMIPowerMgmtCapability, 0));
+}
+
uint32_t getPcap(sdbusplus::bus::bus& bus)
{
auto settingService = ipmi::getService(bus, PCAP_INTERFACE, PCAP_PATH);
@@ -298,6 +305,13 @@ ipmi_ret_t getPowerLimit(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request, ipmi_response_t response,
ipmi_data_len_t data_len, ipmi_context_t context)
{
+ if (!dcmi::isDCMIPowerMgmtSupported())
+ {
+ *data_len = 0;
+ log<level::ERR>("DCMI Power management is unsupported!");
+ return IPMI_CC_INVALID;
+ }
+
auto requestData =
reinterpret_cast<const dcmi::GetPowerLimitRequest*>(request);
std::vector<uint8_t> outPayload(sizeof(dcmi::GetPowerLimitResponse));
@@ -359,6 +373,13 @@ ipmi_ret_t setPowerLimit(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request, ipmi_response_t response,
ipmi_data_len_t data_len, ipmi_context_t context)
{
+ if (!dcmi::isDCMIPowerMgmtSupported())
+ {
+ *data_len = 0;
+ log<level::ERR>("DCMI Power management is unsupported!");
+ return IPMI_CC_INVALID;
+ }
+
auto requestData =
reinterpret_cast<const dcmi::SetPowerLimitRequest*>(request);
std::vector<uint8_t> outPayload(sizeof(dcmi::SetPowerLimitResponse));
@@ -398,6 +419,13 @@ ipmi_ret_t applyPowerLimit(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request, ipmi_response_t response,
ipmi_data_len_t data_len, ipmi_context_t context)
{
+ if (!dcmi::isDCMIPowerMgmtSupported())
+ {
+ *data_len = 0;
+ log<level::ERR>("DCMI Power management is unsupported!");
+ return IPMI_CC_INVALID;
+ }
+
auto requestData =
reinterpret_cast<const dcmi::ApplyPowerLimitRequest*>(request);
std::vector<uint8_t> outPayload(sizeof(dcmi::ApplyPowerLimitResponse));
@@ -1220,6 +1248,13 @@ ipmi_ret_t getPowerReading(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request, ipmi_response_t response,
ipmi_data_len_t data_len, ipmi_context_t context)
{
+ if (!dcmi::isDCMIPowerMgmtSupported())
+ {
+ *data_len = 0;
+ log<level::ERR>("DCMI Power management is unsupported!");
+ return IPMI_CC_INVALID;
+ }
+
ipmi_ret_t rc = IPMI_CC_OK;
auto requestData =
reinterpret_cast<const dcmi::GetPowerReadingRequest*>(request);
diff --git a/dcmihandler.hpp b/dcmihandler.hpp
index e3fa9de..8b16e3d 100644
--- a/dcmihandler.hpp
+++ b/dcmihandler.hpp
@@ -56,6 +56,8 @@ static constexpr auto systemPath = "/org/freedesktop/systemd1";
static constexpr auto systemIntf = "org.freedesktop.systemd1.Manager";
static constexpr auto gDCMICapabilitiesConfig =
"/usr/share/ipmi-providers/dcmi_cap.json";
+static constexpr auto gDCMIPowerMgmtCapability = "PowerManagement";
+static constexpr auto gDCMIPowerMgmtSupported = 0x1;
namespace assettag
{
@@ -161,6 +163,13 @@ struct SetAssetTagResponse
uint8_t tagLength; //!< Total asset tag length.
} __attribute__((packed));
+/** @brief Check whether DCMI power management is supported
+ * in the DCMI Capabilities config file.
+ *
+ * @return True if DCMI power management is supported
+ */
+bool isDCMIPowerMgmtSupported();
+
/** @brief Read the object tree to fetch the object path that implemented the
* Asset tag interface.
*
OpenPOWER on IntegriCloud