diff options
author | crgeddes <crgeddes@us.ibm.com> | 2016-04-15 09:46:34 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2016-04-28 11:29:22 -0400 |
commit | df6509836636649cc2383e660ed5d113a1587fc5 (patch) | |
tree | 142002531d72b1c8a1fd70943cae29526724f2b1 /src/import | |
parent | 4e41dc1eb238e65fcb06a260a7e5c1b172eae120 (diff) | |
download | talos-hostboot-df6509836636649cc2383e660ed5d113a1587fc5.tar.gz talos-hostboot-df6509836636649cc2383e660ed5d113a1587fc5.zip |
Get PoundV Bucket function and associated attributes
Uses the MVPD accessor method provided by FAPI2 interface
to retrieve the right #V bucket data from the appropriate LRP
record.
RTC:127421
Change-Id: Icde553e910338ecffd901102bb3973c52d16710b
Original-Change-Id: I8336b015d2b412c42a9a0e959c06cac011290525
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/23290
Tested-by: Jenkins Server
Tested-by: Hostboot CI
Tested-by: PPE CI
Reviewed-by: Matt K. Light <mklight@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/23777
Tested-by: FSP CI Jenkins
Diffstat (limited to 'src/import')
4 files changed, 449 insertions, 0 deletions
diff --git a/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.C b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.C new file mode 100644 index 000000000..91e4a81cb --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.C @@ -0,0 +1,281 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2015,2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/// +/// @file p9_pm_get_poundv_bucket.C +/// @brief Grab PM data from certain bucket in #V keyword in LRPX record +/// + +// ---------------------------------------------------------------------- +// Includes +// ---------------------------------------------------------------------- +#include <p9_pm_get_poundv_bucket.H> +#include <mvpd_access_defs.H> +#include <attribute_ids.H> + +fapi2::ReturnCode p9_pm_get_poundv_bucket( + const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target, + fapi2::voltageBucketData_t& o_data) +{ + FAPI_INF("Entering p9_pm_get_poundv_bucket ...."); + + + //Create a pointer version of the out param o_data so that + // we can access bytes individually + uint8_t* l_tempBuffer = reinterpret_cast<uint8_t*>(malloc(sizeof(o_data))); + + //Set up a char array to hold the bucket data from an attr read + fapi2::ATTR_POUNDV_BUCKET_DATA_Type l_bucketAttr; + + //Perform an ATTR_GET for POUNDV_BUCKET data on the EQ target + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_POUNDV_BUCKET_DATA, + i_target, + l_bucketAttr)); + + +#ifndef _BIG_ENDIAN + //The first byte is simply a uint8 that describes the bucket ID + l_tempBuffer[0] = l_bucketAttr[0]; + + //Skipping the first byte (which has already been taken of) start reading + //the voltage data 2 bytes at a time. + for(uint8_t offset = 1; offset < sizeof(o_data); offset += 2) + { + //Switch from Big Endian to Little Endian + l_tempBuffer[offset] = l_bucketAttr[offset + 1]; + l_tempBuffer[offset + 1] = l_bucketAttr[offset]; + } + + memcpy(&o_data, + l_tempBuffer, + sizeof(o_data)); + +#else + memcpy(&o_data, + l_bucketAttr, + sizeof(o_data)); +#endif + + +fapi_try_exit: + free(l_tempBuffer); + FAPI_IMP("Exiting p9_pm_get_poundv_bucket ...."); + + return fapi2::current_err; +} + +fapi2::ReturnCode p9_pm_get_poundv_bucket_attr( + const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target, + uint8_t* o_data) +{ + FAPI_IMP("Entering p9_pm_get_poundv_bucket_attr ...."); + uint8_t* l_prDataPtr = NULL; + uint8_t* l_fullVpdData = NULL; + uint8_t l_overridePresent = 0; + uint32_t l_vpdSize = 0; + uint32_t l_eqFapiPos = 0; + uint8_t l_bucketId; + fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS; + + do + { + //To read MVPD we will need the proc parent of the inputted EQ target + fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> l_procParent = + i_target.getParent<fapi2::TARGET_TYPE_PROC_CHIP>(); + + //check if bucket num has been overriden + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_POUNDV_BUCKET_NUM_OVERRIDE, + i_target, + l_overridePresent)); + + if(l_overridePresent != 0) + { + //If it has been overriden then get the override + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_POUNDV_BUCKET_NUM, + i_target, + l_bucketId)); + } + else + { + //Otherwise get the bucket num from MVPD data + //First read is to get size of vpd record, note the o_buffer is NULL + l_rc = getMvpdField(fapi2::MVPD_RECORD_VINI, + fapi2::MVPD_KEYWORD_PR, + l_procParent, + NULL, + l_vpdSize); + + if(l_rc) + { + FAPI_ERR("p9_pm_get_poundv_bucket_attr:: Error reading PR keyword size from VINI record"); + break; + } + + l_prDataPtr = reinterpret_cast<uint8_t*>(malloc(l_vpdSize)); + + //Second read is to get data of vpd record + l_rc = getMvpdField(fapi2::MVPD_RECORD_VINI, + fapi2::MVPD_KEYWORD_PR, + l_procParent, + l_prDataPtr, + l_vpdSize); + + if(l_rc) + { + FAPI_ERR("p9_pm_get_poundv_bucket_attr:: Error reading PR keyword from VINI record"); + break; + } + + memcpy(&l_bucketId, (l_prDataPtr), sizeof(uint8_t)); + } + + + //Need to determine which LRP record to read from depending on which + //bucket we are getting the power management data from. FapiPos will + //tell us which LRP record to use. + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, + i_target, + l_eqFapiPos)); + fapi2::MvpdRecord lprRecord; + + switch(l_eqFapiPos) + { + case 0: + lprRecord = fapi2::MVPD_RECORD_LRP0; + break; + + case 1: + lprRecord = fapi2::MVPD_RECORD_LRP1; + break; + + case 2: + lprRecord = fapi2::MVPD_RECORD_LRP2; + break; + + case 3: + lprRecord = fapi2::MVPD_RECORD_LRP3; + break; + + case 4: + lprRecord = fapi2::MVPD_RECORD_LRP4; + break; + + case 5: + lprRecord = fapi2::MVPD_RECORD_LRP5; + break; + + default: + FAPI_ERR("No LRP record found for EQ with fapi pos = %d", l_eqFapiPos); + assert(0); + break; + } + + //Reset VPD size because we want to find size of another VPD record + l_vpdSize = 0; + + //First read is to get size of vpd record, note the o_buffer is NULL + l_rc = getMvpdField(lprRecord, + fapi2::MVPD_KEYWORD_PDV, + l_procParent, + NULL, + l_vpdSize); + + if(l_rc) + { + FAPI_ERR("p9_pm_get_poundv_bucket_attr:: Error reading PDV keyword size from LRP%d record", l_eqFapiPos); + break; + } + + //Allocate memory for vpd data + l_fullVpdData = reinterpret_cast<uint8_t*>(malloc(l_vpdSize)); + + FAPI_ASSERT(l_vpdSize - 4 - (l_bucketId * 0x33) >= sizeof(fapi2::ATTR_POUNDV_BUCKET_DATA_Type), + fapi2::BAD_VPD_READ() + .set_EXPECTED_SIZE(sizeof(fapi2::ATTR_POUNDV_BUCKET_DATA_Type)) + .set_ACTUAL_SIZE(l_vpdSize - 4 - (l_bucketId * 0x33)), + "#V data read was too small!" ); + + //Second read is to get data of vpd record + l_rc = getMvpdField(lprRecord, + fapi2::MVPD_KEYWORD_PDV, + l_procParent, + l_fullVpdData, + l_vpdSize); + + if(l_rc) + { + FAPI_ERR("p9_pm_get_poundv_bucket_attr:: Error reading PDV keyword from LRP%d record", l_eqFapiPos); + break; + } + + //#V record is laid out as follows: + //Name: 0x2 byte + //Length: 0x2 byte + //Version: 0x1 byte **buffer starts here + //PNP: 0x3 byte + //bucket a: 0x33 byte + //bucket b: 0x33 byte + //bucket c: 0x33 byte + //bucket d: 0x33 byte + //bucket e: 0x33 byte + //bucket f: 0x33 byte + if( *l_fullVpdData == 0x2) + { + memcpy(&o_data, + l_fullVpdData + 4 + (l_bucketId) * 0x33, + sizeof(fapi2::ATTR_POUNDV_BUCKET_DATA_Type)); + } + else + { + FAPI_ERR("p9_pm_get_poundv_bucket_attr::Invalid #V record version: 0x%x", *l_fullVpdData); + FAPI_ASSERT(0, + fapi2::INVALID_POUNDV_VERSION() + .set_POUNDV_VERSION(*l_fullVpdData), + "#V is of an invalid version!" ); + } + + + } + while(0); + +fapi_try_exit: + + if(l_fullVpdData != NULL) + { + free(l_fullVpdData); + } + + if(l_prDataPtr != NULL) + { + free(l_prDataPtr); + } + + FAPI_IMP("Exiting p9_pm_get_poundv_bucket_attr ...."); + + //If there is no issue in the current err, check + //the local rc to see if the mvpd access methods caught anything + if((fapi2::current_err == fapi2::FAPI2_RC_SUCCESS) && + (l_rc != fapi2::FAPI2_RC_SUCCESS)) + { + fapi2::current_err = l_rc; + } + + return fapi2::current_err; +} + + diff --git a/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.H b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.H new file mode 100644 index 000000000..f6581d238 --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.H @@ -0,0 +1,110 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* EKB Project */ +/* */ +/* COPYRIGHT 2015,2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/// +/// @file p9_pm_get_poundv_bucket.H +/// @brief Provide structure for voltageBucketData so that info from #V keyword +/// can be stored inside of this struct. +/// Also define prototype for p9_pm_get_poundv_bucket +/// + +#ifndef _P9_PM_GET_POUND_V_BUCKET_H_ +#define _P9_PM_GET_POUND_V_BUCKET_H_ + +//------------------------------------------------------------------------------ +// Includes +//------------------------------------------------------------------------------ +#include <fapi2.H> + +namespace fapi2 +{ + +//Represents the data contained within a single #V (version=2) bucket +//Note: This structure should not be assumed to be binary identical +//to the contents of the VPD itself. +//Pack the struct so that we can get a consistent size with no +//extra padding +typedef struct __attribute__((__packed__)) voltageBucketData +{ + // bucket Id + uint8_t bucketId; + // Nominal + uint16_t nomFreq; + uint16_t VddNomVltg; + uint16_t IddNomCurr; + uint16_t VcsNomVltg; + uint16_t IcsNomCurr; + // PowerSave + uint16_t PSFreq; + uint16_t VddPSVltg; + uint16_t IddPSCurr; + uint16_t VcsPSVltg; + uint16_t IcsPSCurr; + // Turbo + uint16_t turboFreq; + uint16_t VddTurboVltg; + uint16_t IddTurboCurr; + uint16_t VcsTurboVltg; + uint16_t IcsTurboCurr; + //Ultra Turbo + uint16_t uTurboFreq; + uint16_t VddUTurboVltg; + uint16_t IddUTurboCurr; + uint16_t VcsUTurboVltg; + uint16_t IcsUTurboCurr; + //PowerBus + uint16_t pbFreq; + uint16_t VdnPbVltg; + uint16_t IdnPbCurr; + uint16_t VcsPbVltg; + uint16_t IcsPbCurr; +} voltageBucketData_t; + +} + +//------------------------------------------------------------------------------ +// Function prototype +//------------------------------------------------------------------------------ +/// +/// @brief Read #V bucket data from LRP record based upon +/// bucket ID read off of parent proc chip. This function +/// will pass out a structured format of the #V data of correct +/// endianness. +/// @param[in] i_target EQ chiplet target +/// @param[in] o_data structured data describing the #v bucket used +/// @return FAPI2_RC_SUCCESS if success, else error code. +/// +fapi2::ReturnCode p9_pm_get_poundv_bucket( + const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target, + fapi2::voltageBucketData_t& o_data); + +/// +/// @brief Read #V bucket data from LRP record based upon +/// bucket ID read off of parent proc chip. This function +/// will pass out array of bytes as they are read from the VPD +/// NOTE: This might be incorrect endianness +/// @param[in] i_target EQ chiplet target +/// @param[in] o_data bytes read from #V keyword of an LRP record +/// @return FAPI2_RC_SUCCESS if success, else error code. +/// +fapi2::ReturnCode p9_pm_get_poundv_bucket_attr( + const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target, + uint8_t* o_data); + + +#endif // _P9_PM_GET_POUND_V_BUCKET_H_ diff --git a/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.mk b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.mk new file mode 100644 index 000000000..1b968a4f1 --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.mk @@ -0,0 +1,20 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.mk $ +# +# IBM CONFIDENTIAL +# +# EKB Project +# +# COPYRIGHT 2015,2016 +# [+] International Business Machines Corp. +# +# +# The source code for this program is not published or otherwise +# divested of its trade secrets, irrespective of what has been +# deposited with the U.S. Copyright Office. +# +# IBM_PROLOG_END_TAG +PROCEDURE=p9_pm_get_poundv_bucket +$(call BUILD_PROCEDURE) diff --git a/src/import/chips/p9/procedures/xml/error_info/p9_pm_get_poundv_bucket_errors.xml b/src/import/chips/p9/procedures/xml/error_info/p9_pm_get_poundv_bucket_errors.xml new file mode 100644 index 000000000..056d1d822 --- /dev/null +++ b/src/import/chips/p9/procedures/xml/error_info/p9_pm_get_poundv_bucket_errors.xml @@ -0,0 +1,38 @@ +<!-- IBM_PROLOG_BEGIN_TAG --> +<!-- This is an automatically generated prolog. --> +<!-- --> +<!-- $Source: chips/p9/procedures/xml/error_info/p9_pm_get_poundv_bucket_errors.xml $ --> +<!-- --> +<!-- IBM CONFIDENTIAL --> +<!-- --> +<!-- EKB Project --> +<!-- --> +<!-- COPYRIGHT 2016 --> +<!-- [+] International Business Machines Corp. --> +<!-- --> +<!-- --> +<!-- The source code for this program is not published or otherwise --> +<!-- divested of its trade secrets, irrespective of what has been --> +<!-- deposited with the U.S. Copyright Office. --> +<!-- --> +<!-- IBM_PROLOG_END_TAG --> +<hwpErrors> + <!-- ******************************************************************** --> + <hwpError> + <rc>RC_BAD_VPD_READ</rc> + <description> + Attempted to read #V data and got less data than we expected + </description> + <ffdc>EXPECTED_SIZE</ffdc> + <ffdc>ACTUAL_SIZE</ffdc> + </hwpError> + <!-- ******************************************************************** --> + <hwpError> + <rc>RC_INVALID_POUNDV_VERSION</rc> + <description> + Read unknown version type from #V keyword in a LRP record + </description> + <ffdc>POUNDV_VERSION</ffdc> + </hwpError> + <!-- ******************************************************************** --> +</hwpErrors>
\ No newline at end of file |