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
2 files changed
tree: a447cad67b514a48c0d0710fc2451f74446ee583
  1. app/
  2. dbus-sdr/
  3. docs/
  4. include/
  5. libipmid/
  6. scripts/
  7. softoff/
  8. subprojects/
  9. test/
  10. user_channel/
  11. xyz/
  12. .build.sh
  13. .clang-format
  14. .gitignore
  15. .shellcheck
  16. .travis.yml
  17. apphandler.cpp
  18. apphandler.hpp
  19. chassishandler.cpp
  20. chassishandler.hpp
  21. dcmihandler.cpp
  22. dcmihandler.hpp
  23. elog-errors.hpp
  24. entity_map_json.cpp
  25. entity_map_json.hpp
  26. error-HostEvent.hpp
  27. fruread.hpp
  28. generate_whitelist.sh
  29. generate_whitelist_create.sh
  30. globalhandler.cpp
  31. globalhandler.hpp
  32. groupext.cpp
  33. host-cmd-manager.cpp
  34. host-cmd-manager.hpp
  35. host-interface.cpp
  36. host-interface.hpp
  37. host-ipmid-whitelist.conf
  38. ipmi_fru_info_area.cpp
  39. ipmi_fru_info_area.hpp
  40. ipmid-new.cpp
  41. ipmisensor.cpp
  42. ipmiwhitelist.hpp
  43. LICENSE
  44. meson.build
  45. meson_options.txt
  46. OWNERS
  47. read_fru_data.cpp
  48. read_fru_data.hpp
  49. README.md
  50. selutility.cpp
  51. selutility.hpp
  52. sensordatahandler.cpp
  53. sensordatahandler.hpp
  54. sensorhandler.cpp
  55. sensorhandler.hpp
  56. settings.cpp
  57. settings.hpp
  58. storageaddsel.cpp
  59. storageaddsel.hpp
  60. storagehandler.cpp
  61. storagehandler.hpp
  62. sys_info_param.cpp
  63. sys_info_param.hpp
  64. systemintfcmds.cpp
  65. systemintfcmds.hpp
  66. testaddsel.cpp
  67. testit.cpp
  68. transporthandler.cpp
  69. transporthandler.hpp
  70. whitelist-filter.cpp
README.md

Compile ipmid with default options:

meson builddir
ninja -C builddir

Compile ipmid with yocto defaults:

meson builddir -Dbuildtype=minsize -Db_lto=true -Dtests=disabled
ninja -C builddir

If any of the dependencies are not found on the host system during configuration, meson automatically gets them via its wrap dependencies mentioned in ipmid/subprojects.

Enable/Disable meson wrap feature

meson builddir -Dwrap_mode=nofallback
ninja -C builddir

Enable debug traces

meson builddir -Dbuildtype=debug
ninja -C builddir

Generate test coverage report:

meson builddir -Db_coverage=true -Dtests=enabled
ninja -C builddir test
ninja -C builddir coverage