Skip to content

Commit

Permalink
Added code to send an Error Log to FSP via the firmware_request
Browse files Browse the repository at this point in the history
Change-Id: I6ce94d9cbf62fa7d2afe53b83b6bc5588a39a5d6
RTC:178947
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/45442
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>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: ILYA SMIRNOV <ismirno@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
velozr authored and dcrowell77 committed Sep 18, 2017
1 parent 7c81698 commit 0ab063c
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 90 deletions.
20 changes: 17 additions & 3 deletions src/include/runtime/interface.h
Expand Up @@ -502,6 +502,8 @@ typedef struct hostInterfaces
HBRT_FW_MSG_TYPE_RESP_NOP = 1,
HBRT_FW_MSG_TYPE_RESP_GENERIC = 2,
HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE = 3,
HBRT_FW_MSG_HBRT_FSP = 4,
HBRT_FW_MSG_TYPE_ERROR_LOG = 5,
};

struct hbrt_fw_msg // define struct hbrt_fw_msg
Expand All @@ -524,14 +526,26 @@ typedef struct hostInterfaces
struct
{
uint64_t i_chipId; // processor chip ID plus ID type,
// always proc (0x0)
// always proc (0x0)
uint32_t i_section; // runtime section to update
// (passthru to pore_gen_scom)
// (passthru to pore_gen_scom)
uint32_t i_operation; // type of operation to perform
// (passthru to pore_gen_scom)
// (passthru to pore_gen_scom)
uint64_t i_scomAddr; // fully qualified scom address
uint64_t i_scomData; // data for operation
} req_hcode_update;

// This struct is sent from HBRT with
// io_type set to HBRT_FW_MSG_TYPE_ERR_LOG
// Send an error log to FSP
struct
{
uint32_t i_plid; // platform log identifier
uint32_t i_errlSize; // data size in bytes
uint8_t i_data; // the error log data
// uint8_t *myData =
// (uint8_t*)&l_req_fw_msg->error_log.i_data;
} __attribute__ ((packed)) error_log;
};
};

Expand Down
80 changes: 66 additions & 14 deletions src/usr/errl/runtime/rt_errlmanager.C
Expand Up @@ -172,23 +172,76 @@ void ErrlManager::sendMboxMsg ( errlHndl_t& io_err )
INFO_MRK"Send msg to FSP for errlogId [0x%08x]",
io_err->plid() );

uint32_t l_msgSize = io_err->flattenedSize();
uint8_t * temp_buff = new uint8_t [l_msgSize ];
io_err->flatten ( temp_buff, l_msgSize );

if(g_hostInterfaces && g_hostInterfaces->sendErrorLog)
if(g_hostInterfaces)
{
int rc = g_hostInterfaces->sendErrorLog(io_err->plid(),
l_msgSize,
temp_buff);
uint32_t l_msgSize = io_err->flattenedSize();
if (g_hostInterfaces->sendErrorLog)
{
uint8_t * temp_buff = new uint8_t [l_msgSize ];
io_err->flatten ( temp_buff, l_msgSize );

size_t rc = g_hostInterfaces->sendErrorLog(io_err->plid(),
l_msgSize,
temp_buff);

if(rc)
{
TRACFCOMP(g_trac_errl, ERR_MRK
"Failed sending error log to FSP via "
"sendErrorLog. rc: %d. plid: 0x%08x",
rc,
io_err->plid() );
}

if(rc)
delete [] temp_buff;
}
else if (g_hostInterfaces->firmware_request)
{
// Get an accurate size of memory actually
// needed to transport the data
size_t l_req_fw_msg_size =
hostInterfaces::HBRT_FW_MSG_BASE_SIZE +
sizeof(hostInterfaces::hbrt_fw_msg::error_log) +
l_msgSize;

// Create the firmware_request structure
// to carry the error log data
hostInterfaces::hbrt_fw_msg *l_req_fw_msg =
(hostInterfaces::hbrt_fw_msg *)malloc(l_req_fw_msg_size);

memset(l_req_fw_msg, 0, l_req_fw_msg_size);

// Populate the firmware_request structure with given data
l_req_fw_msg->io_type =
hostInterfaces::HBRT_FW_MSG_TYPE_ERROR_LOG;
l_req_fw_msg->error_log.i_plid = io_err->plid();
l_req_fw_msg->error_log.i_errlSize = l_msgSize;
io_err->flatten (&(l_req_fw_msg->error_log.i_data), l_msgSize);

hostInterfaces::hbrt_fw_msg l_resp_fw_msg;
uint64_t l_resp_fw_msg_size = sizeof(l_resp_fw_msg);
size_t rc = g_hostInterfaces->
firmware_request(l_req_fw_msg_size, l_req_fw_msg,
&l_resp_fw_msg_size, &l_resp_fw_msg);

if(rc)
{
TRACFCOMP(g_trac_errl, ERR_MRK
"Failed sending error log to FSP "
"via firmware_request. rc: %d. plid: 0x%08x",
rc,
io_err->plid() );
}

free(l_req_fw_msg);
}
else
{
TRACFCOMP(g_trac_errl, ERR_MRK
"Failed sending error log to FSP. rc: %d. "
"plid: 0x%08x",
rc,
io_err->plid() );
"Host interfaces sendErrorLog and firmware_request "
"not initialized, error log not sent. plid: 0x%08x",
io_err->plid()
);
}
}
else
Expand All @@ -199,7 +252,6 @@ void ErrlManager::sendMboxMsg ( errlHndl_t& io_err )
io_err->plid()
);
}
delete [] temp_buff;
#endif
delete io_err;
io_err = NULL;
Expand Down
185 changes: 128 additions & 57 deletions src/usr/isteps/pm/runtime/test/firmwareRequestTest.H
Expand Up @@ -32,63 +32,134 @@ class FirmwareRequestTest : public CxxTest::TestSuite
{
public:
/**
* @brief: testFirmwareRequest
* tests that the firmware_request is being accessed properly
* @brief: testFirmwareRequestHcodeUpdate
* test the firmware_request's HCODE update call
*/
void testFirmwareRequest (void)
void testFirmwareRequestHcodeUpdate (void)
{
TRACFCOMP(g_trac_pnor, ENTER_MRK
"FirmwareRequestTest::testFirmwareRequest" );

if (g_hostInterfaces == NULL ||
g_hostInterfaces->firmware_request == NULL)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequest: "
"Hypervisor firmware_request interface not linked");
}
else
{
hostInterfaces::hbrt_fw_msg l_req_fw_msg;
l_req_fw_msg.io_type =
hostInterfaces::HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE;
l_req_fw_msg.req_hcode_update.i_chipId = 0;
l_req_fw_msg.req_hcode_update.i_section = 0;
l_req_fw_msg.req_hcode_update.i_operation = 0;
l_req_fw_msg.req_hcode_update.i_scomAddr = 0;
l_req_fw_msg.req_hcode_update.i_scomData = 0;


hostInterfaces::hbrt_fw_msg l_resp_fw_msg;
uint64_t l_resp_fw_msg_size = sizeof(l_resp_fw_msg);
int rc = g_hostInterfaces->firmware_request(sizeof(l_resp_fw_msg),
&l_req_fw_msg, &l_resp_fw_msg_size, &l_resp_fw_msg);

TRACFCOMP(g_trac_pnor, "FirmwareRequestTest::testFirmwareRequest: "
"rc:%d, type:%d, resp:%d",
rc, l_resp_fw_msg.io_type,
l_resp_fw_msg.resp_generic.o_status);

if (rc != 1)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequest: "
"firware_request failed - returned wrong value");
}

if (l_resp_fw_msg.io_type !=
TRACFCOMP(g_trac_pnor, ENTER_MRK
"FirmwareRequestTest::testFirmwareRequestHcodeUpdate");

if (g_hostInterfaces == NULL ||
g_hostInterfaces->firmware_request == NULL)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequestHcodeUpdate: "
"Hypervisor firmware_request interface not linked");
}
else
{
// Test HCODE Update
// populate the firmware_request structure with arbitrary data
hostInterfaces::hbrt_fw_msg l_req_fw_msg;
l_req_fw_msg.io_type =
hostInterfaces::HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE;
l_req_fw_msg.req_hcode_update.i_chipId = 0x100;
l_req_fw_msg.req_hcode_update.i_section = 20;
l_req_fw_msg.req_hcode_update.i_operation = 30;
l_req_fw_msg.req_hcode_update.i_scomAddr = 0x400;
l_req_fw_msg.req_hcode_update.i_scomData = 0x500;


hostInterfaces::hbrt_fw_msg l_resp_fw_msg;
uint64_t l_resp_fw_msg_size = sizeof(l_resp_fw_msg);
size_t rc = g_hostInterfaces->firmware_request(
sizeof(l_req_fw_msg), &l_req_fw_msg,
&l_resp_fw_msg_size, &l_resp_fw_msg);

TRACFCOMP(g_trac_pnor,
"FirmwareRequestTest::testFirmwareRequestHcodeUpdate: "
"rc:%d, type:%d, resp:%d",
rc, l_resp_fw_msg.io_type,
l_resp_fw_msg.resp_generic.o_status);

if (rc != 1)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequestHcodeUpdate: "
"firware_request - hcode update failed - "
"returned wrong value");
}

if (l_resp_fw_msg.io_type !=
hostInterfaces::HBRT_FW_MSG_TYPE_RESP_GENERIC)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequestHcodeUpdate: "
"firware_request - hcode update failed - "
"received incorrect msg_type");
}

if (l_resp_fw_msg.resp_generic.o_status != 264)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequestHcodeUpdate: "
"firware_request - hcode update failed - "
"received incorrect resp");
}
} // end else
TRACFCOMP(g_trac_pnor, EXIT_MRK
"FirmwareRequestTest::testFirmwareRequestHcodeUpdate");

} // end testFirmwareRequestHcodeUpdate

/**
* @brief: testFirmwareRequestErrLogToFsp
* test the firmware_request's error log to FSP
*/
void testFirmwareRequestErrLogToFsp (void)
{
TRACFCOMP(g_trac_pnor, ENTER_MRK
"FirmwareRequestTest::testFirmwareRequestErrLogToFsp");

if (g_hostInterfaces == NULL ||
g_hostInterfaces->firmware_request == NULL)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequestErrLogToFsp: "
"Hypervisor firmware_request interface not linked");
}
else
{
// Test error log to FSP
// populate the firmware_request structure with arbitrary data
hostInterfaces::hbrt_fw_msg l_req_fw_msg;
l_req_fw_msg.io_type =hostInterfaces::HBRT_FW_MSG_TYPE_ERROR_LOG;
l_req_fw_msg.error_log.i_plid = 0x300;
l_req_fw_msg.error_log.i_errlSize = 1;
l_req_fw_msg.error_log.i_data = 0xAA;

hostInterfaces::hbrt_fw_msg l_resp_fw_msg;
uint64_t l_resp_fw_msg_size = sizeof(l_resp_fw_msg);
size_t rc = g_hostInterfaces->firmware_request(
sizeof(l_req_fw_msg), &l_req_fw_msg,
&l_resp_fw_msg_size, &l_resp_fw_msg);

TRACFCOMP(g_trac_pnor,
"FirmwareRequestTest::testFirmwareRequestErrLogToFsp: "
"rc:%d, type:%d, resp:%d",
rc, l_resp_fw_msg.io_type,
l_resp_fw_msg.resp_generic.o_status);

if (rc != 0)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequestErrLogToFsp: "
"firware_request - error log failed - "
"returned wrong value");
}

if (l_resp_fw_msg.io_type !=
hostInterfaces::HBRT_FW_MSG_TYPE_RESP_GENERIC)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequest: "
"firware_request failed - received incorrect msg_type");
}

if (l_resp_fw_msg.resp_generic.o_status != 264)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequest: "
"firware_request failed - received incorrect resp");
}

TRACFCOMP(g_trac_pnor, EXIT_MRK
"FirmwareRequestTest::testFirmwareRequest");
}
}
};
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequestErrLogToFsp: "
"firware_request - error log failed - "
"received incorrect msg_type");
}

if (l_resp_fw_msg.resp_generic.o_status != 20)
{
TS_FAIL("FirmwareRequestTest::testFirmwareRequestErrLogToFsp: "
"firware_request - error log failed - "
"received incorrect resp");
}
} // end else
TRACFCOMP(g_trac_pnor, EXIT_MRK
"FirmwareRequestTest::testFirmwareRequestErrLogToFsp");

} // end testFirmwareRequestErrLogToFsp
}; // end class FirmwareRequestTest

0 comments on commit 0ab063c

Please sign in to comment.