summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2015-02-18 15:40:49 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2015-02-28 05:48:28 -0600
commit9ca7f528d22e488c53d2dfbad32423806b47ddb0 (patch)
treec372891dddce785dbcac57dc8722ba0128b93c99 /src/usr
parentf35706cfa0329dabc11dee332253afb0dae22232 (diff)
downloadtalos-hostboot-9ca7f528d22e488c53d2dfbad32423806b47ddb0.tar.gz
talos-hostboot-9ca7f528d22e488c53d2dfbad32423806b47ddb0.zip
Send the user power limit to the OCC.
Change-Id: I6da08c11f74f5a4d456dfbf0aac766ad55898754 RTC: 121676 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/15821 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Reviewed-by: Martha Broyles <mbroyles@us.ibm.com> Reviewed-by: Christopher Cain <cjcain@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr')
-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