diff options
Diffstat (limited to 'util/oem_supermicro.c')
-rw-r--r-- | util/oem_supermicro.c | 85 |
1 files changed, 63 insertions, 22 deletions
diff --git a/util/oem_supermicro.c b/util/oem_supermicro.c index a480b7f..1924345 100644 --- a/util/oem_supermicro.c +++ b/util/oem_supermicro.c @@ -68,7 +68,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. void set_loglevel(int level); /*prototype */ extern char fsm_debug; /*mem_if.c*/ -static char * progver = "3.04"; +static char * progver = "3.07"; static char * progname = "ismcoem"; static int verbose = 0; static char fdebug = 0; @@ -415,7 +415,7 @@ int decode_threshold_supermicro(uchar rval, uchar *thresh) * pstring = contains the sensor reading interpretation string (if rv==0) */ int decode_sensor_supermicro(uchar *sdr,uchar *reading,char *pstring, int slen, - int fsimple) + int fsimple, char fdbg) { int i, rv = -1; uchar stype, etype, snum; @@ -428,23 +428,26 @@ int decode_sensor_supermicro(uchar *sdr,uchar *reading,char *pstring, int slen, if (sdr == NULL || reading == NULL) return(rv); if (pstring == NULL || slen == 0) return(rv); + fdebug = fdbg; bval = (reading[2] & 0x3f); snum = sdr[7]; /*sdr01->sens_num*/ stype = sdr[12]; /*sensor_type*/ etype = sdr[13]; /*sdr01->ev_type*/ + get_mfgid(&vend_id,&prod_id); /*saved from ipmi_getdeviceid */ /* sdr[3] rec_type is 0x01 for Full, 0x02 for Compact */ if ((sdr[3] == 0x01) && (etype == 0x01)) { /* full threshold sensor */ - if (bval == 0) return(-1); /* OK, treat it normally */ - /*cannot rely upon the sensor reading[2], so get thresholds and compare*/ + /*if Temp sensor, bits==0 would show BelowCrit, so handle normally */ + if ((stype == 0x01) && (bval == 0)) return(-1); + /*Cannot rely upon the sensor reading[2], so get thresholds and compare*/ rv = GetSensorThresholds(snum,&thresh[0]); if (rv != 0) return(rv); i = decode_threshold_supermicro(reading[0],thresh); if (fdebug) - printf("decode_sensor_supermicro: snum=%x rdg=%x:%x thresh=%x:%x:%x:%x:%x:%x:%x i=%d rv=%d\n", - snum,reading[0],reading[2], thresh[0], thresh[1], thresh[2], thresh[3], + printf("decode_sensor_supermicro: snum=%x stype=%x rdg=%x:%x thresh=%x:%x:%x:%x:%x:%x:%x i=%d rv=%d\n", + snum,stype,reading[0],reading[2], thresh[0], thresh[1], thresh[2], thresh[3], thresh[4], thresh[5], thresh[6], i,rv); switch(i) { - case 0: pstr = "OK*"; break; + case 0: pstr = "OK"; break; case 1: pstr = "Warn-lo"; break; case 2: pstr = "Crit-lo"; break; case 3: pstr = "BelowCrit"; break; @@ -495,6 +498,14 @@ int decode_sensor_supermicro(uchar *sdr,uchar *reading,char *pstring, int slen, default: rv = -1; break; } break; + case 0x29: /* VBAT sensor */ + if (prod_id == 0x0917) { /*X11DRi has inert VBAT full sensor*/ + if (bval == 0) { + pstr = "NotAvailable"; + rv = 0; + } + } + break; default: break; } @@ -593,12 +604,14 @@ int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc, uchar rectype; ulong timestamp; char mybuf[64]; + char mytype[64]; char *type_str = ""; char *pstr = NULL; - int sevid; + int sevid, d1; ushort genid; uchar snum; uchar data1, data2, data3; + char *psens = NULL; fdebug = fdbg; sevid = SEV_INFO; @@ -616,17 +629,22 @@ int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc, switch(evt[10]) { /*sensor type*/ case 0xC0: /* CPU Temp Sensor */ type_str = "OEM_CpuTemp"; - switch((evt[13] & 0x0f)) { /*offset/data1 l.o. nibble*/ + d1 = (evt[13] & 0x0f); /*offset/data1 l.o. nibble*/ + switch(d1) { case 0x02: /* CPU Temp Sensor Overheat event offset */ if (evt[12] & 0x80) { /*EvTyp==0xF0 if deassert*/ pstr = "CpuTemp Overheat OK"; sevid = SEV_INFO; } else { /* EvTyp=0x70 assert */ pstr = "CpuTemp Overheat "; sevid = SEV_MAJ; } - rv = 0; break; - default: pstr = "CpuTemp Event"; rv = 0; break; + default: pstr = "CpuTemp Event"; + sprintf(mytype,"CpuTemp_%02x", d1); + type_str = mytype; + sevid = SEV_MIN; + break; } + rv = 0; break; case 0xC2: /* CPLD Event */ type_str = "OEM_CPLD"; @@ -635,10 +653,10 @@ int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc, if (evt[14] == 0x1c) { pstr = "CPLD CATERR Asserted"; sevid = SEV_CRIT; } else { pstr = "CPLD Event Asserted"; sevid = SEV_MIN; } - rv = 0; break; - default: pstr = "CPLD Event"; rv = 0; break; + default: pstr = "CPLD Event"; sevid = SEV_MIN; break; } + rv = 0; break; case 0xD0: /* BMC Event */ type_str = "OEM_BMC"; @@ -655,13 +673,15 @@ int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc, break; case 0xC5: /* Observed Event: Storage, drive slot */ /* usually OEM(c5) #52 - 6f [01 00 00] */ - pstr = "OEMC5: Storage/DriveSlot fault"; + type_str = "OEM_C5"; + pstr = "Storage/DriveSlot fault"; sevid = SEV_MAJ; rv = 0; break; - case 0xC8: /* Observed Event: Temp/Cooling issue, reboots */ + case 0xC8: /* Observed Event: AC Power on event */ /* usually OEM(c8) #ff - 6f [a0 ff ff] */ - pstr = "OEMC8: Temp/Cooling fault"; + type_str = "OEM_C8"; + pstr = "AC Power On"; sevid = SEV_MAJ; rv = 0; break; @@ -671,11 +691,16 @@ int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc, } if (rv == 0) { format_event(id,timestamp, sevid, genid, type_str, - snum,NULL,pstr,mybuf,outbuf,outsz); + snum,psens,pstr,mybuf,outbuf,outsz); } return(rv); } +/* factory_defaults: set SMC factory defaults + * mode: 0 = detect, default is c0 41 method + * 2 = use c0 41 method, also get guid + * 3 = use f0 40 method (usu X11) + */ static int factory_defaults(int mode) { int rv = -1; @@ -684,7 +709,7 @@ static int factory_defaults(int mode) uchar idata[16]; uchar cc; /* - From SMC IPMICFG -fde session: + From SMC IPMICFG -fde factory defaults session: start_kcs_transaction - 18 01 (get_device_id) start_kcs_transaction - 18 25 (watchdog get) start_kcs_transaction - b0 00 00 (unknown, invalid) @@ -693,6 +718,12 @@ static int factory_defaults(int mode) start_kcs_transaction - 18 01 (get_device_id) start_kcs_transaction - c0 41 (reset_factory_defaults, -fde) */ + if ((prod_id > 2200) && (prod_id < 2300) && (mode == 0)) { + /* Looks like X11 board, may use netfn 3c, cmd 40 ? */ + /* do not auto-set this if mode param is not 3 */ + // mode = 3; /* cmd=0x40 netfn=0x3c (netfn/lun=0xF0) */ + if (fdebug) printf("may also need ipmiutil cmd 00 20 f0 40\n"); + } /* b0 00 00: cmd=00 netfn=2C */ rlen = sizeof(rdata); @@ -703,7 +734,7 @@ static int factory_defaults(int mode) if (fdebug) printf("b0 00 returned %d\n",rv); /* if (rv != 0) return(rv); */ - if (mode == 2) { + if (mode == 2) { /* (get_system_guid) */ rlen = sizeof(rdata); rv = ipmi_cmdraw(0x37, (0x18 >> 2), BMC_SA, PUBLIC_BUS, BMC_LUN, idata, 0, rdata, &rlen, &cc, fdebug); @@ -712,10 +743,15 @@ static int factory_defaults(int mode) if (rv != 0) return(rv); } - /* reset factory defaults cmd=0x41 netfn=0x30 (netfn/lun=0xC0) */ + /* reset factory defaults */ rlen = sizeof(rdata); - rv = ipmi_cmdraw(0x41, (0xc0 >> 2), BMC_SA, PUBLIC_BUS, BMC_LUN, - idata, 0, rdata, &rlen, &cc, fdebug); + if (mode == 3) { /* cmd=0x40 netfn=0x3c (netfn/lun=0xF0) */ + rv = ipmi_cmdraw(0x40, 0x3c, BMC_SA, PUBLIC_BUS, BMC_LUN, + idata, 0, rdata, &rlen, &cc, fdebug); + } else { /* cmd=0x41 netfn=0x30 (netfn/lun=0xC0) if X10 or less */ + rv = ipmi_cmdraw(0x41, (0xc0 >> 2), BMC_SA, PUBLIC_BUS, BMC_LUN, + idata, 0, rdata, &rlen, &cc, fdebug); + } if ((rv == 0) && (cc != 0)) rv = cc; if (fdebug) printf("factory default reset returned %d\n",rv); if (rv != 0) return(rv); @@ -741,6 +777,11 @@ static int ipmi_smcoem_main(int argc, char **argv) char msg[80]; uchar val; + if ((vend_id != VENDOR_SUPERMICRO) && (vend_id != VENDOR_SUPERMICROX)) { + printf("Not SuperMicro firmware, ignoring smcoem\n"); + usage(); + return(ERR_USAGE); + } if (strncmp(argv[0],"intrusion",9) == 0) { printf("Clearing Chassis Intrusion ...\n"); rv = oem_supermicro_reset_intrusion(); |