Skip to content

Commit 6ef2b36

Browse files
committed
oem-ibm: Introducing sensor design for SBE ocmb dump
This commit introduces new oem sensor PDRs of state set id - PLDM_OEM_IBM_SBE_DUMP_UPDATE_STATE(32777) whose state will be set for ocmb dump progress status. This change implements the new sensor based dump design only for ocmb sbe dumps whereas the sbe PROC dump design remains unchanged. As part of this change PLDM will be updating the sensor state with dump progress state. The remote terminus will be using polling mechanism on getStateSensorReadings command for dump status update. Tested: 1. Used pldmtool to set numeric effecter for triggering dump. 2. Tested using sbe error injection( unrecoverable by HRESET ) during IPL [1] and during runtime[1]. Also verified the sensor readings post dump completion. Additionally verified SBE PROC dump [2]. [1]: https://gist.github.com/riyadixitagra/1b02a56477d98bfda158e2112aba0476 [2]: https://gist.github.com/riyadixitagra/3f61ec85722acf2f1983a9f2d8f5e4f0 Signed-off-by: Riya Dixit <[email protected]>
1 parent b4100da commit 6ef2b36

File tree

4 files changed

+176
-11
lines changed

4 files changed

+176
-11
lines changed

libpldmresponder/platform.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,11 @@ Response Handler::setNumericEffecterValue(const pldm_msg* request,
772772

773773
int rc = decode_set_numeric_effecter_value_req(
774774
request, payloadLength, &effecterId, &effecterDataSize, effecterValue);
775+
if (rc)
776+
{
777+
error("Failed to decode set numeric effecter value request, RC = {RC}",
778+
"RC", rc);
779+
}
775780

776781
const pldm::utils::DBusHandler dBusIntf;
777782
uint16_t entityType{};

oem/ibm/libpldmresponder/oem_ibm_handler.cpp

+147-11
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ int pldm::responder::oem_ibm_platform::Handler::
6565
sensorOpState = fetchRealSAIStatus();
6666
presentState = PLDM_SENSOR_NORMAL;
6767
}
68+
else if ((entityType == PLDM_ENTITY_MEMORY_MODULE) &&
69+
(stateSetId == PLDM_OEM_IBM_SBE_DUMP_UPDATE_STATE))
70+
{
71+
sensorOpState = fetchDimmStateSensor(entityInstance);
72+
stateField.push_back({PLDM_SENSOR_ENABLED, PLDM_SENSOR_UNKNOWN,
73+
PLDM_SENSOR_UNKNOWN, sensorOpState});
74+
break;
75+
}
6876
else
6977
{
7078
rc = PLDM_PLATFORM_INVALID_STATE_VALUE;
@@ -161,9 +169,14 @@ int pldm::responder::oem_ibm_platform::Handler::
161169

162170
else
163171
{
164-
error("Invalid entity type received: {ENTITY_TYPE}", "ENTITY_TYPE",
165-
entityType);
172+
error(
173+
"Invalid entity type received: {ENTITY_TYPE} for entityInstance '{INSTANCE}'",
174+
"ENTITY_TYPE", entityType, "INSTANCE", entityInstance);
175+
return PLDM_ERROR_INVALID_DATA;
166176
}
177+
info(
178+
"Processing setNumericEffecter on ID {ID} for effecter type {TYPE} and entity instance {INST}",
179+
"ID", effecterId, "TYPE", entityType, "INST", entityInstance);
167180
rc = setNumericEffecter(entityInstance, value, entityType);
168181
}
169182
return rc;
@@ -879,6 +892,57 @@ void buildAllNumericEffecterDimmPDR(oem_ibm_platform::Handler* platformHandler,
879892
}
880893
}
881894

895+
void buildAllDimmSensorPDR(oem_ibm_platform::Handler* platformHandler,
896+
uint16_t entityType, uint16_t stateSetID,
897+
pdr_utils::Repo& repo)
898+
{
899+
size_t pdrSize = 0;
900+
pdrSize = sizeof(pldm_state_sensor_pdr) +
901+
sizeof(state_sensor_possible_states);
902+
std::vector<uint8_t> entry{};
903+
entry.resize(pdrSize);
904+
pldm_state_sensor_pdr* pdr =
905+
reinterpret_cast<pldm_state_sensor_pdr*>(entry.data());
906+
if (!pdr)
907+
{
908+
error("Failed to get record by PDR type, ERROR:{ERR}", "ERR", lg2::hex,
909+
static_cast<unsigned>(PLDM_PLATFORM_INVALID_SENSOR_ID));
910+
return;
911+
}
912+
auto dimm_info = platformHandler->generateDimmIds();
913+
for (const auto& dimm : dimm_info)
914+
{
915+
pdr->hdr.record_handle = 0;
916+
pdr->hdr.version = 1;
917+
pdr->hdr.type = PLDM_STATE_SENSOR_PDR;
918+
pdr->hdr.record_change_num = 0;
919+
pdr->hdr.length = sizeof(pldm_state_sensor_pdr) - sizeof(pldm_pdr_hdr);
920+
pdr->terminus_handle = TERMINUS_HANDLE;
921+
pdr->sensor_id = platformHandler->getNextSensorId();
922+
pdr->entity_type = entityType;
923+
pdr->entity_instance = dimm;
924+
dumpStatusMap[dimm] = DimmDumpState::UNAVAILABLE;
925+
pdr->container_id = 1;
926+
pdr->sensor_init = PLDM_NO_INIT;
927+
pdr->sensor_auxiliary_names_pdr = false;
928+
pdr->composite_sensor_count = 1;
929+
930+
auto* possibleStatesPtr = pdr->possible_states;
931+
auto possibleStates =
932+
reinterpret_cast<state_sensor_possible_states*>(possibleStatesPtr);
933+
possibleStates->state_set_id = stateSetID;
934+
possibleStates->possible_states_size = 1;
935+
auto state =
936+
reinterpret_cast<state_sensor_possible_states*>(possibleStates);
937+
if (stateSetID == PLDM_OEM_IBM_SBE_DUMP_UPDATE_STATE)
938+
state->states[0].byte = 7;
939+
pldm::responder::pdr_utils::PdrEntry pdrEntry{};
940+
pdrEntry.data = entry.data();
941+
pdrEntry.size = pdrSize;
942+
repo.addRecord(pdrEntry);
943+
}
944+
}
945+
882946
void pldm::responder::oem_ibm_platform::Handler::buildOEMPDR(
883947
pdr_utils::Repo& repo)
884948
{
@@ -943,6 +1007,8 @@ void pldm::responder::oem_ibm_platform::Handler::buildOEMPDR(
9431007
buildAllNumericEffecterDimmPDR(
9441008
this, PLDM_ENTITY_MEMORY_MODULE, ENTITY_INSTANCE_0,
9451009
PLDM_OEM_IBM_SBE_SEMANTIC_ID, repo, instanceDimmMap);
1010+
buildAllDimmSensorPDR(this, PLDM_ENTITY_MEMORY_MODULE,
1011+
PLDM_OEM_IBM_SBE_DUMP_UPDATE_STATE, repo);
9461012
auto sensorId = findStateSensorId(
9471013
repo.getPdr(), 0, PLDM_OEM_IBM_ENTITY_FIRMWARE_UPDATE,
9481014
ENTITY_INSTANCE_0, 1, PLDM_OEM_IBM_VERIFICATION_STATE);
@@ -1014,15 +1080,59 @@ int encodeEventMsg(uint8_t eventType, const std::vector<uint8_t>& eventDataVec,
10141080
return rc;
10151081
}
10161082

1083+
void pldm::responder::oem_ibm_platform::Handler::setDimmStateSensor(
1084+
bool status, uint16_t entityInstance)
1085+
{
1086+
auto pdrs = findStateSensorPDR(TERMINUS_ID, PLDM_ENTITY_MEMORY_MODULE,
1087+
PLDM_OEM_IBM_SBE_DUMP_UPDATE_STATE, pdrRepo);
1088+
if (pdrs.empty())
1089+
{
1090+
error(
1091+
"Failed to find state sensor PDR of entity type 'PLDM_ENTITY_MEMORY_MODULE' and state set id 'PLDM_OEM_IBM_SBE_DUMP_UPDATE_STATE' for entity instance = {ENT_INSTANCE}",
1092+
"ENT_INSTANCE", entityInstance);
1093+
return;
1094+
}
1095+
for (auto& pdr : pdrs)
1096+
{
1097+
auto stateSensorPDR =
1098+
reinterpret_cast<pldm_state_sensor_pdr*>(pdr.data());
1099+
if (entityInstance == stateSensorPDR->entity_instance)
1100+
{
1101+
auto sid = stateSensorPDR->sensor_id;
1102+
info(
1103+
"Sending state sensor event for sensor ID {SID} with status {STATUS}",
1104+
"SID", sid, "STATUS", status);
1105+
if (status)
1106+
{
1107+
sendStateSensorEvent(stateSensorPDR->sensor_id,
1108+
PLDM_STATE_SENSOR_STATE, 0,
1109+
uint8_t(DimmDumpState::SUCCESS),
1110+
uint8_t(dumpStatusMap[entityInstance]));
1111+
dumpStatusMap[entityInstance] = DimmDumpState::SUCCESS;
1112+
}
1113+
else
1114+
{
1115+
sendStateSensorEvent(stateSensorPDR->sensor_id,
1116+
PLDM_STATE_SENSOR_STATE, 0,
1117+
uint8_t(DimmDumpState::RETRY),
1118+
uint8_t(dumpStatusMap[entityInstance]));
1119+
dumpStatusMap[entityInstance] = DimmDumpState::RETRY;
1120+
}
1121+
}
1122+
}
1123+
}
1124+
1125+
int pldm::responder::oem_ibm_platform::Handler::fetchDimmStateSensor(
1126+
uint16_t entityInstance)
1127+
{
1128+
return dumpStatusMap[entityInstance];
1129+
}
1130+
10171131
void pldm::responder::oem_ibm_platform::Handler::setHostEffecterState(
10181132
bool status, uint16_t entityTypeReceived, uint16_t entityInstance)
10191133
{
10201134
pldm::pdr::EntityType entityType;
1021-
if (entityTypeReceived == PLDM_ENTITY_MEMORY_MODULE)
1022-
{
1023-
entityType = PLDM_ENTITY_MEMORY_MODULE;
1024-
}
1025-
else if (entityTypeReceived == PLDM_ENTITY_PROC)
1135+
if (entityTypeReceived == PLDM_ENTITY_PROC)
10261136
{
10271137
entityType = PLDM_ENTITY_PROC;
10281138
}
@@ -1055,6 +1165,9 @@ void pldm::responder::oem_ibm_platform::Handler::setHostEffecterState(
10551165

10561166
auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
10571167
std::vector<set_effecter_state_field> stateField;
1168+
info(
1169+
"State effecter ID {EFFECTER_ID} will be set with state as - {STATUS}",
1170+
"EFFECTER_ID", effecterId, "STATUS", status);
10581171
if (status == true)
10591172
{
10601173
stateField.push_back(set_effecter_state_field{
@@ -1141,15 +1254,29 @@ void pldm::responder::oem_ibm_platform::Handler::monitorDump(
11411254
if (propVal ==
11421255
"xyz.openbmc_project.Common.Progress.OperationStatus.Completed")
11431256
{
1144-
setHostEffecterState(true, entityType, entityInstance);
1257+
if (entityType == PLDM_ENTITY_MEMORY_MODULE)
1258+
{
1259+
setDimmStateSensor(true, entityInstance);
1260+
}
1261+
else
1262+
{
1263+
setHostEffecterState(true, entityType, entityInstance);
1264+
}
11451265
}
11461266
else if (
11471267
propVal ==
11481268
"xyz.openbmc_project.Common.Progress.OperationStatus.Failed" ||
11491269
propVal ==
11501270
"xyz.openbmc_project.Common.Progress.OperationStatus.Aborted")
11511271
{
1152-
setHostEffecterState(false, entityType, entityInstance);
1272+
if (entityType == PLDM_ENTITY_MEMORY_MODULE)
1273+
{
1274+
setDimmStateSensor(false, entityInstance);
1275+
}
1276+
else
1277+
{
1278+
setHostEffecterState(false, entityType, entityInstance);
1279+
}
11531280
}
11541281
}
11551282
sbeDumpMatch = nullptr;
@@ -1205,7 +1332,9 @@ int pldm::responder::oem_ibm_platform::Handler::setNumericEffecter(
12051332

12061333
sdbusplus::message::object_path reply;
12071334
response.read(reply);
1208-
1335+
info(
1336+
"Setting numeric effecter of type {TYPE} with entity instance {INST}",
1337+
"TYPE", entityType, "INST", entityInstance);
12091338
monitorDump(reply, entityType, entityInstance);
12101339
}
12111340
catch (const std::exception& e)
@@ -1215,7 +1344,14 @@ int pldm::responder::oem_ibm_platform::Handler::setNumericEffecter(
12151344
"ERR", e);
12161345
// case when the dump policy is disabled but we set the host effecter as
12171346
// true and the host moves on
1218-
setHostEffecterState(true, entityType, entityInstance);
1347+
if (entityType == PLDM_ENTITY_MEMORY_MODULE)
1348+
{
1349+
setDimmStateSensor(true, entityInstance);
1350+
}
1351+
else
1352+
{
1353+
setHostEffecterState(true, entityType, entityInstance);
1354+
}
12191355
}
12201356
return PLDM_SUCCESS;
12211357
}

oem/ibm/libpldmresponder/oem_ibm_handler.hpp

+23
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,19 @@
2121
#include <sdeventplus/event.hpp>
2222
#include <sdeventplus/utility/timer.hpp>
2323

24+
enum ibm_oem_pldm_state_set_dimm_dump_state_values
25+
{
26+
UNAVAILABLE = 0,
27+
SUCCESS = 0x1,
28+
RETRY = 0x2,
29+
};
30+
2431
typedef ibm_oem_pldm_state_set_firmware_update_state_values CodeUpdateState;
2532

33+
typedef ibm_oem_pldm_state_set_dimm_dump_state_values DimmDumpState;
34+
35+
static std::map<uint16_t, int> dumpStatusMap;
36+
2637
namespace pldm
2738
{
2839
namespace responder
@@ -470,6 +481,18 @@ class Handler : public oem_platform::Handler
470481
/** @brief update containerID in PDRs */
471482
void updateContainerID();
472483

484+
/** @brief read the state of a dimm sensor
485+
* @param entityInstance - the entity instance id of the dimm sensor
486+
* @return the state of the sensor
487+
*/
488+
int fetchDimmStateSensor(uint16_t entityInstance);
489+
490+
/** @brief Methode to set the dimm sensor state
491+
* @param status - the status of dump creation
492+
* @param entityInstance - the entity instance id of the sensor
493+
*/
494+
void setDimmStateSensor(bool status, uint16_t entityInstance);
495+
473496
/** @brief setNumericEffecter
474497
*
475498
* @param[in] entityInstance - the entity Instance

pldmtool/oem/ibm/oem_ibm_state_set.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ extern const std::map<uint16_t, std::string> OemIBMstateSet{
5454
{PLDM_OEM_IBM_FIRMWARE_UPDATE_STATE, "OEM IBM Firmware Update State"},
5555
{PLDM_OEM_IBM_BOOT_STATE, "OEM IBM Boot State"},
5656
{PLDM_OEM_IBM_VERIFICATION_STATE, "OEM IBM Verification State"},
57+
{PLDM_OEM_IBM_SBE_DUMP_UPDATE_STATE, "OEM IBM SBE Dump Update State"},
5758
{PLDM_OEM_IBM_SYSTEM_POWER_STATE, "OEM IBM System Power State"}};
5859

5960
/** @brief Map for PLDM OEM IBM firmware update possible state values

0 commit comments

Comments
 (0)