summaryrefslogtreecommitdiffstats
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
parent4cea4d2b36a0bfc212f34e72792cfa00e43384e9 (diff)
downloadopenpower-occ-control-6ac874e1a1752e29ef4756d9c7e7d33baee9f9d5.tar.gz
openpower-occ-control-6ac874e1a1752e29ef4756d9c7e7d33baee9f9d5.zip
Notify OCC of pcap setting changes
Resolves openbmc/openbmc#948 Change-Id: I03193b07ddaf380468bd0c0e62a41220bdeaecce Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
-rw-r--r--configure.ac4
-rw-r--r--powercap.cpp33
-rw-r--r--powercap.hpp6
3 files changed, 40 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index efc29d8..daff49a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,10 @@ AC_ARG_VAR(OCC_NAME, [The OCC object name])
AS_IF([test "x$OCC_NAME" == "x"], [OCC_NAME="occ"])
AC_DEFINE_UNQUOTED([OCC_NAME], ["$OCC_NAME"], [The OCC object name])
+AC_ARG_VAR(OCC_MASTER_NAME, [The OCC master object name])
+AS_IF([test "x$OCC_MASTER_NAME" == "x"], [OCC_MASTER_NAME="occ-dev0"])
+AC_DEFINE_UNQUOTED([OCC_MASTER_NAME], ["$OCC_MASTER_NAME"], [The OCC master object name])
+
AC_ARG_VAR(OCC_HWMON_PATH, [The OCC hwmon path])
AS_IF([test "x$OCC_HWMON_PATH" == "x"], [OCC_HWMON_PATH="/sys/bus/platform/drivers/occ-hwmon/"])
AC_DEFINE_UNQUOTED([OCC_HWMON_PATH], ["$OCC_HWMON_PATH"], [The OCC hwmon path])
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;
}
diff --git a/powercap.hpp b/powercap.hpp
index efd0729..ddf2a74 100644
--- a/powercap.hpp
+++ b/powercap.hpp
@@ -91,6 +91,12 @@ private:
*/
bool getPcapEnabled();
+ /** @brief Write the input power cap to the occ hwmon entry
+ *
+ * @param[in] pcapValue - Power cap value to write to OCC
+ */
+ void writeOcc(uint32_t pcapValue);
+
/** @brief Reference to sdbus **/
sdbusplus::bus::bus& bus;
OpenPOWER on IntegriCloud