Skip to content

Commit 6b36977

Browse files
riyadixitagraArchanaKakani
authored andcommitted
oem-ibm: Introducing sensor design for SBE ocmb dump (ibm-openbmc#622)
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 595b557 commit 6b36977

File tree

5 files changed

+178
-13
lines changed

5 files changed

+178
-13
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
@@ -66,6 +66,14 @@ int pldm::responder::oem_ibm_platform::Handler::
6666
sensorOpState = fetchRealSAIStatus();
6767
presentState = PLDM_SENSOR_NORMAL;
6868
}
69+
else if ((entityType == PLDM_ENTITY_MEMORY_MODULE) &&
70+
(stateSetId == PLDM_OEM_IBM_SBE_DUMP_UPDATE_STATE))
71+
{
72+
sensorOpState = fetchDimmStateSensor(entityInstance);
73+
stateField.push_back({PLDM_SENSOR_ENABLED, PLDM_SENSOR_UNKNOWN,
74+
PLDM_SENSOR_UNKNOWN, sensorOpState});
75+
break;
76+
}
6977
else
7078
{
7179
rc = PLDM_PLATFORM_INVALID_STATE_VALUE;
@@ -162,9 +170,14 @@ int pldm::responder::oem_ibm_platform::Handler::
162170

163171
else
164172
{
165-
error("Invalid entity type received: {ENTITY_TYPE}", "ENTITY_TYPE",
166-
entityType);
173+
error(
174+
"Invalid entity type received: {ENTITY_TYPE} for entityInstance '{INSTANCE}'",
175+
"ENTITY_TYPE", entityType, "INSTANCE", entityInstance);
176+
return PLDM_ERROR_INVALID_DATA;
167177
}
178+
info(
179+
"Processing setNumericEffecter on ID {ID} for effecter type {TYPE} and entity instance {INST}",
180+
"ID", effecterId, "TYPE", entityType, "INST", entityInstance);
168181
rc = setNumericEffecter(entityInstance, value, entityType);
169182
}
170183
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);
@@ -1015,15 +1081,59 @@ int encodeEventMsg(uint8_t eventType, const std::vector<uint8_t>& eventDataVec,
10151081
return rc;
10161082
}
10171083

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

10571167
auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
10581168
std::vector<set_effecter_state_field> stateField;
1169+
info(
1170+
"State effecter ID {EFFECTER_ID} will be set with state as - {STATUS}",
1171+
"EFFECTER_ID", effecterId, "STATUS", status);
10591172
if (status == true)
10601173
{
10611174
stateField.push_back(set_effecter_state_field{
@@ -1142,15 +1255,29 @@ void pldm::responder::oem_ibm_platform::Handler::monitorDump(
11421255
if (propVal ==
11431256
"xyz.openbmc_project.Common.Progress.OperationStatus.Completed")
11441257
{
1145-
setHostEffecterState(true, entityType, entityInstance);
1258+
if (entityType == PLDM_ENTITY_MEMORY_MODULE)
1259+
{
1260+
setDimmStateSensor(true, entityInstance);
1261+
}
1262+
else
1263+
{
1264+
setHostEffecterState(true, entityType, entityInstance);
1265+
}
11461266
}
11471267
else if (
11481268
propVal ==
11491269
"xyz.openbmc_project.Common.Progress.OperationStatus.Failed" ||
11501270
propVal ==
11511271
"xyz.openbmc_project.Common.Progress.OperationStatus.Aborted")
11521272
{
1153-
setHostEffecterState(false, entityType, entityInstance);
1273+
if (entityType == PLDM_ENTITY_MEMORY_MODULE)
1274+
{
1275+
setDimmStateSensor(false, entityInstance);
1276+
}
1277+
else
1278+
{
1279+
setHostEffecterState(false, entityType, entityInstance);
1280+
}
11541281
}
11551282
}
11561283
sbeDumpMatch = nullptr;
@@ -1206,7 +1333,9 @@ int pldm::responder::oem_ibm_platform::Handler::setNumericEffecter(
12061333

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

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
@@ -489,6 +500,18 @@ class Handler : public oem_platform::Handler
489500
/** @brief update containerID in PDRs */
490501
void updateContainerID();
491502

503+
/** @brief read the state of a dimm sensor
504+
* @param entityInstance - the entity instance id of the dimm sensor
505+
* @return the state of the sensor
506+
*/
507+
int fetchDimmStateSensor(uint16_t entityInstance);
508+
509+
/** @brief Methode to set the dimm sensor state
510+
* @param status - the status of dump creation
511+
* @param entityInstance - the entity instance id of the sensor
512+
*/
513+
void setDimmStateSensor(bool status, uint16_t entityInstance);
514+
492515
/** @brief setNumericEffecter
493516
*
494517
* @param[in] entityInstance - the entity Instance

oem/ibm/test/libpldmresponder_oem_platform_test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ TEST(generateStateEffecterOEMPDR, testGoodRequest)
233233
getSubtree("/xyz/openbmc_project/inventory/system", 0,
234234
std::vector<std::string>{
235235
"xyz.openbmc_project.Inventory.Item.Dimm"}))
236-
.WillOnce(Return(mockDimmResponse));
236+
.WillRepeatedly(Return(mockDimmResponse));
237237

238238
std::unique_ptr<MockOemPlatformHandler> mockoemPlatformHandler =
239239
std::make_unique<MockOemPlatformHandler>(
@@ -395,7 +395,7 @@ TEST(generateStateSensorOEMPDR, testGoodRequest)
395395
getSubtree("/xyz/openbmc_project/inventory/system", 0,
396396
std::vector<std::string>{
397397
"xyz.openbmc_project.Inventory.Item.Dimm"}))
398-
.WillOnce(Return(mockDimmResponse));
398+
.WillRepeatedly(Return(mockDimmResponse));
399399

400400
std::unique_ptr<MockOemPlatformHandler> mockoemPlatformHandler =
401401
std::make_unique<MockOemPlatformHandler>(

pldmtool/oem/ibm/oem_ibm_state_set.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ extern const std::map<uint16_t, std::string> OemIBMstateSet{
5858
{PLDM_OEM_IBM_FIRMWARE_UPDATE_STATE, "OEM IBM Firmware Update State"},
5959
{PLDM_OEM_IBM_BOOT_STATE, "OEM IBM Boot State"},
6060
{PLDM_OEM_IBM_VERIFICATION_STATE, "OEM IBM Verification State"},
61+
{PLDM_OEM_IBM_SBE_DUMP_UPDATE_STATE, "OEM IBM SBE Dump Update State"},
6162
{PLDM_OEM_IBM_SYSTEM_POWER_STATE, "OEM IBM System Power State"}};
6263

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

0 commit comments

Comments
 (0)