ID: 46 - ipmi_fwum needs some re-work

KfwumGetInfo() - simplify logic, code formatting
This commit is contained in:
Zdenek Styblik 2013-10-26 19:03:54 +00:00
parent 068bcb02e4
commit 3df72b68bc

View File

@ -569,124 +569,93 @@ struct KfwumGetInfoResp {
* pNumBank: output ptr for number of banks * pNumBank: output ptr for number of banks
*/ */
static tKFWUM_Status KfwumGetInfo(struct ipmi_intf * intf, unsigned char output, static tKFWUM_Status KfwumGetInfo(struct ipmi_intf * intf, unsigned char output,
unsigned char *pNumBank) unsigned char *pNumBank)
{ {
tKFWUM_Status status = KFWUM_STATUS_OK; tKFWUM_Status status = KFWUM_STATUS_OK;
static struct KfwumGetInfoResp *pGetInfo; static struct KfwumGetInfoResp *pGetInfo;
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.msg.netfn = IPMI_NETFN_FIRMWARE; req.msg.netfn = IPMI_NETFN_FIRMWARE;
req.msg.cmd = KFWUM_CMD_ID_GET_FIRMWARE_INFO; req.msg.cmd = KFWUM_CMD_ID_GET_FIRMWARE_INFO;
req.msg.data_len = 0; req.msg.data_len = 0;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (!rsp) {
lprintf(LOG_ERR, "Error in FWUM Firmware Get Info Command.");
return KFWUM_STATUS_ERROR;
} else if (rsp->ccode != 0) {
lprintf(LOG_ERR, "FWUM Firmware Get Info returned %x\n",
rsp->ccode);
return KFWUM_STATUS_ERROR;
}
if (!rsp) pGetInfo = (struct KfwumGetInfoResp *)rsp->data;
{ if (output) {
printf("Error in FWUM Firmware Get Info Command\n"); printf("\nFWUM info\n");
status = KFWUM_STATUS_ERROR; printf("=========\n");
} printf("Protocol Revision : %02Xh\n",
else if (rsp->ccode) pGetInfo->protocolRevision);
{ printf("Controller Device Id : %02Xh\n",
printf("FWUM Firmware Get Info returned %x\n", rsp->ccode); pGetInfo->controllerDeviceId);
status = KFWUM_STATUS_ERROR; printf("Firmware Revision : %u.%u%u",
} pGetInfo->firmRev1, pGetInfo->firmRev2 >> 4,
pGetInfo->firmRev2 & 0x0f);
if(status == KFWUM_STATUS_OK) if (pGetInfo->byte.mode != 0) {
{ printf(" - DEBUG BUILD\n");
pGetInfo = (struct KfwumGetInfoResp *) rsp->data; } else {
if(output) printf("\n");
{ }
printf("\nFWUM info\n"); printf("Number Of Memory Bank : %u\n", pGetInfo->numBank);
printf("=========\n"); }
printf("Protocol Revision : %02Xh\n", *pNumBank = pGetInfo->numBank;
pGetInfo->protocolRevision); /* Determine wich type of download to use: */
printf("Controller Device Id : %02Xh\n", /* Old FWUM or Old IPMC fw (data_len < 7)
pGetInfo->controllerDeviceId); * --> Address with small buffer size
printf("Firmware Revision : %u.%u%u", */
pGetInfo->firmRev1, pGetInfo->firmRev2 >> 4, if ((pGetInfo->protocolRevision) <= 0x05 || (rsp->data_len < 7 )) {
pGetInfo->firmRev2 & 0x0f); saveFirmwareInfo.downloadType = KFWUM_DOWNLOAD_TYPE_ADDRESS;
if(pGetInfo->byte.mode != 0) saveFirmwareInfo.bufferSize = KFWUM_SMALL_BUFFER;
{ saveFirmwareInfo.overheadSize = KFWUM_OLD_CMD_OVERHEAD;
printf(" - DEBUG BUILD\n"); if (verbose) {
} printf("Protocol Revision :");
else printf(" <= 5 detected, adjusting buffers\n");
{ }
printf("\n"); } else {
} /* Both fw are using the new protocol */
printf("Number Of Memory Bank : %u\n",pGetInfo->numBank); saveFirmwareInfo.downloadType = KFWUM_DOWNLOAD_TYPE_SEQUENCE;
} saveFirmwareInfo.overheadSize = KFWUM_NEW_CMD_OVERHEAD;
* pNumBank = pGetInfo->numBank; /* Buffer size depending on access type (Local or remote) */
/* Look if we run remote or locally */
/* Determine wich type of download to use: */ if (verbose) {
/* Old FWUM or Old IPMC fw (data_len < 7) --> printf("Protocol Revision :");
Address with small buffer size */ printf(" > 5 optimizing buffers\n");
if ( (pGetInfo->protocolRevision) <= 0x05 || (rsp->data_len < 7 ) ) }
{ if (strstr(intf->name,"lan") != NULL) {
saveFirmwareInfo.downloadType = KFWUM_DOWNLOAD_TYPE_ADDRESS; /* also covers lanplus */
saveFirmwareInfo.bufferSize = KFWUM_SMALL_BUFFER; saveFirmwareInfo.bufferSize = KFWUM_SMALL_BUFFER;
saveFirmwareInfo.overheadSize = KFWUM_OLD_CMD_OVERHEAD; if (verbose) {
printf("IOL payload size : %d\n",
if(verbose) saveFirmwareInfo.bufferSize);
{ }
printf("Protocol Revision :"); } else if ((strstr(intf->name,"open")!= NULL)
printf(" <= 5 detected, adjusting buffers\n"); && intf->target_addr != IPMI_BMC_SLAVE_ADDR
} && (intf->target_addr != intf->my_addr)) {
} saveFirmwareInfo.bufferSize = KFWUM_SMALL_BUFFER;
else /* Both fw are using the new protocol */ if (verbose) {
{ printf("IPMB payload size : %d\n",
saveFirmwareInfo.downloadType = KFWUM_DOWNLOAD_TYPE_SEQUENCE; saveFirmwareInfo.bufferSize);
saveFirmwareInfo.overheadSize = KFWUM_NEW_CMD_OVERHEAD; }
/* Buffer size depending on access type (Local or remote) */ } else {
/* Look if we run remote or locally */ saveFirmwareInfo.bufferSize = KFWUM_BIG_BUFFER;
if (verbose) {
if(verbose) printf("SMI payload size : %d\n",
{ saveFirmwareInfo.bufferSize);
printf("Protocol Revision :"); }
printf(" > 5 optimizing buffers\n"); }
} }
return status;
if(strstr(intf->name,"lan")!= NULL) /* also covers lanplus */
{
saveFirmwareInfo.bufferSize = KFWUM_SMALL_BUFFER;
if(verbose)
{
printf("IOL payload size : %d\n" ,
saveFirmwareInfo.bufferSize);
}
}
else if
(
(strstr(intf->name,"open")!= NULL)
&&
intf->target_addr != IPMI_BMC_SLAVE_ADDR
&&
(
intf->target_addr != intf->my_addr
)
)
{
saveFirmwareInfo.bufferSize = KFWUM_SMALL_BUFFER;
if(verbose)
{
printf("IPMB payload size : %d\n" ,
saveFirmwareInfo.bufferSize);
}
}
else
{
saveFirmwareInfo.bufferSize = KFWUM_BIG_BUFFER;
if(verbose)
{
printf("SMI payload size : %d\n",
saveFirmwareInfo.bufferSize);
}
}
}
}
return status;
} }
/* KfwumGetDeviceInfo - Get IPMC/Board information /* KfwumGetDeviceInfo - Get IPMC/Board information