Add NM discovery SDR support
NM discovery is an Intel OEM SDR,
it is used by external SW to check the NM functionality
Tested:
ipmitool sdr dump sdr.bin
The new added sdr is included at the end of the .bin file:
51 c0 0b 57 01 00 0d 01 2c 60 19 18 1a 1b
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
Change-Id: I2b7e8059908791dcc6853be5ba2b9e22210eb736
diff --git a/src/sensorcommands.cpp b/src/sensorcommands.cpp
index d500a00..f58f0e2 100644
--- a/src/sensorcommands.cpp
+++ b/src/sensorcommands.cpp
@@ -1170,8 +1170,9 @@
return ipmi::response(ret);
}
- size_t lastRecord =
- sensorTree.size() + fruCount + ipmi::storage::type12Count - 1;
+ size_t lastRecord = sensorTree.size() + fruCount +
+ ipmi::storage::type12Count +
+ ipmi::storage::nmDiscoverySDRCount - 1;
if (recordID == lastRecordIndex)
{
recordID = lastRecord;
@@ -1187,7 +1188,28 @@
{
std::vector<uint8_t> recordData;
size_t fruIndex = recordID - sensorTree.size();
- if (fruIndex >= fruCount)
+ size_t type12End = fruCount + ipmi::storage::type12Count;
+
+ if (fruIndex >= type12End)
+ {
+ // NM discovery SDR
+ size_t nmDiscoveryIndex = fruIndex - type12End;
+ if (nmDiscoveryIndex >= ipmi::storage::nmDiscoverySDRCount ||
+ offset > sizeof(NMDiscoveryRecord))
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
+
+ std::vector<uint8_t> record =
+ ipmi::storage::getNMDiscoverySDR(nmDiscoveryIndex, recordID);
+ if (record.size() < (offset + bytesToRead))
+ {
+ bytesToRead = record.size() - offset;
+ }
+ recordData.insert(recordData.end(), record.begin() + offset,
+ record.begin() + offset + bytesToRead);
+ }
+ else if (fruIndex >= fruCount)
{
// handle type 12 hardcoded records
size_t type12Index = fruIndex - fruCount;