Skip to content

Commit e6a77a1

Browse files
committed
Add support for PowerSupplyInformation record in MultiRecord area
There was no nice way to represent 12-bit fields as FixedField-s because the bits appear to be disjoint with the bit and byte orders that are used: MSB first for bits, LSB first for bytes. Here is an illustration of two fields, 4-bit field A and 12-bit field B, where field A is located in the most significant bits of a little-endian 2-byte memory area: B7 B6 B5 B4 B3 B2 B1 B0 A3 A2 A1 A0 B11 B10 B9 B8 I could not find any way to unpack A and B using bitstruct. So, I had to resort to using _mergeBitfield=True. That flag reverses the order of all bytes in a record, thus, converting any multi-byte little-endian fields to big-endian. That way, the bytes and bits have the same ordering and the sub-fields become contiguous: A3 A2 A1 A0 B11 B10 B9 B8 B7 B6 B5 B4 B3 B2 B1 B0 bitstruct can handle this bit order naturally. As a result of using _mergeBitfield, bytes are defined in the opposite order comparing to Table 18-1.
1 parent cb2fc9f commit e6a77a1

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

frugy/multirecords_ipmi.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,65 @@
3030
name in enumerate(fmc_voltages_total)}
3131

3232

33+
@ipmi_multirecord(0x00)
34+
class PowerSupplyInformation(MultirecordEntry):
35+
''' Platform Management FRU Information Storage Definition, Table 18-1 '''
36+
37+
# Need to see the fields as big-endian so that 12-bit sub-fields can be
38+
# properly extracted from 2-byte fields.
39+
_mergeBitfield = True
40+
41+
# TODO: add unit metadata to fields
42+
_schema = [
43+
('predictive_fail_lower_thresh', FixedField, 'u8'),
44+
('combined_wattage', FixedField, 'u16', {'constants': {
45+
'no_combined_voltages': 0
46+
}}),
47+
('voltage1', FixedField, 'u4', {'constants': {
48+
'12v': 0,
49+
'-12v': 1,
50+
'5v': 2,
51+
'3.3v': 3,
52+
}}),
53+
('voltage2', FixedField, 'u4', {'constants': {
54+
'12v': 0,
55+
'-12v': 1,
56+
'5v': 2,
57+
'3.3v': 3,
58+
}}),
59+
('holdup_time', FixedField, 'u4'),
60+
('peak_capacity', FixedField, 'u12', {'constants': {
61+
'unspecified': 0xfff
62+
}}),
63+
('_reserved2', FixedField, 'u3', {'default': 0}),
64+
('pin_polarity', FixedField, 'u1'),
65+
('hot_swap', FixedField, 'u1'),
66+
('autoswitch', FixedField, 'u1'),
67+
('pfc', FixedField, 'u1'),
68+
('predictive_fail_support', FixedField, 'u1'),
69+
('dropout_tolerance', FixedField, 'u8'),
70+
('high_freq', FixedField, 'u8', {'constants': {
71+
'only_dc': 0
72+
}}),
73+
('low_freq', FixedField, 'u8', {'constants': {
74+
'accepts_dc': 0
75+
}}),
76+
('high_input_voltage_2', FixedField, 's16', {'div': 10}), # 10mV
77+
('low_input_voltage_2', FixedField, 's16', {'div': 10}), # 10mV
78+
('high_input_voltage_1', FixedField, 's16', {'div': 10}), # 10mV
79+
('low_input_voltage_1', FixedField, 's16', {'div': 10}), # 10mV
80+
('inrush_interval', FixedField, 'u8'),
81+
('inrush_current', FixedField, 'u8', {'constants': {
82+
'unspecified': 0xff
83+
}}),
84+
('peak_va', FixedField, 'u16', {'constants': {
85+
'unspecified': 0xffff
86+
}}),
87+
('_reserved', FixedField, 'u4', {'default': 0}),
88+
('overall_capacity', FixedField, 'u12'),
89+
]
90+
91+
3392
@ipmi_multirecord(0x01)
3493
class DCOutput(MultirecordEntry):
3594
''' Platform Management FRU Information Storage Definition, Table 18-2 '''

0 commit comments

Comments
 (0)