summaryrefslogtreecommitdiffstats
path: root/src/usr/sbeio/runtime
diff options
context:
space:
mode:
authorMarty Gloff <mgloff@us.ibm.com>2017-03-20 14:25:27 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2017-04-10 13:26:13 -0400
commitd85536ac35dd97a666b7b8de090f255b1a33c7d8 (patch)
tree07df13fd800c898b60659ad54920e7c719f6ee66 /src/usr/sbeio/runtime
parent4a0692811d82840b2c6eed9c892c9a866586b989 (diff)
downloadblackbird-hostboot-d85536ac35dd97a666b7b8de090f255b1a33c7d8.tar.gz
blackbird-hostboot-d85536ac35dd97a666b7b8de090f255b1a33c7d8.zip
SBE message passing interface - call appropriate command processor
Add definitions of SBE message and pass-through command. Create mechanism to call functions to process commands. Change-Id: Id14471b1e6f036c278fd5ae1950b942290282c1e RTC: 170761 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/38167 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com> Reviewed-by: Corey V. Swenson <cswenson@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/sbeio/runtime')
-rw-r--r--src/usr/sbeio/runtime/rt_sbeio.C299
1 files changed, 250 insertions, 49 deletions
diff --git a/src/usr/sbeio/runtime/rt_sbeio.C b/src/usr/sbeio/runtime/rt_sbeio.C
index a0737e788..3b653bfcb 100644
--- a/src/usr/sbeio/runtime/rt_sbeio.C
+++ b/src/usr/sbeio/runtime/rt_sbeio.C
@@ -27,33 +27,169 @@
#include <vmmconst.h>
#include <sys/misc.h>
+#include <sbeio/runtime/sbe_msg_passing.H>
+#include <sbeio/sbeioreasoncodes.H>
+#include <util/singleton.H>
#include <errno.h>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
+#include <errl/errlreasoncodes.H>
// targeting support
#include <targeting/common/target.H>
#include <targeting/common/commontargeting.H>
#include <targeting/common/utilFilter.H>
-//#include <targeting/common/targetservice.H>
-//#include <targeting/common/util.H>
#include <runtime/rt_targeting.H>
-// fapi support
-//#include <isteps/hwpf_reasoncodes.H>
-
using namespace TARGETING;
+using namespace ERRORLOG;
+using namespace SBE_MSG;
// Trace
-extern trace_desc_t* g_fapiTd; // defined in rt_fapiPlatUtil.C
+trace_desc_t* g_trac_sbeio;
+TRAC_INIT(&g_trac_sbeio, SBEIO_COMP_NAME, 6*KILOBYTE, TRACE::BUFFER_SLOW);
+
namespace RT_SBEIO
{
+ // Map of process command functions for the pass-through commands
+ ProcessCmdMap_t g_processCmdMap;
+
//------------------------------------------------------------------------
//------------------------------------------------------------------------
+ int process_sbe_msg_cmd_processor(TargetHandle_t i_proc,
+ sbeMessage_t& i_request,
+ sbeMessage_t& o_response)
+ {
+ errlHndl_t errl = nullptr;
+ int rc = 0;
+ uint32_t l_command = i_request.cmdHdr.command;
+
+ if(g_processCmdMap.find(l_command) == g_processCmdMap.end())
+ {
+ TRACFCOMP(g_trac_sbeio, ERR_MRK"process_sbe_msg: process "
+ "command, function pointer not found for command 0x%08x",
+ l_command);
+
+ rc = -201;
+
+ /*@
+ * @errortype
+ * @moduleid SBEIO::SBEIO_RUNTIME
+ * @reasoncode SBEIO::SBEIO_RT_FUNCTION_NOT_SET
+ * @userdata1[0:31] Processor HUID
+ * @userdata1[32:63] Request Command
+ * @userdata2 Sequence ID
+ *
+ * @devdesc SBEIO RT Process Pass-through command function not
+ * set.
+ * @custdesc Firmware error communicating with boot device
+ */
+ errl = new ErrlEntry(ERRL_SEV_UNRECOVERABLE,
+ SBEIO::SBEIO_RUNTIME,
+ SBEIO::SBEIO_RT_FUNCTION_NOT_SET,
+ TWO_UINT32_TO_UINT64(
+ get_huid(i_proc),
+ l_command),
+ i_request.sbeHdr.seqId);
+
+ errl->addFFDC( SBE_COMP_ID,
+ &(i_request),
+ sizeof(sbeHeader_t) + sizeof(cmdHeader_t),
+ 0, // Version
+ ERRL_UDT_NOFORMAT, // parser ignores data
+ // ^^^ @TODO RTC:172362
+ false ); // merge
+ errl->addProcedureCallout(HWAS::EPUB_PRC_HB_CODE,
+ HWAS::SRCI_PRIORITY_HIGH);
+ errl->collectTrace(SBEIO_COMP_NAME);
+ errlCommit(errl, SBE_COMP_ID);
+ }
+ else
+ {
+ // Trace command to be processed
+ TRACFCOMP(g_trac_sbeio, "process_sbe_msg: process "
+ "command, process command 0x%08x with sequence ID 0x%08x",
+ l_command,
+ i_request.sbeHdr.seqId);
+
+ // Call function to process command
+ errl = g_processCmdMap[l_command](i_proc,
+ i_request.cmdHdr.dataSize,
+ i_request.data,
+ &o_response.cmdHdr.status,
+ &o_response.cmdHdr.dataSize,
+ o_response.data);
+
+ if(o_response.cmdHdr.dataSize > SBE_MSG_MAX_DATA)
+ {
+ TRACFCOMP(g_trac_sbeio, ERR_MRK"process_sbe_msg: process "
+ "command, response data size 0x%08x too large",
+ o_response.cmdHdr.dataSize);
+
+ rc = -202;
+
+ /*@
+ * @errortype
+ * @moduleid SBEIO::SBEIO_RUNTIME
+ * @reasoncode SBEIO::SBEIO_RT_RSP_DATA_TOO_LARGE
+ * @userdata1[0:31] Processor HUID
+ * @userdata1[32:63] Request Command
+ * @userdata2[0:31] Sequence ID
+ * @userdata2[32:63] Response Data Size
+ *
+ * @devdesc SBEIO RT Process Pass-through command response
+ * data size too large.
+ * @custdesc Firmware error communicating with boot device
+ */
+ errl = new ErrlEntry(ERRL_SEV_INFORMATIONAL,
+ SBEIO::SBEIO_RUNTIME,
+ SBEIO::SBEIO_RT_RSP_DATA_TOO_LARGE,
+ TWO_UINT32_TO_UINT64(
+ get_huid(i_proc),
+ l_command),
+ TWO_UINT32_TO_UINT64(
+ i_request.sbeHdr.seqId,
+ o_response.cmdHdr.dataSize));
+
+ errl->addFFDC( SBE_COMP_ID,
+ &(i_request),
+ sizeof(sbeHeader_t) + sizeof(cmdHeader_t),
+ 0, // Version
+ ERRL_UDT_NOFORMAT, // parser ignores data
+ // ^^^ @TODO RTC:172362
+ false ); // merge
+ errl->addProcedureCallout(HWAS::EPUB_PRC_HB_CODE,
+ HWAS::SRCI_PRIORITY_HIGH);
+ errl->collectTrace(SBEIO_COMP_NAME);
+ errlCommit(errl, SBE_COMP_ID);
+
+ // Calculate message size for response using max data
+ o_response.sbeHdr.msgSize = sizeof(sbeHeader_t) +
+ sizeof(cmdHeader_t) + SBE_MSG_MAX_DATA;
+ }
+ else
+ {
+ // Calculate message size for response
+ o_response.sbeHdr.msgSize = sizeof(sbeHeader_t) +
+ sizeof(cmdHeader_t) + o_response.cmdHdr.dataSize;
+ }
+
+ // Trace response to command that was processed
+ TRACFCOMP(g_trac_sbeio, "process_sbe_msg: process "
+ "command, response to command 0x%08x with sequence ID "
+ "0x%08x was status 0x%08x",
+ o_response.cmdHdr.command,
+ o_response.sbeHdr.seqId,
+ o_response.cmdHdr.status);
+ }
+
+ return rc;
+ }
+
//------------------------------------------------------------------------
//------------------------------------------------------------------------
@@ -61,34 +197,95 @@ namespace RT_SBEIO
int process_sbe_msg(uint32_t i_procChipId)
{
int rc = 0;
- errlHndl_t err = nullptr;
+ errlHndl_t errl = nullptr;
+
+ // Used to store a local copy of the Pass-through command and preserve
+ // it during processing (response overlays SBE Communication buffer)
+ sbeMessage_t l_request;
- // Convert chipId to HB target
- TargetHandle_t l_proc = nullptr;
- err = RT_TARG::getHbTarget(i_procChipId, l_proc);
- if(err)
+ do
{
- rc = err->reasonCode();
- if (0 == rc)
+ // Convert chipId to HB target
+ TargetHandle_t l_proc = nullptr;
+ errl = RT_TARG::getHbTarget(i_procChipId, l_proc);
+ if(errl)
{
- // If there was a failure, be sure to return non-zero status
- rc = -1;
+ rc = errl->reasonCode();
+ if (0 == rc)
+ {
+ // If there was a failure, be sure to return non-zero status
+ rc = -1;
+ }
+
+ TRACFCOMP(g_trac_sbeio, ERR_MRK"process_sbe_msg: getHbTarget "
+ "returned rc=0x%04X for procChipId: %llx",
+ rc, i_procChipId);
+
+ errlCommit (errl, SBE_COMP_ID);
+
+ break;
}
- TRACFCOMP(g_fapiTd, ERR_MRK"process_sbe_msg: getHbTarget "
- "returned rc=0x%04X for procChipId: %llx",
- rc, i_procChipId);
+ // Get SBE Communication Buffer for target processor
+ uint64_t l_sbeCommAddr =
+ l_proc->getAttr<TARGETING::ATTR_SBE_COMM_ADDR>();
- errlCommit (err, SBE_COMP_ID);
- }
+ // Make sure SBE Communication Buffer is set
+ if(l_sbeCommAddr == NULL)
+ {
+ TRACFCOMP(g_trac_sbeio, ERR_MRK"process_sbe_msg: getAttr "
+ "did not get SBE Communication buffer address");
+
+ rc = -2;
- /* TODO RTC 170760 process SBE message read command */
+ /*@
+ * @errortype
+ * @moduleid SBEIO::SBEIO_RUNTIME
+ * @reasoncode SBEIO::SBEIO_RT_NO_SBE_COMM_BUFFER
+ * @userdata1 Processor HUID
+ * @userdata2 Reserved
+ *
+ * @devdesc SBEIO RT Process Pass-through command SBE
+ * Communication buffer not set.
+ * @custdesc Firmware error communicating with boot device
+ */
+ errl = new ErrlEntry(ERRL_SEV_INFORMATIONAL,
+ SBEIO::SBEIO_RUNTIME,
+ SBEIO::SBEIO_RT_NO_SBE_COMM_BUFFER,
+ get_huid(l_proc),
+ 0);
- /* TODO RTC 170761 call appropriate command processor */
+ errl->addProcedureCallout(HWAS::EPUB_PRC_HB_CODE,
+ HWAS::SRCI_PRIORITY_HIGH);
+ errl->collectTrace(SBEIO_COMP_NAME);
+ errlCommit(errl, SBE_COMP_ID);
+
+ break;
+ }
- /* TODO RTC 170762 process SBE message write response */
+ // Provide access to SBE Communication Buffer as an SBE Message
+ sbeMessage_t *l_sbeMessage =
+ reinterpret_cast<sbeMessage_t*>(l_sbeCommAddr);
- /* TODO RTC 170763 assert CFAM register ??? */
+ /* TODO RTC 170760 process SBE message read command */
+ TRACFCOMP(g_trac_sbeio, "process_sbe_msg: read command");
+
+ // Call appropriate command processor
+ TRACFCOMP(g_trac_sbeio, "process_sbe_msg: call command processor");
+ rc = process_sbe_msg_cmd_processor(l_proc,
+ l_request,
+ *l_sbeMessage);
+ if(rc != 0)
+ {
+ break;
+ }
+
+ /* TODO RTC 170762 process SBE message write response */
+ TRACFCOMP(g_trac_sbeio, "process_sbe_msg: write response");
+
+ /* TODO RTC 170763 assert CFAM register ??? */
+ TRACFCOMP(g_trac_sbeio, "process_sbe_msg: assert CFAM register");
+ } while(0);
return rc;
}
@@ -115,34 +312,38 @@ namespace RT_SBEIO
g_hostInterfaces->get_reserved_mem("ibm,sbe-comm",
l_instance);
l_procChip->setAttr<ATTR_SBE_COMM_ADDR>(l_sbeCommAddr);
-
- /*
- * TODO RTC 170758
- *
- * call performPsuChipOp to tell SBE where to write when SBE is ready
- *
- * psuCommand l_psuCommand(
- * SBE_REQUIRE_RESPONSE,
- * SBE_PSU_GENERIC_MESSAGE,
- * SBE_CMD_CONTROL_SYSTEM_CONFIG);
- *
- * psuResponse l_psuResponse;
- *
- * // Create FFDCPackage struct in psuCommand union
- * uint64_t cd4_FFDCPackage_MbxReg2reserved = &iv_ffdcPackageBuffer;
- *
- * performPsuChipOp(l_procChip,
- * &l_psuCommand,
- * &l_psuResponse,
- * MAX_PSU_SHORT_TIMEOUT_NS,
- * SBE_SYSTEM_CONFIG_REQ_USED_REGS,
- * SBE_SYSTEM_CONFIG_RSP_USED_REGS);
- *
- */
}
}
};
registerSbeio g_registerSbeio;
-}
+} // namespace RT_SBEIO
+
+namespace SBE_MSG
+{
+ // Set an entry in list of process command functions
+ int setProcessCmdFunction(enum passThruCmds i_command,
+ processCmdFunction_t i_function)
+ {
+ int rc = 0;
+
+ do
+ {
+ RT_SBEIO::g_processCmdMap[i_command] = i_function;
+
+ if(RT_SBEIO::g_processCmdMap[i_command] != i_function)
+ {
+ TRACFCOMP(g_trac_sbeio, ERR_MRK"setProcessCmdFunction: "
+ "process command function not set for command 0x%08x",
+ i_command);
+
+ rc = -1;
+
+ break;
+ }
+ } while(0);
+
+ return rc;
+ }
+} // namespace SBE_MSG
OpenPOWER on IntegriCloud