diff options
author | Thi Tran <thi@us.ibm.com> | 2018-01-29 20:56:41 -0600 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2018-02-03 19:48:04 -0500 |
commit | 53b3c1f1d859cb5a6b03060b46933d4ac049ca83 (patch) | |
tree | b97feb581ebce9cd0b4156315c16bc4de8660517 /src/usr/sbeio/sbe_secureHwp.C | |
parent | 07c9730e0a3ff5bf6ca59b09fc91da69ac4c9753 (diff) | |
download | blackbird-hostboot-53b3c1f1d859cb5a6b03060b46933d4ac049ca83.tar.gz blackbird-hostboot-53b3c1f1d859cb5a6b03060b46933d4ac049ca83.zip |
HB supports - Use ADU chipops to switch fabric configuration
Change-Id: I090cdac654d9c6efbe30748713687c6e36ff914d
RTC:177597
CQ:SW413432
Backport: release-fips910
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/52878
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: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/sbeio/sbe_secureHwp.C')
-rw-r--r-- | src/usr/sbeio/sbe_secureHwp.C | 198 |
1 files changed, 155 insertions, 43 deletions
diff --git a/src/usr/sbeio/sbe_secureHwp.C b/src/usr/sbeio/sbe_secureHwp.C index f6b3117ba..246935e78 100644 --- a/src/usr/sbeio/sbe_secureHwp.C +++ b/src/usr/sbeio/sbe_secureHwp.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* Contributors Listed Below - COPYRIGHT 2012,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -36,38 +36,124 @@ #include <sbeio/sbeioreasoncodes.H> #include <targeting/common/targetservice.H> +#define DEBUG_TRACE 0 // 0 = disable extern trace_desc_t* g_trac_sbeio; +// ------------------------- +// Structure definitions +// ------------------------- + +// Argument pointer lay-out +// uint64_t i_address +// uint32_t i_bytes, +// uint8_t* i_data, +// uint32_t i_mem_flags +struct argData_t +{ + uint32_t address_0; + uint32_t address_1; + uint32_t dataLen; + uint64_t dataLoc; + uint32_t flags; +} PACKED; + #define SBE_TRACD(printf_string,args...) \ TRACDCOMP(g_trac_sbeio,"secureHwp: " printf_string,##args) #define SBE_TRACF(printf_string,args...) \ TRACFCOMP(g_trac_sbeio,"secureHwp: " printf_string,##args) - namespace SBEIO { - //List out name of valid hwps that have chipop equivalents - //these static variable will be used by - static const char* test_hwp = "test_hwp"; // SBE_FIFO_CMD_PLACEHOLDER_HWP - /** - * @brief Convert a hwp name passed in as a string to a chipOp code - * @param[in] i_hwpName name of hwp as a string - * @return fifoSecureHwpMessage returns a chipOp representing the HWP, if found - * otherwise returns UNSUPPORTED_HWP enum + * @brief Perform an SBE PutMem chip-op with arguments given from a + * "p9_putmemproc" secured function call. + * + * @param[in] i_target TARGETING::Target which the HWP is being called on + * @param[in] i_argPtr Pointer to arguments of the HWP + * @param[in] i_argSize Argument size in bytes + * + * @return errlHndl_t Error log handle on failure. */ - SbeFifo::fifoSecureHwpMessage convertHwpStringToOpCode(const char* i_hwpName) + errlHndl_t putMemChipOpRequest(TARGETING::Target *i_target, + const uint8_t* i_argPtr, + const size_t i_argSize) { - //Default to undefined HWP - SbeFifo::fifoSecureHwpMessage l_hwpOpCode = SbeFifo::fifoSecureHwpMessage::SBE_FIFO_CMD_UNSUPPORTED_HWP; + SBE_TRACD(ENTER_MRK "putMemChipOpRequest"); + errlHndl_t l_errl = nullptr; - //If we find a match, set the return value - if(strcmp(i_hwpName,test_hwp) == 0) + do { - l_hwpOpCode = SbeFifo::fifoSecureHwpMessage::SBE_FIFO_CMD_PLACEHOLDER_HWP; - } - return l_hwpOpCode; + +#if DEBUG_TRACE + for (uint32_t ii = 0; ii < i_argSize; ii++) + { + SBE_TRACF("putMemChipOpRequest - i_argPtr[%d] = 0x%.2X", ii, i_argPtr[ii]); + } +#endif + + // Setup command + SbeFifo::fifoPutMemRequest l_fifoRequest; + SbeFifo::fifoPutMemResponse l_fifoResponse; + + // Map input arg pointer into structure + argData_t* l_argPtr = (argData_t*)i_argPtr; + + // Address bits 0:31 + l_fifoRequest.address[0] = l_argPtr->address_0; + + // Address bits 32:63 + l_fifoRequest.address[1] = l_argPtr->address_1; + + // Data length + l_fifoRequest.dataLen = l_argPtr->dataLen; + + // Allocate memory for data + l_fifoRequest.dataPtr = + reinterpret_cast<uint32_t *>(malloc(l_fifoRequest.dataLen)); + + // Copy data from memory into allocated memory + memcpy(l_fifoRequest.dataPtr, + reinterpret_cast<uint32_t *>(l_argPtr->dataLoc), + l_fifoRequest.dataLen); + + // Flag + l_fifoRequest.flags = l_argPtr->flags; + + // Command length + l_fifoRequest.wordCnt = SbeFifo::PUTMEM_CMD_BUF_LEN_IN_WORDS + + (l_fifoRequest.dataLen / SbeFifo::BYTES_PER_WORD); + if (l_fifoRequest.dataLen % SbeFifo::BYTES_PER_WORD) + { + l_fifoRequest.wordCnt += 1; + } + + SBE_TRACF("INFO_MRK: Target: 0x%.8X, Address: 0x%.16llX, Datalen: %d, " + "Data[0]: 0x%.8X, Flags 0x%.4x, WordCnt: %d", + TARGETING::get_huid(i_target), + ((uint64_t)(l_fifoRequest.address[0]) << 32) | l_fifoRequest.address[1], + l_fifoRequest.dataLen, + *l_fifoRequest.dataPtr, + l_fifoRequest.flags, + l_fifoRequest.wordCnt); + + l_errl = SbeFifo::getTheInstance().performFifoChipOp( + i_target, + (uint32_t *)&l_fifoRequest, + (uint32_t *)&l_fifoResponse, + sizeof(l_fifoResponse)); + if (l_errl) + { + SBE_TRACF("ERR_MRK: SBE Putmem chip-op call returns an error."); + } + + free(l_fifoRequest.dataPtr); + + } while(0); + + SBE_TRACD(EXIT_MRK "putMemChipOpRequest"); + + return l_errl; } /** @@ -76,11 +162,10 @@ namespace SBEIO * @param[in] i_target The target of which the HWP is intended to be called on, * this must be the first param of the request HWP * - * @param[in] i_dataPointer Pointer to a blob of data that contains additional parameters - * for the requests HWP + * @param[in] i_argPtr Pointer to argument data for the request HWP + * arguments for the requests HWP * - * @param[in] i_dataSize Size of blob of data that contains additional parameters - * for the requests HWP + * @param[in] i_argSize Size of argument data for the requests HWP, in bytes * * @param[in] i_hwpName Pointer to string of chars representing hwp name * @@ -88,16 +173,18 @@ namespace SBEIO * */ errlHndl_t sendSecureHwpRequest(TARGETING::Target * i_target, - uint8_t * i_dataPointer, - uint64_t i_dataSize, + uint8_t * i_argPtr, + size_t i_argSize, const char * i_hwpName) { errlHndl_t errl = nullptr; do { - SBE_TRACD(ENTER_MRK "sendSecureHwpRequest"); - //First we need to figure out if this is a proc, if it isn't - //then we need to find its parent proccessor chip + SBE_TRACF(ENTER_MRK "sendSecureHwpRequest: HWP %s, Target 0x%.8X", + i_hwpName, TARGETING::get_huid(i_target)); + + // First we need to figure out if this is a proc, if it isn't + // then we need to find its parent proccessor chip auto l_targType = i_target->getAttr<TARGETING::ATTR_TYPE>(); TARGETING::Target * l_proc; if(l_targType == TARGETING::TYPE_PROC) @@ -109,29 +196,54 @@ namespace SBEIO l_proc = const_cast<TARGETING::Target *>(getParentChip(i_target)); } - SbeFifo::fifoSecureHwpRequest l_fifoRequest(i_dataSize, i_dataPointer); - SbeFifo::fifoStandardResponse l_fifoResponse; - - //Command is computed by converting hwp string to function - l_fifoRequest.command = convertHwpStringToOpCode(i_hwpName); - l_fifoRequest.targetType = translateToSBETargetType(i_target); - l_fifoRequest.chipletId = getChipletIDForSBE(i_target); + // ----------------------------------------------- + // Identify HWP and call appropriate chip-op setup + // ----------------------------------------------- + // HWP = p9_putmemproc + if (strcmp(i_hwpName,"p9_putmemproc") == 0) + { + // Perform PutMem chip-op + errl = putMemChipOpRequest(l_proc, i_argPtr, i_argSize); + if (errl) + { + break; + } + } - SBE_TRACD(ENTER_MRK "requesting secureHwp %d on proc %d HB -> SBE ", - l_fifoRequest.command, - l_proc->getAttr<TARGETING::ATTR_POSITION>()); + // HWP = test_hwp + else if (strcmp(i_hwpName, "test_hwp") == 0) + { + } - errl = SbeFifo::getTheInstance().performFifoChipOp(l_proc, - (uint32_t *)&l_fifoRequest, - (uint32_t *)&l_fifoResponse, - sizeof(SbeFifo::fifoStandardResponse)); + // HWP = procedure_to_call + // This procedure is called via error path test case. + // Return an error so FAPI_PLAT_CALL_SUBROUTINE invokes + // a local copy written for the test case. + else if (strcmp(i_hwpName, "procedure_to_call") == 0) + { + SBE_TRACF(ERR_MRK "sendSecureHwpRequest: HWP %s not supported in SBE.", i_hwpName); + errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, + SBEIO_FIFO, + SBEIO_FIFO_INVALID_OPERATION, + 0, + 0, + true /*SW error*/); + errl->collectTrace(SBEIO_COMP_NAME); + break; + } - SBE_TRACD(EXIT_MRK "sendSecureHwpRequest"); + // HWP = unknown + // Assert if HWP is not recognized, either a code bug or HWP needs + // to be supported + else + { + assert(false,"sendSecureHwpRequest: HWP name is not recognized: %s", i_hwpName); + } }while(0); + SBE_TRACD(EXIT_MRK "sendSecureHwpRequest"); return errl; }; } //end namespace SBEIO - |