dbus-sdr: implement SDR Record Type 8
- implement SDR Record Type 8 sensor like ipmi_entity_get_sdr function
in sensorhandler.cpp, and will locate at the last of SDR list
TEST:
~# ipmitool sdr elist all -vvv
...
...
...
SDR record ID : 0x00d9
SDR record type : 0x08
SDR record next : 0x00da
SDR record bytes: 11
Getting 11 bytes from SDR at offset 5
SDR record ID : 0x00d9
SDR record ID : 0x00da
SDR record type : 0x08
SDR record next : 0xffff
SDR record bytes: 11
Getting 11 bytes from SDR at offset 5
SDR record ID : 0x00da
~# ipmitool raw 0x04 0x21 0x00 0x00 0xd9 0x00 0x00 0xff
da 00 d9 00 51 08 0b 1e 00 80 0b 03 0b 07 1d 00
1d 01
~# ipmitool raw 0x04 0x21 0x00 0x00 0xda 0x00 0x00 0xff
ff ff da 00 51 08 0b 1e 01 80 0b 08 0b 0b 1d 02
1d 03
Signed-off-by: Harvey Wu <Harvey.Wu@quantatw.com>
Change-Id: I4998532402158f299dcb34c29734b23b5f8dc719
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index 4e971b3..81bdf23 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -19,6 +19,7 @@
#include "dbus-sdr/sdrutils.hpp"
#include "dbus-sdr/sensorutils.hpp"
#include "dbus-sdr/storagecommands.hpp"
+#include "entity_map_json.hpp"
#include <algorithm>
#include <array>
@@ -1925,8 +1926,13 @@
return GENERAL_ERROR;
}
- size_t lastRecord =
- getNumberOfSensors() + fruCount + ipmi::storage::type12Count - 1;
+ const auto& entityRecords =
+ ipmi::sensor::EntityInfoMapContainer::getContainer()
+ ->getIpmiEntityRecords();
+ size_t entityCount = entityRecords.size();
+
+ size_t lastRecord = getNumberOfSensors() + fruCount +
+ ipmi::storage::type12Count + entityCount - 1;
if (recordID == lastRecordIndex)
{
recordID = lastRecord;
@@ -1940,12 +1946,24 @@
if (recordID >= getNumberOfSensors())
{
- size_t fruIndex = recordID - getNumberOfSensors();
+ size_t sdrIndex = recordID - getNumberOfSensors();
- if (fruIndex >= fruCount)
+ if (sdrIndex >= fruCount + ipmi::storage::type12Count)
+ {
+ // handle type 8 entity map records
+ ipmi::sensor::EntityInfoMap::const_iterator entity =
+ entityRecords.find(static_cast<uint8_t>(
+ sdrIndex - fruCount - ipmi::storage::type12Count));
+ if (entity == entityRecords.end())
+ {
+ return IPMI_CC_SENSOR_INVALID;
+ }
+ recordData = ipmi::storage::getType8SDRs(entity, recordID);
+ }
+ else if (sdrIndex >= fruCount)
{
// handle type 12 hardcoded records
- size_t type12Index = fruIndex - fruCount;
+ size_t type12Index = sdrIndex - fruCount;
if (type12Index >= ipmi::storage::type12Count)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -1958,7 +1976,7 @@
{
// handle fru records
get_sdr::SensorDataFruRecord data;
- ret = ipmi::storage::getFruSdrs(ctx, fruIndex, data);
+ ret = ipmi::storage::getFruSdrs(ctx, sdrIndex, data);
if (ret != IPMI_CC_OK)
{
return GENERAL_ERROR;
@@ -2315,9 +2333,14 @@
return ipmi::response(ret);
}
+ const auto& entityRecords =
+ ipmi::sensor::EntityInfoMapContainer::getContainer()
+ ->getIpmiEntityRecords();
+ int entityCount = entityRecords.size();
+
auto& sensorTree = getSensorTree();
- size_t lastRecord =
- getNumberOfSensors() + fruCount + ipmi::storage::type12Count - 1;
+ size_t lastRecord = getNumberOfSensors() + fruCount +
+ ipmi::storage::type12Count + entityCount - 1;
uint16_t nextRecordId = lastRecord > recordID ? recordID + 1 : 0XFFFF;
if (!getSensorSubtree(sensorTree) && sensorTree.empty())