Skip to content

Commit

Permalink
Add common XSCOM error literals to HBRT
Browse files Browse the repository at this point in the history
Add a set of common XSCOM error literals that can be used
by all platforms.  Add mechanisms to translate this common
set of literals into XSCOM error callouts.  Preserve legacy
handling/translation.

Change-Id: I0f9ce25604efa0caf7d49e4ec7b5f2176a3c3a91
RTC: 86782
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/54650
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Reviewed-by: Corey V. Swenson <cswenson@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
brianebakke authored and dcrowell77 committed Feb 27, 2018
1 parent d01ca15 commit bb0dc7d
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 32 deletions.
19 changes: 19 additions & 0 deletions src/include/runtime/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@ enum MemoryError_t
};


/** Common return codes to translate into pib error codes. */
// RC for a piberr is equal to 0x1000 plus the pib error value,
// made into a negative
enum HbrtRcPiberr_t
{
HBRT_RC_PIBERR_MASK = (0x00000000u - 0x00001007u), // 0xFFFF_EFF9

HBRT_RC_PIBERR_001_BUSY = (0x00000000u - 0x00001001u), // 0xFFFF_EFFF
HBRT_RC_PIBERR_010_OFFLINE = (0x00000000u - 0x00001002u), // 0xFFFF_EFFE
HBRT_RC_PIBERR_011_PGOOD = (0x00000000u - 0x00001003u), // 0xFFFF_EFFD
HBRT_RC_PIBERR_100_INVALIDADDR = (0x00000000u - 0x00001004u), // 0xFFFF_EFFC
HBRT_RC_PIBERR_101_CLOCKERR = (0x00000000u - 0x00001005u), // 0xFFFF_EFFB
HBRT_RC_PIBERR_110_PARITYERR = (0x00000000u - 0x00001006u), // 0xFFFF_EFFA
HBRT_RC_PIBERR_111_TIMEOUT = (0x00000000u - 0x00001007u), // 0xFFFF_EFF9

HBRT_RC_SOMEOTHERERROR = (0x00000000u - 0x00001008u) // 0xFFFF_EFF8
};


/**
* I2C Master Description: chip, engine and port packed into
* a single 64-bit argument
Expand Down
170 changes: 138 additions & 32 deletions src/usr/xscom/runtime/rt_xscom.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2013,2017 */
/* Contributors Listed Below - COPYRIGHT 2013,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -64,6 +64,115 @@ DEVICE_REGISTER_ROUTE(DeviceFW::WILDCARD,
DeviceFW::IBSCOM,
TARGETING::TYPE_MEMBUF,
xscomPerformOp);

struct RcPibErrMap
{
PIB::PibError iv_Piberr;
HbrtRcPiberr_t iv_Common;
int iv_Opal; // note : opal values taken from opal-api.h
};


const RcPibErrMap pibErrTbl[] =
{
// 001
PIB::PIB_RESOURCE_OCCUPIED,
HBRT_RC_PIBERR_001_BUSY,
-12, // OPAL_XSCOM_BUSY

// 002
PIB::PIB_CHIPLET_OFFLINE,
HBRT_RC_PIBERR_010_OFFLINE,
-14, // OPAL_XSCOM_CHIPLET_OFF

// 003
PIB::PIB_PARTIAL_GOOD,
HBRT_RC_PIBERR_011_PGOOD,
-25, // OPAL_XSCOM_PARTIAL_GOOD

// 004
PIB::PIB_INVALID_ADDRESS,
HBRT_RC_PIBERR_100_INVALIDADDR,
-26, // OPAL_XSCOM_ADDR_ERROR

// 005
PIB::PIB_CLOCK_ERROR,
HBRT_RC_PIBERR_101_CLOCKERR,
-27, // OPAL_XSCOM_CLOCK_ERROR

// 006
PIB::PIB_PARITY_ERROR,
HBRT_RC_PIBERR_110_PARITYERR,
-28, // OPAL_XSCOM_PARITY_ERROR

// 007
PIB::PIB_TIMEOUT,
HBRT_RC_PIBERR_111_TIMEOUT,
-29 // OPAL_XSCOM_TIMEOUT
};


/**
* @brief Internal routine that translates a HBRT return code to a
* PIB error code
*
* @param[in] i_rc HBRT return code,
* @return PibError, PIB::PIB_NO_ERROR if not translatable
*
*/
PIB::PibError HbrtRcToPibErr( HbrtRcPiberr_t i_rc )
{
int l_entryCnt = sizeof(pibErrTbl) / sizeof(RcPibErrMap);
PIB::PibError l_rv = PIB::PIB_NO_ERROR;

for // loop thru the xlate table
( int i = 0;
i < l_entryCnt;
i++ )
{
if // matching entry found
( pibErrTbl[i].iv_Common == i_rc )
{
// extract translation value
l_rv = pibErrTbl[i].iv_Piberr;
break;
}
}

return( l_rv );
}


/**
* @brief Internal routine that translates an OPAL return code to a
* PIB error code
*
* @param[in] i_rc OPAL return code
* @return PibError, PIB::PIB_NO_ERROR if not translatable
*/
PIB::PibError OpalRcToPibErr( int i_rc )
{
int l_entryCnt = sizeof(pibErrTbl) / sizeof(RcPibErrMap);
PIB::PibError l_rv = PIB::PIB_NO_ERROR;

for // loop thru the xlate table
( int i = 0;
i < l_entryCnt;
i++ )
{
if // matching entry found
( pibErrTbl[i].iv_Opal == i_rc )
{
// extract translation value
l_rv = pibErrTbl[i].iv_Piberr;
break;
}
}

return( l_rv );
}


/**
* @brief Internal routine that verifies the validity of input parameters
* for an XSCOM access.
Expand Down Expand Up @@ -212,51 +321,48 @@ errlHndl_t xScomDoOp(DeviceFW::OperationType i_ioType,
rc,
i_scomAddr);

// translate the rc into a pib error when possible
uint32_t l_piberr = PIB::PIB_NO_ERROR;
// attempt to translate rc into a pib error assuming
// the rc is in common format
HbrtRcPiberr_t l_commonRc = static_cast<HbrtRcPiberr_t>(rc);
PIB::PibError l_piberr = HbrtRcToPibErr( l_commonRc );

if( TARGETING::is_sapphire_load() )
if // input was translated to a PIB error code
( l_piberr != PIB::PIB_NO_ERROR )
{
// values taken from opal-api.h
switch( rc )
{
case(-12 /*OPAL_XSCOM_BUSY*/):
l_piberr = PIB::PIB_RESOURCE_OCCUPIED;
break;
case(-14 /*OPAL_XSCOM_CHIPLET_OFF*/):
l_piberr = PIB::PIB_CHIPLET_OFFLINE;
break;
case(-25 /*OPAL_XSCOM_PARTIAL_GOOD*/):
l_piberr = PIB::PIB_PARTIAL_GOOD;
break;
case(-26 /*OPAL_XSCOM_ADDR_ERROR*/):
l_piberr = PIB::PIB_INVALID_ADDRESS;
break;
case(-27 /*OPAL_XSCOM_CLOCK_ERROR*/):
l_piberr = PIB::PIB_CLOCK_ERROR;
break;
case(-28 /*OPAL_XSCOM_PARITY_ERROR*/):
l_piberr = PIB::PIB_PARITY_ERROR;
break;
case(-29 /*OPAL_XSCOM_TIMEOUT*/):
l_piberr = PIB::PIB_TIMEOUT;
break;
}
// (translation was successful)
}
else if( TARGETING::is_phyp_load() )

else if // input was common format, but not a PIB error
( l_commonRc == HBRT_RC_SOMEOTHERERROR )
{
// (already translated to PIB::PIB_NO_ERROR,
// no more translation needed)
}

else if // legacy opal
( TARGETING::is_sapphire_load() )
{
// attempt to translate rc into a pib error assuming
// the rc is in old opal format
// this preserves legacy behavior to avoid co-req/pre-req
l_piberr = OpalRcToPibErr( rc );
}

else if // legacy phyp
( TARGETING::is_phyp_load() )
{
//@todo-RTC:86782-Add PHYP support
// default to OFFLINE for now to trigger
// the multicast workaround in scom.C
l_piberr = PIB::PIB_CHIPLET_OFFLINE;
}

else
{
// our testcases respond back with the
// pib error directly
if( rc > 0 )
{
l_piberr = rc;
l_piberr = static_cast<PIB::PibError>(rc);
}
}

Expand Down

0 comments on commit bb0dc7d

Please sign in to comment.