diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-11-06 01:42:44 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-11-06 01:42:44 +0100 |
commit | 7551a684bcbc7de7ac3d2e52eea0f9f812affd18 (patch) | |
tree | 469d3c40a1c88fcb3ec208a820f7a0fa93dca81c /util/oem_supermicro.c | |
parent | c71717661b7ee871e5bc957f314ad8779e85abc6 (diff) | |
parent | ee6c7128ed0d58cb1812049463a13bba9cfb31b7 (diff) |
Merge tag 'upstream/2.9.7'
Upstream version 2.9.7
Diffstat (limited to 'util/oem_supermicro.c')
-rw-r--r-- | util/oem_supermicro.c | 127 |
1 files changed, 125 insertions, 2 deletions
diff --git a/util/oem_supermicro.c b/util/oem_supermicro.c index 5d7dee9..35df1bd 100644 --- a/util/oem_supermicro.c +++ b/util/oem_supermicro.c @@ -66,7 +66,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.96"; +static char * progver = "2.97"; static char * progname = "ismcoem"; static int verbose = 0; static char fdebug = 0; @@ -106,6 +106,18 @@ int oem_supermicro_get_bmc_status(uchar *sts) return(rv); } +/* + * oem_supermicro_get_bmc_services_status + * + * Request + * 0x30 - OEM network function + * 0x70 - OEM cmd + * 0xF0 - subcommand + * 0x?? - action 00=disable, 01=enable, 02=status + * + * Response + * 0x?? - if action=status: 00=disabled, 01=enabled + */ int oem_supermicro_set_bmc_status(uchar sts) { int rv; @@ -132,6 +144,83 @@ int oem_supermicro_set_bmc_status(uchar sts) return(rv); } +/* + oem_supermicro_psstatus1(uchar psnum, uchar *val) +*/ +int oem_supermicro_psstatus1(uchar psnum, uchar *val) +{ + int rv; + int rlen; + uchar idata[16]; + uchar rdata[16]; + uchar cc; + + idata[0] = 0x07; /*busid*/ + if (psnum <= 1) idata[1] = 0x70; /* PS 1 */ + else if (psnum == 2) idata[1] = 0x72; /* PS 2 */ + else /*if (psnum == 3)*/ idata[1] = 0x74; /* PS 3 */ + idata[2] = 0x01; /* return one byte of PS status data */ + idata[3] = 0x0C; + rlen = sizeof(rdata); + rv = ipmi_cmd(MASTER_WRITE_READ, idata, 4, rdata, &rlen, &cc, fdebug); + if ((rv == 0) && (cc != 0)) rv = cc; + if (rv == 0) { *val = rdata[0]; } + return(rv); +} + +/* + oem_supermicro_psstatus2(uchar psnum, uchar *val) + Get PMBus Power Supply Status, for X10 motherboards +*/ +int oem_supermicro_psstatus2(uchar psnum, uchar *val) +{ + int rv; + int rlen; + uchar idata[16]; + uchar rdata[16]; + uchar cc; + + idata[0] = 0x07; /*busid*/ + if (psnum <= 1) idata[1] = 0x78; /* PS 1 */ + else if (psnum == 2) idata[1] = 0x7A; /* PS 2 */ + else /*if (psnum == 3)*/ idata[1] = 0x7C; /* PS 3 */ + idata[2] = 0x01; /* return one byte of PS status data */ + idata[3] = 0x78; + rlen = sizeof(rdata); + rv = ipmi_cmd(MASTER_WRITE_READ, idata, 4, rdata, &rlen, &cc, fdebug); + if ((rv == 0) && (cc != 0)) rv = cc; + if (rv == 0) { *val = rdata[0]; } + return(rv); +} + +/* + oem_supermicro_psstatus3(uchar psnum, uchar *val) + Get PMBus Power Supply Status, for X10 motherboards + + raw 0x06 0x52 0x07 0xb0 0x01 0x0c for power supply 1 + raw 0x06 0x52 0x07 0xb2 0x01 0x0c for power supply 2 +*/ +int oem_supermicro_psstatus3(uchar psnum, uchar *val) +{ + int rv; + int rlen; + uchar idata[16]; + uchar rdata[16]; + uchar cc; + + idata[0] = 0x07; /*busid*/ + if (psnum <= 1) idata[1] = 0xB0; /* PS 1 */ + else if (psnum == 2) idata[1] = 0xB2; /* PS 2 */ + else /*if (psnum == 3)*/ idata[1] = 0xB4; /* PS 3 */ + idata[2] = 0x01; /* return one byte of PS status data */ + idata[3] = 0x0C; + rlen = sizeof(rdata); + rv = ipmi_cmd(MASTER_WRITE_READ, idata, 4, rdata, &rlen, &cc, fdebug); + if ((rv == 0) && (cc != 0)) rv = cc; + if (rv == 0) { *val = rdata[0]; } + return(rv); +} + int oem_supermicro_get_lan_port(uchar *val) { int rv; @@ -448,12 +537,13 @@ static void usage(void) printf(" bmcstatus [enable| disable] = get/set BMC status\n"); printf(" firmware = get extra firmware info\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"); } static int ipmi_smcoem_main(int argc, char **argv) { - int rv = 0; + int n,rv = 0; char msg[80]; uchar val; @@ -506,6 +596,39 @@ static int ipmi_smcoem_main(int argc, char **argv) if (rv == 0) oem_supermicro_show_lan_port(val); } } + } else if (strncmp(argv[0],"powersupply",11) == 0) { + if (argv[1] == NULL) { + usage(); + rv = ERR_USAGE; + } else { + char DevRec[16]; + int xver = 9; + n = atoi(argv[1]); /* power supply number */ + rv = ipmi_getdeviceid( DevRec, sizeof(DevRec),fdebug); + if (rv == 0) { + int vend_id, prod_id; + /* 1562 (0x061A) = X8SIU */ + /* 1572 (0x0624) = X9SCM */ + /* 1797 (0x0705) = X9DR7 */ + /* 2137 (0x0859) = X10DRH */ + vend_id = DevRec[6] + (DevRec[7] << 8) + (DevRec[8] << 16); + prod_id = DevRec[9] + (DevRec[10] << 8); + if (prod_id > 0x0800) xver = 10; + else if (prod_id > 1570) xver = 9; + else xver = 8; + } + if (xver == 10) rv = oem_supermicro_psstatus3(n, &val); + else if (xver == 9) rv = oem_supermicro_psstatus2(n, &val); + else /*xver==8*/ rv = oem_supermicro_psstatus1(n, &val); + if (rv == 0) { + if (val == 0x00) strcpy(msg,"good"); + else if (val == 0x02) strcpy(msg,"ok"); + else sprintf(msg,"bad 0x%02x",val); + printf("X%d Power Supply %d status = %d (%s)\n",xver,n,val,msg); + } else { + printf("X%d Power Supply %d error = %d\n",xver,n,rv); + } + } } else { usage(); rv = ERR_USAGE; |