summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2
diff options
context:
space:
mode:
authorcrgeddes <crgeddes@us.ibm.com>2016-05-06 13:36:36 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2016-06-02 10:43:06 -0400
commit977c4ed35c3120a0f978e5a518ea3e0eab66e073 (patch)
treec472f86dc42edd65266e9f57e4aa6be9f40293c2 /src/usr/fapi2
parent93ff4cbbfc243a45e0926b139786206793436e3f (diff)
downloadtalos-hostboot-977c4ed35c3120a0f978e5a518ea3e0eab66e073.tar.gz
talos-hostboot-977c4ed35c3120a0f978e5a518ea3e0eab66e073.zip
Clean up MVPD plat support
Update fapi2 MVPD accessor tests to be more robust. Reworked error handling for accessor functions Change-Id: I54bcbedb81728b2c50b17e3c02018269669d5401 RTC:152953 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/24204 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Matt Derksen <v2cibmd@us.ibm.com> Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/fapi2')
-rw-r--r--src/usr/fapi2/attribute_service.C2
-rwxr-xr-xsrc/usr/fapi2/plat_mvpd_access.C116
-rw-r--r--src/usr/fapi2/test/fapi2MvpdTestCxx.H552
3 files changed, 355 insertions, 315 deletions
diff --git a/src/usr/fapi2/attribute_service.C b/src/usr/fapi2/attribute_service.C
index 20e26efee..831f95c62 100644
--- a/src/usr/fapi2/attribute_service.C
+++ b/src/usr/fapi2/attribute_service.C
@@ -393,7 +393,7 @@ ReturnCode platGetFusedCoreMode(uint8_t & o_isFused)
// ******************************************************************************
// fapi2::platAttrSvc::platGetPoundVBucketData function
-// ******************************************************************************
+//******************************************************************************
ReturnCode platGetPoundVBucketData(const Target<TARGET_TYPE_EQ>& i_fapiTarget,
uint8_t * o_poundVData)
{
diff --git a/src/usr/fapi2/plat_mvpd_access.C b/src/usr/fapi2/plat_mvpd_access.C
index dada82910..47e5c63e5 100755
--- a/src/usr/fapi2/plat_mvpd_access.C
+++ b/src/usr/fapi2/plat_mvpd_access.C
@@ -113,9 +113,38 @@ fapi2::ReturnCode MvpdRecordXlate(const fapi2::MvpdRecord i_fapiRecord,
uint8_t l_index = static_cast<uint8_t>(i_fapiRecord);
- if (l_index >= NUM_MVPD_RECORDS ||
- mvpdFapiRecordToHbRecord[l_index].rec == MVPD::MVPD_INVALID_RECORD
- )
+ if (l_index >= NUM_MVPD_RECORDS)
+ {
+ FAPI_ERR("MvpdRecordXlate: Index went out of bounds looking for record: 0x%x", i_fapiRecord);
+ /*@
+ * @errortype
+ * @moduleid MOD_FAPI2_MVPD_ACCESS
+ * @reasoncode RC_RECORD_OUT_OF_BOUNDS
+ * @userdata1 Record enumerator
+ * @userdata2[0:31] Index
+ * @userdata2[32:63] Max Index
+ * @devdesc Attempt to read an MVPD field using
+ * an invalid record
+ * @custdesc Firmware error during IPL
+ */
+
+ errlHndl_t l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi2::MOD_FAPI2_MVPD_ACCESS,
+ fapi2::RC_RECORD_OUT_OF_BOUNDS,
+ i_fapiRecord,
+ TWO_UINT32_TO_UINT64(l_index,
+ NUM_MVPD_RECORDS),
+ true);
+
+ //Set the record index to INVALID
+ //Don't set the data because we dont know anything about it
+ o_recordIndex = MVPD_INVALID_CHIP_UNIT;
+
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+ }
+ else if(mvpdFapiRecordToHbRecord[l_index].rec == MVPD::MVPD_INVALID_RECORD)
{
FAPI_ERR("MvpdRecordXlate: Invalid MVPD Record: 0x%x", i_fapiRecord);
/*@
@@ -127,23 +156,22 @@ fapi2::ReturnCode MvpdRecordXlate(const fapi2::MvpdRecord i_fapiRecord,
* @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);
+ i_fapiRecord, 0, true);
+
+ //Set information that we found
+ o_hbRecord = MVPD::MVPD_INVALID_RECORD;
+ o_recordIndex = mvpdFapiRecordToHbRecord[l_index].recIndex;
// 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
+
+ if(!l_rc)
{
o_hbRecord = mvpdFapiRecordToHbRecord[l_index].rec;
o_recordIndex = mvpdFapiRecordToHbRecord[l_index].recIndex;
@@ -163,8 +191,8 @@ fapi2::ReturnCode MvpdKeywordXlate(const fapi2::MvpdKeyword i_fapiKeyword,
{
// 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
+ // the FAPI keyword enumerators starting at zero and incrementing.
+ //Structure to map fapi2::MVPD_KEYWORD to chiplet chip num position
struct mvpdKeywordToHb
{
MVPD::mvpdKeyword keyword;
@@ -225,36 +253,66 @@ fapi2::ReturnCode MvpdKeywordXlate(const fapi2::MvpdKeyword i_fapiKeyword,
uint8_t l_index = static_cast<uint8_t>(i_fapiKeyword);
- if (l_index >= NUM_MVPD_KEYWORDS ||
- mvpdFapiKeywordToHbKeyword[l_index].keyword == MVPD::INVALID_MVPD_KEYWORD
- )
+
+
+ if (l_index >= NUM_MVPD_KEYWORDS)
{
- FAPI_ERR("MvpdKeywordXlate: Invalid MVPD Keyword: 0x%x", i_fapiKeyword);
+ FAPI_ERR("MvpdKeywordXlate: Index went out of bounds looking for 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
+ * @moduleid MOD_FAPI2_MVPD_ACCESS
+ * @reasoncode RC_KEYWORD_OUT_OF_BOUNDS
+ * @userdata1 Keyword enumerator
+ * @userdata2[0:31] Index
+ * @userdata2[32:63] Max Index
+ * @devdesc Attempt to read an MVPD field using
+ * an invalid keyword
+ * @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_KEYWORD,
- i_fapiKeyword, 0, hbSwError);
+ fapi2::RC_KEYWORD_OUT_OF_BOUNDS,
+ i_fapiKeyword,
+ TWO_UINT32_TO_UINT64(l_index,
+ NUM_MVPD_KEYWORDS),
+ true);
+
+ //Set the keyword index to INVALID
+ //Don't set the data because we dont know anything about it
+ o_keywordIndex = MVPD_INVALID_CHIP_UNIT;
// Add the error log pointer as data to the ReturnCode
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
}
-
- if ( l_index >= NUM_MVPD_KEYWORDS )
+ else if(mvpdFapiKeywordToHbKeyword[l_index].keyword == MVPD::INVALID_MVPD_KEYWORD)
{
- o_hbKeyword = MVPD::INVALID_MVPD_KEYWORD;
- o_keywordIndex = MVPD_INVALID_CHIP_UNIT;
+ 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
+ * @custdesc Firmware error during IPL
+ */
+
+ errlHndl_t l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi2::MOD_FAPI2_MVPD_ACCESS,
+ fapi2::RC_INVALID_KEYWORD,
+ i_fapiKeyword, 0, true);
+
+ //Set information that we found
+ o_hbKeyword = MVPD::INVALID_MVPD_KEYWORD;
+ o_keywordIndex = mvpdFapiKeywordToHbKeyword[l_index].keywordIndex;
+
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
}
- else
+
+ if(!l_rc)
{
o_hbKeyword = mvpdFapiKeywordToHbKeyword[l_index].keyword;
o_keywordIndex = mvpdFapiKeywordToHbKeyword[l_index].keywordIndex;
diff --git a/src/usr/fapi2/test/fapi2MvpdTestCxx.H b/src/usr/fapi2/test/fapi2MvpdTestCxx.H
index 8adeb0d7e..9bd00c956 100644
--- a/src/usr/fapi2/test/fapi2MvpdTestCxx.H
+++ b/src/usr/fapi2/test/fapi2MvpdTestCxx.H
@@ -49,291 +49,273 @@ 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
+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 ( size_t l_fapi2Index = MvpdRecord::MVPD_RECORD_FIRST;
+ l_fapi2Index < MvpdRecord::MVPD_RECORD_LAST; ++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);
+
+
+ if ( l_rc )
+ {
+ errlHndl_t l_errl = fapi2::rcToErrl(l_rc);
+ if(l_errl->reasonCode() != fapi2::RC_INVALID_RECORD)
+ {
+ TS_FAIL("testMvpdRecordCheck: Exceeded max index while searching for record MVPDRecord::0x%x", l_fapi2Index);
+ }
+ }
+
+ if( l_fapi2Index != l_fapi_check )
+ {
+ TS_FAIL("testMvpdRecordCheck:Record enumeration order changed, Actual = 0x%x Expected = 0x%x", l_fapi2Index, l_fapi_check );
+ }
+
+ }
+
+ 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 ( size_t l_fapi2Index = MvpdRecord::MVPD_RECORD_FIRST;
+ l_fapi2Index < MvpdRecord::MVPD_RECORD_LAST; ++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 )
+ {
+ errlHndl_t l_errl = fapi2::rcToErrl(l_rc);
+ if(l_errl->reasonCode() != fapi2::RC_INVALID_KEYWORD)
+ {
+ TS_FAIL("testMvpdKeywordCheck: Exceeded max index while searching for MVPDKeyword::0x%x", l_fapi2Index);
+ }
+ }
+
+ if( l_fapi2Index != l_fapi_check )
+ {
+ TS_FAIL("testMvpdKeywordCheck:Keyword enumeration order changed, Actual = 0x%x Expected = 0x%x", l_fapi2Index, l_fapi_check );
+ }
+
+ }
+
+ 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_ERR("getMvpdField: Failed getting Record buffer size");
+ 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_ERR( "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 : All Tests FAILED");
+ }
+
+ FAPI_INF("testMvpdValidate: EXIT !!");
+
+ } //testMvpdValidate
void testMvpdGetPoundVBucket(void)
{
OpenPOWER on IntegriCloud