summaryrefslogtreecommitdiff
path: root/util/oem_supermicro.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-08-24 05:56:37 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-08-24 05:56:37 +0200
commitdb5e8f26947114f06480dd22b9db7e22e50ee133 (patch)
treebb7418b545d295ea7cc4f5e7404d262e51082e0f /util/oem_supermicro.c
parent55adddbc16f65732b57ab8585c47001fced91d77 (diff)
Imported Upstream version 3.0.0upstream/3.0.0
Diffstat (limited to 'util/oem_supermicro.c')
-rw-r--r--util/oem_supermicro.c112
1 files changed, 93 insertions, 19 deletions
diff --git a/util/oem_supermicro.c b/util/oem_supermicro.c
index 47838da..3937f0d 100644
--- a/util/oem_supermicro.c
+++ b/util/oem_supermicro.c
@@ -67,7 +67,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 = "2.99";
+static char * progver = "3.00";
static char * progname = "ismcoem";
static int verbose = 0;
static char fdebug = 0;
@@ -401,24 +401,34 @@ int decode_sensor_supermicro(uchar *sdr,uchar *reading,char *pstring, int slen)
//if (dbg) printf("supermicro %x sensor reading %x\n",stype,reading);
rv = 0;
switch(bval) {
- case 0x0000: pstr = "00 Low"; break;
- case 0x0001: pstr = "01 Medium"; break;
- case 0x0002: pstr = "02 High"; break;
- case 0x0004: pstr = "04 Overheat"; break;
- case 0x0007: pstr = "07 Not Installed"; break;
+ case 0x0000: pstr = "00_Low"; break;
+ case 0x0001: pstr = "01_Medium"; break;
+ case 0x0002: pstr = "02_High"; break;
+ case 0x0004: pstr = "04_Overheat"; break;
+ case 0x0007: pstr = "07_Not Installed"; break;
default: rv = -1; break;
}
break;
case 0x08: /* Power Supply Status (Full/Discrete) Table 42-3 */
- rv = 0;
- switch(bval) {
- case 0x00: pstr = "00 Absent"; break; /*bit 0*/
- case 0x01: pstr = "01 Present"; break; /*bit 0*/
- case 0x02: pstr = "02 Failure"; break; /*bit 1*/
- case 0x04: pstr = "04 Predict Fail"; break; /*bit 2*/
- case 0x08: pstr = "08 Input Lost"; break; /*bit 3*/
- default: rv = -1; break;
- }
+ rv = 0;
+ switch(bval) {
+ case 0x00: pstr = "00_Absent"; break; /*bit 0*/
+ case 0x01: pstr = "01_Present"; break; /*bit 0*/
+ case 0x02: pstr = "02_Failure"; break; /*bit 1*/
+ case 0x04: pstr = "04_Predict Fail"; break; /*bit 2*/
+ case 0x08: pstr = "08_Input Lost"; break; /*bit 3*/
+ default: rv = -1; break;
+ }
+ break;
+ case 0x0D: /* HDD Status (Full/Discrete) Table 42-3 */
+ rv = 0;
+ switch(bval) {
+ case 0x00: pstr = "00_Absent"; break; /*bit 0*/
+ case 0x01: pstr = "01_Present"; break; /*bit 0*/
+ case 0x02: pstr = "02_Failure"; break; /*bit 1*/
+ case 0x04: pstr = "04_Predict Fail"; break; /*bit 2*/
+ default: rv = -1; break;
+ }
break;
default:
break;
@@ -545,7 +555,7 @@ int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc,
}
rv = 0;
break;
- default: pstr = "CpuTemp Event"; break;
+ default: pstr = "CpuTemp Event"; rv = 0; break;
}
break;
case 0xC2: /* CPLD Event */
@@ -557,7 +567,7 @@ int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc,
else { pstr = "CPLD Event Asserted"; sevid = SEV_MIN; }
rv = 0;
break;
- default: pstr = "CPLD Event"; break;
+ default: pstr = "CPLD Event"; rv = 0; break;
}
break;
case 0xD0: /* BMC Event */
@@ -571,8 +581,20 @@ int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc,
case 0x02: pstr = "BMC warm reset"; break;
}
}
+ rv = 0;
+ break;
+ case 0xC5: /* Observed Event: Storage, drive slot */
+ /* usually OEM(c5) #52 - 6f [01 00 00] */
+ pstr = "OEMC5: Storage/DriveSlot fault";
+ sevid = SEV_MAJ;
+ rv = 0;
+ break;
+ case 0xC8: /* Observed Event: Temp/Cooling issue, reboots */
+ /* usually OEM(c8) #ff - 6f [a0 ff ff] */
+ pstr = "OEMC8: Temp/Cooling fault";
+ sevid = SEV_MAJ;
+ rv = 0;
break;
- case 0xC8: /* Observed Event */
default: /*other sensor types*/
break;
}
@@ -584,12 +606,60 @@ int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc,
return(rv);
}
+static int factory_defaults(int mode)
+{
+ int rv = -1;
+ int rlen;
+ uchar rdata[32];
+ uchar idata[16];
+ uchar cc;
+ /*
+ From SMC IPMICFG -fde session:
+ start_kcs_transaction - 18 01 (get_device_id)
+ start_kcs_transaction - 18 25 (watchdog get)
+ start_kcs_transaction - b0 00 00 (unknown, invalid)
+ start_kcs_transaction - 18 01 (get_device_id)
+ start_kcs_transaction - 18 37 (get_system_guid)
+ start_kcs_transaction - 18 01 (get_device_id)
+ start_kcs_transaction - c0 41 (reset_factory_defaults, -fde)
+ */
+
+ /* b0 00 00: cmd=00 netfn=2C */
+ rlen = sizeof(rdata);
+ idata[0] = 0x00;
+ rv = ipmi_cmdraw(0x00, (0xb0 >> 2), BMC_SA, PUBLIC_BUS, BMC_LUN,
+ idata, 1, rdata, &rlen, &cc, fdebug);
+ if ((rv == 0) && (cc != 0)) rv = cc;
+ if (fdebug) printf("b0 00 returned %d\n",rv);
+ /* if (rv != 0) return(rv); */
+
+ if (mode == 2) {
+ rlen = sizeof(rdata);
+ rv = ipmi_cmdraw(0x37, (0x18 >> 2), BMC_SA, PUBLIC_BUS, BMC_LUN,
+ idata, 0, rdata, &rlen, &cc, fdebug);
+ if ((rv == 0) && (cc != 0)) rv = cc;
+ if (fdebug) printf("get_guid returned %d\n",rv);
+ if (rv != 0) return(rv);
+ }
+
+ /* reset factory defaults cmd=0x41 netfn=0x30 (netfn/lun=0xC0) */
+ rlen = sizeof(rdata);
+ 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);
+
+ return(rv);
+}
+
static void usage(void)
{
printf("Usage: %s <command> [arg]\n",progname);
printf(" intrusion = reset chassis intrusion\n");
printf(" bmcstatus [enable| disable] = get/set BMC status\n");
printf(" firmware = get extra firmware info\n");
+ printf(" factory = reset to factory defaults\n");
printf(" lanport [dedicated| lan1| failover] = get/set IPMI LAN port\n");
printf(" powersupply <num> = get PMBus PowerSupply status\n");
printf("These commands may not work on all SuperMicro systems\n");
@@ -628,7 +698,11 @@ static int ipmi_smcoem_main(int argc, char **argv)
printf("Getting SMC Firmare Information ...\n");
rv = oem_supermicro_get_firmware_str(msg, sizeof(msg));
if (rv == 0) printf("%s\n",msg);
- } else if (strncmp(argv[0],"lanport",9) == 0) {
+ } else if (strncmp(argv[0],"factory",7) == 0) {
+ rv = factory_defaults(0);
+ if (rv == 0) printf("Reset firmware to factory defaults\n");
+ else printf("Error %d resetting firmware to factory defaults\n",rv);
+ } else if (strncmp(argv[0],"lanport",7) == 0) {
rv = oem_supermicro_get_lan_port(&val);
if (rv == 0) {
oem_supermicro_show_lan_port(val);