summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/usr/htmgt/htmgt.C7
-rw-r--r--src/usr/htmgt/htmgt_activate.C90
-rw-r--r--src/usr/htmgt/htmgt_activate.H6
3 files changed, 103 insertions, 0 deletions
diff --git a/src/usr/htmgt/htmgt.C b/src/usr/htmgt/htmgt.C
index 1c8cef57e..b6498ca05 100644
--- a/src/usr/htmgt/htmgt.C
+++ b/src/usr/htmgt/htmgt.C
@@ -105,6 +105,13 @@ namespace HTMGT
// Send ALL config data
sendOccConfigData();
+ // Set the User PCAP
+ l_err = sendOccUserPowerCap();
+ if (l_err)
+ {
+ break;
+ }
+
// Wait for all OCCs to go to the target state
l_err = waitForOccState();
if ( l_err )
diff --git a/src/usr/htmgt/htmgt_activate.C b/src/usr/htmgt/htmgt_activate.C
index 2d6941ab1..a18d5039e 100644
--- a/src/usr/htmgt/htmgt_activate.C
+++ b/src/usr/htmgt/htmgt_activate.C
@@ -37,8 +37,11 @@
#include <targeting/common/attributes.H>
#include <targeting/common/targetservice.H>
+#include <ipmi/ipmisensor.H>
#include <sys/time.h>
+using namespace TARGETING;
+
namespace HTMGT
{
@@ -157,6 +160,93 @@ namespace HTMGT
}
+ //Sends the user selected power limit to the master OCC
+ errlHndl_t sendOccUserPowerCap()
+ {
+ errlHndl_t err = NULL;
+ Target* sys = NULL;
+ bool active = false;
+ uint16_t limit = 0;
+ uint16_t min = 0;
+ uint16_t max = 0;
+ targetService().getTopLevelTarget(sys);
+ assert(sys != NULL);
+
+ do
+ {
+#ifdef CONFIG_BMC_IPMI
+ err = SENSOR::getUserPowerLimit(limit, active);
+ if (err)
+ {
+ TMGT_ERR("sendOccUserPowerCap: Error getting user "
+ "power limit");
+ break;
+ }
+#endif
+
+ TMGT_INF("SENSOR::getUserPowerLimit returned %d, active = %d",
+ limit, active);
+
+ if (active)
+ {
+ //Make sure this value is between the min & max allowed
+ min = sys->getAttr<ATTR_OPEN_POWER_MIN_POWER_CAP_WATTS>();
+ max = sys->
+ getAttr<ATTR_OPEN_POWER_N_PLUS_ONE_BULK_POWER_LIMIT_WATTS>();
+
+ if ((limit != 0) && (limit < min))
+ {
+ TMGT_INF("sendOccUserPowerCap: User power cap %d is below"
+ " the minimum of %d, clipping value",
+ limit, min);
+ limit = min;
+ }
+ else if (limit > max)
+ {
+ TMGT_INF("sendOccUserPowerCap: User power cap %d is above"
+ " the maximum of %d, clipping value",
+ limit, min);
+ limit = max;
+ }
+ }
+ else
+ {
+ //The OCC knows it isn't activated by getting a value of 0.
+ limit = 0;
+ }
+
+
+ Occ* occ = occMgr::instance().getMasterOcc();
+ if (occ)
+ {
+ uint8_t data[2];
+ data[0] = limit >> 8;
+ data[1] = limit & 0xFF;
+
+ TMGT_INF("sendOccUserPowerCap: Sending power cap %d to OCC %d",
+ limit, occ->getInstance());
+
+ OccCmd cmd(occ, OCC_CMD_SET_POWER_CAP, 2, data);
+
+ err = cmd.sendOccCmd();
+ if (err)
+ {
+ TMGT_ERR("sendOccUserPowerCap: Failed sending command "
+ "to OCC %d with rc = 0x%04X",
+ occ->getInstance(), err->reasonCode());
+ break;
+ }
+ }
+ else
+ {
+ //Other code deals with a missing master
+ TMGT_ERR("sendOccUserPowerCap: No Master OCC found");
+ }
+
+ } while (0);
+
+ return err;
+ }
} // end namespace
diff --git a/src/usr/htmgt/htmgt_activate.H b/src/usr/htmgt/htmgt_activate.H
index 405bcbd00..74bf8ee70 100644
--- a/src/usr/htmgt/htmgt_activate.H
+++ b/src/usr/htmgt/htmgt_activate.H
@@ -54,5 +54,11 @@ namespace HTMGT
errlHndl_t setOccActiveSensors();
+ /**
+ * @brief Sends the User selected Power Cap to the master OCC.
+ */
+ errlHndl_t sendOccUserPowerCap();
+
+
} // end namespace
#endif
OpenPOWER on IntegriCloud