diff options
| author | Bill Schwartz <whs@us.ibm.com> | 2013-11-15 17:23:29 -0600 |
|---|---|---|
| committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-12-09 12:07:20 -0600 |
| commit | 5ec9d6332a0b9c91b133690ab356dc4052a5e291 (patch) | |
| tree | 19e95ce95b075f371bbbdc79abca6571351fa962 /src/usr/hwpf/test | |
| parent | 8419ba440403c1b02b74ad89a91fccd85fa45ea9 (diff) | |
| download | talos-hostboot-5ec9d6332a0b9c91b133690ab356dc4052a5e291.tar.gz talos-hostboot-5ec9d6332a0b9c91b133690ab356dc4052a5e291.zip | |
Route ATTR_L4_BANK_DELETE_VPD to C-VPD
Create MBvpd accessor to access cvpd record VSPD keyword MX for get and set
for attribute ATTR_L4_BANK_DELETE_VPD.
Split and rename fapiwinkle test since its all hwp mvpd & mbvpd accessor tests
Change-Id: I3bae2e89b2ef7fd30a88c269d42223c00333bb72
RTC: 91431
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/7278
Tested-by: Jenkins Server
Reviewed-by: Brian H. Horton <brianh@linux.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/test')
| -rw-r--r-- | src/usr/hwpf/test/hwpMBvpdAccessorTest.H (renamed from src/usr/hwpf/test/fapiwinkletest.H) | 1009 | ||||
| -rw-r--r-- | src/usr/hwpf/test/hwpMvpdAccessorTest.H | 899 |
2 files changed, 1034 insertions, 874 deletions
diff --git a/src/usr/hwpf/test/fapiwinkletest.H b/src/usr/hwpf/test/hwpMBvpdAccessorTest.H index faae88919..eb0d54f64 100644 --- a/src/usr/hwpf/test/fapiwinkletest.H +++ b/src/usr/hwpf/test/hwpMBvpdAccessorTest.H @@ -1,7 +1,7 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: src/usr/hwpf/test/fapiwinkletest.H $ */ +/* $Source: src/usr/hwpf/test/hwpmbvpdaccessortest.H $ */ /* */ /* IBM CONFIDENTIAL */ /* */ @@ -21,19 +21,23 @@ /* */ /* IBM_PROLOG_END_TAG */ -#ifndef __FAPIWINKLETEST_H -#define __FAPIWINKLETEST_H +#ifndef __HWPMBVPDACCESSORTEST_H +#define __HWPMBVPDACCESSORTEST_H // set to 1 for doing unit tests, set to 0 for production -#define UNITTESTfwt 0 -#define UNITTEST2fwt 0 #define HWPMBVPDACCESSORTEST_UT0 0 // 0 = just one chip, 1 = all +#define HWPMBVPDACCESSORTEST_UT1 0 // 0 = the last keword added, 1 = all & dump +#define HWPMBVPDACCESSORTEST_UT2 0 // 0 = min slope intercept tests +#define HWPMBVPDACCESSORTEST_UT3 0 // 0 = min L4 Bank Delete tests +#define HWPMBVPDACCESSORTEST_UT4 0 // 0 = min term data tests +#define HWPMBVPDACCESSORTEST_UT5 0 // 0 = min phase rotator data tests +#define HWPMBVPDACCESSORTEST_UT6 0 // 0 = include those moved in v5.3 redefine #define HWPMBVPDACCESSORTEST_UT7 0 // 0 = min sensor map tests /** - * @file fapiwinkletest.H + * @file hwpmbvpdaccessortest.H * - * @brief Test cases for winkle HWP utilities. + * @brief Test cases for MBvpd HWP accessors. */ #include <cxxtest/TestSuite.H> @@ -44,7 +48,6 @@ #include <targeting/common/commontargeting.H> #include <targeting/common/utilFilter.H> -#include <getMvpdRing.H> #include <setMvpdRing.H> #include <mvpd_accessors/getMBvpdPhaseRotatorData.H> #include <mvpd_accessors/getMBvpdAddrMirrorData.H> @@ -53,124 +56,22 @@ #include <mvpd_accessors/getMBvpdVersion.H> #include <mvpd_accessors/getMBvpdDram2NModeEnabled.H> #include <mvpd_accessors/getMBvpdSensorMap.H> +#include <mvpd_accessors/accessMBvpdL4BankDelete.H> #include <errl/errlmanager.H> #include <errl/errlentry.H> #include <devicefw/driverif.H> #include <trace/interface.H> -// pull in CompressedScanData def from proc_slw_build HWP -#include <p8_scan_compression.H> using namespace fapi; using namespace TARGETING; -class FapiWinkleTest: public CxxTest::TestSuite +class hwpMBvpdAccessorTest : public CxxTest::TestSuite { public: /** - * @brief call fapiGetMvpdField to fetch a mvpd records. - * - */ - void testGetMvpd() - { - fapi::ReturnCode l_fapirc; - uint8_t *l_pdRRecord = NULL; - uint32_t l_pdRLen = 0; - - // list of MVPD records to test. Need to be in PNOR or procmvpd.dat - // when g_usePNOR is false. - struct _testMvpdRecords { - fapi::MvpdRecord record; - fapi::MvpdKeyword keyword; - } l_mvpdRecords[] = { -#if UNITTESTfwt - { MVPD_RECORD_CP00, MVPD_KEYWORD_PDG}, - { MVPD_RECORD_MER0, MVPD_KEYWORD_PDI}, -// { MVPD_RECORD_VER0, MVPD_KEYWORD_PDI}, //VER0 in spec,not supported -#endif - { MVPD_RECORD_VWML, MVPD_KEYWORD_PDI}, - }; - - TS_TRACE( "testGetMvpd entry" ); - - TARGETING::TargetHandleList l_cpuTargetList; - getAllChips(l_cpuTargetList, TYPE_PROC); - - TS_TRACE( "testGetMvpd l_cpuTargetList.size()= 0x%x ", - l_cpuTargetList.size() ); - - - // loop thru all the cpu's - for (TargetHandleList::iterator l_cpu_iter = l_cpuTargetList.begin(); - l_cpu_iter != l_cpuTargetList.end(); - ++l_cpu_iter) - { - // make a local copy of the CPU target - TARGETING::Target* l_cpu_target = *l_cpu_iter; - - TS_TRACE( "target HUID %.8X", TARGETING::get_huid(l_cpu_target)); - - // cast OUR type of target to a FAPI type of target. - fapi::Target l_fapi_cpu_target( - TARGET_TYPE_PROC_CHIP, - (const_cast<TARGETING::Target*>(l_cpu_target)) ); - - // loop through mvpd records of interest - const uint32_t numRecords = - sizeof(l_mvpdRecords)/sizeof(l_mvpdRecords[0]); - for (uint8_t i=0;i<numRecords;i++) { - - TS_TRACE( "record = 0x%x keyword = 0x%x", - l_mvpdRecords[i].record, - l_mvpdRecords[i].keyword); - - TS_TRACE( "call fapiGetMvpdField with NULL pointer" ); - - // call fapiGetMvpdField once with a NULL pointer to get the - // buffer size should return no error now. - l_fapirc = fapiGetMvpdField(l_mvpdRecords[i].record, - l_mvpdRecords[i].keyword, - l_fapi_cpu_target, - NULL, - l_pdRLen ); - if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) - { - TS_FAIL( "fapiGetMvpdField: expected FAPI_RC_SUCCESS" ); - fapiLogError(l_fapirc); - return; - } - - TS_TRACE( "fapiGetMvpdField: size of record = 0x%x", - l_pdRLen ); - - // do a malloc instead of a new just for variety - l_pdRRecord = reinterpret_cast<uint8_t *>(malloc(l_pdRLen) ); - - // call fapiGetMvpdField once with a valid pointer - l_fapirc = fapiGetMvpdField(l_mvpdRecords[i].record, - l_mvpdRecords[i].keyword, - l_fapi_cpu_target, - l_pdRRecord, - l_pdRLen ); - if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) - { - TS_FAIL( "fapiGetMvpdField: expected FAPI_RC_SUCCESS" ); - fapiLogError(l_fapirc); - free( l_pdRRecord ); - return; - } - - // clean up memory - free( l_pdRRecord ); - } - } - - TS_TRACE( "testGetMvpd exit" ); - } - - /** * @brief call fapiGetMBvpdField to fetch memory buffer vpd records. * */ @@ -185,7 +86,7 @@ public: fapi::MBvpdRecord record; fapi::MBvpdKeyword keyword; } l_mbvpdRecords[] = { -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT1 { MBVPD_RECORD_VEIR, MBVPD_KEYWORD_PDI}, // { MBVPD_RECORD_VER0, MBVPD_KEYWORD_PDI},//in spec, not supported { MBVPD_RECORD_MER0, MBVPD_KEYWORD_PDI}, @@ -237,7 +138,7 @@ public: TS_TRACE( "call fapiGetMBvpdField with NULL pointer" ); - // call fapiGetMvpdField once with a NULL pointer to get the + // call fapiGetMvpdField once with a NULL pointer to get the // buffer size should return no error now. l_fapirc = fapiGetMBvpdField(l_mbvpdRecords[i].record, l_mbvpdRecords[i].keyword, @@ -270,7 +171,7 @@ public: free( l_pRecord ); return; } -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT1 TRACFCOMP(g_trac_test,"testMBvpd:Record=%d,Keyword=%d", l_mbvpdRecords[i].record, l_mbvpdRecords[i].keyword); @@ -321,7 +222,7 @@ public: TS_TRACE( "testGetSlopeInterceptData l_memBufList.size()=%d", l_memBufList.size() ); // loop thru memory buffers -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbNum = 0; // check them all in unit test #else uint8_t l_mbNum = (l_memBufList.size() > 0) ? l_memBufList.size()-1 : 0; @@ -347,7 +248,7 @@ public: if (l_fapirc) break; TS_TRACE( "testSlopeInterceptData accessor " "MASTER_POWER_SLOPE=0x%08x", l_val); -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT2 // MASTER_POWER_INTERCEPT l_fapirc = (*l_getMBvpdSlopeInterceptData)(l_fapi_mb_target, @@ -376,7 +277,7 @@ public: if (l_fapirc) break; TS_TRACE( "testSlopeInterceptData attr " "MASTER_POWER_SLOPE=0x%08x", l_val); -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT2 // MASTER_POWER_INTERCEPT l_fapirc = FAPI_ATTR_GET(ATTR_CDIMM_VPD_MASTER_POWER_INTERCEPT, &l_fapi_mb_target, l_val); @@ -412,6 +313,102 @@ public: } /** + * @brief call accessMBvpdL4BankDelete to fetch VSPD keyword MX + * + */ + void testL4BankDelete() + { + fapi::ReturnCode l_fapirc( fapi::FAPI_RC_SUCCESS ); +#if HWPMBVPDACCESSORTEST_UT3 + accessMBvpdL4BankDelete_FP_t (l_accessMBvpdL4BankDelete) + = &accessMBvpdL4BankDelete; +#endif + + TS_TRACE( "testL4BankDelete entry" ); + + TARGETING::TargetHandleList l_memBufList; + getAllChips(l_memBufList, TYPE_MEMBUF); + + TS_TRACE( "testL4BankDelete l_memBufList.size()=%d", + l_memBufList.size() ); + // loop thru memory buffers +#if HWPMBVPDACCESSORTEST_UT0 + uint8_t l_mbNum = 0; // check them all in unit test +#else + uint8_t l_mbNum = (l_memBufList.size() > 0) ? l_memBufList.size()-1 : 0; +#endif + for (; l_mbNum < l_memBufList.size(); l_mbNum++ ) + { + // make a local copy of the memory buffer target + TARGETING::Target* l_mb_target = l_memBufList[l_mbNum]; + + // cast OUR type of target to a FAPI type of target. + fapi::Target l_fapi_mb_target( TARGET_TYPE_MEMBUF_CHIP, + (const_cast<TARGETING::Target*>(l_mb_target)) ); + + // verify HWP accessor + uint32_t l_val = 0xffffffff; + +#if HWPMBVPDACCESSORTEST_UT3 + // Get + l_fapirc=(*l_accessMBvpdL4BankDelete)(l_fapi_mb_target, + l_val, + GET_L4_BANK_DELETE_MODE); + if (l_fapirc) + { + TS_FAIL( "fapiGetVersion: HWP accessor get fail rc=0x%x", + static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); + } + else + { + TS_TRACE( "testL4BankDelete accessor get 0x%08x",l_val); + } + // Set (use same value) + l_fapirc=(*l_accessMBvpdL4BankDelete)(l_fapi_mb_target, + l_val, + SET_L4_BANK_DELETE_MODE); + if (l_fapirc) + { + TS_FAIL( "fapiL4BankDelete accessor set fail rc=0x%x", + static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); + } +#endif + // verify attribute + l_val = 0xffffffff; + // Get + l_fapirc = FAPI_ATTR_GET(ATTR_L4_BANK_DELETE_VPD, + &l_fapi_mb_target, + l_val); + if (l_fapirc) + { + TS_FAIL( "fapiL4BankDelete: HWP attribute get fail rc=0x%x", + static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); + } + else + { + TS_TRACE( "testL4BankDelete attribute get 0x%08x",l_val); + } +#if HWPMBVPDACCESSORTEST_UT3 + // Set (use same value) + l_fapirc = FAPI_ATTR_SET(ATTR_L4_BANK_DELETE_VPD, + &l_fapi_mb_target, + l_val); + if (l_fapirc) + { + TS_FAIL( "fapiL4BankDelete: HWP attribute set fail rc=0x%x", + static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); + } +#endif + } + + TS_TRACE( "testL4BankDelete exit" ); + } + +/** * @brief call getMBvpdSensorMap to fetch sensor map * attributes from the MW keyword * @@ -513,7 +510,7 @@ public: TS_TRACE( "testGetVersion l_memBufList.size()=%d", l_memBufList.size() ); // loop thru memory buffers -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbNum = 0; // check them all in unit test #else uint8_t l_mbNum = (l_memBufList.size() > 0) ? l_memBufList.size()-1 : 0; @@ -528,7 +525,7 @@ public: l_mbaList.size()); // loop thru all the mbas (should be 2) -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbaNum = 0; // check them all in unit test #else uint8_t l_mbaNum = (l_mbaList.size() > 0) ? l_mbaList.size()-1:0 ; @@ -562,7 +559,7 @@ public: } // loop thru all the DIMMs (should be 4) -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_dimmNum = 0; // check them all in unit test #else uint8_t l_dimmNum = @@ -570,8 +567,6 @@ public: #endif for (; l_dimmNum < l_dimmList.size(); l_dimmNum++ ) { -// uint32_t l_val = 0xFFFFFFFF; - // dump physical path to target EntityPath l_path; l_path = l_dimmList[l_dimmNum]->getAttr<ATTR_PHYS_PATH>(); @@ -620,7 +615,7 @@ public: TS_TRACE( "testGetDram2NModeEnabled l_memBufList.size()=%d", l_memBufList.size() ); // loop thru memory buffers -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbNum = 0; // check them all in unit test #else uint8_t l_mbNum = (l_memBufList.size() > 0) ? l_memBufList.size()-1 : 0; @@ -635,7 +630,7 @@ public: l_mbaList.size()); // loop thru all the mbas (should be 2) -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbaNum = 0; // check them all in unit test #else uint8_t l_mbaNum = (l_mbaList.size() > 0) ? l_mbaList.size()-1:0 ; @@ -704,7 +699,7 @@ public: TS_TRACE( "testGetAddrMirrorData l_memBufList.size()=%d", l_memBufList.size() ); // loop thru memory buffers -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbNum = 0; // check them all in unit test #else uint8_t l_mbNum = (l_memBufList.size() > 0) ? l_memBufList.size()-1 : 0; @@ -719,7 +714,7 @@ public: l_mbaList.size()); // loop thru all the mbas (should be 2) -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbaNum = 0; // check them all in unit test #else uint8_t l_mbaNum = (l_mbaList.size() > 0) ? l_mbaList.size()-1:0 ; @@ -778,7 +773,7 @@ public: { fapi::ReturnCode l_fapirc; uint8_t val1[2][2] = {{0xFF,0xFF},{0xFF,0xFF}}; -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t val2[2][2][4]={ {{0xFF,0xFF,0xFF,0xFF},{0xFF,0xFF,0xFF,0xFF}}, {{0xFF,0xFF,0xFF,0xFF},{0xFF,0xFF,0xFF,0xFF}}}; @@ -786,10 +781,10 @@ public: uint8_t val4[2] = {0xFF,0xFF}; #endif uint32_t val3[2] = {0xFFFFFFFF,0xFFFFFFFF}; -#if UNITTEST2fwt +#if HWPMBVPDACCESSORTEST_UT4 uint8_t val5[2] = {0xFF,0xFF}; #endif -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 getMBvpdTermData_FP_t (l_getMBvpdTermData) = &getMBvpdTermData; #endif @@ -803,7 +798,7 @@ public: l_memBufList.size() ); // loop thru memory buffers -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbNum = 0; // check them all in unit test #else uint8_t l_mbNum = (l_memBufList.size() > 0) ? l_memBufList.size()-1 : 0; @@ -818,7 +813,7 @@ public: l_mbaList.size()); // loop thru all the mbas (should be 2) -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbaNum = 0; // check them all in unit test #else uint8_t l_mbaNum = (l_mbaList.size() > 0) ? l_mbaList.size()-1:0 ; @@ -835,7 +830,7 @@ public: TARGET_TYPE_MBA_CHIPLET, (const_cast<TARGETING::Target*>(l_mbaList[l_mbaNum])) ); -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT4 // check for interface errors being caught. Just once. if (l_errorChk) { // check size matches type for each of the 4 types @@ -902,7 +897,7 @@ public: "TERM_DATA_DRAM_RON=(0x%02x,0x%02x),(0x%02x,0x%02x)", val1[0][0], val1[0][1], val1[1][0], val1[1][1]); -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT4 // TERM_DATA_DRAM_RTT_NOM l_fapirc = FAPI_ATTR_GET(ATTR_VPD_DRAM_RTT_NOM, &l_fapi_mba_target, val2); @@ -1085,7 +1080,7 @@ public: "TERM_DATA_CKE_PRI_MAP=0x%08x,0x%08x", val3[0], val3[1]); -#if UNITTEST2fwt +#if HWPMBVPDACCESSORTEST_UT4 // TERM_DATA_CKE_PWR_MAP val3[0] = 0xFFFFFFFF; val3[1] = 0xFFFFFFFF; @@ -1154,7 +1149,7 @@ public: l_memBufList.size() ); // loop thru memory buffers -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbNum = 0; // check them all in unit test #else uint8_t l_mbNum = (l_memBufList.size() > 0) ? l_memBufList.size()-1 : 0; @@ -1169,7 +1164,7 @@ public: l_mbaList.size()); // loop thru all the mbas (should be 2) -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT0 uint8_t l_mbaNum = 0; // check them all in unit test #else uint8_t l_mbaNum = (l_mbaList.size() > 0) ? l_mbaList.size()-1:0 ; @@ -1199,7 +1194,7 @@ public: " ATTR_VPD_CEN_PHASE_ROT_M0_CLK_P0=(0x%02x,0x%02x)", l_attr_eff_cen_phase_rot[0], l_attr_eff_cen_phase_rot[1]); -#if UNITTESTfwt +#if HWPMBVPDACCESSORTEST_UT5 l_fapirc = FAPI_ATTR_GET(ATTR_VPD_CEN_PHASE_ROT_M0_CLK_P1, &l_fapi_mba_target, l_attr_eff_cen_phase_rot); @@ -1624,7 +1619,7 @@ public: l_attr_eff_cen_phase_rot[1]); #endif -#ifdef UNITTEST2fwt +#ifdef HWPMBVPDACCESSORTEST_UT6 l_fapirc = FAPI_ATTR_GET(ATTR_VPD_TSYS_ADR, &l_fapi_mba_target, l_attr_eff_cen_phase_rot); @@ -1656,740 +1651,6 @@ public: } - - // Structure used to save/restore the VPD - typedef struct saveRestoreData_t { - TARGETING::Target* target; - uint8_t* CP00_pdG; - size_t CP00_pdG_size; - uint8_t* CP00_pdR; - size_t CP00_pdR_size; - } saveRestoreData_t; - - /** - * @brief Test get and set of Repair Rings - */ - void testRepairRings() - { - fapi::ReturnCode l_fapirc; - uint8_t *l_pRingBuf = NULL; - uint32_t l_ringBufsize = 0; - uint32_t l_ringId = 0; - uint32_t l_chipletId = 0; - uint32_t l_bufsize = 0x200; - errlHndl_t l_errhdl = NULL; - - // This data needs to be in sync with the procmvpd.dat file - // the setMvpdFunc tests use the last row. The test - // expects it to be a mid x20 byte ring in the #G keyword - struct _testRRstr { - fapi::MvpdKeyword keyword; - uint32_t ringIdval; - uint32_t chipletIdval; - uint32_t size; - uint32_t rc; - } l_ringModifiers[] = { - { MVPD_KEYWORD_PDG, 0xa4, 0xFF, 0x20, //last #G - fapi::RC_REPAIR_RING_NOT_FOUND }, - { MVPD_KEYWORD_PDR, 0xe0, 0x08, 0x20, //first #R - FAPI_RC_SUCCESS }, - { MVPD_KEYWORD_PDR, 0xe2, 0x16, 0x20, //big #R - FAPI_RC_SUCCESS }, - { MVPD_KEYWORD_PDG, 0xa2, 0x08, 0x20, //mid #G - FAPI_RC_SUCCESS }, - { MVPD_KEYWORD_PDR, 0xe1, 0x16, 0x20,//big #R - FAPI_RC_SUCCESS }, - }; - const size_t VALID_INDEX = 2; - const size_t TEST_INDEX = 4; - - TS_TRACE( "testRepairRings entry" ); - - std::list<saveRestoreData_t> l_srData; - - TARGETING::TargetHandleList l_cpuTargetList; - getAllChips(l_cpuTargetList, TYPE_PROC); - - // loop thru all the cpu's - for (TargetHandleList::iterator l_cpu_iter = l_cpuTargetList.begin(); - l_cpu_iter != l_cpuTargetList.end(); - ++l_cpu_iter) - { - // make a local copy of the CPU target - TARGETING::Target* l_cpu_target = *l_cpu_iter; - - TS_TRACE( "testRepairRings: " - "target HUID %.8X", - TARGETING::get_huid(l_cpu_target)); - - //-- Save the entire VPD record to restore later - saveRestoreData_t tmpsave; - tmpsave.target = l_cpu_target; - - // do a read with NULL buffer to get the record size - l_errhdl = deviceRead( l_cpu_target, - NULL, - tmpsave.CP00_pdG_size, - DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDG ) ); - if( l_errhdl ) - { - TS_FAIL("Error finding size of CP00/#G for %.8X", - TARGETING::get_huid(l_cpu_target)); - errlCommit( l_errhdl, VPD_COMP_ID ); - continue; - } - - // now go get the data - tmpsave.CP00_pdG = new uint8_t[tmpsave.CP00_pdG_size]; - l_errhdl = deviceRead( l_cpu_target, - tmpsave.CP00_pdG, - tmpsave.CP00_pdG_size, - DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDG ) ); - if( l_errhdl ) - { - TS_FAIL("Error reading CP00/#G from %.8X", - TARGETING::get_huid(l_cpu_target)); - errlCommit( l_errhdl, VPD_COMP_ID ); - delete[] tmpsave.CP00_pdG; - continue; - } - - // do a read with NULL buffer to get the record size - l_errhdl = deviceRead( l_cpu_target, - NULL, - tmpsave.CP00_pdR_size, - DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDR ) ); - if( l_errhdl ) - { - TS_FAIL("Error finding size of CP00/#R for %.8X", - TARGETING::get_huid(l_cpu_target)); - errlCommit( l_errhdl, VPD_COMP_ID ); - continue; - } - - // now go get the data - tmpsave.CP00_pdR = new uint8_t[tmpsave.CP00_pdR_size]; - l_errhdl = deviceRead( l_cpu_target, - tmpsave.CP00_pdR, - tmpsave.CP00_pdR_size, - DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDR ) ); - if( l_errhdl ) - { - TS_FAIL("Error reading CP00/#R from %.8X", - TARGETING::get_huid(l_cpu_target)); - errlCommit( l_errhdl, VPD_COMP_ID ); - delete[] tmpsave.CP00_pdR; - continue; - } - - // add to the master list - l_srData.push_back(tmpsave); - - // cast OUR type of target to a FAPI type of target. - fapi::Target l_fapi_cpu_target( - TARGET_TYPE_PROC_CHIP, - (const_cast<TARGETING::Target*>(l_cpu_target)) ); - - // allocate some space to put the record(s) - if( l_pRingBuf != NULL ) - { - delete[] l_pRingBuf; - } - l_pRingBuf = new uint8_t[l_bufsize]; - - // ---------------------------------------------------------------- - // Pass in 0 for the ring modifier, should return with "not found" - // error - // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: pass in invalid ringId" ); - l_ringBufsize = l_bufsize; - l_ringId = 0; // ringId - l_chipletId = 0; // chipletId - l_fapirc = getMvpdRing( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDR, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x Bufsize=0x%x", - l_ringId, - l_chipletId, - l_ringBufsize ); - if ( l_fapirc != fapi::RC_REPAIR_RING_NOT_FOUND ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL("testRepairRings: expect not found rc FAIL: 0x%x, 0x%x", - fapi::RC_REPAIR_RING_NOT_FOUND, - static_cast<uint32_t>(l_fapirc) ); - fapiLogError(l_fapirc); - } - - // ---------------------------------------------------------------- - // Pass in a buffer size that is too small with a valid - // ringId/chipletId, should return error with correct length - // and invalid size return code.. - // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: pass buffer too small %d ", - VALID_INDEX ); - l_ringBufsize = 0x0; - l_ringId = l_ringModifiers[VALID_INDEX].ringIdval; - l_chipletId = l_ringModifiers[VALID_INDEX].chipletIdval; - l_fapirc = getMvpdRing( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDR, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x: Bufsize=0x%x", - l_ringId, - l_chipletId, - l_ringBufsize ); - if ( l_fapirc != fapi::RC_REPAIR_RING_INVALID_SIZE ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL("testRepairRings: expect invalid size FAIL: exp=0x%x," - " act=0x%x, ring=0x%X", - fapi::RC_REPAIR_RING_INVALID_SIZE, - static_cast<uint32_t>(l_fapirc), - l_ringId); - - fapiLogError(l_fapirc); - } - else if ( l_ringBufsize != l_ringModifiers[VALID_INDEX].size ) - { - TS_FAIL( "testRepairRings: size mismatch FAIL1 on ring 0x%X:" - " exp=0x%x, act=0x%x", - l_ringId, - l_ringModifiers[VALID_INDEX].size, - l_ringBufsize ); - } - - // ---------------------------------------------------------------- - // Pass in a NULL pointer with a valid ringId/chipletId, should - // return with correct length and successful return code. - // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: get size of ring %d ", VALID_INDEX ); - l_ringBufsize = 0x0; - l_ringId = l_ringModifiers[VALID_INDEX].ringIdval; - l_chipletId = l_ringModifiers[VALID_INDEX].chipletIdval; - l_fapirc = getMvpdRing( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDR, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - NULL, - l_ringBufsize ); - TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x: Bufsize=0x%x", - l_ringId, - l_chipletId, - l_ringBufsize ); - if ( l_fapirc ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: expect success rc FAIL: 0x%x, 0x%x", - fapi::FAPI_RC_SUCCESS, - static_cast<uint32_t>(l_fapirc)); - - fapiLogError(l_fapirc); - } - else if ( l_ringBufsize != l_ringModifiers[VALID_INDEX].size ) - { - TS_FAIL( "testRepairRings: size mismatch FAIL2 on ring 0x%X:" - " exp=0x%x, act=0x%x", - l_ringId, - l_ringModifiers[VALID_INDEX].size, - l_ringBufsize ); - } - - // ---------------------------------------------------------------- - // Fetch rings - // ---------------------------------------------------------------- - const uint32_t numRings = - sizeof(l_ringModifiers)/sizeof(l_ringModifiers[0]); - for (size_t i=0;i<numRings;i++) - { - TS_TRACE( "testRepairRings: get ring %d", i ); - l_ringBufsize = l_bufsize; - l_ringId = l_ringModifiers[i].ringIdval; - l_chipletId = l_ringModifiers[i].chipletIdval; - l_fapirc = getMvpdRing( MVPD_RECORD_CP00, - l_ringModifiers[i].keyword, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - TS_TRACE("testRepairRings ringId=0x%x chipletId=0x%x size=0x%x", - l_ringId, l_chipletId, l_ringBufsize ); - - if ( l_fapirc != l_ringModifiers[i].rc ) - { - // note: uint32_t below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: getMvpdRing rc FAIL 1: rc=0x%x," - " ring=0x%X, chiplet=0x%X, i=%d", - static_cast<uint32_t>(l_fapirc), - l_ringId, - l_chipletId, - i ); - fapiLogError(l_fapirc); - continue; - } - else if( l_fapirc != fapi::FAPI_RC_SUCCESS ) - { - // not an error, but the next check isn't valid - continue; - } - - if ( l_ringBufsize != l_ringModifiers[i].size ) - { - TS_FAIL( "testRepairRings: size mismatch FAIL3 on ring %X:" - " exp=0x%x, act=0x%x", - l_ringId, - l_ringModifiers[i].size, - l_ringBufsize ); - } - - // Dump ring buffer here. - TRACDBIN(g_trac_test,"testRepairRings:Dump Repair Ring Buffer:", - l_pRingBuf, - l_ringBufsize ); - } - - // ---------------------------------------------------------------- - // write different data, read it back to verify, then put the - // original data back. - // ---------------------------------------------------------------- - uint32_t l_offset =0; - uint8_t l_data = 0; - uint8_t *l_pData = NULL; - - // use data from last fetch test case. - TS_TRACE( "testRepairRings: update in place ring %d", TEST_INDEX ); - l_ringId = l_ringModifiers[TEST_INDEX].ringIdval; - l_chipletId = l_ringModifiers[TEST_INDEX].chipletIdval; - l_ringBufsize = l_ringModifiers[TEST_INDEX].size; - - // put in recognizable data for the debug data dump - l_pData = l_pRingBuf+sizeof(CompressedScanData); - for (l_offset = 0,l_data=0x10; l_offset < - l_ringBufsize-sizeof(CompressedScanData); l_offset++) - { - *l_pData++ = l_data++; - } - TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", - l_pRingBuf, - l_ringBufsize ); - setMvpdRing_FP_t (l_setMvpdRing) = &setMvpdRing; //verify typedef - l_fapirc = (*l_setMvpdRing)( MVPD_RECORD_CP00, - l_ringModifiers[TEST_INDEX].keyword, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - - if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: setMvpdRing rc FAIL 1: exp=0x%x," - " rc=0x%x", - fapi::FAPI_RC_SUCCESS, - static_cast<uint32_t>(l_fapirc) ); - fapiLogError(l_fapirc); - } - - // ---------------------------------------------------------------- - // write back a smaller ring to cause a shift left in the record - // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: shrink a ring %d", TEST_INDEX ); - l_ringBufsize = l_ringModifiers[TEST_INDEX].size-4; - reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> - iv_size = l_ringBufsize; - - // put in recognizable data for the debug data dump - l_pData = l_pRingBuf+sizeof(CompressedScanData); - for (l_offset = 0,l_data=0x20; l_offset < - l_ringBufsize-sizeof(CompressedScanData); l_offset++) - { - *l_pData++ = l_data++; - } - TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", - l_pRingBuf, - l_ringBufsize ); - l_fapirc = setMvpdRing( MVPD_RECORD_CP00, - l_ringModifiers[TEST_INDEX].keyword, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - - if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: setMvpdRing rc FAIL 2:" - " exp=0x%x, rc=0x%x", - fapi::FAPI_RC_SUCCESS, - static_cast<uint32_t>(l_fapirc) ); - - fapiLogError(l_fapirc); - } - - // ---------------------------------------------------------------- - // write back a larger ring to cause a shift right in the record - // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: grow a ring %d", TEST_INDEX ); - l_ringBufsize = l_ringModifiers[TEST_INDEX].size+16; - reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> - iv_size = l_ringBufsize; - - // put in recognizable data for the debug data dump - l_pData = l_pRingBuf+sizeof(CompressedScanData); - for (l_offset = 0,l_data=0x30; l_offset < - l_ringBufsize-sizeof(CompressedScanData); l_offset++) - { - *l_pData++ = l_data++; - } - TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", - l_pRingBuf, - l_ringBufsize ); - l_fapirc = setMvpdRing( MVPD_RECORD_CP00, - l_ringModifiers[TEST_INDEX].keyword, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - - if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: setMvpdRing rc FAIL 3: exp=0x%x," - " rc=0x%x", - fapi::FAPI_RC_SUCCESS, - static_cast<uint32_t>(l_fapirc) ); - - fapiLogError(l_fapirc); - } - - // ---------------------------------------------------------------- - // append a ring that is not already there to the end - // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: append a ring" ); - l_ringId = 0x77; - l_chipletId = 0x88; - l_ringBufsize = l_ringModifiers[TEST_INDEX].size; - reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> - iv_size = l_ringBufsize; - reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> - iv_ringId = l_ringId; - reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> - iv_chipletId = l_chipletId; - - // put in recognizable data for the debug data dump - l_pData = l_pRingBuf+sizeof(CompressedScanData); - for (l_offset = 0,l_data=0x50; l_offset < - l_ringBufsize-sizeof(CompressedScanData); l_offset++) - { - *l_pData++ = l_data++; - } - TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", - l_pRingBuf, - l_ringBufsize ); - l_fapirc = setMvpdRing( MVPD_RECORD_CP00, - l_ringModifiers[TEST_INDEX].keyword, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - - if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: setMvpdRing rc FAIL 4: exp=0x%x," - " rc=0x%x", - fapi::FAPI_RC_SUCCESS, - static_cast<uint32_t>(l_fapirc) ); - - fapiLogError(l_fapirc); - } - - // read back data to prove the writes worked - l_ringId = l_ringModifiers[TEST_INDEX].ringIdval; - l_chipletId = l_ringModifiers[TEST_INDEX].chipletIdval; - l_ringBufsize = l_ringModifiers[TEST_INDEX].size+16; - l_fapirc = getMvpdRing( MVPD_RECORD_CP00, - l_ringModifiers[TEST_INDEX].keyword, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - - if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) - { - TS_FAIL( "testRepairRings: getMvpdRing rc FAIL 2: 0x%x, 0x%x", - fapi::FAPI_RC_SUCCESS, - static_cast<uint32_t>(l_fapirc) ); - fapiLogError(l_fapirc); - } - else - { - l_pData = l_pRingBuf+sizeof(CompressedScanData); - for( l_offset = 0,l_data=0x30; - l_offset < l_ringBufsize-sizeof(CompressedScanData); - l_offset++) - { - if( l_pData[l_offset] != l_data++ ) - { - TS_FAIL("Mismatch after write on ring %X", - l_ringId); - TRACFBIN(g_trac_test, - "ringdata=", - l_pRingBuf,l_ringBufsize); - } - } - } - - // read back data to prove the writes worked - l_ringId = 0x77; - l_chipletId = 0x88; - l_ringBufsize = l_ringModifiers[TEST_INDEX].size; - l_fapirc = getMvpdRing( MVPD_RECORD_CP00, - l_ringModifiers[TEST_INDEX].keyword, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - - if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) - { - TS_FAIL( "testRepairRings: getMvpdRing rc FAIL 3: 0x%x, 0x%x", - fapi::FAPI_RC_SUCCESS, - static_cast<uint32_t>(l_fapirc) ); - fapiLogError(l_fapirc); - } - else - { - l_pData = l_pRingBuf+sizeof(CompressedScanData); - for (l_offset = 0,l_data=0x50; - l_offset < l_ringBufsize-sizeof(CompressedScanData); - l_offset++) - { - if( l_pData[l_offset] != l_data++ ) - { - TS_FAIL("Mismatch after write on ring %X", - l_ringId); - TRACFBIN(g_trac_test, - "ringdata=", - l_pRingBuf,l_ringBufsize); - } - } - } - - - // ---------------------------------------------------------------- - // Pass in a buffer size that does not match the exact size - // of the ringId/chipletId, should return with correct length - // and invalid size return code. - // ---------------------------------------------------------------- - TS_TRACE("testRepairRing:bad size ring=0x%x chiplet=0x%x size=0x%x", - l_ringId, - l_chipletId, - l_ringBufsize ); - l_ringBufsize = l_bufsize; - l_ringId = l_ringModifiers[TEST_INDEX].ringIdval; - l_chipletId = l_ringModifiers[TEST_INDEX].chipletIdval; - l_fapirc = setMvpdRing( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDR, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - - if ( l_fapirc != fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL("testRepairRings:invalid ring size rc FAIL:" - " exp=0x%x, act=0x%x", - fapi::RC_REPAIR_RING_INVALID_SIZE, - static_cast<uint32_t>(l_fapirc)); - - fapiLogError(l_fapirc); - } - - // ---------------------------------------------------------------- - // Pass in 0 for the ring modifier, should return with "not found" - // error - // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: pass in invalid ringId" ); - l_ringBufsize = l_ringModifiers[TEST_INDEX].size; - l_ringId = 0; // ringId - l_chipletId = 0; // chipletId - l_fapirc = setMvpdRing( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDR, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - - TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x size=0x%x", - l_ringId, - l_chipletId, - l_ringBufsize ); - if ( l_fapirc != fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: rc FAIL: exp=0x%x, act=0x%x", - fapi::RC_REPAIR_RING_NOT_FOUND, - static_cast<uint32_t>(l_fapirc) ); - fapiLogError(l_fapirc); - } - // ---------------------------------------------------------------- - // Pass in a NULL pointer with a valid ringId/chipletId, should - // return with correct length and successful return code. - // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: get size of ring(from set) %d ", - TEST_INDEX ); - l_ringBufsize = 0x0; - l_ringId = l_ringModifiers[TEST_INDEX].ringIdval; - l_chipletId = l_ringModifiers[TEST_INDEX].chipletIdval; - l_fapirc = setMvpdRing( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDR, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - NULL, - l_ringBufsize ); - - TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x size=0x%x", - l_ringId, - l_chipletId, - l_ringBufsize ); - if ( l_fapirc != fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: setMvpdRing rc FAIL 5:" - " exp=0x%x, act=0x%x", - fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER, - static_cast<uint32_t>(l_fapirc)); - - fapiLogError(l_fapirc); - } - - // ---------------------------------------------------------------- - // Pass in an invalid chiplet id with a valid ring, should fail - // ---------------------------------------------------------------- - l_ringBufsize = l_bufsize; - l_ringId = l_ringModifiers[TEST_INDEX].ringIdval; - l_chipletId = 0x22; - TS_TRACE("testRepairRing:invalid chiplet ring=0x%X chiplet=0x%X" - " size=0x%x", - l_ringId, - l_chipletId, - l_ringBufsize ); - l_fapirc = getMvpdRing( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDR, - l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - - if ( l_fapirc != fapi::RC_REPAIR_RING_NOT_FOUND ) - { - // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL("testRepairRings:invalid chipletid rc FAIL:" - " exp=0x%x, act=0x%x", - fapi::RC_REPAIR_RING_NOT_FOUND, - static_cast<uint32_t>(l_fapirc)); - - fapiLogError(l_fapirc); - } - - } - - //-- Put the original data back into the vpd - for( std::list<saveRestoreData_t>::iterator sv = l_srData.begin(); - sv != l_srData.end(); - ++sv ) - { - if( sv->target == NULL ) - { - continue; - } - - if( sv->CP00_pdG != NULL ) - { - l_errhdl = deviceWrite( sv->target, - sv->CP00_pdG, - sv->CP00_pdG_size, - DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDG ) ); - if( l_errhdl ) - { - TS_FAIL("Error restoring CP00/#G to %.8X", - TARGETING::get_huid(sv->target)); - errlCommit( l_errhdl, VPD_COMP_ID ); - } - delete[] sv->CP00_pdG; - sv->CP00_pdG = NULL; - } - - if( sv->CP00_pdR != NULL ) - { - l_errhdl = deviceWrite( sv->target, - sv->CP00_pdR, - sv->CP00_pdR_size, - DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, - MVPD_KEYWORD_PDR ) ); - if( l_errhdl ) - { - TS_FAIL("Error restoring CP00/#R to %.8X", - TARGETING::get_huid(sv->target)); - errlCommit( l_errhdl, VPD_COMP_ID ); - } - delete[] sv->CP00_pdR; - sv->CP00_pdR = NULL; - } - } - //-- - - // delete allocated space - if( l_pRingBuf ) - { - delete[] l_pRingBuf; - } - for( std::list<saveRestoreData_t>::iterator sv = l_srData.begin(); - sv != l_srData.end(); - ++sv ) - { - if( sv->CP00_pdG != NULL ) - { - delete[] sv->CP00_pdG; - sv->CP00_pdG = NULL; - } - if( sv->CP00_pdR != NULL ) - { - delete[] sv->CP00_pdR; - sv->CP00_pdR = NULL; - } - } - - - TS_TRACE( "testRepairRings exit" ); - } - -}; // end class FapiWinkleTest +}; // end class #endif diff --git a/src/usr/hwpf/test/hwpMvpdAccessorTest.H b/src/usr/hwpf/test/hwpMvpdAccessorTest.H new file mode 100644 index 000000000..3e9137f3f --- /dev/null +++ b/src/usr/hwpf/test/hwpMvpdAccessorTest.H @@ -0,0 +1,899 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/hwpf/test/hwpMvpdAccessorTest.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,2013 */ +/* */ +/* p1 */ +/* */ +/* Object Code Only (OCO) source materials */ +/* Licensed Internal Code Source Materials */ +/* IBM HostBoot Licensed Internal Code */ +/* */ +/* 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. */ +/* */ +/* Origin: 30 */ +/* */ +/* IBM_PROLOG_END_TAG */ + +#ifndef __HWPMVPDACCESSORTEST_H +#define __HWPMVPDACCESSORTEST_H + +// set to 1 for doing unit tests, set to 0 for production +#define HWPMVPDACCESSORTEST_UT 0 + +/** + * @file hwpMvpdAccessorTest.H + * + * @brief Test cases for Mvpd HWP accessors. +*/ + +#include <cxxtest/TestSuite.H> + +#include <fapi.H> +#include <fapiPlatHwpInvoker.H> + +#include <targeting/common/commontargeting.H> +#include <targeting/common/utilFilter.H> + +#include <getMvpdRing.H> +#include <setMvpdRing.H> + +#include <errl/errlmanager.H> +#include <errl/errlentry.H> +#include <devicefw/driverif.H> +#include <trace/interface.H> + +// pull in CompressedScanData def from proc_slw_build HWP +#include <p8_scan_compression.H> + +using namespace fapi; +using namespace TARGETING; + +class hwpMvpdAccessorTest: public CxxTest::TestSuite +{ +public: + + /** + * @brief call fapiGetMvpdField to fetch a mvpd records. + * + */ + void testGetMvpd() + { + fapi::ReturnCode l_fapirc( fapi::FAPI_RC_SUCCESS ); + uint8_t *l_pdRRecord = NULL; + uint32_t l_pdRLen = 0; + + // list of MVPD records to test. Need to be in PNOR or procmvpd.dat + // when g_usePNOR is false. + struct _testMvpdRecords { + fapi::MvpdRecord record; + fapi::MvpdKeyword keyword; + } l_mvpdRecords[] = { +#if HWPMVPDACCESSORTEST_UT + { MVPD_RECORD_CP00, MVPD_KEYWORD_PDG}, + { MVPD_RECORD_MER0, MVPD_KEYWORD_PDI}, +// { MVPD_RECORD_VER0, MVPD_KEYWORD_PDI}, //VER0 in spec,not supported +#endif + { MVPD_RECORD_VWML, MVPD_KEYWORD_PDI}, + }; + + TS_TRACE( "testGetMvpd entry" ); + + TARGETING::TargetHandleList l_cpuTargetList; + getAllChips(l_cpuTargetList, TYPE_PROC); + + TS_TRACE( "testGetMvpd l_cpuTargetList.size()= 0x%x ", + l_cpuTargetList.size() ); + + + // loop thru all the cpu's + for (TargetHandleList::iterator l_cpu_iter = l_cpuTargetList.begin(); + l_cpu_iter != l_cpuTargetList.end(); + ++l_cpu_iter) + { + // make a local copy of the CPU target + TARGETING::Target* l_cpu_target = *l_cpu_iter; + + TS_TRACE( "target HUID %.8X", TARGETING::get_huid(l_cpu_target)); + + // cast OUR type of target to a FAPI type of target. + fapi::Target l_fapi_cpu_target( + TARGET_TYPE_PROC_CHIP, + (const_cast<TARGETING::Target*>(l_cpu_target)) ); + + // loop through mvpd records of interest + const uint32_t numRecords = + sizeof(l_mvpdRecords)/sizeof(l_mvpdRecords[0]); + for (uint8_t i=0;i<numRecords;i++) { + + TS_TRACE( "record = 0x%x keyword = 0x%x", + l_mvpdRecords[i].record, + l_mvpdRecords[i].keyword); + + TS_TRACE( "call fapiGetMvpdField with NULL pointer" ); + + // call fapiGetMvpdField once with a NULL pointer to get the + // buffer size should return no error now. + l_fapirc = fapiGetMvpdField(l_mvpdRecords[i].record, + l_mvpdRecords[i].keyword, + l_fapi_cpu_target, + NULL, + l_pdRLen ); + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + TS_FAIL( "fapiGetMvpdField: expected FAPI_RC_SUCCESS" ); + fapiLogError(l_fapirc); + return; + } + + TS_TRACE( "fapiGetMvpdField: size of record = 0x%x", + l_pdRLen ); + + // do a malloc instead of a new just for variety + l_pdRRecord = reinterpret_cast<uint8_t *>(malloc(l_pdRLen) ); + + // call fapiGetMvpdField once with a valid pointer + l_fapirc = fapiGetMvpdField(l_mvpdRecords[i].record, + l_mvpdRecords[i].keyword, + l_fapi_cpu_target, + l_pdRRecord, + l_pdRLen ); + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + TS_FAIL( "fapiGetMvpdField: expected FAPI_RC_SUCCESS" ); + fapiLogError(l_fapirc); + free( l_pdRRecord ); + return; + } + + // clean up memory + free( l_pdRRecord ); + } + } + + TS_TRACE( "testGetMvpd exit" ); + } + + + // Structure used to save/restore the VPD + typedef struct saveRestoreData_t { + TARGETING::Target* target; + uint8_t* CP00_pdG; + size_t CP00_pdG_size; + uint8_t* CP00_pdR; + size_t CP00_pdR_size; + } saveRestoreData_t; + + /** + * @brief Test get and set of Repair Rings + */ + void testRepairRings() + { + fapi::ReturnCode l_fapirc = fapi::FAPI_RC_SUCCESS; + uint8_t *l_pRingBuf = NULL; + uint32_t l_ringBufsize = 0; + uint32_t l_ringId = 0; + uint32_t l_chipletId = 0; + uint32_t l_bufsize = 0x200; + errlHndl_t l_errhdl = NULL; + + // This data needs to be in sync with the procmvpd.dat file + // the setMvpdFunc tests use the last row. The test + // expects it to be a mid x20 byte ring in the #G keyword + struct _testRRstr { + fapi::MvpdKeyword keyword; + uint32_t ringIdval; + uint32_t chipletIdval; + uint32_t size; + uint32_t rc; + } l_ringModifiers[] = { + { MVPD_KEYWORD_PDG, 0xa4, 0xFF, 0x20, //last #G + fapi::RC_REPAIR_RING_NOT_FOUND }, + { MVPD_KEYWORD_PDR, 0xe0, 0x08, 0x20, //first #R + FAPI_RC_SUCCESS }, + { MVPD_KEYWORD_PDR, 0xe2, 0x16, 0x20, //big #R + FAPI_RC_SUCCESS }, + { MVPD_KEYWORD_PDG, 0xa2, 0x08, 0x20, //mid #G + FAPI_RC_SUCCESS }, + { MVPD_KEYWORD_PDR, 0xe1, 0x16, 0x20,//big #R + FAPI_RC_SUCCESS }, + }; + const size_t VALID_INDEX = 2; + const size_t TEST_INDEX = 4; + + TS_TRACE( "testRepairRings entry" ); + + std::list<saveRestoreData_t> l_srData; + + TARGETING::TargetHandleList l_cpuTargetList; + getAllChips(l_cpuTargetList, TYPE_PROC); + + // loop thru all the cpu's + for (TargetHandleList::iterator l_cpu_iter = l_cpuTargetList.begin(); + l_cpu_iter != l_cpuTargetList.end(); + ++l_cpu_iter) + { + // make a local copy of the CPU target + TARGETING::Target* l_cpu_target = *l_cpu_iter; + + TS_TRACE( "testRepairRings: " + "target HUID %.8X", + TARGETING::get_huid(l_cpu_target)); + + //-- Save the entire VPD record to restore later + saveRestoreData_t tmpsave; + tmpsave.target = l_cpu_target; + + // do a read with NULL buffer to get the record size + l_errhdl = deviceRead( l_cpu_target, + NULL, + tmpsave.CP00_pdG_size, + DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDG ) ); + if( l_errhdl ) + { + TS_FAIL("Error finding size of CP00/#G for %.8X", + TARGETING::get_huid(l_cpu_target)); + errlCommit( l_errhdl, VPD_COMP_ID ); + continue; + } + + // now go get the data + tmpsave.CP00_pdG = new uint8_t[tmpsave.CP00_pdG_size]; + l_errhdl = deviceRead( l_cpu_target, + tmpsave.CP00_pdG, + tmpsave.CP00_pdG_size, + DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDG ) ); + if( l_errhdl ) + { + TS_FAIL("Error reading CP00/#G from %.8X", + TARGETING::get_huid(l_cpu_target)); + errlCommit( l_errhdl, VPD_COMP_ID ); + delete[] tmpsave.CP00_pdG; + continue; + } + + // do a read with NULL buffer to get the record size + l_errhdl = deviceRead( l_cpu_target, + NULL, + tmpsave.CP00_pdR_size, + DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR ) ); + if( l_errhdl ) + { + TS_FAIL("Error finding size of CP00/#R for %.8X", + TARGETING::get_huid(l_cpu_target)); + errlCommit( l_errhdl, VPD_COMP_ID ); + continue; + } + + // now go get the data + tmpsave.CP00_pdR = new uint8_t[tmpsave.CP00_pdR_size]; + l_errhdl = deviceRead( l_cpu_target, + tmpsave.CP00_pdR, + tmpsave.CP00_pdR_size, + DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR ) ); + if( l_errhdl ) + { + TS_FAIL("Error reading CP00/#R from %.8X", + TARGETING::get_huid(l_cpu_target)); + errlCommit( l_errhdl, VPD_COMP_ID ); + delete[] tmpsave.CP00_pdR; + continue; + } + + // add to the master list + l_srData.push_back(tmpsave); + + // cast OUR type of target to a FAPI type of target. + fapi::Target l_fapi_cpu_target( + TARGET_TYPE_PROC_CHIP, + (const_cast<TARGETING::Target*>(l_cpu_target)) ); + + // allocate some space to put the record(s) + if( l_pRingBuf != NULL ) + { + delete[] l_pRingBuf; + } + l_pRingBuf = new uint8_t[l_bufsize]; + + // ---------------------------------------------------------------- + // Pass in 0 for the ring modifier, should return with "not found" + // error + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: pass in invalid ringId" ); + l_ringBufsize = l_bufsize; + l_ringId = 0; // ringId + l_chipletId = 0; // chipletId + l_fapirc = getMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x Bufsize=0x%x", + l_ringId, + l_chipletId, + l_ringBufsize ); + if ( l_fapirc != fapi::RC_REPAIR_RING_NOT_FOUND ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL("testRepairRings: expect not found rc FAIL: 0x%x, 0x%x", + fapi::RC_REPAIR_RING_NOT_FOUND, + static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); + } + + // ---------------------------------------------------------------- + // Pass in a buffer size that is too small with a valid + // ringId/chipletId, should return error with correct length + // and invalid size return code.. + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: pass buffer too small %d ", + VALID_INDEX ); + l_ringBufsize = 0x0; + l_ringId = l_ringModifiers[VALID_INDEX].ringIdval; + l_chipletId = l_ringModifiers[VALID_INDEX].chipletIdval; + l_fapirc = getMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x: Bufsize=0x%x", + l_ringId, + l_chipletId, + l_ringBufsize ); + if ( l_fapirc != fapi::RC_REPAIR_RING_INVALID_SIZE ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL("testRepairRings: expect invalid size FAIL: exp=0x%x," + " act=0x%x, ring=0x%X", + fapi::RC_REPAIR_RING_INVALID_SIZE, + static_cast<uint32_t>(l_fapirc), + l_ringId); + + fapiLogError(l_fapirc); + } + else if ( l_ringBufsize != l_ringModifiers[VALID_INDEX].size ) + { + TS_FAIL( "testRepairRings: size mismatch FAIL1 on ring 0x%X:" + " exp=0x%x, act=0x%x", + l_ringId, + l_ringModifiers[VALID_INDEX].size, + l_ringBufsize ); + } + + // ---------------------------------------------------------------- + // Pass in a NULL pointer with a valid ringId/chipletId, should + // return with correct length and successful return code. + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: get size of ring %d ", VALID_INDEX ); + l_ringBufsize = 0x0; + l_ringId = l_ringModifiers[VALID_INDEX].ringIdval; + l_chipletId = l_ringModifiers[VALID_INDEX].chipletIdval; + l_fapirc = getMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + NULL, + l_ringBufsize ); + TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x: Bufsize=0x%x", + l_ringId, + l_chipletId, + l_ringBufsize ); + if ( l_fapirc ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: expect success rc FAIL: 0x%x, 0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(l_fapirc)); + + fapiLogError(l_fapirc); + } + else if ( l_ringBufsize != l_ringModifiers[VALID_INDEX].size ) + { + TS_FAIL( "testRepairRings: size mismatch FAIL2 on ring 0x%X:" + " exp=0x%x, act=0x%x", + l_ringId, + l_ringModifiers[VALID_INDEX].size, + l_ringBufsize ); + } + + // ---------------------------------------------------------------- + // Fetch rings + // ---------------------------------------------------------------- + const uint32_t numRings = + sizeof(l_ringModifiers)/sizeof(l_ringModifiers[0]); + for (size_t i=0;i<numRings;i++) + { + TS_TRACE( "testRepairRings: get ring %d", i ); + l_ringBufsize = l_bufsize; + l_ringId = l_ringModifiers[i].ringIdval; + l_chipletId = l_ringModifiers[i].chipletIdval; + l_fapirc = getMvpdRing( MVPD_RECORD_CP00, + l_ringModifiers[i].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + TS_TRACE("testRepairRings ringId=0x%x chipletId=0x%x size=0x%x", + l_ringId, l_chipletId, l_ringBufsize ); + + if ( l_fapirc != l_ringModifiers[i].rc ) + { + // note: uint32_t below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: getMvpdRing rc FAIL 1: rc=0x%x," + " ring=0x%X, chiplet=0x%X, i=%d", + static_cast<uint32_t>(l_fapirc), + l_ringId, + l_chipletId, + i ); + fapiLogError(l_fapirc); + continue; + } + else if( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + // not an error, but the next check isn't valid + continue; + } + + if ( l_ringBufsize != l_ringModifiers[i].size ) + { + TS_FAIL( "testRepairRings: size mismatch FAIL3 on ring %X:" + " exp=0x%x, act=0x%x", + l_ringId, + l_ringModifiers[i].size, + l_ringBufsize ); + } + + // Dump ring buffer here. + TRACDBIN(g_trac_test,"testRepairRings:Dump Repair Ring Buffer:", + l_pRingBuf, + l_ringBufsize ); + } + + // ---------------------------------------------------------------- + // write different data, read it back to verify, then put the + // original data back. + // ---------------------------------------------------------------- + uint32_t l_offset =0; + uint8_t l_data = 0; + uint8_t *l_pData = NULL; + + // use data from last fetch test case. + TS_TRACE( "testRepairRings: update in place ring %d", TEST_INDEX ); + l_ringId = l_ringModifiers[TEST_INDEX].ringIdval; + l_chipletId = l_ringModifiers[TEST_INDEX].chipletIdval; + l_ringBufsize = l_ringModifiers[TEST_INDEX].size; + + // put in recognizable data for the debug data dump + l_pData = l_pRingBuf+sizeof(CompressedScanData); + for (l_offset = 0,l_data=0x10; l_offset < + l_ringBufsize-sizeof(CompressedScanData); l_offset++) + { + *l_pData++ = l_data++; + } + TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", + l_pRingBuf, + l_ringBufsize ); + setMvpdRing_FP_t (l_setMvpdRing) = &setMvpdRing; //verify typedef + l_fapirc = (*l_setMvpdRing)( MVPD_RECORD_CP00, + l_ringModifiers[TEST_INDEX].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: setMvpdRing rc FAIL 1: exp=0x%x," + " rc=0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); + } + + // ---------------------------------------------------------------- + // write back a smaller ring to cause a shift left in the record + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: shrink a ring %d", TEST_INDEX ); + l_ringBufsize = l_ringModifiers[TEST_INDEX].size-4; + reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> + iv_size = l_ringBufsize; + + // put in recognizable data for the debug data dump + l_pData = l_pRingBuf+sizeof(CompressedScanData); + for (l_offset = 0,l_data=0x20; l_offset < + l_ringBufsize-sizeof(CompressedScanData); l_offset++) + { + *l_pData++ = l_data++; + } + TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", + l_pRingBuf, + l_ringBufsize ); + l_fapirc = setMvpdRing( MVPD_RECORD_CP00, + l_ringModifiers[TEST_INDEX].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: setMvpdRing rc FAIL 2:" + " exp=0x%x, rc=0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(l_fapirc) ); + + fapiLogError(l_fapirc); + } + + // ---------------------------------------------------------------- + // write back a larger ring to cause a shift right in the record + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: grow a ring %d", TEST_INDEX ); + l_ringBufsize = l_ringModifiers[TEST_INDEX].size+16; + reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> + iv_size = l_ringBufsize; + + // put in recognizable data for the debug data dump + l_pData = l_pRingBuf+sizeof(CompressedScanData); + for (l_offset = 0,l_data=0x30; l_offset < + l_ringBufsize-sizeof(CompressedScanData); l_offset++) + { + *l_pData++ = l_data++; + } + TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", + l_pRingBuf, + l_ringBufsize ); + l_fapirc = setMvpdRing( MVPD_RECORD_CP00, + l_ringModifiers[TEST_INDEX].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: setMvpdRing rc FAIL 3: exp=0x%x," + " rc=0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(l_fapirc) ); + + fapiLogError(l_fapirc); + } + + // ---------------------------------------------------------------- + // append a ring that is not already there to the end + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: append a ring" ); + l_ringId = 0x77; + l_chipletId = 0x88; + l_ringBufsize = l_ringModifiers[TEST_INDEX].size; + reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> + iv_size = l_ringBufsize; + reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> + iv_ringId = l_ringId; + reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> + iv_chipletId = l_chipletId; + + // put in recognizable data for the debug data dump + l_pData = l_pRingBuf+sizeof(CompressedScanData); + for (l_offset = 0,l_data=0x50; l_offset < + l_ringBufsize-sizeof(CompressedScanData); l_offset++) + { + *l_pData++ = l_data++; + } + TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", + l_pRingBuf, + l_ringBufsize ); + l_fapirc = setMvpdRing( MVPD_RECORD_CP00, + l_ringModifiers[TEST_INDEX].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: setMvpdRing rc FAIL 4: exp=0x%x," + " rc=0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(l_fapirc) ); + + fapiLogError(l_fapirc); + } + + // read back data to prove the writes worked + l_ringId = l_ringModifiers[TEST_INDEX].ringIdval; + l_chipletId = l_ringModifiers[TEST_INDEX].chipletIdval; + l_ringBufsize = l_ringModifiers[TEST_INDEX].size+16; + l_fapirc = getMvpdRing( MVPD_RECORD_CP00, + l_ringModifiers[TEST_INDEX].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + TS_FAIL( "testRepairRings: getMvpdRing rc FAIL 2: 0x%x, 0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); + } + else + { + l_pData = l_pRingBuf+sizeof(CompressedScanData); + for( l_offset = 0,l_data=0x30; + l_offset < l_ringBufsize-sizeof(CompressedScanData); + l_offset++) + { + if( l_pData[l_offset] != l_data++ ) + { + TS_FAIL("Mismatch after write on ring %X", + l_ringId); + TRACFBIN(g_trac_test, + "ringdata=", + l_pRingBuf,l_ringBufsize); + } + } + } + + // read back data to prove the writes worked + l_ringId = 0x77; + l_chipletId = 0x88; + l_ringBufsize = l_ringModifiers[TEST_INDEX].size; + l_fapirc = getMvpdRing( MVPD_RECORD_CP00, + l_ringModifiers[TEST_INDEX].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + TS_FAIL( "testRepairRings: getMvpdRing rc FAIL 3: 0x%x, 0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); + } + else + { + l_pData = l_pRingBuf+sizeof(CompressedScanData); + for (l_offset = 0,l_data=0x50; + l_offset < l_ringBufsize-sizeof(CompressedScanData); + l_offset++) + { + if( l_pData[l_offset] != l_data++ ) + { + TS_FAIL("Mismatch after write on ring %X", + l_ringId); + TRACFBIN(g_trac_test, + "ringdata=", + l_pRingBuf,l_ringBufsize); + } + } + } + + + // ---------------------------------------------------------------- + // Pass in a buffer size that does not match the exact size + // of the ringId/chipletId, should return with correct length + // and invalid size return code. + // ---------------------------------------------------------------- + TS_TRACE("testRepairRing:bad size ring=0x%x chiplet=0x%x size=0x%x", + l_ringId, + l_chipletId, + l_ringBufsize ); + l_ringBufsize = l_bufsize; + l_ringId = l_ringModifiers[TEST_INDEX].ringIdval; + l_chipletId = l_ringModifiers[TEST_INDEX].chipletIdval; + l_fapirc = setMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL("testRepairRings:invalid ring size rc FAIL:" + " exp=0x%x, act=0x%x", + fapi::RC_REPAIR_RING_INVALID_SIZE, + static_cast<uint32_t>(l_fapirc)); + + fapiLogError(l_fapirc); + } + + // ---------------------------------------------------------------- + // Pass in 0 for the ring modifier, should return with "not found" + // error + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: pass in invalid ringId" ); + l_ringBufsize = l_ringModifiers[TEST_INDEX].size; + l_ringId = 0; // ringId + l_chipletId = 0; // chipletId + l_fapirc = setMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x size=0x%x", + l_ringId, + l_chipletId, + l_ringBufsize ); + if ( l_fapirc != fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: rc FAIL: exp=0x%x, act=0x%x", + fapi::RC_REPAIR_RING_NOT_FOUND, + static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); + } + // ---------------------------------------------------------------- + // Pass in a NULL pointer with a valid ringId/chipletId, should + // return with correct length and successful return code. + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: get size of ring(from set) %d ", + TEST_INDEX ); + l_ringBufsize = 0x0; + l_ringId = l_ringModifiers[TEST_INDEX].ringIdval; + l_chipletId = l_ringModifiers[TEST_INDEX].chipletIdval; + l_fapirc = setMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + NULL, + l_ringBufsize ); + + TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x size=0x%x", + l_ringId, + l_chipletId, + l_ringBufsize ); + if ( l_fapirc != fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: setMvpdRing rc FAIL 5:" + " exp=0x%x, act=0x%x", + fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER, + static_cast<uint32_t>(l_fapirc)); + + fapiLogError(l_fapirc); + } + + // ---------------------------------------------------------------- + // Pass in an invalid chiplet id with a valid ring, should fail + // ---------------------------------------------------------------- + l_ringBufsize = l_bufsize; + l_ringId = l_ringModifiers[TEST_INDEX].ringIdval; + l_chipletId = 0x22; + TS_TRACE("testRepairRing:invalid chiplet ring=0x%X chiplet=0x%X" + " size=0x%x", + l_ringId, + l_chipletId, + l_ringBufsize ); + l_fapirc = getMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::RC_REPAIR_RING_NOT_FOUND ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL("testRepairRings:invalid chipletid rc FAIL:" + " exp=0x%x, act=0x%x", + fapi::RC_REPAIR_RING_NOT_FOUND, + static_cast<uint32_t>(l_fapirc)); + + fapiLogError(l_fapirc); + } + + } + + //-- Put the original data back into the vpd + for( std::list<saveRestoreData_t>::iterator sv = l_srData.begin(); + sv != l_srData.end(); + ++sv ) + { + if( sv->target == NULL ) + { + continue; + } + + if( sv->CP00_pdG != NULL ) + { + l_errhdl = deviceWrite( sv->target, + sv->CP00_pdG, + sv->CP00_pdG_size, + DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDG ) ); + if( l_errhdl ) + { + TS_FAIL("Error restoring CP00/#G to %.8X", + TARGETING::get_huid(sv->target)); + errlCommit( l_errhdl, VPD_COMP_ID ); + } + delete[] sv->CP00_pdG; + sv->CP00_pdG = NULL; + } + + if( sv->CP00_pdR != NULL ) + { + l_errhdl = deviceWrite( sv->target, + sv->CP00_pdR, + sv->CP00_pdR_size, + DEVICE_MVPD_ADDRESS( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR ) ); + if( l_errhdl ) + { + TS_FAIL("Error restoring CP00/#R to %.8X", + TARGETING::get_huid(sv->target)); + errlCommit( l_errhdl, VPD_COMP_ID ); + } + delete[] sv->CP00_pdR; + sv->CP00_pdR = NULL; + } + } + //-- + + // delete allocated space + if( l_pRingBuf ) + { + delete[] l_pRingBuf; + } + for( std::list<saveRestoreData_t>::iterator sv = l_srData.begin(); + sv != l_srData.end(); + ++sv ) + { + if( sv->CP00_pdG != NULL ) + { + delete[] sv->CP00_pdG; + sv->CP00_pdG = NULL; + } + if( sv->CP00_pdR != NULL ) + { + delete[] sv->CP00_pdR; + sv->CP00_pdR = NULL; + } + } + + + TS_TRACE( "testRepairRings exit" ); + } + +}; // end class + +#endif |

