diff options
author | Richard J. Knight <rjknight@us.ibm.com> | 2015-01-30 06:29:17 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2015-02-12 09:29:00 -0600 |
commit | 2dbd115aa927b95af61f9d691d068e3ae3989bad (patch) | |
tree | d2fb714b011d4b1d39b7c3636b8a4bc3c23c0203 /src/usr | |
parent | 50a2fe79b94ebb35b7d2df88a1d29887f85efee2 (diff) | |
download | talos-hostboot-2dbd115aa927b95af61f9d691d068e3ae3989bad.tar.gz talos-hostboot-2dbd115aa927b95af61f9d691d068e3ae3989bad.zip |
Add support to retrieve the user power limit from the BMC
-Add support for DCMI get power limit command used
to retrieve the limit setting and limit activation
status from the BMC.
Change-Id: I9bf7336bedd929d5202db8c48477d7025a5311ab
RTC:122808
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/15445
Tested-by: Jenkins Server
Reviewed-by: Brian Silver <bsilver@us.ibm.com>
Reviewed-by: WILLIAM G. HOFFA <wghoffa@us.ibm.com>
Reviewed-by: Brian H. Horton <brianh@linux.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/ipmi/ipmidcmi.C | 127 | ||||
-rw-r--r-- | src/usr/ipmi/ipmisensor.C | 18 | ||||
-rw-r--r-- | src/usr/ipmi/makefile | 1 |
3 files changed, 145 insertions, 1 deletions
diff --git a/src/usr/ipmi/ipmidcmi.C b/src/usr/ipmi/ipmidcmi.C new file mode 100644 index 000000000..6372cdf67 --- /dev/null +++ b/src/usr/ipmi/ipmidcmi.C @@ -0,0 +1,127 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/ipmi/ipmidcmi.C $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file ipmidcmi.C + * @brief IPMI DCMI command extensions + */ + +#include <errl/errlentry.H> +#include <errl/errlmanager.H> +#include <ipmi/ipmiif.H> +#include <ipmi/ipmisensor.H> +#include <ipmi/ipmi_reasoncodes.H> +extern trace_desc_t * g_trac_ipmi; + +namespace SENSOR +{ + enum dcmi_cc + { + POWER_LIMIT_ACTIVE = 0x00, + POWER_LIMIT_NOT_ACTIVE = 0x80, + }; + + // fetch the user defined power limit stored on the BMC + // using the DCMI Get Power Limit command + errlHndl_t getUserPowerLimit( uint16_t &o_powerLimit, bool &o_limitActive ) + { + o_powerLimit = 0; + + // assume the limit has not been activated + o_limitActive = false; + + errlHndl_t l_err = NULL; + + // per DCMI spec data size is 3 bytes + size_t len = 3; + + //create request data buffer + uint8_t* data = new uint8_t[len]; + + IPMI::completion_code cc = IPMI::CC_UNKBAD; + + data[0] = 0xDC; // Group Extension Identification + data[1] = 0x00; // reserved + data[2] = 0x00; // reserved + + l_err = IPMI::sendrecv(IPMI::get_power_limit(), cc, len, data); + + SENSOR::dcmi_cc l_cc = static_cast<SENSOR::dcmi_cc>(cc); + + if( l_err == NULL ) + { + // make sure the completion code is good, then read the bytes + if( (l_cc == POWER_LIMIT_NOT_ACTIVE) || + (l_cc == POWER_LIMIT_ACTIVE) ) + { + // from the dcmi spec + // byte 1 completion code + // byte 2 0xDC + // byte 3:4 reserved + // byte 5 exception actions + // byte 6:7 power limit + // data[0] is pointing at byte 2 of the dcmi spec description + // so our offsets will be off by two below + o_powerLimit = data[4]; + o_powerLimit = ( o_powerLimit << 8 ) + data[5]; + + TRACFCOMP(g_trac_ipmi,"Power limit is %d watts",o_powerLimit); + TRACFCOMP(g_trac_ipmi,"Power limit is %s", ((cc) ? "not active": "active")); + + // the completion code also tells us if the limit is active + if(l_cc == POWER_LIMIT_ACTIVE ) + { + o_limitActive = true; + } + + delete[] data; + } + else + { + TRACFCOMP(g_trac_ipmi,"bad completion code from BMC=0x%x",cc); + + /* @errorlog tag + * @errortype ERRL_SEV_UNRECOVERABLE + * @moduleid IPMI::MOD_IPMIDCMI + * @reasoncode IPMI::RC_DCMI_CMD_FAILED + * @userdata1 BMC IPMI Completion code. + * @devdesc Request to get power limit information + * failed + */ + + l_err = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + IPMI::MOD_IPMIDCMI, + IPMI::RC_DCMI_CMD_FAILED, + static_cast<uint64_t>(cc),0, true); + + l_err->collectTrace(IPMI_COMP_NAME); + + } + } + + return l_err; + } + +}; // end name space diff --git a/src/usr/ipmi/ipmisensor.C b/src/usr/ipmi/ipmisensor.C index c81c3871d..4e6a03973 100644 --- a/src/usr/ipmi/ipmisensor.C +++ b/src/usr/ipmi/ipmisensor.C @@ -989,8 +989,24 @@ namespace SENSOR } } - return l_sensor_number; } + // $TODO - RTC:123217 - modify code get info from attribute when available + // interface to retrieve the APSS channel sensor numbers. + errlHndl_t getAPSSChannelSensorNumbers( + const uint16_t (* &o_sensor_numbers)[16]) + { + + static const uint16_t numbers[16] = { 0x47, 0x38, 0x39, 0x3A, + 0x3B, 0x3C, 0x3D, 0x3E, + 0x3F, 0x40, 0x41, 0x42, + 0x43, 0x44, 0x45, 0x46 }; + + o_sensor_numbers = &numbers; + + return NULL; + + } + }; // end name space diff --git a/src/usr/ipmi/makefile b/src/usr/ipmi/makefile index 3662689c4..8dad57f3e 100644 --- a/src/usr/ipmi/makefile +++ b/src/usr/ipmi/makefile @@ -37,6 +37,7 @@ OBJS += ipmiwatchdog.o OBJS += ipmifruinv.o OBJS += ipmipowerstate.o OBJS += ipmiselrecord.o +OBJS += ipmidcmi.o #SUBDIRS += test.d |