summaryrefslogtreecommitdiffstats
path: root/src/import
diff options
context:
space:
mode:
authorSteven Janssen <janssens@us.ibm.com>2016-05-11 13:24:34 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2016-05-16 14:40:41 -0400
commit3f7e122b3e5a48a5d371788ec790a3b746f3d97d (patch)
treeb7bc2c9f84b1c12eebed6c661ba4941ec08d385c /src/import
parent9ce9b2574c96f93d6795c65d6b71f66bc3c95a4e (diff)
downloadtalos-hostboot-3f7e122b3e5a48a5d371788ec790a3b746f3d97d.tar.gz
talos-hostboot-3f7e122b3e5a48a5d371788ec790a3b746f3d97d.zip
splitting up functionality to bring p9_pm_get_poundv_attr accessible to cronus
Change-Id: I70b1ba297035b40c2d000d0281d148e55caf0083 Original-Change-Id: Iac60adb51f18677e6bdf07c0204393928c0a90d3 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/24391 Tested-by: Jenkins Server Tested-by: Hostboot CI Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com> Reviewed-by: Matt K. Light <mklight@us.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com> Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/24603 Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/import')
-rw-r--r--src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.C231
-rw-r--r--src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.H56
-rw-r--r--src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.mk20
3 files changed, 307 insertions, 0 deletions
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
new file mode 100644
index 000000000..9e2ca2673
--- /dev/null
+++ b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.C
@@ -0,0 +1,231 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.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_attr.C
+/// @brief Grab PM data from certain bucket in #V keyword in LRPX record
+///
+
+// ----------------------------------------------------------------------
+// Includes
+// ----------------------------------------------------------------------
+#include <p9_pm_get_poundv_bucket_attr.H>
+#include <mvpd_access_defs.H>
+#include <attribute_ids.H>
+
+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;
+ }
+
+ //Bucket ID is byte[4] of the PR keyword
+ memcpy(&l_bucketId, (l_prDataPtr + 4), 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 - 1) * 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 - 1) * 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 - 1) * 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_attr.H b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.H
new file mode 100644
index 000000000..e6cd81cb3
--- /dev/null
+++ b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.H
@@ -0,0 +1,56 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.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_ATTR_H_
+#define _P9_PM_GET_POUND_V_BUCKET_ATTR_H_
+
+//------------------------------------------------------------------------------
+// Includes
+//------------------------------------------------------------------------------
+#include <fapi2.H>
+
+// function pointer typedef definition for HWP call support
+typedef fapi2::ReturnCode (*p9_pm_get_poundv_bucket_attr_FP_t) (
+ const fapi2::Target<fapi2::TARGET_TYPE_EQ>&,
+ uint8_t* o_data);
+
+extern "C" {
+
+///
+/// @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);
+
+} // extern "C"
+
+#endif // _P9_PM_GET_POUND_V_BUCKET_ATTR_H_
diff --git a/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.mk b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.mk
new file mode 100644
index 000000000..539c38d25
--- /dev/null
+++ b/src/import/chips/p9/procedures/hwp/pm/p9_pm_get_poundv_bucket_attr.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_attr.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_attr
+$(call BUILD_PROCEDURE)
OpenPOWER on IntegriCloud