Add support for resource dump delete.
Add support for deleting resource dumps in host memory.
Change requestDelete to accept dump type.
Update system dump delete to pass dump type.
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
Change-Id: I8dcf85a2b38da15ff8451003c11232e340c4ca89
diff --git a/host-transport-extensions/default/default.cpp b/host-transport-extensions/default/default.cpp
index bc49afc..7b613df 100644
--- a/host-transport-extensions/default/default.cpp
+++ b/host-transport-extensions/default/default.cpp
@@ -12,7 +12,7 @@
throw std::runtime_error("Hostdump offload method not specified");
}
-void requestDelete(uint32_t)
+void requestDelete(uint32_t, uint32_t)
{
throw std::runtime_error("Hostdump delete method not specified");
}
diff --git a/host-transport-extensions/pldm/default/pldm_interface.cpp b/host-transport-extensions/pldm/default/pldm_interface.cpp
index f432b03..09b96db 100644
--- a/host-transport-extensions/pldm/default/pldm_interface.cpp
+++ b/host-transport-extensions/pldm/default/pldm_interface.cpp
@@ -21,7 +21,7 @@
throw std::runtime_error("PLDM: Hostdump offload method not specified");
}
-void requestDelete(uint32_t)
+void requestDelete(uint32_t, uint32_t)
{
throw std::runtime_error("PLDM: Hostdump delete method not specified");
}
diff --git a/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp b/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp
index a26a5d3..981076c 100644
--- a/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp
+++ b/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.cpp
@@ -46,9 +46,9 @@
pldm::requestOffload(id);
}
-void requestDelete(uint32_t id)
+void requestDelete(uint32_t id, uint32_t dumpType)
{
- pldm::requestDelete(id);
+ pldm::requestDelete(id, dumpType);
}
} // namespace host
@@ -119,7 +119,7 @@
if (rc != PLDM_SUCCESS)
{
log<level::ERR>("Message encode failure. ", entry("RC=%d", rc));
- elog<NotAllowed>(Reason("Host system dump offload via pldm is not "
+ elog<NotAllowed>(Reason("Host dump offload via pldm is not "
"allowed due to encode failed"));
}
@@ -135,7 +135,7 @@
auto e = errno;
log<level::ERR>("pldm_send failed", entry("RC=%d", rc),
entry("ERRNO=%d", e));
- elog<NotAllowed>(Reason("Host system dump offload via pldm is not "
+ elog<NotAllowed>(Reason("Host dump offload via pldm is not "
"allowed due to fileack send failed"));
}
pldm_msg* response = reinterpret_cast<pldm_msg*>(responseMsg);
@@ -144,12 +144,21 @@
entry("RC=%d", static_cast<uint16_t>(response->payload[0])));
}
-/*
- * Using FileAck pldm command with file type as PLDM_FILE_TYPE_DUMP
- * to delete host system dump
- */
-void requestDelete(uint32_t dumpId)
+void requestDelete(uint32_t dumpId, uint32_t dumpType)
{
+ pldm_fileio_file_type pldmDumpType;
+ switch (dumpType)
+ {
+ case PLDM_FILE_TYPE_DUMP:
+ pldmDumpType = PLDM_FILE_TYPE_DUMP;
+ break;
+ case PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS:
+ pldmDumpType = PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS;
+ break;
+ default:
+ throw std::runtime_error("Unknown pldm dump file-io type to delete "
+ "host dump");
+ }
const size_t pldmMsgHdrSize = sizeof(pldm_msg_hdr);
std::array<uint8_t, pldmMsgHdrSize + PLDM_FILE_ACK_REQ_BYTES> fileAckReqMsg;
@@ -157,21 +166,20 @@
auto pldmInstanceId = getPLDMInstanceID(mctpEndPointId);
- // - PLDM_FILE_TYPE_DUMP - To indicate FileAck for Host system dump
// - PLDM_SUCCESS - To indicate dump was readed (offloaded) or user decided,
- // no longer host system dump is not required so, initiate deletion from
+ // no longer host dump is not required so, initiate deletion from
// host memory
- int retCode = encode_file_ack_req(
- pldmInstanceId, PLDM_FILE_TYPE_DUMP, dumpId, PLDM_SUCCESS,
- reinterpret_cast<pldm_msg*>(fileAckReqMsg.data()));
+ int retCode =
+ encode_file_ack_req(pldmInstanceId, pldmDumpType, dumpId, PLDM_SUCCESS,
+ reinterpret_cast<pldm_msg*>(fileAckReqMsg.data()));
if (retCode != PLDM_SUCCESS)
{
- log<level::ERR>(
- "Failed to encode pldm FileAck to delete host system dump",
- entry("SRC_DUMP_ID=%d", dumpId),
- entry("PLDM_RETURN_CODE=%d", retCode));
- elog<NotAllowed>(Reason("Host system dump deletion via pldm is not "
+ log<level::ERR>("Failed to encode pldm FileAck to delete host dump",
+ entry("SRC_DUMP_ID=%d", dumpId),
+ entry("PLDM_FILE_IO_TYPE=%d", pldmDumpType),
+ entry("PLDM_RETURN_CODE=%d", retCode));
+ elog<NotAllowed>(Reason("Host dump deletion via pldm is not "
"allowed due to encode fileack failed"));
}
@@ -189,13 +197,13 @@
if (retCode != PLDM_REQUESTER_SUCCESS)
{
auto errorNumber = errno;
- log<level::ERR>(
- "Failed to send pldm FileAck to delete host system dump",
- entry("SRC_DUMP_ID=%d", dumpId),
- entry("PLDM_RETURN_CODE=%d", retCode),
- entry("ERRNO=%d", errorNumber),
- entry("ERRMSG=%s", strerror(errorNumber)));
- elog<NotAllowed>(Reason("Host system dump deletion via pldm is not "
+ log<level::ERR>("Failed to send pldm FileAck to delete host dump",
+ entry("SRC_DUMP_ID=%d", dumpId),
+ entry("PLDM_FILE_IO_TYPE=%d", pldmDumpType),
+ entry("PLDM_RETURN_CODE=%d", retCode),
+ entry("ERRNO=%d", errorNumber),
+ entry("ERRMSG=%s", strerror(errorNumber)));
+ elog<NotAllowed>(Reason("Host dump deletion via pldm is not "
"allowed due to fileack send failed"));
}
@@ -207,16 +215,16 @@
if (retCode || completionCode)
{
- log<level::ERR>("Failed to delete host system dump",
+ log<level::ERR>("Failed to delete host dump",
entry("SRC_DUMP_ID=%d", dumpId),
+ entry("PLDM_FILE_IO_TYPE=%d", pldmDumpType),
entry("PLDM_RETURN_CODE=%d", retCode),
entry("PLDM_COMPLETION_CODE=%d", completionCode));
- elog<NotAllowed>(Reason("Host system dump deletion via pldm is "
+ elog<NotAllowed>(Reason("Host dump deletion via pldm is "
"failed"));
}
- log<level::INFO>("Deleted host system dump",
- entry("SRC_DUMP_ID=%d", dumpId));
+ log<level::INFO>("Deleted host dump", entry("SRC_DUMP_ID=%d", dumpId));
}
} // namespace pldm
} // namespace dump
diff --git a/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.hpp b/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.hpp
index 1ab099a..b4b0d9d 100644
--- a/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.hpp
+++ b/host-transport-extensions/pldm/oem/ibm/pldm_oem_cmds.hpp
@@ -20,10 +20,11 @@
* @brief Request to delete dump
*
* @param[in] id - The Dump Source ID.
+ * @param[in] dumpType - Type of the dump.
* @return NULL
*
*/
-void requestDelete(uint32_t id);
+void requestDelete(uint32_t id, uint32_t dumpType);
} // namespace host
namespace pldm
@@ -56,10 +57,11 @@
* @brief Request to delete dump
*
* @param[in] id - The Dump Source ID.
+ * @param[in] dumpType - Type of the dump.
* @return NULL
*
*/
-void requestDelete(uint32_t id);
+void requestDelete(uint32_t id, uint32_t dumpType);
} // namespace pldm
} // namespace dump
} // namespace phosphor