sensorhandler: Fix Get Sensor Reading threshold bit mapping
IPMI v2.0 (Spec rev 1.1), Table 35 "Get Sensor Reading" defines the
Present threshold comparison status byte as:
[7:6] = 1b (reserved, must read as 1)
[5] = >= Upper Non-Recoverable (UNR)
[4] = >= Upper Critical (UC)
[3] = >= Upper Non-Critical (UNC)
[2] = <= Lower Non-Recoverable (LNR)
[1] = <= Lower Critical (LC)
[0] = <= Lower Non-Critical (LNC)
Previous implementation packed UC/UNC/LC/LNC into bits [3:0] and left
[7:6] unset. This is out of spec and causes the IPMI raw Get Sensor
Reading response to return an incorrect threshold status byte, leading
to misinterpretation by clients.
This change:
* Sets bits [7:6] to 1 as required by the spec.
* Maps UC/UNC/LC/LNC to bits [4]/[3]/[1]/[0], respectively.
* Leaves UNR/LNR ([5]/[2]) as 0 for now (unused in OpenBMC).
Impact: fixes the byte returned by IPMI raw Get Sensor Reading and
makes threshold status reporting spec compliant. No D-Bus or API change.
Testing:
- bitbake phosphor-host-ipmid builds successfully
- on target, ipmitool raw 0x04 0x2d <sensor#> and ipmitool sensor get
show [7:6] = 11b and expected UC, UNC, LC, LNC bit positions
Change-Id: I0a0b07e8fe82357d39329054fed7966bb67f6f91
Signed-off-by: You Peng Wu <twpeng50606@gmail.com>
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index c5dbcfc..0b27090 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -339,11 +339,10 @@
warningAlarmLow = false;
}
response.thresholdLevelsStates =
- (static_cast<uint8_t>(critAlarmHigh) << 3) |
- (static_cast<uint8_t>(critAlarmLow) << 2) |
- (static_cast<uint8_t>(warningAlarmHigh) << 1) |
- (static_cast<uint8_t>(warningAlarmLow));
-
+ 0xC0 | (static_cast<uint8_t>(warningAlarmLow) << 0) |
+ (static_cast<uint8_t>(critAlarmLow) << 1) |
+ (static_cast<uint8_t>(warningAlarmHigh) << 3) |
+ (static_cast<uint8_t>(critAlarmHigh) << 4);
return response;
}