diff options
author | Andrew Geissler <andrewg@us.ibm.com> | 2017-06-20 15:46:52 -0500 |
---|---|---|
committer | Andrew Geissler <andrewg@us.ibm.com> | 2017-07-17 10:16:00 -0500 |
commit | 32016d18e1b4ddeb8390ee2032e51582a9bca58c (patch) | |
tree | 97e786b1ba341e861587ec5398b9d74c7a463f3e | |
parent | 805e04bf2a291d1cfd87b88eebd0a77ee1c08de0 (diff) | |
download | openpower-occ-control-32016d18e1b4ddeb8390ee2032e51582a9bca58c.tar.gz openpower-occ-control-32016d18e1b4ddeb8390ee2032e51582a9bca58c.zip |
Register callbacks for pcap property changes
Change-Id: I39b38a931ffdf260d9ee45f02cdd31e9e884b04d
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | powercap.cpp | 29 | ||||
-rw-r--r-- | powercap.hpp | 78 |
3 files changed, 111 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index 0ab5856..d26ed99 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,8 @@ # Build these headers, don't install them noinst_HEADERS = \ occ_pass_through.hpp \ - occ_status.hpp + occ_status.hpp \ + powercap.hpp sbin_PROGRAMS = openpower-occ-control openpower_occ_control_SOURCES = \ @@ -9,7 +10,8 @@ openpower_occ_control_SOURCES = \ occ_status.cpp \ occ_device.cpp \ app.cpp \ - org/open_power/OCC/PassThrough/error.cpp + org/open_power/OCC/PassThrough/error.cpp \ + powercap.cpp BUILT_SOURCES = org/open_power/OCC/PassThrough/error.hpp \ org/open_power/OCC/PassThrough/error.cpp diff --git a/powercap.cpp b/powercap.cpp new file mode 100644 index 0000000..2d5362d --- /dev/null +++ b/powercap.cpp @@ -0,0 +1,29 @@ +#include <powercap.hpp> +#include <phosphor-logging/log.hpp> + +namespace open_power +{ +namespace occ +{ +namespace powercap +{ + +using namespace phosphor::logging; + + +void PowerCap::pcapChanged(sdbusplus::message::message& msg) +{ + log<level::DEBUG>("Power Cap Change Detected"); + if (!occStatus.occActive()) + { + // Nothing to do + return; + } + // TODO - Process this change +} + +} // namespace open_power + +} // namespace occ + +}// namespace powercap diff --git a/powercap.hpp b/powercap.hpp new file mode 100644 index 0000000..878822b --- /dev/null +++ b/powercap.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include <sdbusplus/bus.hpp> +#include <sdbusplus/bus/match.hpp> +#include "occ_status.hpp" +#include "config.h" + +namespace open_power +{ +namespace occ +{ +namespace powercap +{ + +namespace sdbusRule = sdbusplus::bus::match::rules; + +/** @class PowerCap + * @brief Monitors for changes to the power cap and notifies occ + * + * The customer power cap is provided to the OCC by host TMGT when the occ + * first goes active or is reset. This code is responsible for sending + * the power cap to the OCC if the cap is changed while the occ is active. + */ + +class PowerCap +{ +public: + /** @brief PowerCap object to inform occ of changes to cap + * + * This object will monitor for changes to the power cap setting and + * power cap enable properties. If a change is detected, and the occ + * is active, then this object will notify the OCC of the change. + * + * @param[in] bus - The Dbus bus object + * @param[in] occStatus - The occ status object + */ + PowerCap(sdbusplus::bus::bus &bus, + Status &occStatus) : + bus(bus), + occStatus(occStatus), + pcapMatch( + bus, + sdbusRule::member("PropertiesChanged") + + sdbusRule::path( + "/xyz/openbmc_project/control/host0/power_cap") + + sdbusRule::argN(0, "xyz.openbmc_project.Control.Power.Cap") + + sdbusRule::interface("org.freedesktop.DBus.Properties"), + std::bind(std::mem_fn(&PowerCap::pcapChanged), + this, std::placeholders::_1)) + {}; + +private: + + /** @brief Callback for pcap setting changes + * + * Process change and inform OCC + * + * @param[in] msg - Data associated with pcap change signal + * + */ + void pcapChanged(sdbusplus::message::message& msg); + + /** @brief Reference to sdbus **/ + sdbusplus::bus::bus& bus; + + /* @brief OCC Status object */ + Status &occStatus; + + /** @brief Used to subscribe to dbus pcap propety changes **/ + sdbusplus::bus::match_t pcapMatch; + + }; + +} // namespace open_power + +} // namespace occ + +}// namespace powercap |