fru: add macro FRU_AREA macros

Use two macros defining the FRU block sizes instead of hard-coded magic
values.

Signed-off-by: Patrick Venture <venture@google.com>
This commit is contained in:
Patrick Venture 2018-12-05 07:43:20 -08:00 committed by Alexander Amelkin
parent be3d57c013
commit feecd2bbf4

View File

@ -483,6 +483,11 @@ free_fru_bloc(t_ipmi_fru_bloc *bloc)
} }
} }
/* By how many bytes to reduce a write command on a size failure. */
#define FRU_BLOCK_SZ 8
/* Baseline for a large enough piece to reduce via steps instead of bytes. */
#define FRU_AREA_MAXIMUM_BLOCK_SZ 32
/* /*
* write FRU[doffset:length] from the pFrubuf[soffset:length] * write FRU[doffset:length] from the pFrubuf[soffset:length]
* rc=1 on success * rc=1 on success
@ -605,8 +610,8 @@ write_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
} }
if (fru_cc_rq2big(rsp->ccode)) { if (fru_cc_rq2big(rsp->ccode)) {
if (fru->max_write_size > 8) { if (fru->max_write_size > FRU_BLOCK_SZ) {
fru->max_write_size -= 8; fru->max_write_size -= FRU_BLOCK_SZ;
lprintf(LOG_INFO, "Retrying FRU write with request size %d", lprintf(LOG_INFO, "Retrying FRU write with request size %d",
fru->max_write_size); fru->max_write_size);
continue; continue;
@ -737,10 +742,11 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
/* if we get C7h or C8h or CAh return code then we requested too /* if we get C7h or C8h or CAh return code then we requested too
* many bytes at once so try again with smaller size */ * many bytes at once so try again with smaller size */
if (fru_cc_rq2big(rsp->ccode) if (fru_cc_rq2big(rsp->ccode)
&& fru->max_read_size > 8) { && fru->max_read_size > FRU_BLOCK_SZ)
if (fru->max_read_size > 32) { {
if (fru->max_read_size > FRU_AREA_MAXIMUM_BLOCK_SZ) {
/* subtract read length more aggressively */ /* subtract read length more aggressively */
fru->max_read_size -= 8; fru->max_read_size -= FRU_BLOCK_SZ;
} else { } else {
/* subtract length less aggressively */ /* subtract length less aggressively */
fru->max_read_size--; fru->max_read_size--;
@ -842,7 +848,7 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
if (rsp->ccode) { if (rsp->ccode) {
/* if we get C7 or C8 or CA return code then we requested too /* if we get C7 or C8 or CA return code then we requested too
* many bytes at once so try again with smaller size */ * many bytes at once so try again with smaller size */
if (fru_cc_rq2big(rsp->ccode) && (--fru_data_rqst_size > 8)) { if (fru_cc_rq2big(rsp->ccode) && (--fru_data_rqst_size > FRU_BLOCK_SZ)) {
lprintf(LOG_INFO, lprintf(LOG_INFO,
"Retrying FRU read with request size %d", "Retrying FRU read with request size %d",
fru_data_rqst_size); fru_data_rqst_size);