From 0bfa76155cb641893089337054d169c73946a69c Mon Sep 17 00:00:00 2001 From: Prasad Bg Ranganath Date: Wed, 4 Jan 2017 06:05:47 -0600 Subject: PSTATE parameter block:POUNDV parsing function vs native implementation Change-Id: Ia480c2b2594b87e000e8c90cc3493fff57249338 RTC:162565 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/34330 Tested-by: Jenkins Server Tested-by: Hostboot CI Reviewed-by: Daniel M. Crowell Reviewed-by: Gregory S. Still Reviewed-by: Jennifer A. Stofer Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/34584 Tested-by: Jenkins OP Build CI --- .../p9/procedures/hwp/pm/p9_pm_get_poundv_bucket.C | 33 +---------------- .../hwp/pm/p9_pm_get_poundv_bucket_attr.C | 15 ++++++-- .../procedures/hwp/pm/p9_pstate_parameter_block.C | 43 ++++------------------ .../procedures/hwp/pm/p9_pstate_parameter_block.mk | 3 +- 4 files changed, 23 insertions(+), 71 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 index 0d051d70f..756c4bd7e 100644 --- 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 @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -39,11 +39,6 @@ fapi2::ReturnCode p9_pm_get_poundv_bucket( { FAPI_IMP("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(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; @@ -52,33 +47,9 @@ fapi2::ReturnCode p9_pm_get_poundv_bucket( 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 - + memcpy(&o_data, l_bucketAttr, sizeof(o_data)); fapi_try_exit: - free(l_tempBuffer); FAPI_IMP("Exiting p9_pm_get_poundv_bucket ...."); return fapi2::current_err; diff --git a/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.C b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.C index d370f8e51..a456afaa6 100644 --- a/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.C +++ b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -51,6 +51,7 @@ fapi2::ReturnCode p9_pm_get_poundv_bucket_attr( uint32_t l_sysNestFreq = 0; fapi2::voltageBucketData_t* l_currentBucket = NULL; uint8_t l_numMatches = 0; + uint16_t l_pbFreq = 0; fapi2::MvpdRecord lrpRecord = fapi2::MVPD_RECORD_LAST; //To read MVPD we will need the proc parent of the inputted EQ target @@ -186,7 +187,13 @@ fapi2::ReturnCode p9_pm_get_poundv_bucket_attr( for(int i = 0; i < NUM_BUCKETS; i++) { - if(l_buckets[i].pbFreq == l_sysNestFreq) +#ifndef _BIG_ENDIAN + l_pbFreq = ( (((l_buckets[i].pbFreq) >> 8) & 0x00FF) | (((l_buckets[i].pbFreq) << 8) & 0xFF00) ); +#else + l_pbFreq = l_buckets[i].pbFreq; +#endif + + if(l_pbFreq == l_sysNestFreq) { l_numMatches++; @@ -196,7 +203,7 @@ fapi2::ReturnCode p9_pm_get_poundv_bucket_attr( " Multiple buckets (%d) reporting the same nest frequency" " Bucket Nest = %d Bucket ID = %d, First Bucket = %d", l_numMatches, - l_buckets[i].pbFreq, + l_pbFreq, (i + 1), l_currentBucket); @@ -208,7 +215,7 @@ fapi2::ReturnCode p9_pm_get_poundv_bucket_attr( } //save FFDC in case we fail - l_bucketNestFreqs[i] = l_buckets[i].pbFreq; + l_bucketNestFreqs[i] = l_pbFreq; } if(l_numMatches == 1) diff --git a/src/import/chips/p9/procedures/hwp/pm/p9_pstate_parameter_block.C b/src/import/chips/p9/procedures/hwp/pm/p9_pstate_parameter_block.C index 2548632a9..b642b9dd7 100644 --- a/src/import/chips/p9/procedures/hwp/pm/p9_pstate_parameter_block.C +++ b/src/import/chips/p9/procedures/hwp/pm/p9_pstate_parameter_block.C @@ -43,12 +43,8 @@ // Includes // ---------------------------------------------------------------------- #include -//#include -//#include -//#include -//#include -//#include #include +#include "p9_pm_get_poundv_bucket.H" // START OF PSTATE PARAMETER BLOCK function @@ -502,10 +498,9 @@ proc_get_mvpd_data(const fapi2::Target& i_target, { std::vector> l_eqChiplets; - uint8_t* l_buffer = reinterpret_cast(malloc(PDV_BUFFER_ALLOC) ); + fapi2::voltageBucketData_t l_poundv_data; + uint8_t* l_buffer = reinterpret_cast(malloc(sizeof(l_poundv_data)) ); uint8_t* l_buffer_inc; - uint32_t l_bufferSize = 512; - uint32_t l_record = 0; uint32_t chiplet_mvpd_data[PV_D][PV_W]; uint8_t j = 0; uint8_t i = 0; @@ -533,38 +528,18 @@ proc_get_mvpd_data(const fapi2::Target& i_target, for (j = 0; j < l_eqChiplets.size(); j++) { - l_bufferSize = 512; uint8_t l_chipNum = 0xFF; FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, l_eqChiplets[j], l_chipNum)); FAPI_INF("Chip Number => %u", l_chipNum); - // set l_record to appropriate lprx record (add quad number to lrp0) - l_record = (uint32_t)fapi2::MVPD_RECORD_LRP0 + l_chipNum; - - FAPI_INF("Record Number => %u", l_record); // clear out buffer to known value before calling fapiGetMvpdField - memset(l_buffer, 0, 512); - - //@todo RTC 162565 - Change code to use POUNDV accessor function - // Get Chiplet MVPD data and put in chiplet_mvpd_data using accessor function - FAPI_TRY(getMvpdField((fapi2::MvpdRecord)l_record, - fapi2::MVPD_KEYWORD_PDV, - i_target, - l_buffer, - l_bufferSize)); - - // check buffer size - if (l_bufferSize < PDV_BUFFER_SIZE) - { - FAPI_ERR("**** ERROR : Wrong size buffer returned from fapiGetMvpdField for #V => %d", - l_bufferSize ); - // @todo-L3 - //const uint32_t &BUFFER_SIZE = l_bufferSize; //const fapi2::Target& CHIP_TARGET= i_target; - //FAPI_SET_HWP_ERROR(l_rc, RC_PROCPM_PSTATE_DATABLOCK_PDV_BUFFER_SIZE_ERROR); - break; - } + memset(l_buffer, 0, sizeof(l_poundv_data)); + + FAPI_TRY(p9_pm_get_poundv_bucket(l_eqChiplets[j], l_poundv_data)); + + memcpy(l_buffer, &l_poundv_data, sizeof(l_poundv_data)); // clear array memset(chiplet_mvpd_data, 0, sizeof(chiplet_mvpd_data)); @@ -572,8 +547,6 @@ proc_get_mvpd_data(const fapi2::Target& i_target, // fill chiplet_mvpd_data 2d array with data iN buffer (skip first byte - bucket id) #define UINT16_GET(__uint8_ptr) ((uint16_t)( ( (*((const uint8_t *)(__uint8_ptr)) << 8) | *((const uint8_t *)(__uint8_ptr) + 1) ) )) - //@todo RTC 162565 - Change code to use POUNDV accessor function - // use copy of allocated buffer pointer to increment through buffer l_buffer_inc = l_buffer; bucket_id = *l_buffer_inc; diff --git a/src/import/chips/p9/procedures/hwp/pm/p9_pstate_parameter_block.mk b/src/import/chips/p9/procedures/hwp/pm/p9_pstate_parameter_block.mk index bac8f0f54..756059f81 100644 --- a/src/import/chips/p9/procedures/hwp/pm/p9_pstate_parameter_block.mk +++ b/src/import/chips/p9/procedures/hwp/pm/p9_pstate_parameter_block.mk @@ -5,7 +5,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2015,2016 +# Contributors Listed Below - COPYRIGHT 2015,2017 # [+] International Business Machines Corp. # # @@ -30,4 +30,5 @@ PPB_INCLUDES+=$(PROJECT_ROOT)/chips/p9/procedures/hwp/pm $(call ADD_MODULE_INCDIR,$(PROCEDURE),$(PPB_INCLUDES)) #$(call ADD_MODULE_SRCDIR,$(PROCEDURE),$(ROOTPATH)/chips/p9/procedures/hwp/lib) lib$(PROCEDURE)_DEPLIBS+=p9_pm_utils +lib$(PROCEDURE)_DEPLIBS+=p9_pm_get_poundv_bucket $(call BUILD_PROCEDURE) -- cgit v1.2.1