fix sdr count when number > 255
- After PR-60906, it will count the fru data and type 12 sensors.
But when SDR count > 255, there are some problems.
- If the lun of cmd isn't 0, the start position of recordID need to be
updated.
- Using if condition to add type 12 sensors. Because if sensor number
+ fru device is 254, it will overflow after adding 2 type 12 sensors.
- The type of sdrCount is uint8, which means the maximum value is 255,
so it needs to break while loop if the count reaches 255.
refs:
https://gerrit.openbmc.org/c/openbmc/phosphor-host-ipmid/+/60906
TEST:
root@bmc:~# ipmitool sdr elist | wc -l
281 => 0x119
root@bmc:~# ipmitool sdr elist all | wc -l
295 => 0x127
Before:
root@bmc:~# ipmitool raw -l 0 0x04 0x20 0x00
ff 83 c8 56 a2 63
root@bmc:~# ipmitool raw -l 0 0x04 0x20 0x01 ERROR
27 83 c8 56 a2 63
=> count overflow
root@bmc:~# ipmitool raw -l 1 0x04 0x20 0x00
1a 83 c8 56 a2 63
root@bmc:~# ipmitool raw -l 1 0x04 0x20 0x01 ERROR
1c 83 c8 56 a2 63
=> doesn't count the fru data
After:
root@bmc:~# ipmitool raw -l 0 0x04 0x20 0x00
ff 83 3e 2c a3 63
root@bmc:~# ipmitool raw -l 0 0x04 0x20 0x01
ff 83 3e 2c a3 63
root@bmc:~# ipmitool raw -l 1 0x04 0x20 0x00
1a 83 3e 2c a3 63
root@bmc:~# ipmitool raw -l 1 0x04 0x20 0x01
28 83 3e 2c a3 63
If count < 255,
root@bmc:~# ipmitool sdr elist | wc -l
151
root@bmc:~# ipmitool sdr elist all | wc -l
165
root@bmc:~# ipmitool raw -l 0 0x04 0x20 0x00
97 81 f0 2b a2 63
root@bmc:~# ipmitool raw -l 0 0x04 0x20 0x01
a5 81 f0 2b a2 63
Signed-off-by: Harvey Wu <Harvey.Wu@quantatw.com>
Change-Id: Ic4645c82d85e154bea5dc7fdd6b54d1331e58c36
diff --git a/sensorhandler.hpp b/sensorhandler.hpp
index 43ed82f..357ade4 100644
--- a/sensorhandler.hpp
+++ b/sensorhandler.hpp
@@ -191,8 +191,9 @@
SENSOR_DATA_FULL_RECORD = 0x1,
SENSOR_DATA_COMPACT_RECORD = 0x2,
SENSOR_DATA_EVENT_RECORD = 0x3,
- SENSOR_DATA_FRU_RECORD = 0x11,
SENSOR_DATA_ENTITY_RECORD = 0x8,
+ SENSOR_DATA_FRU_RECORD = 0x11,
+ SENSOR_DATA_MGMT_CTRL_LOCATOR = 0x12,
};
// Record key