4
* MontaVista IPMI code for converting values to strings.
6
* Author: MontaVista Software, Inc.
7
* Corey Minyard <minyard@mvista.com>
10
* Copyright 2002,2003 MontaVista Software Inc.
12
* This program is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU Lesser General Public License
14
* as published by the Free Software Foundation; either version 2 of
15
* the License, or (at your option) any later version.
18
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
* You should have received a copy of the GNU Lesser General Public
30
* License along with this program; if not, write to the Free
31
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36
#include <OpenIPMI/ipmi_bits.h>
37
#include <OpenIPMI/ipmi_msgbits.h>
38
#include <OpenIPMI/ipmi_auth.h>
39
#include <OpenIPMI/ipmiif.h>
40
#include <OpenIPMI/ipmi_err.h>
42
#include <OpenIPMI/internal/ipmi_malloc.h>
45
ipmi_update_e_string(enum ipmi_update_e val)
48
case IPMI_ADDED: return "added";
49
case IPMI_DELETED: return "deleted";
50
case IPMI_CHANGED: return "changed";
51
default: return "invalid";
55
static char *hysteresis_support_types[] =
62
#define NUM_HYSTERESIS_SUPPORT_TYPES (sizeof(hysteresis_support_types)/sizeof(char *))
64
ipmi_get_hysteresis_support_string(unsigned int val)
66
if (val >= NUM_HYSTERESIS_SUPPORT_TYPES)
68
return hysteresis_support_types[val];
71
static char *threshold_access_support_types[] =
78
#define NUM_THRESHOLD_ACCESS_SUPPORT_TYPES (sizeof(threshold_access_support_types)/sizeof(char *))
80
ipmi_get_threshold_access_support_string(unsigned int val)
82
if (val >= NUM_THRESHOLD_ACCESS_SUPPORT_TYPES)
84
return threshold_access_support_types[val];
87
static char *event_support_types[] =
94
#define NUM_EVENT_SUPPORT_TYPES (sizeof(event_support_types)/sizeof(char *))
96
ipmi_get_event_support_string(unsigned int val)
98
if (val >= NUM_EVENT_SUPPORT_TYPES)
100
return event_support_types[val];
103
static char *sensor_types[] =
116
"other_units_based_sensor",
119
"power_memory_resize",
120
"system_firmware_progress",
121
"event_logging_disabled",
124
"critical_interrupt",
127
"microcontroller_coprocessor",
132
"cable_interconnect",
134
"system_boot_initiated",
139
"system_acpi_power_state",
145
"management_subsystem_health",
148
#define NUM_SENSOR_TYPES (sizeof(sensor_types)/sizeof(char *))
150
ipmi_get_sensor_type_string(unsigned int val)
152
if (val >= NUM_SENSOR_TYPES)
154
return sensor_types[val];
157
static char *event_reading_types[] =
163
"discrete_predictive_failure",
164
"discrete_limit_exceeded",
165
"discrete_performance_met",
167
"discrete_device_presense",
168
"discrete_device_enable",
169
"discrete_availability",
170
"discrete_redundancy",
171
"discrete_acpi_power",
173
#define NUM_EVENT_READING_TYPES (sizeof(event_reading_types)/sizeof(char *))
175
ipmi_get_event_reading_type_string(unsigned int val)
177
if (val == IPMI_EVENT_READING_TYPE_SENSOR_SPECIFIC)
178
return "sensor specific";
180
if (val >= NUM_EVENT_READING_TYPES)
182
return event_reading_types[val];
185
static char *sensor_directions[] =
191
#define NUM_SENSOR_DIRECTIONS (sizeof(sensor_directions)/sizeof(char *))
193
ipmi_get_sensor_direction_string(unsigned int val)
195
if (val >= NUM_SENSOR_DIRECTIONS)
197
return sensor_directions[val];
200
static char *rate_unit_types[] =
210
#define NUM_RATE_UNIT_TYPES (sizeof(rate_unit_types)/sizeof(char *))
212
ipmi_get_rate_unit_string(unsigned int val)
214
if (val >= NUM_RATE_UNIT_TYPES)
216
return rate_unit_types[val];
219
static char *unit_types[] =
310
"correctable_errors",
311
"uncorrectable_errors",
315
#define NUM_UNIT_TYPES (sizeof(unit_types)/sizeof(char *))
317
ipmi_get_unit_type_string(unsigned int val)
319
if (val >= NUM_UNIT_TYPES)
321
return unit_types[val];
324
static char *threshold_types[] =
326
"lower non-critical",
328
"lower non-recoverable",
329
"upper non-critical",
331
"upper non-recoverable"
333
#define NUM_THRESHOLD_TYPES (sizeof(threshold_types)/sizeof(char *))
335
ipmi_get_threshold_string(enum ipmi_thresh_e val)
337
if (val > NUM_THRESHOLD_TYPES)
339
return threshold_types[val];
342
static char *value_dir_types[] =
347
#define NUM_VALUE_DIR_TYPES (sizeof(value_dir_types)/sizeof(char *))
349
ipmi_get_value_dir_string(enum ipmi_event_value_dir_e val)
351
if (val > NUM_VALUE_DIR_TYPES)
353
return value_dir_types[val];
356
static char *event_dir_types[] =
361
#define NUM_EVENT_DIR_TYPES (sizeof(event_dir_types)/sizeof(char *))
363
ipmi_get_event_dir_string(enum ipmi_event_dir_e val)
365
if (val > NUM_EVENT_DIR_TYPES)
367
return event_dir_types[val];
370
static char *entity_id_types[] =
372
"unspecified", /* 0 */
378
"system_management_module",
382
"power_supply", /* 10 */
386
"power_system_board",
388
"system_internal_expansion_board",
389
"other_system_board",
392
"power_module", /* 20 */
393
"power_management_board",
394
"chassis_back_panel_board",
397
"other_chassis_board",
402
"cooling_unit", /* 30 */
403
"cable_interconnect",
405
"system_management_software",
410
"remote_mgmt_comm_device",
411
"external_environment",
414
"connectivity switch",
415
"processor/memory module",
417
"processor I/O module",
418
"management controller firmware",
424
"processor front side bus",
426
#define NUM_ENTITY_ID_TYPES (sizeof(entity_id_types)/sizeof(char *))
428
ipmi_get_entity_id_string(unsigned int val)
430
if (val >= NUM_ENTITY_ID_TYPES)
432
return entity_id_types[val];
435
static char *event_reading_states[256][16] =
438
{ "lower non-critical - going low",
439
"lower non-critical - going high",
440
"lower critical - going low",
441
"lower critical - going high",
442
"lower non-recoverable - going low",
443
"lower non-recoverable - going high",
444
"upper non-critical - going low",
445
"upper non-critical - going high",
446
"upper critical - going low",
447
"upper critical - going high",
448
"upper non-recoverable - going low",
449
"upper non-recoverable - going high", },
450
{ "transition to idle", "transition to active", "transition to busy" },
451
{ "state deasserted", "state asserted" },
452
{ "predictive failure deasserted", "predictive failure asserted" },
453
{ "limit not exceeded", "limit exceeded" },
454
{ "performance met", "performance lags" },
455
{ "transition to ok",
456
"transition to non-cricital from ok",
457
"transition to critical from ok",
458
"transition to non-recoverable from less severe",
459
"transition to non-critical from more severe",
460
"transition to critical from non-recoverable",
461
"transition to non-recoverable",
464
{ "device removed/absent", "device inserted/present" },
465
{ "device disabled", "device enabled" },
467
"transition to in test",
468
"transition to power off",
469
"transition to on line",
470
"transition to off line",
471
"transition to off duty",
472
"transition to degraded",
473
"transition to power save",
477
"redundancy degraded",
478
"non-redundant: sufficient resources from redundant",
479
"non-redundant: sufficient resources from insufficient resources",
480
"non-redundant: insufficient resources",
481
"redundancy degraded from fully redundant",
482
"redundancy degraded from non-redundant" },
489
static char *sensor_states[256][16] =
497
"general chassis intrusion",
498
"drive bay intrusion",
499
"I/O card area intrusion",
500
"processor area intrusion",
502
"unauthorized doc/undock",
507
"pre-boot password violation - user password",
508
"pre-boot password violation - setup password",
509
"pre-boot password violation - network boot password",
510
"other pre-boot password violation",
511
"out-of-band access password violation",
517
"FRB2/Hand in POST failure",
518
"FRB3/Processor startup/initialization failure",
519
"configuration error",
520
"SM BIOS 'uncorrectable CPU-complex error'",
521
"processor presence detected",
522
"processor disabled",
523
"terminator presence detected"
527
"power supply failure detected",
528
"predictive failure",
529
"power supply AC lost",
530
"AC lost or out-of-range",
531
"AC out of range, but present"
534
"power off/power down",
537
"interlock power down",
539
"soft power control failure",
540
"power unit falure detected",
541
"predictive failure",
549
"memory scrub failed (stuck bit)",
550
"memory device disabled",
551
"correctable ECC log limit reached",
553
"configuration error",
555
"memory automatically throttled",
560
"predictive failure",
562
"consistancy/parity check in progress",
565
"rebuild/remap in progress",
566
"rebuild/remap aborted",
570
"system firmware error",
571
"system firmware hang",
572
"system firmware progress"
575
"correctable memory error logging disabled",
576
"event type logging siabled",
577
"log area reset/cleared",
578
"all event logging disabled",
581
"BIOS watchdog reset",
583
"os watchdog shutdown",
584
"os watchdog power down",
585
"os watchdog power cycle",
586
"os watchdog NMI/diag interrupt",
587
"os watchdog expired",
588
"os watchdog pretimout interrupt",
591
"system reconfigured",
592
"OEM system boot event",
593
"undetermined system hardware failure",
594
"entry added to auxiliary log",
598
"front panel NMI/diag interrupt",
600
"I/O channel check NMI",
604
"EISA fail safe timeout",
605
"bus correctable error",
606
"bus uncorrectable error",
610
"power button pressed",
611
"sleep button pressed",
612
"reset button pressed"
621
"cable/interconnect is connected",
622
"configuration error",
626
"initiated by power up",
627
"initiated by hard reset",
628
"initiated by warm reset",
629
"user requested PXE boot",
630
"automatic boot to diagnostic"
634
"non-bootable diskette left in drive",
635
"PXE server not found",
636
"invalid boot sector",
637
"timeout waiting for user selection of boot source"
642
"PXE boot completed",
643
"diagnostic boot completed",
644
"CD-ROM boot completed",
645
"ROM boot completed",
649
"stop during OS load/initialization",
653
"fault status asserted",
654
"identify status asserted",
655
"slot/connector device installed/attached",
656
"slot/connector ready for device installation",
657
"slot/connector ready for device removal",
659
"slot/connector device removal request",
660
"interlock asserted",
665
"S1 'Sleeping with system H/W & processor context maintained'",
666
"S2 'sleeping, processor context lost'",
667
"S3 'sleeping, processor & h/w context lost, memory retained'",
668
"S4 'non-volatile sleep/suspend to disk'",
672
"sleeping in an S1, S2, or S3 state",
674
"S5 entered by override",
692
"platform generated page",
693
"platform generated LAN alert",
694
"platform event trap generated",
695
"platform generated SNMP trap"
704
"LAN heartbeat lost",
708
"sensor access degraded or unavailable",
709
"controller access degraded or unavailable",
710
"management controller off-line",
711
"management controller unavailable",
716
"battery presence detected"
721
ipmi_get_reading_name(unsigned int event_reading_type,
722
unsigned int sensor_type,
726
if (event_reading_type == IPMI_EVENT_READING_TYPE_SENSOR_SPECIFIC) {
727
if ((sensor_type > 255) || (val > 15))
729
rv = sensor_states[sensor_type][val];
731
if ((event_reading_type > 255) || (val > 15))
733
rv = event_reading_states[event_reading_type][val];
740
static char *control_types[] =
755
#define NUM_CONTROL_TYPES (sizeof(control_types)/sizeof(char *))
757
ipmi_get_control_type_string(unsigned int val)
759
if (val >= NUM_CONTROL_TYPES)
761
return control_types[val];
764
static char *colors[] =
774
#define NUM_COLORS (sizeof(colors)/sizeof(char *))
776
ipmi_get_color_string(unsigned int val)
778
if (val >= NUM_COLORS)
783
static char *ipmi_netfns[] =
785
"chassis(c):%02x", // +0 : 0x00
786
"chassis(r):%02x", // +1 : 0x01
787
"bridge(c):%02x", // +2 : 0x02
788
"bridge(r):%02x", // +3 : 0x03
789
"s/e(c):%02x", // +4 : 0x04
790
"s/e(r):%02x", // +5 : 0x05
791
"app(c):%02x", // +6 : 0x06
792
"app(r):%02x", // +7 : 0x07
793
"firmware(c):%02x", // +8 : 0x08
794
"firmware(r):%02x", // +9 : 0x09
795
"storage(c):%02x", // +10: 0x0a
796
"storage(r):%02x", // +11: 0x0b
797
"transport(c):%02x", // +12: 0x0c
798
"transport(r):%02x", // +13: 0x0d
799
"reserved(c):%02x", // +14: 0x0e..0x2b reserved
800
"reserved(r):%02x", // +15: 0x2b
801
"grpext(c):%02x", // +16: 0x2c
802
"grpext(r):%02x", // +17: 0x2d
803
"oem/grp(c):%02x", // +18: 0x2e
804
"oem/grp(r):%02x", // +19: 0x2f
805
"ctlrspec(c):%02x", // +20: 0x30..3f Controller specific
806
"ctlrspec(r):%02x", // +21: 0x3f
809
* Convert a NetFN code into a string
812
ipmi_get_netfn_string(unsigned int netfn,
814
unsigned int buf_len)
821
netfn_fs = ipmi_netfns[(netfn & 0x01) + 20];
822
else if ( netfn > 0x2d )
823
netfn_fs = ipmi_netfns[(netfn & 0x01) + 18];
824
else if ( netfn > 0x2b )
825
netfn_fs = ipmi_netfns[(netfn & 0x01) + 16];
826
else if ( netfn > 0x0d )
827
netfn_fs = ipmi_netfns[(netfn & 0x01) + 14];
829
netfn_fs = ipmi_netfns[netfn];
831
snprintf(buffer, buf_len, netfn_fs, netfn);
836
static char * ipmi_app_cmds[] =
838
"reserved:%02x", // +0 : 0x00
839
"GetDevId:%02x", // +1 : 0x01
840
"ColdReset:%02x", // +2 : 0x02
841
"WarmReset:%02x", // +3 : 0x03
842
"GetSelfTest:%02x", // +4 : 0x04
843
"ManuTestOn:%02x", // +5 : 0x05
844
"SetACPIpwr:%02x", // +6 : 0x06
845
"GetACPIpwr:%02x", // +7 : 0x07
846
"GetDevGUID:%02x", // +8 : 0x08 (0x09..0x21 unassigned)
847
"ResetWdog:%02x", // +9 : 0x22
848
"unassigned:%02x", // +10: 0x23 unassigned
849
"SetWdog:%02x", // +11: 0x24
850
"GetWdog:%02x", // +12: 0x25 (0x26..0x2d unassigned)
851
"SetBMCgblEna:%02x", // +13: 0x2e
852
"GetBMCgblEna:%02x", // +14: 0x2f
853
"ClrMsgFlags:%02x", // +15: 0x30
854
"GetMsgFlags:%02x", // +16: 0x31
855
"EnaMsgChRcv:%02x", // +17: 0x32
856
"GetMsg:%02x", // +18: 0x33
857
"SndMsg:%02x", // +19: 0x34
858
"ReadEvntMsg:%02x", // +20: 0x35
859
"GetBTifCap:%02x", // +21: 0x36
860
"GetSysGUID:%02x", // +22: 0x37
861
"GetChAuthCap:%02x", // +23: 0x38
862
"GetSessChlng:%02x", // +24: 0x39
863
"ActiSess:%02x", // +25: 0x3a
864
"SetSessPrivlvl:%02x", // +26: 0x3b
865
"CloseSess:%02x", // +27: 0x3c
866
"GetSessInfo:%02x", // +28: 0x3d
867
"unassigned:%02x", // +29: 0x3e unassigned
868
"GetAuthCode:%02x", // +30: 0x3f
869
"SetChAccess:%02x", // +31: 0x40
870
"GetChAccess:%02x", // +32: 0x41
871
"GetChInfoCmd:%02x", // +33: 0x42
872
"SetUsrAccCmd:%02x", // +34: 0x43
873
"GetUsrAccCmd:%02x", // +35: 0x44
874
"SetUsrName:%02x", // +36: 0x45
875
"GetUsrName:%02x", // +37: 0x46
876
"SetUsrPasswd:%02x", // +38: 0x47
877
"ActPayload:%02x", // +39: 0x48
878
"DeactPayload:%02x", // +40: 0x49
879
"GetPayloadActStat:%02x", // +41: 0x4a
880
"GetPayloadInstInfo:%02x", // +42: 0x4b
881
"SetUserPayloadAcc:%02x", // +43: 0x4c
882
"GetUserPayloadAcc:%02x", // +44: 0x4d
883
"GetChanPayloadSup:%02x", // +45: 0x4e
884
"GetChanPayloadVer:%02x", // +46: 0x4f
885
"GetChanOEMPayloadInf:%02x",// +47: 0x50
886
"unassigned:%02x", // +48: 0x51 unassigned
887
"MstrWrRd:%02x", // +49: 0x52
888
"unassigned:%02x", // +50: 0x53 unassigned
889
"GetChanCipherSuites:%02x", // +51: 0x54
890
"SuspResPayloadEnc:%02x", // +52: 0x55
891
"SetChanSecKey:%02x", // +53: 0x56
892
"GetSysIntfCap:%02x", // +54: 0x57
895
static char * ipmi_chassis_cmds[] =
897
"GetChassisCap:%02x", // +0 : 0x00
898
"GetChassisSts:%02x", // +1 : 0x01
899
"ChassisCtrl:%02x", // +2 : 0x02
900
"ChassisReset:%02x", // +3 : 0x03
901
"ChassisIdent:%02x", // +4 : 0x04
902
"SetChassisCap:%02x", // +5 : 0x05
903
"SetPwrRestPol:%02x", // +6 : 0x06
904
"GetSysRstCause:%02x", // +7 : 0x07
905
"SetSysBootOp:%02x", // +8 : 0x08
906
"GetSysBootOp:%02x", // +9 : 0x09
907
"unassigned:%02x", // +10: 0x0a..0x0e unassigned
908
"GetPOHcounter:%02x", // +11: 0x0f
911
static char * ipmi_se_cmds[] =
913
"SetEvntRcvr:%02x", // +0 : 0x00
914
"GetEvntRcvr:%02x", // +1 : 0x01
915
"EventMsg:%02x", // +2 : 0x02 (0x03..0x0f unassigned)
916
"GetPEFcap:%02x", // +3 : 0x10
917
"ArmPEFtimer:%02x", // +4 : 0x11
918
"SetPEFconfig:%02x", // +5 : 0x12
919
"GetPEFconfig:%02x", // +6 : 0x13
920
"SetLastEvId:%02x", // +7 : 0x14
921
"GetLastEvId:%02x", // +8 : 0x15
922
"AlertImmed:%02x", // +9 : 0x16
923
"PETackn:%02x", // +10: 0x17 (0x18..0x1f unassigned)
924
"GetDevSDRinfo:%02x", // +11: 0x20
925
"GetDevSDR:%02x", // +12: 0x21
926
"ReservSDRreposit:%02x", // +13: 0x22
927
"GetSensReadFact:%02x", // +14: 0x23
928
"SetSensHyst:%02x", // +15: 0x24
929
"GetSensHyst:%02x", // +16: 0x25
930
"SetSensThresh:%02x", // +17: 0x26
931
"GetSensThresh:%02x", // +18: 0x27
932
"SetSensEvEna:%02x", // +29: 0x28
933
"GetSensEvEna:%02x", // +20: 0x29
934
"RearmSensEv:%02x", // +21: 0x2a
935
"GetSensEvStat:%02x", // +22: 0x2b
936
"unassigned:%02x", // +23: 0x2c unassigned
937
"GetSensReading:%02x", // +24: 0x2d
938
"SetSensType:%02x", // +25: 0x2e
939
"GetSensType:%02x", // +26: 0x2f
942
static char * ipmi_storage_cmds[] =
944
"unassigned:%02x", // +0 : 0x00..0x0f unassigned
945
"GetFRUinvInfo:%02x", // +1 : 0x10
946
"ReadFRUdata:%02x", // +2 : 0x11
947
"WriteFRUdata:%02x", // +3 : 0x12 (0x13..0x1f unassigned)
948
"GetSDRrepInfo:%02x", // +4 : 0x20
949
"GetSDRrepAlloc:%02x", // +5 : 0x21
950
"ResrvSDRrepo:%02x", // +6 : 0x22
951
"GetSDR:%02x", // +7 : 0x23
952
"AddSDR:%02x", // +8 : 0x24
953
"PartialAddSDR:%02x", // +9 : 0x25
954
"DeleteSDR:%02x", // +10: 0x26
955
"ClrSDRrepo:%02x", // +11: 0x27
956
"GetSDRrepTime:%02x", // +12: 0x28
957
"SetSDRrepTime:%02x", // +13: 0x29
958
"EntrSDRrepUpd:%02x", // +14: 0x2a
959
"ExitSDRrepUpd:%02x", // +15: 0x2b
960
"RunInitAgent:%02x", // +16: 0x2c (0x2d..0x3f unassigned)
961
"GetSELinfo:%02x", // +17: 0x40
962
"GetSELallocInfo:%02x", // +18: 0x41
963
"ReservSEL:%02x", // +19: 0x42
964
"GetSELentry:%02x", // +20: 0x43
965
"AddSELentry:%02x", // +21: 0x44
966
"PartAddSELentry:%02x", // +22: 0x45
967
"DeleteSELent:%02x", // +23: 0x46
968
"ClrSEL:%02x", // +24: 0x47
969
"GetSELtime:%02x", // +25: 0x48
970
"SetSELtime:%02x", // +26: 0x49 (0x4a..0x59 unassigned)
971
"GetAuxLogSts:%02x", // +27: 0x5a
972
"SetAuxLogSts:%02x", // +28: 0x5b
975
static char * ipmi_transport_cmds[] =
977
"unassigned:%02x", // +0 : 0x00 unassigned
978
"SetLANconfParm:%02x", // +1 : 0x01
979
"GetLANconfParm:%02x", // +2 : 0x02
980
"SuspBMCarps:%02x", // +3 : 0x03
981
"GetIPstats:%02x", // +4 : 0x04 (0x05..0x0f unassigned)
982
"SetSerialConf:%02x", // +5 : 0x10
983
"GetSerialConf:%02x", // +6 : 0x11
984
"SetSerialMux:%02x", // +7 : 0x12
985
"GetTAPrespCodes:%02x", // +8 : 0x13
986
"SetPPPproxyTx:%02x", // +9 : 0x14
987
"GetPPPproxyTx:%02x", // +10: 0x15
988
"SendPPPproxyPkt:%02x", // +11: 0x16
989
"GetPPPproxyRxData:%02x", // +12: 0x17
990
"SerialConnAct:%02x", // +13: 0x18
991
"Callback:%02x", // +14: 0x19
992
"SetUsrCallOpts:%02x", // +15: 0x1a
993
"GetUsrCallOpts:%02x", // +16: 0x1b
994
"unassigned:%02x", // +17: 0x1c
995
"unassigned:%02x", // +18: 0x1d
996
"unassigned:%02x", // +19: 0x1e
997
"unassigned:%02x", // +20: 0x1f
998
"SOLActivating:%02x", // +21: 0x20
999
"SetSOLConfParm:%02x", // +22: 0x21
1000
"GetSOLConfParm:%02x", // +23: 0x22
1003
static char * ipmi_bridge_cmds[] =
1005
"GetBridgeState:%02x", // +0 : 0x00
1006
"SetBridgeState:%02x", // +1 : 0x01
1007
"GetICMBaddr:%02x", // +2 : 0x02
1008
"SetICMBaddr:%02x", // +3 : 0x03
1009
"SetBridgeProxyAddr:%02x", // +4 : 0x04
1010
"GetBridgeStats:%02x", // +5 : 0x05
1011
"GetICMBcaps:%02x", // +6 : 0x06
1012
"unassigned:%02x", // +7 : 0x07 unassigned
1013
"ClrBridgeStats:%02x", // +8 : 0x08
1014
"GetBridgeProxyAddr:%02x", // +9 : 0x09
1015
"GetICMBConnInfo:%02x", // +10: 0x0a
1016
"GetICMBConnId:%02x", // +11: 0x0b
1017
"SendICMBConnId:%02x", // +12: 0x0c (0x0d..0x0f unassigned)
1018
"Prep4Disc:%02x", // +13: 0x10
1019
"GetAddresses:%02x", // +14: 0x11
1020
"SetDiscovered:%02x", // +15: 0x12
1021
"GetChassDevId:%02x", // +16: 0x13
1022
"SetChassDevId:%02x", // +17: 0x14 (0x15..0x1f unassigned)
1023
"BridgeRequest:%02x", // +18: 0x20
1024
"BridgeMessage:%02x", // +19: 0x21 (0x22..0x2f unassigned)
1025
"GetEventCnt:%02x", // +20: 0x30
1026
"SetEventDest:%02x", // +21: 0x31
1027
"SetEventRecpState:%02x", // +22: 0x32
1028
"SndICMBevMsg:%02x", // +23: 0x33
1029
"GetEventDest:%02x", // +24: 0x34
1030
"GetEventRecpState:%02x", // +25: 0x35 (0x36..0xbf unassigned)
1031
"OEMcommands:%02x", // +26: 0xc0..0xfe
1032
"ErrorReport:%02x", // +27: 0xff
1036
* Convert a NetFN/Command code into a string
1039
ipmi_get_command_string(unsigned int netfn,
1042
unsigned int buf_len)
1045
char *cmd_fs = NULL;
1049
if ( netfn <= 0x0d ) {
1051
case IPMI_CHASSIS_NETFN:
1052
case IPMI_CHASSIS_NETFN | 1:
1054
netfn_table=ipmi_chassis_cmds;
1056
cmd_fs = netfn_table[cmd];
1057
else if ( cmd == 0x0f )
1058
cmd_fs = netfn_table[11];
1061
case IPMI_BRIDGE_NETFN:
1062
case IPMI_BRIDGE_NETFN | 1:
1064
netfn_table=ipmi_bridge_cmds;
1066
cmd_fs = netfn_table[cmd];
1067
else if ( (cmd > 0x0f) && (cmd < 0x15) )
1068
cmd_fs = netfn_table[cmd - 0x10 + 13];
1069
else if ( (cmd > 0x1f) && (cmd < 0x22) )
1070
cmd_fs = netfn_table[cmd - 0x20 + 18];
1071
else if ( (cmd > 0x2f) && (cmd < 0x36) )
1072
cmd_fs = netfn_table[cmd - 0x30 + 20];
1073
else if ( (cmd > 0xbf) && (cmd < 0xff) )
1074
cmd_fs = netfn_table[26];
1077
case IPMI_SENSOR_EVENT_NETFN:
1078
case IPMI_SENSOR_EVENT_NETFN | 1:
1080
netfn_table=ipmi_se_cmds;
1082
cmd_fs = netfn_table[cmd];
1083
else if ( (cmd > 0x0f) && (cmd < 0x18) )
1084
cmd_fs = netfn_table[cmd - 0x10 + 3];
1085
else if ( (cmd > 0x1f) && (cmd < 0x30) )
1086
cmd_fs = netfn_table[cmd - 0x20 + 11];
1089
case IPMI_APP_NETFN:
1090
case IPMI_APP_NETFN | 1:
1092
netfn_table=ipmi_app_cmds;
1094
cmd_fs = netfn_table[cmd];
1095
else if ( (cmd > 0x21) && (cmd < 0x26) )
1096
cmd_fs = netfn_table[cmd - 0x22 + 9];
1097
else if ( (cmd > 0x2d) && (cmd < 0x58) )
1098
cmd_fs = netfn_table[cmd - 0x2e + 13];
1101
case IPMI_FIRMWARE_NETFN:
1102
case IPMI_FIRMWARE_NETFN | 1:
1104
cmd_fs="unknown:%02x";
1107
case IPMI_STORAGE_NETFN:
1108
case IPMI_STORAGE_NETFN | 1:
1110
netfn_table=ipmi_storage_cmds;
1112
cmd_fs = netfn_table[0];
1113
else if ( (cmd > 0x0f) && (cmd < 0x13) )
1114
cmd_fs = netfn_table[cmd - 0x10 + 1];
1115
else if ( (cmd > 0x1f) && (cmd < 0x2d) )
1116
cmd_fs = netfn_table[cmd - 0x20 + 4];
1117
else if ( (cmd > 0x3f) && (cmd < 0x4a) )
1118
cmd_fs = netfn_table[cmd - 0x40 + 17];
1119
else if ( (cmd > 0x59) && (cmd < 0x5c) )
1120
cmd_fs = netfn_table[cmd - 0x5a + 27];
1123
case IPMI_TRANSPORT_NETFN:
1124
case IPMI_TRANSPORT_NETFN | 1:
1126
netfn_table=ipmi_transport_cmds;
1128
cmd_fs = netfn_table[cmd];
1129
else if ( (cmd > 0x0f) && (cmd < 0x23) )
1130
cmd_fs = netfn_table[cmd - 0x10 + 5];
1137
cmd_fs = "unknown:%02x";
1139
snprintf(buffer, buf_len, cmd_fs, cmd);
1144
static char *ipmi_ccodes[] =
1146
"Normal:%02x", // +0 : 0x00 (0x01..0xbf undefined)
1147
"NodeBusy:%02x", // +1 : 0xc0
1148
"InvCmd:%02x", // +2 : 0xc1
1149
"InvCmd4LUN:%02x", // +3 : 0xc2
1150
"Timeout:%02x", // +4 : 0xc3
1151
"OutOfSpace:%02x", // +5 : 0xc4
1152
"ResvCancInv:%02x", // +6 : 0xc5
1153
"DataTrunc:%02x", // +7 : 0xc6
1154
"DataLenInv:%02x", // +8 : 0xc7
1155
"DataLenOvr:%02x", // +9 : 0xc8
1156
"PrmRangeErr:%02x", // +10: 0xc9
1157
"InsuffData:%02x", // +11: 0xca
1158
"ObjNotPres:%02x", // +12: 0xcb
1159
"InvDataFld:%02x", // +13: 0xcc
1160
"IllCmd4Obj:%02x", // +14: 0xcd
1161
"NoResponse:%02x", // +15: 0xce
1162
"DupReq:%02x", // +16: 0xcf
1163
"SDRrepoBusy:%02x", // +17: 0xd0
1164
"FirmwareUpd:%02x", // +18: 0xd1
1165
"BMCiniting:%02x", // +19: 0xd2
1166
"DestUnavail:%02x", // +20: 0xd3
1167
"PrivError:%02x", // +21: 0xd4
1168
"InvalState:%02x", // +22: 0xd5 (0xd6..0xfe undefined)
1169
"Unspecified:%02x", // +23: 0xff
1172
* Convert a Completion Code into a string
1175
ipmi_get_cc_string(unsigned int cc,
1177
unsigned int buf_len)
1182
cc_fs = ipmi_ccodes[0];
1183
else if ( (cc > 0xbf) && (cc < 0xd6) )
1184
cc_fs = ipmi_ccodes[cc - 0xc0 + 1];
1185
else if ( cc == 0xff )
1186
cc_fs = ipmi_ccodes[23];
1188
cc_fs = "Unknown:%02x";
1190
snprintf(buffer, buf_len, cc_fs, cc);
1196
static const char *sol_error_codes[] =
1198
"SoLCharTransUnavail",
1207
static const char *rmcpp_error_codes[] =
1209
"InsufResourForSess",
1215
"NoMatchIntegPayld",
1219
"InsufResourForRole",
1225
"NoCipherSuiteMatch",
1231
ipmi_get_error_string(unsigned int err,
1233
unsigned int buf_len)
1240
strncpy(buffer, "Success (No error)", buf_len);
1244
temp_buffer = ipmi_mem_alloc(buf_len);
1246
temp_buffer = buffer;
1248
if (IPMI_IS_OS_ERR(err))
1250
strncpy(temp_buffer, strerror(IPMI_GET_OS_ERR(err)), buf_len);
1252
} else if (IPMI_IS_IPMI_ERR(err))
1254
ipmi_get_cc_string(IPMI_GET_IPMI_ERR(err), temp_buffer, buf_len);
1256
} else if (IPMI_IS_RMCPP_ERR(err))
1258
int rmcpp_err = IPMI_GET_RMCPP_ERR(err);
1259
if ((rmcpp_err <= 0) && (rmcpp_err > 0x12))
1261
snprintf(temp_buffer, buf_len, "%s (0x%02x)", rmcpp_error_codes[rmcpp_err - 1], IPMI_GET_RMCPP_ERR(err));
1263
} else if (IPMI_IS_SOL_ERR(err))
1265
int sol_err = IPMI_GET_SOL_ERR(err);
1266
if ((sol_err < 1) || (sol_err > 7))
1268
snprintf(temp_buffer, buf_len, sol_error_codes[sol_err - 1]);
1273
strncpy(temp_buffer, "Unknown", buf_len);
1274
err_type = "Unknown";
1277
if (temp_buffer != buffer)
1279
snprintf(buffer, buf_len, "%s: %s", err_type, temp_buffer);
1280
ipmi_mem_free(temp_buffer);
1286
/* Get a string name fo the hot swap state. */
1288
ipmi_hot_swap_state_name(enum ipmi_hot_swap_states state)
1291
case IPMI_HOT_SWAP_NOT_PRESENT: return "not_present";
1292
case IPMI_HOT_SWAP_INACTIVE: return "inactive";
1293
case IPMI_HOT_SWAP_ACTIVATION_REQUESTED: return "activation_requested";
1294
case IPMI_HOT_SWAP_ACTIVATION_IN_PROGRESS: return "activation_in_progress";
1295
case IPMI_HOT_SWAP_ACTIVE: return "active";
1296
case IPMI_HOT_SWAP_DEACTIVATION_REQUESTED: return "deactivation_requested";
1297
case IPMI_HOT_SWAP_DEACTIVATION_IN_PROGRESS: return "deactivation_in_progress";
1298
case IPMI_HOT_SWAP_OUT_OF_CON: return "out_of_con";
1299
default: return "invalid_state";
1303
static char *domain_types[] =
1309
#define NUM_DOMAIN_TYPES (sizeof(domain_types)/sizeof(char *))
1312
ipmi_domain_get_type_string(enum ipmi_domain_type dtype)
1314
if ((dtype < 0) || (dtype >= NUM_DOMAIN_TYPES))
1316
return domain_types[dtype];
1320
ipmi_authtype_string(int authtype)
1323
case IPMI_AUTHTYPE_DEFAULT:
1325
case IPMI_AUTHTYPE_NONE:
1327
case IPMI_AUTHTYPE_MD2:
1329
case IPMI_AUTHTYPE_MD5:
1331
case IPMI_AUTHTYPE_STRAIGHT:
1333
case IPMI_AUTHTYPE_OEM:
1335
case IPMI_AUTHTYPE_RMCP_PLUS:
1343
ipmi_privilege_string(int privilege)
1346
case IPMI_PRIVILEGE_CALLBACK:
1348
case IPMI_PRIVILEGE_USER:
1350
case IPMI_PRIVILEGE_OPERATOR:
1352
case IPMI_PRIVILEGE_ADMIN:
1354
case IPMI_PRIVILEGE_OEM: