diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2018-06-26 00:18:29 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2018-06-26 00:18:29 +0200 |
commit | e0c1c866ffe02e0a0263ea14750eae32940e7e73 (patch) | |
tree | 6160ef5da64195cd4c18375ed6a7eb0bd32e0b2c /util/ifru.c | |
parent | afca8e5a682f3b087d9e63cf88a1ab0bdcba523c (diff) | |
parent | cf37726b789ff5344c5ad376cee1fb99459e5785 (diff) |
Update upstream source from tag 'upstream/3.1.1'
Update to upstream version '3.1.1'
with Debian dir 8a00ab19696666598c7c15367cc89d75ebcf338e
Diffstat (limited to 'util/ifru.c')
-rw-r--r-- | util/ifru.c | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/util/ifru.c b/util/ifru.c index effa9b7..86e47bf 100644 --- a/util/ifru.c +++ b/util/ifru.c @@ -116,7 +116,7 @@ extern int ipmi_kontronoem_main(void * intf, int argc, char ** argv); extern char *progver; /*from ipmiutil.c*/ static char *progname = "ipmiutil fru"; #else -static char *progver = "3.08"; +static char *progver = "3.11"; static char *progname = "ifru"; #endif @@ -200,7 +200,7 @@ static int sdr_get_reservation(uchar *res_id, int fdev) { return(-1); } #define STRING_DATA_TYPE_SIX_BIT_ASCII 0x02 #define STRING_DATA_TYPE_LANG_DEPENDENT 0x03 -#define FRUCHUNK_SZ 16 +#define FRUCHUNK_SZ 16 /* optimal chunk = 16 bytes */ #define FRU_END 0xC1 #define FRU_EMPTY_FIELD 0xC0 #define FRU_TYPE_MASK 0xC0 @@ -270,7 +270,7 @@ int load_fru(uchar sa, uchar frudev, uchar frutype, uchar **pfrubuf) { int ret = 0; - uchar indata[16]; + uchar indata[FRUCHUNK_SZ+9]; uchar resp[18]; int sresp; uchar cc; @@ -282,6 +282,7 @@ load_fru(uchar sa, uchar frudev, uchar frutype, uchar **pfrubuf) if (pfrubuf == NULL) return(ERR_BAD_PARAM); *pfrubuf = NULL; + memset(indata, 0, sizeof(indata)); indata[0] = frudev; sresp = sizeof(resp); if (fdebug) printf("load_fru: sa=%02x, frudev=%02x, addrtype=%d\n", @@ -315,14 +316,14 @@ load_fru(uchar sa, uchar frudev, uchar frutype, uchar **pfrubuf) } indata[1] = fruoff & 0x00FF; indata[2] = (fruoff & 0xFF00) >> 8; - sresp = sizeof(resp); + sresp = sizeof(resp); ret = ipmi_cmd_mc(READ_FRU_DATA,indata,4,resp,&sresp,&cc,fdebug); - if (ret != 0) break; - else if (cc != 0) { - if (i == 0) ret = cc & 0x00ff; - if (fdebug) printf("read_fru[%d]: ret = %d cc = %x\n",i,ret,cc); - break; - } + if (ret != 0) break; + else if (cc != 0) { + if (i == 0) ret = cc & 0x00ff; + if (fdebug) printf("read_fru[%d]: ret = %d cc = %x\n",i,ret,cc); + break; + } memcpy(&frubuf[i],&resp[1],chunk); } @@ -338,16 +339,16 @@ load_fru(uchar sa, uchar frudev, uchar frutype, uchar **pfrubuf) if (fdebug) printf("get_SystemGuid: ret = %d\n",rv); } if (rv == 0 && cc == 0) { - if (fdebug) { - printf("system guid (%d): ",sresp); - for (i=0; i<16; i++) printf("%02x ",resp[i]); - printf("\n"); - } - memcpy(&guid,&resp,16); - guid[16] = 0; + if (fdebug) { + printf("system guid (%d): ",sresp); + for (i=0; i<16; i++) printf("%02x ",resp[i]); + printf("\n"); + } + memcpy(&guid,&resp,16); + guid[16] = 0; } else { - printf("WARNING: GetSystemGuid error %d, %s\n",rv,decode_rv(rv)); - /*do not pass this error upstream*/ + printf("WARNING: GetSystemGuid error %d, %s\n",rv,decode_rv(rv)); + /*do not pass this error upstream*/ } } /*endif*/ return(ret); @@ -1077,8 +1078,8 @@ int write_fru_data(uchar id, ushort offset, uchar *data, int dlen, char fdebug) int ret = -1; int chunk; ushort fruoff; - uchar req[25]; - uchar resp[16]; + uchar req[FRUCHUNK_SZ+9]; + uchar resp[FRUCHUNK_SZ]; int sresp; uchar cc; int i, j; @@ -1880,25 +1881,26 @@ int i_fru(int argc, char **argv) recid = 0; while (recid != LAST_REC) { - if (do_reserve) { + if (do_reserve) { /* reserve the SDR repository */ ret = sdr_get_reservation((uchar *)&rsvid,fdevsdrs); if (fdebug) printf("sdr_get_reservation ret=%d\n",ret); - if (ret == 0) do_reserve = 0; - } - - len = sizeof(sdr); /*sizeof(sdr); get 32 sdr bytes*/ - ret = get_sdr(recid,rsvid,&nextid,sdr,&len,&cc); - if ((ret != 0) || (cc != 0)) { - printf("SDR[%04x] error %d ccode = %x\n",recid,ret,cc); - if ((cc == 0xC5) || (cc == 0x83)) ; /*do not stop (ARC)*/ - else break; /*stop if errors*/ - } - if (len >= MIN_SDR_SZ) { - if ((sdr[3] == 0x11) || (sdr[3] == 0x12)) /*SDR FRU or IPMB type*/ - ret = get_show_fru(recid, sdr,len); - do_reserve = 1; - } /*endif get_show_fru */ + if (ret == 0) do_reserve = 0; + } + + len = sizeof(sdr); /*sizeof(sdr); get 32 sdr bytes*/ + ret = get_sdr(recid,rsvid,&nextid,sdr,&len,&cc); + if ((ret != 0) || (cc != 0)) { + printf("SDR[%04x] error %d ccode = %x\n",recid,ret,cc); + if (cc == 0xC5) do_reserve = 1; /*retry w reserve*/ + if (cc == 0x83) os_usleep(0,100); /*busy, retry*/ + else break; /*stop if errors*/ + } + if (len >= MIN_SDR_SZ) { + if ((sdr[3] == 0x11) || (sdr[3] == 0x12)) /*SDR FRU or IPMB type*/ + ret = get_show_fru(recid, sdr,len); + do_reserve = 1; + } /*endif get_show_fru */ #ifdef PICMG_CHILD /* * Special logic for blade child MCs in PICMG ATCA systems |