summaryrefslogtreecommitdiffstats
path: root/powercap.cpp
diff options
context:
space:
mode:
authorAndrew Geissler <andrewg@us.ibm.com>2017-07-10 15:54:58 -0500
committerAndrew Geissler <andrewg@us.ibm.com>2017-07-18 13:52:12 -0500
commit6ac874e1a1752e29ef4756d9c7e7d33baee9f9d5 (patch)
treecfd5eeaa9fde706c56567693eac5e73c4f361ee9 /powercap.cpp
parent4cea4d2b36a0bfc212f34e72792cfa00e43384e9 (diff)
downloadopenpower-occ-control-6ac874e1a1752e29ef4756d9c7e7d33baee9f9d5.zip
openpower-occ-control-6ac874e1a1752e29ef4756d9c7e7d33baee9f9d5.tar.gz
Notify OCC of pcap setting changes
Resolves openbmc/openbmc#948 Change-Id: I03193b07ddaf380468bd0c0e62a41220bdeaecce Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'powercap.cpp')
-rw-r--r--powercap.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/powercap.cpp b/powercap.cpp
index 7e8c0db..0aca3e4 100644
--- a/powercap.cpp
+++ b/powercap.cpp
@@ -113,6 +113,34 @@ bool PowerCap::getPcapEnabled()
return pcapEnabled.get<bool>();
}
+void PowerCap::writeOcc(uint32_t pcapValue)
+{
+ // Create path out to master occ hwmon entry
+ std::unique_ptr<fs::path> fileName =
+ std::make_unique<fs::path>(OCC_HWMON_PATH);
+ *fileName /= OCC_MASTER_NAME;
+ *fileName /= "/hwmon/";
+
+ // Need to get the hwmonXX directory name, there better only be 1 dir
+ assert(std::distance(fs::directory_iterator(*fileName),
+ fs::directory_iterator{}) == 1);
+ // Now set our path to this full path, including this hwmonXX directory
+ fileName = std::make_unique<fs::path>(*fs::directory_iterator(*fileName));
+ // Append on the hwmon string where we write the user power cap
+ *fileName /= "/caps1_user";
+
+ auto pcapString {std::to_string(pcapValue)};
+
+ log<level::INFO>("Writing pcap value to hwmon",
+ entry("PCAP_PATH=%s",*fileName),
+ entry("PCAP_VALUE=%s",pcapString.c_str()));
+ // Open the hwmon file and write the power cap
+ std::ofstream file(*fileName, std::ios::out);
+ file << pcapString;
+ file.close();
+ return;
+}
+
void PowerCap::pcapChanged(sdbusplus::message::message& msg)
{
if (!occStatus.occActive())
@@ -157,12 +185,11 @@ void PowerCap::pcapChanged(sdbusplus::message::message& msg)
entry("PCAP_ENABLED=%u",pcapEnabled));
// Determine desired action to write to occ
+
auto occInput = getOccInput(pcap, pcapEnabled);
- log<level::DEBUG>("Writing new power cap setting to OCC",
- entry("OCC_PCAP_VAL=%u",occInput));
// Write action to occ
- // TODO
+ writeOcc(occInput);
return;
}
OpenPOWER on IntegriCloud