summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H5
-rwxr-xr-xsrc/usr/fapi2/fapi2.mk1
-rwxr-xr-xsrc/usr/fapi2/makefile2
-rwxr-xr-xsrc/usr/fapi2/plat_mvpd_access.C407
-rw-r--r--src/usr/fapi2/test/fapi2MvpdTestCxx.H337
-rw-r--r--src/usr/fapi2/test/makefile1
6 files changed, 752 insertions, 1 deletions
diff --git a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H
index 730e809f7..5e8578cec 100644
--- a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H
+++ b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H
@@ -50,6 +50,7 @@ namespace fapi2
MOD_FAPI2_VERIFYCFAMACCESSTARGET = 0x07,
MOD_FAPI2_PLAT_GET_OTHER_END_TEST = 0x08,
MOD_FAPI2_PLAT_GET_OTHER_END = 0x09,
+ MOD_FAPI2_MVPD_ACCESS = 0x0A,
};
/**
@@ -66,6 +67,9 @@ namespace fapi2
RC_NULL_FAPI_TARGET = HWPF_COMP_ID | 0x0A,
RC_LOOKING_FOR_TYPE_NA = HWPF_COMP_ID | 0x0B,
+ // MVPD generated errors
+ RC_INVALID_RECORD = HWPF_COMP_ID | 0x0C,
+ RC_INVALID_KEYWORD = HWPF_COMP_ID | 0x0D,
//Platform generated errors
RC_NO_PROCS_FOUND = FAPI2_COMP_ID | 0x0B,
@@ -95,6 +99,7 @@ namespace fapi2
RC_INCORRECT_OTHER_END = FAPI2_COMP_ID | 0x24,
RC_FOUND_TOO_MANY_PEERS = FAPI2_COMP_ID | 0x25,
RC_FOUND_NO_PEERS = FAPI2_COMP_ID | 0x26,
+
// HWP generated errors
RC_HWP_GENERATED_ERROR = HWPF_COMP_ID | 0x0f,
diff --git a/src/usr/fapi2/fapi2.mk b/src/usr/fapi2/fapi2.mk
index cde9535e2..0df698bef 100755
--- a/src/usr/fapi2/fapi2.mk
+++ b/src/usr/fapi2/fapi2.mk
@@ -41,6 +41,7 @@ OBJS += plat_hwp_invoker.o
OBJS += target.o
OBJS += plat_hw_access.o
OBJS += plat_spd_access.o
+OBJS += plat_mvpd_access.o
#EKB Objects (mirrored in src/import)
OBJS += error_info.o
diff --git a/src/usr/fapi2/makefile b/src/usr/fapi2/makefile
index 26dcfca2b..391f67c64 100755
--- a/src/usr/fapi2/makefile
+++ b/src/usr/fapi2/makefile
@@ -48,4 +48,4 @@ include ${ROOTPATH}/src/import/hwpf/fapi2/tools/createIfAttrService.mk
include ${ROOTPATH}/config.mk
-vpath %.C ${GENDIR} \ No newline at end of file
+vpath %.C ${GENDIR}
diff --git a/src/usr/fapi2/plat_mvpd_access.C b/src/usr/fapi2/plat_mvpd_access.C
new file mode 100755
index 000000000..dada82910
--- /dev/null
+++ b/src/usr/fapi2/plat_mvpd_access.C
@@ -0,0 +1,407 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/plat_mvpd_access.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2016 */
+/* [+] 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 plat_mvpd_access.C
+ *
+ * @brief Implements the mvpd_access.H functions
+ */
+
+#include <stdint.h>
+#include <errl/errlentry.H>
+
+// fapi2 support changes
+#include <mvpd_access.H>
+#include <mvpd_access_defs.H>
+#include <hwpf_fapi2_reasoncodes.H>
+#include <devicefw/userif.H>
+#include <vpd/mvpdenums.H>
+
+// Invalid chip unit
+const uint8_t MVPD_INVALID_CHIP_UNIT = 0xFF;
+
+namespace fapi2
+{
+
+//******************************************************************************
+// MvpdRecordXlate
+// Translates a FAPI MVPD Record enumerator into a Hostboot MVPD Record
+// enumerator
+//******************************************************************************
+fapi2::ReturnCode MvpdRecordXlate(const fapi2::MvpdRecord i_fapiRecord,
+ MVPD::mvpdRecord & o_hbRecord,
+ uint8_t & o_recordIndex)
+{
+ // Create a lookup table for converting a FAPI MVPD record enumerator to a
+ // Hostboot MVPD record enumerator. This is a simple array and relies on
+ // the FAPI record enumerators starting at zero and incrementing.
+
+ //Structure to map fapi2::MVPD_RECORD to chiplet chip num position
+ struct mvpdRecordToChip
+ {
+ MVPD::mvpdRecord rec;
+ // This is the fapi2 Index to the MVPD record
+ uint8_t recIndex;
+ };
+ static const mvpdRecordToChip mvpdFapiRecordToHbRecord[] =
+ {
+ /** MVPD record mapping to FAPI2 MVPD **/
+ {MVPD::CRP0,MVPD_RECORD_CRP0},
+ {MVPD::CP00,MVPD_RECORD_CP00},
+ {MVPD::VINI,MVPD_RECORD_VINI},
+ {MVPD::LRP0,MVPD_RECORD_LRP0},
+ {MVPD::LRP1,MVPD_RECORD_LRP1},
+ {MVPD::LRP2,MVPD_RECORD_LRP2},
+ {MVPD::LRP3,MVPD_RECORD_LRP3},
+ {MVPD::LRP4,MVPD_RECORD_LRP4},
+ {MVPD::LRP5,MVPD_RECORD_LRP5},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LRP6},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LRP7},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LRP8},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LRP9},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LRPA},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LRPB},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LRPC},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LRPD},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LRPE},
+ {MVPD::LWP0,MVPD_RECORD_LWP0},
+ {MVPD::LWP1,MVPD_RECORD_LWP1},
+ {MVPD::LWP2,MVPD_RECORD_LWP2},
+ {MVPD::LWP3,MVPD_RECORD_LWP3},
+ {MVPD::LWP4,MVPD_RECORD_LWP4},
+ {MVPD::LWP5,MVPD_RECORD_LWP5},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LWP6},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LWP7},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LWP8},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LWP9},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LWPA},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LWPB},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LWPC},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LWPD},
+ {MVPD::MVPD_INVALID_RECORD,MVPD_RECORD_LWPE},
+ /* Record available in HB but not in FAPI*/
+ //{MVPD::VRML,MVPD_RECORD_VRML},
+ {MVPD::VWML,MVPD_RECORD_VWML},
+ {MVPD::MER0,MVPD_RECORD_MER0},
+ //{MVPD::VMSC,MVPD_RECORD_VMSC},
+ };
+ const uint8_t NUM_MVPD_RECORDS =
+ sizeof(mvpdFapiRecordToHbRecord)/sizeof(mvpdFapiRecordToHbRecord[0]);
+
+ fapi2::ReturnCode l_rc;
+
+ uint8_t l_index = static_cast<uint8_t>(i_fapiRecord);
+
+ if (l_index >= NUM_MVPD_RECORDS ||
+ mvpdFapiRecordToHbRecord[l_index].rec == MVPD::MVPD_INVALID_RECORD
+ )
+ {
+ FAPI_ERR("MvpdRecordXlate: Invalid MVPD Record: 0x%x", i_fapiRecord);
+ /*@
+ * @errortype
+ * @moduleid MOD_FAPI2_MVPD_ACCESS
+ * @reasoncode RC_INVALID_RECORD
+ * @userdata1 Record enumerator
+ * @devdesc Attempt to read an MVPD field using an invalid record
+ * @custdesc Firmware error during IPL
+ */
+
+ const bool hbSwError = true;
+ errlHndl_t l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi2::MOD_FAPI2_MVPD_ACCESS,
+ fapi2::RC_INVALID_RECORD,
+ i_fapiRecord, 0, hbSwError);
+
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+ }
+
+ if ( l_index >= NUM_MVPD_RECORDS )
+ {
+ o_hbRecord = MVPD::MVPD_INVALID_RECORD;
+ o_recordIndex = MVPD_INVALID_CHIP_UNIT;
+ }
+ else
+ {
+ o_hbRecord = mvpdFapiRecordToHbRecord[l_index].rec;
+ o_recordIndex = mvpdFapiRecordToHbRecord[l_index].recIndex;
+ }
+
+ return l_rc;
+}
+
+//******************************************************************************
+// MvpdKeywordXlate
+// Translates a FAPI MVPD Keyword enumerator into a Hostboot MVPD Keyword
+// enumerator
+//******************************************************************************
+fapi2::ReturnCode MvpdKeywordXlate(const fapi2::MvpdKeyword i_fapiKeyword,
+ MVPD::mvpdKeyword & o_hbKeyword,
+ uint8_t & o_keywordIndex)
+{
+ // Create a lookup table for converting a FAPI MVPD keyword enumerator to a
+ // Hostboot MVPD keyword enumerator. This is a simple array and relies on
+ // the FAPI record enumerators starting at zero and incrementing.
+ //Structure to map fapi2::MVPD_RECORD to chiplet chip num position
+ struct mvpdKeywordToHb
+ {
+ MVPD::mvpdKeyword keyword;
+ // This is the fapi2 Index to the MVPD Keyword
+ uint8_t keywordIndex;
+ };
+ static const mvpdKeywordToHb mvpdFapiKeywordToHbKeyword[] =
+ {
+ {MVPD::VD, MVPD_KEYWORD_VD},
+ {MVPD::ED, MVPD_KEYWORD_ED},
+ {MVPD::TE, MVPD_KEYWORD_TE},
+ {MVPD::DD, MVPD_KEYWORD_DD},
+ {MVPD::INVALID_MVPD_KEYWORD, MVPD_KEYWORD_PDP},
+ {MVPD::INVALID_MVPD_KEYWORD, MVPD_KEYWORD_ST},
+ {MVPD::DN, MVPD_KEYWORD_DN},
+ {MVPD::PG, MVPD_KEYWORD_PG},
+ {MVPD::PK, MVPD_KEYWORD_PK},
+ {MVPD::pdR, MVPD_KEYWORD_PDR},
+ {MVPD::pdV, MVPD_KEYWORD_PDV},
+ {MVPD::pdH, MVPD_KEYWORD_PDH},
+ {MVPD::SB, MVPD_KEYWORD_SB},
+ {MVPD::DR, MVPD_KEYWORD_DR},
+ {MVPD::VZ, MVPD_KEYWORD_VZ},
+ {MVPD::CC, MVPD_KEYWORD_CC},
+ {MVPD::CE, MVPD_KEYWORD_CE},
+ {MVPD::FN, MVPD_KEYWORD_FN},
+ {MVPD::PN, MVPD_KEYWORD_PN},
+ {MVPD::SN, MVPD_KEYWORD_SN},
+ {MVPD::PR, MVPD_KEYWORD_PR},
+ {MVPD::HE, MVPD_KEYWORD_HE},
+ {MVPD::CT, MVPD_KEYWORD_CT},
+ {MVPD::HW, MVPD_KEYWORD_HW},
+ {MVPD::pdM, MVPD_KEYWORD_PDM},
+ {MVPD::IN, MVPD_KEYWORD_IN},
+ {MVPD::INVALID_MVPD_KEYWORD, MVPD_KEYWORD_PD2},
+ {MVPD::INVALID_MVPD_KEYWORD, MVPD_KEYWORD_PD3},
+ {MVPD::INVALID_MVPD_KEYWORD, MVPD_KEYWORD_OC},
+ {MVPD::INVALID_MVPD_KEYWORD, MVPD_KEYWORD_FO},
+ {MVPD::pdI, MVPD_KEYWORD_PDI},
+ {MVPD::pdG, MVPD_KEYWORD_PDG},
+ {MVPD::INVALID_MVPD_KEYWORD, MVPD_KEYWORD_MK},
+ {MVPD::PB, MVPD_KEYWORD_PB},
+ {MVPD::CH, MVPD_KEYWORD_CH},
+ {MVPD::IQ, MVPD_KEYWORD_IQ},
+
+ /*Keywords available in HB but not in FAPI enum*/
+ //{MVPD::PM, MVPD_KEYWORD_PM},
+ //{MVPD::PZ, MVPD_KEYWORD_PZ},
+ //{MVPD::n20, MVPD_KEYWORD_N20},
+ //{MVPD::n21, MVPD_KEYWORD_N21},
+ //{MVPD::n30, MVPD_KEYWORD_N30},
+ //{MVPD::n31, MVPD_KEYWORD_N31},
+ };
+ const uint8_t NUM_MVPD_KEYWORDS =
+ sizeof(mvpdFapiKeywordToHbKeyword)/sizeof(mvpdFapiKeywordToHbKeyword[0]);
+
+ fapi2::ReturnCode l_rc;
+
+ uint8_t l_index = static_cast<uint8_t>(i_fapiKeyword);
+
+ if (l_index >= NUM_MVPD_KEYWORDS ||
+ mvpdFapiKeywordToHbKeyword[l_index].keyword == MVPD::INVALID_MVPD_KEYWORD
+ )
+ {
+ FAPI_ERR("MvpdKeywordXlate: Invalid MVPD Keyword: 0x%x", i_fapiKeyword);
+ /*@
+ * @errortype
+ * @moduleid MOD_FAPI2_MVPD_ACCESS
+ * @reasoncode RC_INVALID_KEYWORD
+ * @userdata1 Keyword enumerator
+ * @devdesc Attempt to read an MVPD field using an invalid keyword
+ */
+
+ const bool hbSwError = true;
+ errlHndl_t l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi2::MOD_FAPI2_MVPD_ACCESS,
+ fapi2::RC_INVALID_KEYWORD,
+ i_fapiKeyword, 0, hbSwError);
+
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+ }
+
+ if ( l_index >= NUM_MVPD_KEYWORDS )
+ {
+ o_hbKeyword = MVPD::INVALID_MVPD_KEYWORD;
+ o_keywordIndex = MVPD_INVALID_CHIP_UNIT;
+ }
+ else
+ {
+ o_hbKeyword = mvpdFapiKeywordToHbKeyword[l_index].keyword;
+ o_keywordIndex = mvpdFapiKeywordToHbKeyword[l_index].keywordIndex;
+ }
+
+ return l_rc;
+}
+
+//******************************************************************************
+// getMvpdField
+//******************************************************************************
+fapi2::ReturnCode getMvpdField
+ (const fapi2::MvpdRecord i_record,
+ const fapi2::MvpdKeyword i_keyword,
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> &i_procTarget,
+ uint8_t * const i_pBuffer,
+ uint32_t &io_fieldSize)
+{
+ uint8_t l_recIndex = MVPD_INVALID_CHIP_UNIT;
+ uint8_t l_keyIndex = MVPD_INVALID_CHIP_UNIT;
+ errlHndl_t l_errl = NULL;
+ fapi2::ReturnCode l_rc;
+ FAPI_DBG("getMvpdField entry");
+
+ do
+ {
+ // Translate the FAPI record to a Hostboot record
+ MVPD::mvpdRecord l_hbRecord = MVPD::MVPD_INVALID_RECORD;
+
+ l_rc = fapi2::MvpdRecordXlate(i_record, l_hbRecord, l_recIndex);
+
+ if (l_rc)
+ {
+ break;
+ }
+
+ // Translate the FAPI keyword to a Hostboot keyword
+ MVPD::mvpdKeyword l_hbKeyword = MVPD::INVALID_MVPD_KEYWORD;
+
+ l_rc = fapi2::MvpdKeywordXlate(i_keyword, l_hbKeyword, l_keyIndex);
+
+ if (l_rc)
+ {
+ break;
+ }
+
+ // deviceRead will return the size of the field if the
+ // pointer is NULL
+ size_t l_fieldLen = io_fieldSize;
+
+ l_errl = deviceRead(
+ reinterpret_cast< TARGETING::Target*>(i_procTarget.get()),
+ i_pBuffer,
+ l_fieldLen,
+ DEVICE_MVPD_ADDRESS(l_hbRecord, l_hbKeyword));
+
+ if (l_errl)
+ {
+ FAPI_ERR("getMvpdField: ERROR: deviceRead : errorlog PLID=0x%x",
+ l_errl->plid());
+
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+
+ break;
+ }
+
+ // Success, update callers io_fieldSize for the case where the
+ // pointer is NULL and deviceRead returned the actual size
+ io_fieldSize = l_fieldLen;
+
+ FAPI_DBG("getMvpdField: returning field len=0x%x", io_fieldSize);
+
+ } while(0);
+
+ if( l_rc)
+ {
+ io_fieldSize = 0;
+ }
+
+ FAPI_DBG( "getMvpdField: exit" );
+
+ return l_rc;
+}
+
+//******************************************************************************
+// setMvpdField
+//******************************************************************************
+fapi2::ReturnCode setMvpdField
+ (const fapi2::MvpdRecord i_record,
+ const fapi2::MvpdKeyword i_keyword,
+ const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> &i_procTarget,
+ const uint8_t * const i_pBuffer,
+ const uint32_t i_fieldSize)
+{
+ fapi2::ReturnCode l_rc;
+ uint8_t l_recIndex = MVPD_INVALID_CHIP_UNIT;
+ uint8_t l_keyIndex = MVPD_INVALID_CHIP_UNIT;
+ errlHndl_t l_errl = NULL;
+ FAPI_DBG("setMvpdField entry");
+
+ do
+ {
+ // Translate the FAPI record to a Hostboot record
+ MVPD::mvpdRecord l_hbRecord = MVPD::MVPD_INVALID_RECORD;
+
+ l_rc = fapi2::MvpdRecordXlate(i_record, l_hbRecord, l_recIndex);
+
+ if (l_rc)
+ {
+ break;
+ }
+
+ // Translate the FAPI keyword to a Hostboot keyword
+ MVPD::mvpdKeyword l_hbKeyword = MVPD::INVALID_MVPD_KEYWORD;
+
+ l_rc = fapi2::MvpdKeywordXlate(i_keyword, l_hbKeyword, l_keyIndex);
+
+ if (l_rc)
+ {
+ break;
+ }
+
+ size_t l_fieldLen = i_fieldSize;
+
+ l_errl = deviceWrite(
+ reinterpret_cast< TARGETING::Target*>(i_procTarget.get()),
+ const_cast<uint8_t *>(i_pBuffer),
+ l_fieldLen,
+ DEVICE_MVPD_ADDRESS(l_hbRecord, l_hbKeyword));
+
+ } while(0);
+
+ if (l_errl)
+ {
+ FAPI_ERR("setMvpdField: ERROR: deviceWrite : errorlog PLID=0x%x",
+ l_errl->plid());
+
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+
+ }
+
+ FAPI_DBG( "setMvpdField: exit" );
+
+ return l_rc;
+}
+
+} // fapi2
+
diff --git a/src/usr/fapi2/test/fapi2MvpdTestCxx.H b/src/usr/fapi2/test/fapi2MvpdTestCxx.H
new file mode 100644
index 000000000..c961434fe
--- /dev/null
+++ b/src/usr/fapi2/test/fapi2MvpdTestCxx.H
@@ -0,0 +1,337 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/fapi2MvpdTestCxx.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2016 */
+/* [+] 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 */
+#ifndef __MVPDTEST_H__
+#define __MVPDTEST_H__
+
+/**
+ * @file MvpdTestCxx.H
+ *
+ * @brief Test case for MVPD code
+ */
+
+#include <stdio.h>
+#include <cxxtest/TestSuite.H>
+#include <errl/errlmanager.H>
+#include <errl/errlentry.H>
+#include <vpd/mvpdenums.H>
+#include <mvpd_access.H>
+#include <mvpd_access_defs.H>
+#include "../plat_mvpd_access.C"
+#include <fapi2.H>
+#include <devicefw/userif.H>
+#include <vpd/mvpdenums.H>
+
+using namespace TARGETING;
+
+class MVPDTest: public CxxTest::TestSuite
+{
+ public:
+
+ /**
+ * @brief Test basic 1x1 FAPI2 and HB record mapping check
+ *
+ */
+ void testMvpdRecordCheck (void)
+ {
+ MVPD::mvpdRecord l_hbRecord = MVPD::MVPD_INVALID_RECORD;
+ uint8_t l_fapi_check=0xFF;
+ fapi2::ReturnCode l_rc;
+
+ FAPI_INF("testMvpdRecordCheck: ENTER");
+
+ // TBD : The fapi2 records enum comes from EKB. Latter add the
+ // end of list value to enumeration. For now MVPD_RECORD_MER0
+ // is the last entry.
+ // For each fapi2 record entry, loop till the last entry
+ for ( size_t l_fapi2Index = MvpdRecord::MVPD_RECORD_CRP0;
+ l_fapi2Index <= MvpdRecord::MVPD_RECORD_MER0; ++l_fapi2Index)
+ {
+ // Translate the FAPI record to a Hostboot record.
+ // This returns the MVPD record and the corresponding
+ // fapi2 record index of it.
+ // Ex Table: {MVPD::CRP0, fapi2::MVPD_RECORD_CRP0},
+ l_rc = fapi2::MvpdRecordXlate((fapi2::MvpdRecord)l_fapi2Index,
+ l_hbRecord,
+ l_fapi_check);
+
+ FAPI_INF("testMvpdRecordCheck() - FAPI2 Record: "
+ "0x%04x, - [ HB Record: 0x%04x, Index: 0x%04x ]",
+ l_fapi2Index,
+ l_hbRecord,
+ l_fapi_check);
+
+ // Either this will err or return Invalid.
+ // The LRP/LWP records are associated with the EQ chiplets and
+ // have 6 of them (0-5). For all of the invalid entries, it
+ // returns with MVPD_INVALID_RECORD.
+ if ( l_rc )
+ {
+ // if error returned from the table index translation
+ // check if it is valid ELSE ignore the error for the
+ // in this test use case.
+ if( l_fapi2Index != l_fapi_check )
+ {
+ TS_FAIL("testMvpdRecordCheck: Mapping Unexpected Failure !!");
+ break;
+ }
+ }
+ else
+ {
+ if( l_fapi2Index != l_fapi_check )
+ {
+ TS_FAIL("testMvpdRecordCheck:Record enumeration order changed");
+ break;
+ }
+ }
+
+ }
+
+ FAPI_INF("testMvpdRecordCheck: EXIT !!");
+
+ } // testMvpdRecordCheck
+
+ /**
+ * @brief Test basic 1x1 FAPI2 and HB keyword mapping check
+ *
+ */
+ void testMvpdKeywordCheck (void)
+ {
+ MVPD::mvpdKeyword l_hbKeyword = MVPD::INVALID_MVPD_KEYWORD;
+ uint8_t l_fapi_check=0xFF;
+ fapi2::ReturnCode l_rc;
+
+ FAPI_INF("testMvpdKeywordCheck: ENTER ");
+
+ // For each fapi2 keyword entry, loop till the last entry
+ for ( size_t l_fapi2Index = MvpdKeyword::MVPD_KEYWORD_VD;
+ l_fapi2Index <= MvpdKeyword::MVPD_KEYWORD_IQ; ++l_fapi2Index)
+ {
+ // Translate the FAPI record to a Hostboot record.
+ // This returns the MVPD record and the corresponding
+ // fapi2 keyword index of it.
+ l_rc = fapi2::MvpdKeywordXlate((fapi2::MvpdKeyword)l_fapi2Index,
+ l_hbKeyword,
+ l_fapi_check);
+
+ FAPI_INF("testMvpdKeywordCheck() - FAPI2 Keyword: "
+ "0x%04x, - [ HB Keyword: 0x%04x, Index: 0x%04x ]",
+ l_fapi2Index,
+ l_hbKeyword,
+ l_fapi_check);
+
+ if ( l_rc )
+ {
+ // if error returned from the table index translation
+ // check if it is valid ELSE ignore the error for the
+ // in this test use case.
+ if( l_fapi2Index != l_fapi_check )
+ {
+ TS_FAIL("testMvpdKeywordCheck: Mapping Unexpected Failure !!");
+ break;
+ }
+ }
+ else
+ {
+ if( l_fapi2Index != l_fapi_check )
+ {
+ TS_FAIL("testMvpdKeywordCheck: Keyword enumeration order changed");
+ break;
+ }
+ }
+
+ }
+
+ FAPI_INF("testMvpdKeywordCheck: EXIT !!");
+
+ } // testMvpdKeywordCheck
+
+ /**
+ * @brief Test to Read using MVPD HB interface and verify
+ *
+ */
+ void testMvpdValidate (void)
+ {
+ errlHndl_t l_errl = NULL;
+ fapi2::ReturnCode l_rc;
+ uint8_t *l_fieldData = NULL;
+ uint32_t l_fieldBuffer = 0;
+ uint32_t testPassCount = 0;
+
+ FAPI_INF("testMvpdValidate: ENTER ");
+
+ // list of MVPD records to test
+ struct testMVPDRecords {
+ MvpdRecord record;
+ MvpdKeyword keyword;
+ };
+
+ // Build the record, let it test both successful and failure
+ // use cases.
+ struct testMVPDRecords l_mvpdRecords[] = {
+ // Records to use
+ { MVPD_RECORD_CRP0, MVPD_KEYWORD_VD},
+ { MVPD_RECORD_CP00, MVPD_KEYWORD_ED},
+ { MVPD_RECORD_VINI, MVPD_KEYWORD_TE},
+ { MVPD_RECORD_LRP0, MVPD_KEYWORD_DD},
+ { MVPD_RECORD_LRP1, MVPD_KEYWORD_DN},
+ { MVPD_RECORD_LRP2, MVPD_KEYWORD_PG},
+ { MVPD_RECORD_LRP3, MVPD_KEYWORD_PK},
+ { MVPD_RECORD_LRP4, MVPD_KEYWORD_PDR},
+ { MVPD_RECORD_LRP5, MVPD_KEYWORD_PDV},
+ { MVPD_RECORD_LWP0, MVPD_KEYWORD_PN},
+ { MVPD_RECORD_LWP1, MVPD_KEYWORD_SN},
+ { MVPD_RECORD_LWP2, MVPD_KEYWORD_PR},
+ { MVPD_RECORD_LWP3, MVPD_KEYWORD_HE},
+ { MVPD_RECORD_LWP4, MVPD_KEYWORD_CT},
+ { MVPD_RECORD_LWP5, MVPD_KEYWORD_HW},
+ };
+
+ TARGETING::TargetHandleList l_chipList;
+
+ // Get a list of all of the proc chips
+ TARGETING::getAllChips(l_chipList, TARGETING::TYPE_PROC, false);
+
+ // Loop through the record
+ FAPI_INF( "testMvpdValidate l_chipList.size()= 0x%x ",
+ l_chipList.size() );
+
+ // loop thru all the cpu's
+ for (TargetHandleList::iterator l_cpu_iter = l_chipList.begin();
+ l_cpu_iter != l_chipList.end();
+ ++l_cpu_iter)
+ {
+ // Local place holder for CPU target
+ TARGETING::Target* l_cpu_target = *l_cpu_iter;
+
+ FAPI_INF("target HUID %.8X", TARGETING::get_huid(l_cpu_target));
+
+ // Call the interface
+ // loop through mvpd records prepared
+ const uint32_t numRecords =
+ sizeof(l_mvpdRecords)/sizeof(l_mvpdRecords[0]);
+ for (uint8_t i=0;i<numRecords;i++) {
+
+ FAPI_INF( "record = 0x%x keyword = 0x%x",
+ l_mvpdRecords[i].record,
+ l_mvpdRecords[i].keyword);
+
+ // call getMvpdField once with a NULL pointer to get the
+ // buffer size should return the size
+ l_rc = getMvpdField(l_mvpdRecords[i].record,
+ l_mvpdRecords[i].keyword,
+ l_cpu_target,
+ NULL,
+ l_fieldBuffer );
+ if ( l_rc != fapi2::FAPI2_RC_SUCCESS )
+ {
+ FAPI_INF("getMvpdField: Failed getting Record buffer");
+ continue;
+ }
+
+ FAPI_INF( "getMvpdField: size of record = 0x%x",
+ l_fieldBuffer );
+
+ // Validate the Records
+ l_fieldData = reinterpret_cast<uint8_t *>
+ (malloc(l_fieldBuffer) );
+
+ // call getMvpdField once with a valid buffer
+ l_rc = getMvpdField(l_mvpdRecords[i].record,
+ l_mvpdRecords[i].keyword,
+ l_cpu_target,
+ l_fieldData,
+ l_fieldBuffer );
+ if ( l_rc != fapi2::FAPI2_RC_SUCCESS )
+ {
+ FAPI_INF( "getMvpdField: Error Getting the Record" );
+ free( l_fieldData );
+ continue;
+ }
+
+ //*** Validate using Device Read **
+ // The size length is already fetched in above using the
+ // interface. Use the Buffer length and fetch the data
+ // via device read.
+ size_t l_fieldLen = l_fieldBuffer;
+ uint8_t* l_devData = NULL;
+ l_devData = reinterpret_cast<uint8_t *>
+ (malloc(l_fieldBuffer));
+
+ l_errl = deviceRead(
+ l_cpu_target,
+ l_devData,
+ l_fieldLen,
+ DEVICE_MVPD_ADDRESS(l_mvpdRecords[i].record,
+ l_mvpdRecords[i].keyword
+ )
+ );
+ if (l_errl)
+ {
+ FAPI_ERR("deviceRead: ERROR: errorlog PLID=0x%x",
+ l_errl->plid());
+ FAPI_INF( "deviceRead: Error Getting the Record" );
+ free( l_devData );
+ continue;
+ }
+
+ // Interface vs device read fetched record data
+ if ( !memcmp(l_fieldData,l_devData,sizeof(l_fieldBuffer)))
+ {
+ FAPI_INF( "getMvpdField: Record fetch success:PASSED" );
+ testPassCount++;
+ }
+ else
+ {
+ FAPI_INF( "getMvpdField: Record fetch are different" );
+ FAPI_ERR( "Error: Fetch record = 0x%x :"
+ "device read record = 0x%x",
+ l_fieldData,l_devData );
+ }
+
+ // clean up memory if we are here
+ free( l_fieldData );
+ free( l_devData );
+
+ }// Loop through the records
+
+ } // Loop target list
+
+ // Allowing to run through the table both valid and invalid entries
+ // so that it test both the successful and failure use cases.
+ if (testPassCount)
+ {
+ FAPI_INF(" testMvpdValidate : Test Passed = %d",testPassCount);
+ }
+ else
+ {
+ TS_FAIL(" testMvpdValidate : Test PASSED");
+ }
+
+ FAPI_INF("testMvpdValidate: EXIT !!");
+
+ } //testMvpdValidate
+};
+
+#endif
diff --git a/src/usr/fapi2/test/makefile b/src/usr/fapi2/test/makefile
index ae19dd34d..58f0cf231 100644
--- a/src/usr/fapi2/test/makefile
+++ b/src/usr/fapi2/test/makefile
@@ -49,6 +49,7 @@ TESTS += fapi2GetChildrenTest.H
TESTS += fapi2BasicTryTest.H
TESTS += fapi2GetOtherEndTest.H
TESTS += fapi2SpdTestCxx.H
+TESTS += fapi2MvpdTestCxx.H
include ${ROOTPATH}/config.mk
OpenPOWER on IntegriCloud