Add watches for throttling reported by the OCC
Add Error objects to watch the sysfs entries provided by the OCC hwmon
driver that report various types of throttling. Also needed to add a
boolean input to the Error callback interface.
Resolves openbmc/openbmc#1821
Change-Id: I4425770a92ace0f73024b3dc4c577ce46957a62a
Signed-off-by: Eddie James <eajames@us.ibm.com>
diff --git a/occ_device.hpp b/occ_device.hpp
index 7ffb0ef..fd30641 100644
--- a/occ_device.hpp
+++ b/occ_device.hpp
@@ -13,6 +13,7 @@
{
class Manager;
+class Status;
namespace fs = std::experimental::filesystem;
/** @class Device
@@ -38,18 +39,38 @@
Device(EventPtr& event,
const std::string& name,
const Manager& manager,
- std::function<void()> callBack = nullptr) :
+ Status& status,
+ std::function<void(bool)> callBack = nullptr) :
#ifdef I2C_OCC
config(name),
#else
config(name + '-' + "dev0"),
#endif
errorFile(fs::path(config) / "occ_error"),
+ statusObject(status),
error(event, errorFile, callBack),
presence(event,
fs::path(config) / "occs_present",
manager,
- callBack)
+ callBack),
+ throttleProcTemp(
+ event,
+ fs::path(config) / "occ_dvfs_ot",
+ std::bind(std::mem_fn(&Device::throttleProcTempCallback),
+ this,
+ std::placeholders::_1)),
+ throttleProcPower(
+ event,
+ fs::path(config) / "occ_dvfs_power",
+ std::bind(std::mem_fn(&Device::throttleProcPowerCallback),
+ this,
+ std::placeholders::_1)),
+ throttleMemTemp(
+ event,
+ fs::path(config) / "occ_mem_throttle",
+ std::bind(std::mem_fn(&Device::throttleMemTempCallback),
+ this,
+ std::placeholders::_1))
{
// Nothing to do here
}
@@ -89,6 +110,9 @@
presence.addWatch();
}
+ throttleProcTemp.addWatch();
+ throttleProcPower.addWatch();
+ throttleMemTemp.addWatch();
error.addWatch();
}
@@ -98,6 +122,10 @@
// we can always safely remove watch even if we don't add it
presence.removeWatch();
error.removeWatch();
+ error.removeWatch();
+ throttleMemTemp.removeWatch();
+ throttleProcPower.removeWatch();
+ throttleProcTemp.removeWatch();
}
private:
@@ -118,12 +146,20 @@
*/
static fs::path unBindPath;
+ /** Store the associated Status instance */
+ Status& statusObject;
+
/** Abstraction of error monitoring */
Error error;
/** Abstraction of OCC presence monitoring */
Presence presence;
+ /** Error instances for watching for throttling events */
+ Error throttleProcTemp;
+ Error throttleProcPower;
+ Error throttleMemTemp;
+
/** @brief file writer to achieve bind and unbind
*
* @param[in] filename - Name of file to be written
@@ -141,6 +177,24 @@
/** @brief Returns if device represents the master OCC */
bool master() const;
+
+ /** @brief callback for the proc temp throttle event
+ *
+ * @param[in] error - True if an error is reported, false otherwise
+ */
+ void throttleProcTempCallback(bool error);
+
+ /** @brief callback for the proc power throttle event
+ *
+ * @param[in] error - True if an error is reported, false otherwise
+ */
+ void throttleProcPowerCallback(bool error);
+
+ /** @brief callback for the proc temp throttle event
+ *
+ * @param[in] error - True if an error is reported, false otherwise
+ */
+ void throttleMemTempCallback(bool error);
};
} // namespace occ