1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
|
/*
* oem_supermicro.c
* Handle SuperMicro OEM command functions
*
* Change history:
* 12/06/2010 ARCress - included in source tree
*
*---------------------------------------------------------------------
*/
/*M*
Copyright (c) 2010 Kontron America, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
a.. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
b.. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
c.. Neither the name of Kontron nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*M*/
#ifdef WIN32
#include <windows.h>
#include "getopt.h"
#else
#if defined(HPUX)
/* getopt is defined in stdio.h */
#elif defined(MACOS)
/* getopt is defined in unistd.h */
#include <unistd.h>
#include <sys/time.h>
#else
#include <getopt.h>
#endif
#endif
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "ipmicmd.h"
#include "ievents.h"
#include "oem_supermicro.h"
#ifdef MOVED /*moved to oem_supermicro.h*/
#define SUPER_NETFN_OEM 0x30
#define SUPER_CMD_BMCSTATUS 0x70
#define SUPER_CMD_RESET_INTRUSION 0x03
#define SUPER_NETFN_OEMFW 0x3C
#define SUPER_CMD_OEMFWINFO 0x20
#endif
void set_loglevel(int level); /*prototype */
extern char fsm_debug; /*mem_if.c*/
static char * progver = "2.98";
static char * progname = "ismcoem";
static int verbose = 0;
static char fdebug = 0;
static uchar g_bus = PUBLIC_BUS;
static uchar g_sa = BMC_SA;
static uchar g_lun = BMC_LUN;
static uchar g_addrtype = ADDR_SMI;
static int vend_id = 0;
static int prod_id = 0;
int oem_supermicro_get_bmc_status(uchar *sts)
{
int rv;
int rlen, ilen;
uchar rdata[16];
uchar idata[16];
uchar cc;
if (sts == NULL) return(LAN_ERR_INVPARAM);
if ((vend_id == VENDOR_SUPERMICROX) ||
(vend_id == VENDOR_SUPERMICRO)) {
/* subfunc 0xF0 is invalid for newer SMC systems */
idata[0] = 0x02; /* action: get status */
ilen = 1;
} else {
idata[0] = 0xF0; /* subfunction */
idata[1] = 0x02; /* action: get status */
// idata[2] = 0;
ilen = 2;
}
rlen = sizeof(rdata);
rv = ipmi_cmdraw(SUPER_CMD_BMCSTATUS, SUPER_NETFN_OEM,
BMC_SA, PUBLIC_BUS, BMC_LUN,
idata, ilen, rdata, &rlen, &cc, fdebug);
if ((rv == 0) && (cc != 0)) rv = cc;
if (rv == 0) { *sts = rdata[0]; }
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;
int rlen, ilen;
uchar rdata[16];
uchar idata[16];
uchar cc;
if (sts > 1) sts = 1; /* actions: 0=disable, 1=enable, 2=status*/
if ((vend_id == VENDOR_SUPERMICROX) ||
(vend_id == VENDOR_SUPERMICRO)) {
idata[0] = sts;
ilen = 1;
} else {
idata[0] = 0xF0; /* subfunction */
idata[1] = sts;
ilen = 2;
}
rlen = sizeof(rdata);
rv = ipmi_cmdraw(SUPER_CMD_BMCSTATUS, SUPER_NETFN_OEM,
BMC_SA, PUBLIC_BUS, BMC_LUN,
idata, ilen, rdata, &rlen, &cc, fdebug);
if ((rv == 0) && (cc != 0)) rv = cc;
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;
int rlen, ilen;
uchar rdata[16];
uchar idata[16];
uchar cc;
idata[0] = 0x0c; /* subfunction */
idata[1] = 0x00; /* get */
ilen = 2;
rlen = sizeof(rdata);
rv = ipmi_cmdraw(SUPER_CMD_BMCSTATUS, SUPER_NETFN_OEM,
BMC_SA, PUBLIC_BUS, BMC_LUN,
idata, ilen, rdata, &rlen, &cc, fdebug);
if ((rv == 0) && (cc != 0)) rv = cc;
if (rv == 0) { *val = rdata[0]; }
return(rv);
}
int oem_supermicro_set_lan_port(uchar val)
{
int rv;
int rlen, ilen;
uchar rdata[16];
uchar idata[16];
uchar cc;
idata[0] = 0x0c; /* subfunction */
idata[1] = 0x01; /* set */
idata[2] = val;
ilen = 3;
rlen = sizeof(rdata);
rv = ipmi_cmdraw(SUPER_CMD_BMCSTATUS, SUPER_NETFN_OEM,
BMC_SA, PUBLIC_BUS, BMC_LUN,
idata, ilen, rdata, &rlen, &cc, fdebug);
if ((rv == 0) && (cc != 0)) rv = cc;
return(rv);
}
char *oem_supermicro_lan_port_string(uchar val)
{
char *p;
switch(val) {
case 0: p = "Dedicated"; break;
case 1: p = "Onboard_LAN1"; break;
case 2: p = "Failover"; break;
default: p = "unknown"; break;
}
return(p);
}
static void oem_supermicro_show_lan_port(uchar val)
{
printf("Current LAN interface is %s\n",
oem_supermicro_lan_port_string(val));
}
int oem_supermicro_get_health(char *pstr, int sz)
{
int rv;
uchar bsts;
char *str;
rv = oem_supermicro_get_bmc_status(&bsts);
if (rv == 0) {
if (bsts == 0x01) str = "BMC status = enabled";
else str = "BMC status = disabled";
strncpy(pstr, str, sz);
}
return(rv);
}
/*
* oem_supermicro_get_firmware_info
*
* From post by ipmitool developer.
* http://sourceforge.net/mailarchive/message.php?msg_name=49ABCCC3.4040004%40cern.ch
*
* Request
* 0x3C - OEM network function
* 0x20 - OEM cmd (SUPER_CMD_OEMFWINFO)
*
* Response data:
* 4 bytes - firmware major version (LSB first)
* 4 bytes - firmware minor version (LSB first)
* 4 bytes - firmware sub version (LSB first)
* 4 bytes - firmware build number (LSB first)
* 1 byte - hardware ID
* ? bytes - firmware tag, null terminated string
*/
int oem_supermicro_get_firmware_info(uchar *info)
{
int rv;
int rlen;
uchar rdata[32];
uchar idata[16];
uchar cc;
if (info == NULL) return(LAN_ERR_INVPARAM);
rlen = sizeof(rdata);
rv = ipmi_cmdraw(SUPER_CMD_OEMFWINFO, SUPER_NETFN_OEM,
BMC_SA, PUBLIC_BUS, BMC_LUN,
idata, 0, rdata, &rlen, &cc, fdebug);
if ((rv == 0) && (cc != 0)) rv = cc;
if (rv == 0) { memcpy(info,rdata,rlen); }
return(rv);
}
int oem_supermicro_get_firmware_str(char *pstr, int sz)
{
int rv;
uchar info[32];
uint32 fwmaj;
uint32 fwmin;
uint32 fwsub;
uint32 fwbld;
uchar hwid;
rv = oem_supermicro_get_firmware_info(info);
if (rv == 0) {
fwmaj = info[0] + (info[1] << 8) + (info[2] << 16) + (info[3] << 24);
fwmin = info[4] + (info[5] << 8) + (info[6] << 16) + (info[7] << 24);
fwsub = info[8] + (info[9] << 8) + (info[10] << 16) + (info[11] << 24);
fwbld = info[12] +(info[13] << 8) + (info[14] << 16) + (info[15] << 24);
hwid = info[16];
/*info[17] = fw tag string */
snprintf(pstr,sz,"Firmware %d.%d.%d.%d HW %d %s\n",fwmaj,fwmin,fwsub,
fwbld,hwid,&info[17]);
}
return(rv);
}
int oem_supermicro_reset_intrusion(void)
{
int rv;
int rlen;
uchar rdata[32];
uchar idata[16];
uchar cc;
// if (state == NULL) return(LAN_ERR_INVPARAM);
rlen = sizeof(rdata);
rv = ipmi_cmdraw(SUPER_CMD_RESET_INTRUSION, SUPER_NETFN_OEM,
BMC_SA, PUBLIC_BUS, BMC_LUN,
idata, 0, rdata, &rlen, &cc, fdebug);
if ((rv == 0) && (cc != 0)) rv = cc;
if (rv == 0) { /* check rdata for more info */ }
return(rv);
}
/*
* decode_sensor_supermicro
* inputs:
* sdr = the SDR buffer
* reading = the 3 or 4 bytes of data from GetSensorReading
* pstring = points to the output string buffer
* slen = size of the output buffer
* outputs:
* rv = 0 if this sensor was successfully interpreted here,
* non-zero otherwise, to use default interpretations.
* pstring = contains the sensor reading interpretation string (if rv==0)
*/
int decode_sensor_supermicro(uchar *sdr,uchar *reading,char *pstring, int slen)
{
int rv = -1;
uchar stype;
uchar bval;
char *pstr = NULL;
if (sdr == NULL || reading == NULL) return(rv);
if (pstring == NULL || slen == 0) return(rv);
/* sdr[3] is 0x01 for Full, 0x02 for Compact */
bval = reading[2];
stype = sdr[12];
switch(stype) {
case 0xC0: /* CPU Temp Sensor, EvTyp=0x70 (Full) */
//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;
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;
}
break;
default:
break;
}
if (rv == 0) strncpy(pstring, pstr, slen);
return(rv);
}
int decode_mem_supermicro(int prod, uchar b2, uchar b3, char *desc, int *psz)
{
int array, dimm, n;
int rv = -1;
uchar bdata;
if ((desc == NULL) || (psz == NULL)) return -1;
if (b2 == 0xff) bdata = b3; /*ff is reserved*/
else bdata = b2; /* normal case */
array = (bdata & 0xc0) >> 6;
dimm = bdata & 0x3f;
/* bdata = 0x10 (16.) means CPU 1, DIMM 6 */
array = bdata / 10;
dimm = bdata % 10;
#ifdef DMIOK
/* Use DMI if we get confirmation about array/dimm indices. */
if (! is_remote()) {
fsm_debug = fdebug;
rv = get_MemDesc(array,dimm,desc,psz);
/* if (rv != 0) desc has "DIMM[%d}" */
}
#endif
if (rv != 0) {
n = sprintf(desc,"DIMM%d/CPU%d",dimm,array);
*psz = n;
rv = 0;
}
return(rv);
} /*end decode_mem_supermicro*/
/*
* decode_sel_supermicro
* inputs:
* evt = the 16-byte IPMI SEL event
* outbuf = points to the output string buffer
* outsz = size of the output buffer
* outputs:
* rv = 0 if this event was successfully interpreted here,
* non-zero otherwise, to use default interpretations.
* outbuf = will contain the interpreted event text string (if rv==0)
*/
int decode_sel_supermicro(uchar *evt, char *outbuf, int outsz, char fdesc,
char fdbg)
{
int rv = -1;
ushort id;
uchar rectype;
ulong timestamp;
char mybuf[64];
char *type_str = "";
char *pstr = NULL;
int sevid;
ushort genid;
uchar snum;
fdebug = fdbg;
sevid = SEV_INFO;
id = evt[0] + (evt[1] << 8);
rectype = evt[2];
snum = evt[11];
timestamp = evt[3] + (evt[4] << 8) + (evt[5] << 16) + (evt[6] << 24);
genid = evt[7] | (evt[8] << 8);
if (rectype == 0x02)
{
sprintf(mybuf,"%02x [%02x %02x %02x]", evt[12],evt[13],evt[14],evt[15]);
switch(evt[10]) { /*sensor type*/
case 0xC0: /* CPU Temp Sensor */
type_str = "OEM_CpuTemp";
switch((evt[13] &0x0f)) { /*offset/data1 l.o. nibble*/
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"; break;
}
break;
case 0xC2: /* CPLD Event */
type_str = "OEM_CPLD";
switch((evt[13] & 0x0f)) { /* data1 usu 0xa0*/
case 0x00:
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"; break;
}
break;
default: /*other sensor types*/
break;
}
}
if (rv == 0) {
format_event(id,timestamp, sevid, genid, type_str,
snum,NULL,pstr,mybuf,outbuf,outsz);
}
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(" 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 n,rv = 0;
char msg[80];
uchar val;
if (strncmp(argv[0],"intrusion",9) == 0) {
printf("Clearing Chassis Intrusion ...\n");
rv = oem_supermicro_reset_intrusion();
} else if (strncmp(argv[0],"bmcstatus",9) == 0) {
printf("Getting BMC status ...\n");
rv = oem_supermicro_get_health(msg, sizeof(msg));
if (rv != 0) return(rv);
printf("%s\n",msg);
if (argv[1] != NULL) {
if (strncmp(argv[1],"disable",7) == 0) {
val = 0;
} else if (strncmp(argv[1],"enable",6) == 0) {
val = 1;
} else {
usage();
return(ERR_USAGE);
}
printf("Setting BMC status to %s ...\n",argv[1]);
rv = oem_supermicro_set_bmc_status(val);
if (rv != 0) return(rv);
rv = oem_supermicro_get_health(msg, sizeof(msg));
if (rv == 0) printf("%s\n",msg);
}
} else if (strncmp(argv[0],"firmware",8) == 0) {
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) {
rv = oem_supermicro_get_lan_port(&val);
if (rv == 0) {
oem_supermicro_show_lan_port(val);
if (argv[1] != NULL) {
if (strncmp(argv[1],"dedicated",9) == 0) {
val = 0;
} else if (strncmp(argv[1],"lan1",4) == 0) {
val = 1;
} else if (strncmp(argv[1],"failover",8) == 0) {
val = 2;
} else {
usage();
return(ERR_USAGE);
}
printf("Setting LAN interface to %s ...\n",argv[1]);
rv = oem_supermicro_set_lan_port(val);
if (rv != 0) return(rv);
rv = oem_supermicro_get_lan_port(&val);
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;
}
return(rv);
}
#ifdef METACOMMAND
int i_smcoem(int argc, char **argv)
#else
#ifdef WIN32
int __cdecl
#else
int
#endif
main(int argc, char **argv)
#endif
{
int rv = 0;
uchar devrec[16];
int c, i;
char *s1;
printf("%s ver %s\n", progname,progver);
set_loglevel(LOG_NOTICE);
parse_lan_options('V',"4",0); /*default to admin priv*/
while ( (c = getopt( argc, argv,"m:xzEF:J:N:P:R:T:U:V:YZ:?")) != EOF )
switch(c) {
case 'm': /* specific IPMB MC, 3-byte address, e.g. "409600" */
g_bus = htoi(&optarg[0]); /*bus/channel*/
g_sa = htoi(&optarg[2]); /*device slave address*/
g_lun = htoi(&optarg[4]); /*LUN*/
g_addrtype = ADDR_IPMB;
if (optarg[6] == 's') {
g_addrtype = ADDR_SMI; s1 = "SMI";
} else { g_addrtype = ADDR_IPMB; s1 = "IPMB"; }
ipmi_set_mc(g_bus,g_sa,g_lun,g_addrtype);
printf("Use MC at %s bus=%x sa=%x lun=%x\n",
s1,g_bus,g_sa,g_lun);
break;
case 'x': fdebug = 2; /* normal (dbglog if isol) */
verbose = 1;
break;
case 'z': fdebug = 3; /*full debug (for isol)*/
verbose = 1;
break;
case 'N': /* nodename */
case 'U': /* remote username */
case 'P': /* remote password */
case 'R': /* remote password */
case 'E': /* get password from IPMI_PASSWORD environment var */
case 'F': /* force driver type */
case 'T': /* auth type */
case 'J': /* cipher suite */
case 'V': /* priv level */
case 'Y': /* prompt for remote password */
case 'Z': /* set local MC address */
parse_lan_options(c,optarg,fdebug);
break;
default:
usage();
return(ERR_USAGE);
break;
}
for (i = 0; i < optind; i++) { argv++; argc--; }
if (argc == 0) {
usage();
return(ERR_USAGE);
}
rv = ipmi_getdeviceid(devrec,16,fdebug);
if (rv == 0) {
char ipmi_maj, ipmi_min;
ipmi_maj = devrec[4] & 0x0f;
ipmi_min = devrec[4] >> 4;
vend_id = devrec[6] + (devrec[7] << 8) + (devrec[8] << 16);
prod_id = devrec[9] + (devrec[10] << 8);
show_devid( devrec[2], devrec[3], ipmi_maj, ipmi_min);
}
rv = ipmi_smcoem_main(argc, argv);
ipmi_close_();
return(rv);
}
/* end oem_supermicro.c */
|