Skip to content

Commit

Permalink
Support set data length command to improve AMESTER performance with O…
Browse files Browse the repository at this point in the history
…pen BMC

Change-Id: Ie788fad2a7e5a95f356244e88befce5d72a35a6e
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/54844
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: Sheldon R. Bailey <baileysh@us.ibm.com>
Reviewed-by: Christopher J. Cain <cjcain@us.ibm.com>
Reviewed-by: Martha Broyles <mbroyles@us.ibm.com>
  • Loading branch information
marthabroyles committed Mar 1, 2018
1 parent e4bc12d commit c44bd0f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 21 deletions.
59 changes: 45 additions & 14 deletions src/occ_405/amec/amec_amester.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@
// Externs
//*************************************************************************/
extern uint32_t G_present_hw_cores;

//*************************************************************************/
// Macros
//*************************************************************************/

//*************************************************************************/
// Defines/Enums
//*************************************************************************/
// default length to IPMI limit so we don't break AMESTER using IPMI
// Updated AMESTER can send command to increase the length on systems that do not
// use IPMI and support a larger data length to improve AMESTER performance
uint16_t G_amester_max_data_length = IPMI_MAX_MSG_SIZE;

///Maximum size of trace buffer
// NOTE: Any names in this file using timescale will NOT be kept in sync
Expand Down Expand Up @@ -338,7 +341,7 @@ uint8_t amester_api( const IPMIMsg_t * i_msg,
uint16_t l_sensor_id = 0; // sensor id
uint16_t l_sensor_count = 0; // sensor count
uint8_t l_sensor_type = 0; // sensor type
uint16_t l_maxlen = 0, l_retlen = 0; // for echo command and 0xff command
uint16_t l_maxlen = 0, l_retlen = 0; // for echo command, 0xfd and 0xff commands
uint16_t l_resp_length = *io_resp_length;
sensorrec_t SensorInfo;

Expand All @@ -358,7 +361,7 @@ uint8_t amester_api( const IPMIMsg_t * i_msg,
for (l_in = 1; l_in + 1 < i_msg->u8CmdDataLen; l_in=l_in+2)
{
// exit when a return message is filled. -1 is for IPMI return code
if (l_out + AME_SDRS > IPMI_MAX_MSG_SIZE - 1) break;
if (l_out + AME_SDRS > (G_amester_max_data_length - 1)) break;

// Get the next sensor
l_sensor_id = CONVERT_UINT8_ARRAY_UINT16(i_msg->au8CmdData_ptr[l_in],
Expand Down Expand Up @@ -482,8 +485,8 @@ uint8_t amester_api( const IPMIMsg_t * i_msg,
break;
}

// max response length is IPMI_MAX_MSG_SIZE
if( ((l_final_length+(*io_resp_length)) < IPMI_MAX_MSG_SIZE) &&
// max response length is G_amester_max_data_length
if( ((l_final_length+(*io_resp_length)) < G_amester_max_data_length) &&
((l_final_length+(*io_resp_length)) < l_resp_length ) )
{
memcpy( o_resp, l_temp_buffer, *io_resp_length); // Copy to final output buffer
Expand Down Expand Up @@ -569,10 +572,39 @@ uint8_t amester_api( const IPMIMsg_t * i_msg,
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;

// Configure AMESTER data length
case 0xfd:
*io_resp_length = 0;
// Check command data length
if (i_msg->u8CmdDataLen == 3)
{
l_maxlen = CONVERT_UINT8_ARRAY_UINT16( i_msg->au8CmdData_ptr[1],
i_msg->au8CmdData_ptr[2]);

// make sure the OCC command/response buffer supports the size -6 byte header
// and the length isn't going below the IPMI limit (save performance)
if( (l_maxlen > (CMDH_FSP_CMD_SIZE - 6)) ||
(l_maxlen < IPMI_MAX_MSG_SIZE) )
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
}
else
{
G_amester_max_data_length = l_maxlen;
l_rc = COMPCODE_NORMAL;
}

}
else
{
l_rc = COMPCODE_REQ_DATA_LEN_INVALID;
}
break;

// Note: Amester uses the echo command to figure out how much data it is
// allowed to send in 1 message to OCC.
case 0xfe: //echo
l_maxlen = IPMI_MAX_MSG_SIZE - 1; // -1 for completion code
l_maxlen = G_amester_max_data_length - 1; // -1 for completion code
l_retlen = l_maxlen;

// Pick the smaller of the input length and max output length.
Expand All @@ -597,17 +629,17 @@ uint8_t amester_api( const IPMIMsg_t * i_msg,
// Note: Amester uses this command to find out the maximum length output
// message OCC supports.
case 0xff:
l_maxlen = IPMI_MAX_MSG_SIZE - 1; // -1 for completion code
l_maxlen = G_amester_max_data_length - 1; // -1 for completion code

if (i_msg->u8CmdDataLen == 3)
{
l_maxlen = CONVERT_UINT8_ARRAY_UINT16( i_msg->au8CmdData_ptr[1],
i_msg->au8CmdData_ptr[2]);
}

if (l_maxlen > IPMI_MAX_MSG_SIZE -1)
if (l_maxlen > (G_amester_max_data_length -1))
{
l_maxlen = IPMI_MAX_MSG_SIZE -1;
l_maxlen = G_amester_max_data_length -1;
}

// Check length
Expand Down Expand Up @@ -875,7 +907,7 @@ uint8_t amester_manual_throttle( const IPMIMsg_t * i_msg,
l_rc=COMPCODE_NORMAL;
break;

case 37: // parameter 37: Read out (IPMI_MAX_MSG_SIZE-2*STREAM_VECTOR_SIZE) byte vector from
case 37: // parameter 37: Read out (G_amester_max_data_length-2*STREAM_VECTOR_SIZE) byte vector from
// streaming buffer
g_amec->read_stream_index=(uint32_t)((i_msg->au8CmdData_ptr[2]<<8)+i_msg->au8CmdData_ptr[3]);
temp1=i_msg->au8CmdData_ptr[4];
Expand Down Expand Up @@ -1178,7 +1210,7 @@ void amec_tb_cmd_info(const IPMIMsg_t *i_psMsg,

for(; l_id < AMEC_TB_NUMBER_OF_TRACES; l_id++)
{
if(l_j + AMEC_TB_CONFIG_SIZE >= IPMI_MAX_MSG_SIZE) break; // end of response buffer
if(l_j + AMEC_TB_CONFIG_SIZE >= G_amester_max_data_length) break; // end of response buffer

l_src = g_amec_tb_list[l_id].name;
while(*l_src != 0)
Expand Down Expand Up @@ -1423,7 +1455,6 @@ void amec_tb_cmd_read(const IPMIMsg_t *i_psMsg,
/*------------------------------------------------------------------------*/
amec_tb_t *l_trace;
UINT16 l_i=0; // output index
UINT16 l_maxresponse = IPMI_MAX_MSG_SIZE - 1; // -1 since return code is 1B
UINT32 l_j; // index to copy from

/*------------------------------------------------------------------------*/
Expand All @@ -1448,8 +1479,8 @@ void amec_tb_cmd_read(const IPMIMsg_t *i_psMsg,
i_psMsg->au8CmdData_ptr[5]
);

// Copy bytes to be read into response buffer
for(l_i = 0; l_i < l_maxresponse; l_i++, l_j++)
// Copy bytes to be read into response buffer. -1 since return code is 1B
for(l_i = 0; l_i < (G_amester_max_data_length - 1); l_i++, l_j++)
{
if(l_j >= l_trace->size) // wrap around to beginning of buffer.
{
Expand Down
5 changes: 3 additions & 2 deletions src/occ_405/amec/amec_parm.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
//*************************************************************************/
// Externs
//*************************************************************************/
extern uint16_t G_amester_max_data_length;

//*************************************************************************/
// Defines/Enums
Expand Down Expand Up @@ -100,7 +101,7 @@ void amec_parm_get_config(const IPMIMsg_t *i_psMsg,

for (; l_id < AMEC_PARM_NUMBER_OF_PARAMETERS; l_id++)
{
if (l_j + strlen(g_amec_parm_list[l_id].name) + 1 + 10 >= IPMI_MAX_MSG_SIZE)
if (l_j + strlen(g_amec_parm_list[l_id].name) + 1 + 10 >= G_amester_max_data_length)
{
// +1 = null terminator in name.
// +10 = type, mode, vector_length, length (optional)
Expand Down Expand Up @@ -150,7 +151,7 @@ void amec_parm_read(const IPMIMsg_t *const i_psMsg,
/*------------------------------------------------------------------------*/
AMEC_PARM_GUID l_id;
UINT16 i=0; // output index
UINT16 l_maxresponse = IPMI_MAX_MSG_SIZE - 1; // -1 since return code is 1B
UINT16 l_maxresponse = G_amester_max_data_length - 1; // -1 since return code is 1B
UINT8 *l_src_ptr; // pointer to first byte of data
UINT8 *l_end_ptr; // mark end of data
UINT32 b; // start byte
Expand Down
10 changes: 5 additions & 5 deletions src/occ_405/cmdh/cmdh_fsp_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern bool G_vrm_thermal_monitoring;
extern uint32_t G_first_proc_gpu_config;
extern bool G_vrm_vdd_temp_expired;
extern bool G_reset_prep;

extern uint16_t G_amester_max_data_length;

#include <gpe_export.h>
extern gpe_shared_data_t G_shared_gpe_data;
Expand Down Expand Up @@ -1963,11 +1963,11 @@ errlHndl_t cmdh_amec_pass_through(const cmdh_fsp_cmd_t * i_cmd_ptr,
l_rc = ERRL_RC_SUCCESS;
}

// Protect IPMI from overflowing a buffer
if(l_rsp_data_length > IPMI_MAX_MSG_SIZE)
// Protect from overflowing buffer
if(l_rsp_data_length > G_amester_max_data_length)
{
TRAC_ERR("amester_entry_point returned too much data. Got back %d bytes, but we only support sending %d bytes to IPMI",
l_rsp_data_length, IPMI_MAX_MSG_SIZE);
l_rsp_data_length, G_amester_max_data_length);
/* @
* @errortype
* @moduleid AMEC_AMESTER_INTERFACE
Expand All @@ -1985,7 +1985,7 @@ errlHndl_t cmdh_amec_pass_through(const cmdh_fsp_cmd_t * i_cmd_ptr,
NULL, //Trace Buf
DEFAULT_TRACE_SIZE, //Trace Size
l_rsp_data_length, //userdata1
IPMI_MAX_MSG_SIZE //userdata2
G_amester_max_data_length //userdata2
);

l_rc = ERRL_RC_INTERNAL_FAIL;
Expand Down

0 comments on commit c44bd0f

Please sign in to comment.