oem-ibm: Resource dump support

This commit includes the changes to support resource dump. Input
parameters to initiate resource dump are vsp string and the
password.

Resource Dump Flow:
1. PLDM waits for the resource dump create signal from
   dump manager
2. BMC sends the NewfileAvailable command to hypervisor with
   resource dump paramters
   Format: <Length of the VSP String><VSP String>
   <Length of the Password><Password>
3. Hypervisor reads and validates the data and send the File Ack
   command back to BMC
4. Once completed, BMC receives the NewfileAvailable command from
   hypervisor with resource dump details
5. User initiates the dump offload
6. BMC receives the  write file by type from memory command from
   hypervisor
7. Once this operation is completed BMC receives the File Ack
   command from hyperviosr

Tested By:
1. Initiating the resource dump using pldmtool, busctl and redfish
2. Verified that resource dump entry is updated with source id,
   length, completion time and status.
3. Dump offload is successful with initiating from redfish
4. Verified that new resource dump is generated at hypervisor level
5. Error scenarios tested are like empty vsp string, not supported
   vsp string etc.

Signed-off-by: Jayashankar Padath <jayashankar.padath@in.ibm.com>
Change-Id: Iedcdf3cf16c263a2d1749bb5251f7f6244c327ea
diff --git a/oem/ibm/libpldm/file_io.h b/oem/ibm/libpldm/file_io.h
index 866a31c..a501c93 100644
--- a/oem/ibm/libpldm/file_io.h
+++ b/oem/ibm/libpldm/file_io.h
@@ -46,14 +46,16 @@
 /** @brief PLDM File I/O table types
  */
 enum pldm_fileio_file_type {
-	PLDM_FILE_TYPE_PEL = 0,
-	PLDM_FILE_TYPE_LID_PERM = 1,
-	PLDM_FILE_TYPE_LID_TEMP = 2,
-	PLDM_FILE_TYPE_DUMP = 3,
-	PLDM_FILE_TYPE_CERT_SIGNING_REQUEST = 4,
-	PLDM_FILE_TYPE_SIGNED_CERT = 5,
-	PLDM_FILE_TYPE_ROOT_CERT = 6,
-	PLDM_FILE_TYPE_LID_MARKER = 7,
+	PLDM_FILE_TYPE_PEL = 0x0,
+	PLDM_FILE_TYPE_LID_PERM = 0x1,
+	PLDM_FILE_TYPE_LID_TEMP = 0x2,
+	PLDM_FILE_TYPE_DUMP = 0x3,
+	PLDM_FILE_TYPE_CERT_SIGNING_REQUEST = 0x4,
+	PLDM_FILE_TYPE_SIGNED_CERT = 0x5,
+	PLDM_FILE_TYPE_ROOT_CERT = 0x6,
+	PLDM_FILE_TYPE_LID_MARKER = 0x7,
+	PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS = 0x8,
+	PLDM_FILE_TYPE_RESOURCE_DUMP = 0x9,
 };
 
 #define PLDM_RW_FILE_MEM_REQ_BYTES 20
diff --git a/oem/ibm/libpldmresponder/file_io.hpp b/oem/ibm/libpldmresponder/file_io.hpp
index 9f6492c..a79c677 100644
--- a/oem/ibm/libpldmresponder/file_io.hpp
+++ b/oem/ibm/libpldmresponder/file_io.hpp
@@ -7,6 +7,7 @@
 #include "oem/ibm/libpldm/host.h"
 
 #include "common/utils.hpp"
+#include "oem/ibm/requester/dbus_to_file_handler.hpp"
 #include "oem_ibm_handler.hpp"
 #include "pldmd/handler.hpp"
 
@@ -155,11 +156,16 @@
 
 namespace oem_ibm
 {
+static constexpr auto dumpObjPath = "/xyz/openbmc_project/dump/resource/entry/";
+static constexpr auto resDumpEntry = "com.ibm.Dump.Entry.Resource";
 class Handler : public CmdHandler
 {
   public:
-    Handler(oem_platform::Handler* oemPlatformHandler) :
-        oemPlatformHandler(oemPlatformHandler)
+    Handler(oem_platform::Handler* oemPlatformHandler, int hostSockFd,
+            uint8_t hostEid, dbus_api::Requester* dbusImplReqester) :
+        oemPlatformHandler(oemPlatformHandler),
+        hostSockFd(hostSockFd), hostEid(hostEid),
+        dbusImplReqester(dbusImplReqester)
     {
         handlers.emplace(PLDM_READ_FILE_INTO_MEMORY,
                          [this](const pldm_msg* request, size_t payloadLength) {
@@ -216,6 +222,48 @@
                              return this->newFileAvailable(request,
                                                            payloadLength);
                          });
+
+        resDumpMatcher = std::make_unique<sdbusplus::bus::match::match>(
+            pldm::utils::DBusHandler::getBus(),
+            sdbusplus::bus::match::rules::interfacesAdded() +
+                sdbusplus::bus::match::rules::argNpath(0, dumpObjPath),
+            [hostSockFd, hostEid,
+             dbusImplReqester](sdbusplus::message::message& msg) {
+                std::map<
+                    std::string,
+                    std::map<std::string, std::variant<std::string, uint32_t>>>
+                    interfaces;
+                sdbusplus::message::object_path path;
+                msg.read(path, interfaces);
+                std::string vspstring;
+                std::string password;
+
+                for (auto& interface : interfaces)
+                {
+                    if (interface.first == resDumpEntry)
+                    {
+                        for (const auto& property : interface.second)
+                        {
+                            if (property.first == "VSPString")
+                            {
+                                vspstring =
+                                    std::get<std::string>(property.second);
+                            }
+                            else if (property.first == "Password")
+                            {
+                                password =
+                                    std::get<std::string>(property.second);
+                            }
+                        }
+                        auto dbusToFileHandler = std::make_unique<
+                            pldm::requester::oem_ibm::DbusToFileHandler>(
+                            hostSockFd, hostEid, dbusImplReqester, path);
+                        dbusToFileHandler->processNewResourceDump(vspstring,
+                                                                  password);
+                        break;
+                    }
+                }
+            });
     }
 
     /** @brief Handler for readFileIntoMemory command
@@ -317,6 +365,15 @@
 
   private:
     oem_platform::Handler* oemPlatformHandler;
+    int hostSockFd;
+    uint8_t hostEid;
+    dbus_api::Requester* dbusImplReqester;
+    using DBusInterfaceAdded = std::vector<std::pair<
+        std::string,
+        std::vector<std::pair<std::string, std::variant<std::string>>>>>;
+    std::unique_ptr<sdbusplus::bus::match::match>
+        resDumpMatcher; //!< Pointer to capture the interface added signal
+                        //!< for new resource dump
 };
 
 } // namespace oem_ibm
diff --git a/oem/ibm/libpldmresponder/file_io_by_type.cpp b/oem/ibm/libpldmresponder/file_io_by_type.cpp
index bdc1332..fd0144e 100644
--- a/oem/ibm/libpldmresponder/file_io_by_type.cpp
+++ b/oem/ibm/libpldmresponder/file_io_by_type.cpp
@@ -130,35 +130,31 @@
         case PLDM_FILE_TYPE_PEL:
         {
             return std::make_unique<PelHandler>(fileHandle);
-            break;
         }
         case PLDM_FILE_TYPE_LID_PERM:
         {
             return std::make_unique<LidHandler>(fileHandle, true);
-            break;
         }
         case PLDM_FILE_TYPE_LID_TEMP:
         {
             return std::make_unique<LidHandler>(fileHandle, false);
-            break;
         }
         case PLDM_FILE_TYPE_LID_MARKER:
         {
             return std::make_unique<LidHandler>(fileHandle, false,
                                                 PLDM_FILE_TYPE_LID_MARKER);
-            break;
         }
         case PLDM_FILE_TYPE_DUMP:
+        case PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS:
+        case PLDM_FILE_TYPE_RESOURCE_DUMP:
         {
-            return std::make_unique<DumpHandler>(fileHandle);
-            break;
+            return std::make_unique<DumpHandler>(fileHandle, fileType);
         }
         case PLDM_FILE_TYPE_CERT_SIGNING_REQUEST:
         case PLDM_FILE_TYPE_SIGNED_CERT:
         case PLDM_FILE_TYPE_ROOT_CERT:
         {
             return std::make_unique<CertHandler>(fileHandle, fileType);
-            break;
         }
         default:
         {
diff --git a/oem/ibm/libpldmresponder/file_io_type_dump.cpp b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
index 04f3639..985a278 100644
--- a/oem/ibm/libpldmresponder/file_io_type_dump.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
@@ -17,6 +17,7 @@
 #include <exception>
 #include <filesystem>
 #include <iostream>
+#include <type_traits>
 
 using namespace pldm::responder::utils;
 using namespace pldm::utils;
@@ -28,34 +29,70 @@
 
 static constexpr auto dumpEntry = "xyz.openbmc_project.Dump.Entry";
 static constexpr auto dumpObjPath = "/xyz/openbmc_project/dump/system";
-int DumpHandler::fd = -1;
+static constexpr auto systemDumpEntry = "xyz.openbmc_project.Dump.Entry.System";
+static constexpr auto resDumpObjPath = "/xyz/openbmc_project/dump/resource";
+static constexpr auto resDumpEntry = "com.ibm.Dump.Entry.Resource";
 
-static std::string findDumpObjPath(uint32_t fileHandle)
+// Resource dump file path to be deleted once hyperviosr validates the input
+// parameters. Need to re-look in to this name when we support multiple
+// resource dumps.
+static constexpr auto resDumpDirPath = "/var/lib/pldm/resourcedump/1";
+
+int DumpHandler::fd = -1;
+namespace fs = std::filesystem;
+
+std::string DumpHandler::findDumpObjPath(uint32_t fileHandle)
 {
     static constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
     static constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
     static constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
-    static constexpr auto systemDumpEntry =
-        "xyz.openbmc_project.Dump.Entry.System";
     auto& bus = pldm::utils::DBusHandler::getBus();
 
+    // Stores the current resource dump entry path
+    std::string curResDumpEntryPath{};
+
     try
     {
         std::vector<std::string> paths;
         auto method = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
                                           MAPPER_INTERFACE, "GetSubTreePaths");
-        method.append(dumpObjPath);
-        method.append(0);
-        method.append(std::vector<std::string>({systemDumpEntry}));
+        if (dumpType == PLDM_FILE_TYPE_DUMP)
+        {
+            method.append(dumpObjPath);
+            method.append(0);
+            method.append(std::vector<std::string>({systemDumpEntry}));
+        }
+        else if ((dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP) ||
+                 (dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS))
+        {
+            method.append(resDumpObjPath);
+            method.append(0);
+            method.append(std::vector<std::string>({resDumpEntry}));
+        }
+
         auto reply = bus.call(method);
         reply.read(paths);
+
         for (const auto& path : paths)
         {
-            auto dumpId = pldm::utils::DBusHandler().getDbusProperty<uint32_t>(
-                path.c_str(), "SourceDumpId", systemDumpEntry);
+            uint32_t dumpId = 0;
+            curResDumpEntryPath = path;
+            if (dumpType == PLDM_FILE_TYPE_DUMP)
+            {
+                dumpId = pldm::utils::DBusHandler().getDbusProperty<uint32_t>(
+                    path.c_str(), "SourceDumpId", systemDumpEntry);
+            }
+            else if (dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP ||
+                     dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS)
+            {
+                dumpId = pldm::utils::DBusHandler().getDbusProperty<uint32_t>(
+                    path.c_str(), "SourceDumpId", resDumpEntry);
+            }
+
             if (dumpId == fileHandle)
             {
-                return path;
+                curResDumpEntryPath = path;
+                break;
             }
         }
     }
@@ -65,9 +102,7 @@
                   << e.what() << "\n";
     }
 
-    std::cerr << "failed to find dump object for dump id " << fileHandle
-              << "\n";
-    return {};
+    return curResDumpEntryPath;
 }
 
 int DumpHandler::newFileAvailable(uint64_t length)
@@ -75,15 +110,38 @@
     static constexpr auto dumpInterface = "xyz.openbmc_project.Dump.NewDump";
     auto& bus = pldm::utils::DBusHandler::getBus();
 
+    auto notifyObjPath = dumpObjPath;
+    if (dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP)
+    {
+        // Setting the Notify path for resource dump
+        notifyObjPath = resDumpObjPath;
+
+        uint32_t sourceDumpId = fileHandle;
+        auto path = findDumpObjPath(fileHandle);
+
+        pldm::utils::PropertyValue propValue{sourceDumpId};
+
+        DBusMapping dbusMapping{path, resDumpEntry, "SourceDumpId", "uint32_t"};
+        try
+        {
+            pldm::utils::DBusHandler().setDbusProperty(dbusMapping, propValue);
+        }
+        catch (const std::exception& e)
+        {
+            std::cerr << "failed to make a d-bus call to DUMP manager to set "
+                         "resource dump SourceDumpId, ERROR="
+                      << e.what() << "\n";
+        }
+    }
+
     try
     {
         auto service =
-            pldm::utils::DBusHandler().getService(dumpObjPath, dumpInterface);
+            pldm::utils::DBusHandler().getService(notifyObjPath, dumpInterface);
         using namespace sdbusplus::xyz::openbmc_project::Dump::server;
-        auto method = bus.new_method_call(service.c_str(), dumpObjPath,
+        auto method = bus.new_method_call(service.c_str(), notifyObjPath,
                                           dumpInterface, "Notify");
         method.append(fileHandle, length);
-
         bus.call_noreply(method);
     }
     catch (const std::exception& e)
@@ -96,7 +154,7 @@
     return PLDM_SUCCESS;
 }
 
-static std::string getOffloadUri(uint32_t fileHandle)
+std::string DumpHandler::getOffloadUri(uint32_t fileHandle)
 {
     auto path = findDumpObjPath(fileHandle);
     if (path.empty())
@@ -121,8 +179,7 @@
     return socketInterface;
 }
 
-int DumpHandler::writeFromMemory(uint32_t /*offset*/, uint32_t length,
-                                 uint64_t address,
+int DumpHandler::writeFromMemory(uint32_t, uint32_t length, uint64_t address,
                                  oem_platform::Handler* /*oemPlatformHandler*/)
 {
     if (DumpHandler::fd == -1)
@@ -145,8 +202,7 @@
     return transferFileDataToSocket(DumpHandler::fd, length, address);
 }
 
-int DumpHandler::write(const char* buffer, uint32_t /*offset*/,
-                       uint32_t& length,
+int DumpHandler::write(const char* buffer, uint32_t, uint32_t& length,
                        oem_platform::Handler* /*oemPlatformHandler*/)
 {
     int rc = writeToUnixSocket(DumpHandler::fd, buffer, length);
@@ -164,12 +220,44 @@
     return PLDM_SUCCESS;
 }
 
-int DumpHandler::fileAck(uint8_t /*fileStatus*/)
+int DumpHandler::fileAck(uint8_t fileStatus)
 {
-    if (DumpHandler::fd >= 0)
+    auto path = findDumpObjPath(fileHandle);
+    if (dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS)
     {
-        auto path = findDumpObjPath(fileHandle);
-        if (!path.empty())
+        if (fileStatus != PLDM_SUCCESS)
+        {
+            std::cerr << "Failue in resource dump file ack" << std::endl;
+            pldm::utils::reportError(
+                "xyz.openbmc_project.bmc.pldm.InternalFailure");
+
+            PropertyValue value{
+                "xyz.openbmc_project.Common.Progress.OperationStatus.Failed"};
+            DBusMapping dbusMapping{path, "xyz.openbmc_project.Common.Progress",
+                                    "Status", "string"};
+            try
+            {
+                pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
+            }
+            catch (const std::exception& e)
+            {
+                std::cerr << "failed to make a d-bus call to DUMP "
+                             "manager, ERROR="
+                          << e.what() << "\n";
+            }
+        }
+
+        if (fs::exists(resDumpDirPath))
+        {
+            fs::remove_all(resDumpDirPath);
+        }
+        return PLDM_SUCCESS;
+    }
+
+    if (DumpHandler::fd >= 0 && !path.empty())
+    {
+        if (dumpType == PLDM_FILE_TYPE_DUMP ||
+            dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP)
         {
             PropertyValue value{true};
             DBusMapping dbusMapping{path, dumpEntry, "Offloaded", "bool"};
@@ -188,12 +276,33 @@
             auto socketInterface = getOffloadUri(fileHandle);
             std::remove(socketInterface.c_str());
             DumpHandler::fd = -1;
-            return PLDM_SUCCESS;
         }
+        return PLDM_SUCCESS;
     }
 
     return PLDM_ERROR;
 }
 
+int DumpHandler::readIntoMemory(uint32_t offset, uint32_t& length,
+                                uint64_t address,
+                                oem_platform::Handler* /*oemPlatformHandler*/)
+{
+    if (dumpType != PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS)
+    {
+        return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
+    }
+    return transferFileData(resDumpDirPath, true, offset, length, address);
+}
+
+int DumpHandler::read(uint32_t offset, uint32_t& length, Response& response,
+                      oem_platform::Handler* /*oemPlatformHandler*/)
+{
+    if (dumpType != PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS)
+    {
+        return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
+    }
+    return readFile(resDumpDirPath, offset, length, response);
+}
+
 } // namespace responder
 } // namespace pldm
diff --git a/oem/ibm/libpldmresponder/file_io_type_dump.hpp b/oem/ibm/libpldmresponder/file_io_type_dump.hpp
index cb4a1ad..2c425d1 100644
--- a/oem/ibm/libpldmresponder/file_io_type_dump.hpp
+++ b/oem/ibm/libpldmresponder/file_io_type_dump.hpp
@@ -17,32 +17,30 @@
   public:
     /** @brief DumpHandler constructor
      */
-    DumpHandler(uint32_t fileHandle) : FileHandler(fileHandle)
+    DumpHandler(uint32_t fileHandle, uint16_t fileType) :
+        FileHandler(fileHandle), dumpType(fileType)
     {}
 
     virtual int writeFromMemory(uint32_t offset, uint32_t length,
                                 uint64_t address,
                                 oem_platform::Handler* /*oemPlatformHandler*/);
 
-    virtual int readIntoMemory(uint32_t /*offset*/, uint32_t& /*length*/,
-                               uint64_t /*address*/,
-                               oem_platform::Handler* /*oemPlatformHandler*/)
-    {
-        return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
-    }
-    virtual int read(uint32_t /*offset*/, uint32_t& /*length*/,
-                     Response& /*response*/,
-                     oem_platform::Handler* /*oemPlatformHandler*/)
-    {
-        return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
-    }
+    virtual int readIntoMemory(uint32_t offset, uint32_t& length,
+                               uint64_t address,
+                               oem_platform::Handler* /*oemPlatformHandler*/);
+
+    virtual int read(uint32_t offset, uint32_t& length, Response& response,
+                     oem_platform::Handler* /*oemPlatformHandler*/);
 
     virtual int write(const char* buffer, uint32_t offset, uint32_t& length,
                       oem_platform::Handler* /*oemPlatformHandler*/);
 
     virtual int newFileAvailable(uint64_t length);
 
-    virtual int fileAck(uint8_t /*fileStatus*/);
+    virtual int fileAck(uint8_t fileStatus);
+
+    std::string findDumpObjPath(uint32_t fileHandle);
+    std::string getOffloadUri(uint32_t fileHandle);
 
     /** @brief DumpHandler destructor
      */
@@ -50,7 +48,8 @@
     {}
 
   private:
-    static int fd; //!< fd to manage the dump offload to bmc
+    static int fd;     //!< fd to manage the dump offload to bmc
+    uint16_t dumpType; //!< type of the dump
 };
 
 } // namespace responder
diff --git a/oem/ibm/requester/dbus_to_file_handler.cpp b/oem/ibm/requester/dbus_to_file_handler.cpp
new file mode 100644
index 0000000..754b901
--- /dev/null
+++ b/oem/ibm/requester/dbus_to_file_handler.cpp
@@ -0,0 +1,195 @@
+#include "dbus_to_file_handler.hpp"
+
+#include "libpldm/requester/pldm.h"
+#include "oem/ibm/libpldm/file_io.h"
+
+#include "common/utils.hpp"
+
+namespace pldm
+{
+namespace requester
+{
+namespace oem_ibm
+{
+
+using namespace pldm::utils;
+using namespace sdbusplus::bus::match::rules;
+
+static constexpr auto resDumpObjPath =
+    "/xyz/openbmc_project/dump/resource/entry";
+static constexpr auto resDumpEntry = "com.ibm.Dump.Entry.Resource";
+static constexpr auto resDumpProgressIntf =
+    "xyz.openbmc_project.Common.Progress";
+static constexpr auto resDumpStatus =
+    "xyz.openbmc_project.Common.Progress.OperationStatus.Failed";
+
+DbusToFileHandler::DbusToFileHandler(
+    int mctp_fd, uint8_t mctp_eid, dbus_api::Requester* requester,
+    sdbusplus::message::object_path resDumpCurrentObjPath) :
+    mctp_fd(mctp_fd),
+    mctp_eid(mctp_eid), requester(requester),
+    resDumpCurrentObjPath(resDumpCurrentObjPath)
+{}
+
+void DbusToFileHandler::sendNewFileAvailableCmd(uint64_t fileSize)
+{
+    if (requester == NULL)
+    {
+        std::cerr << "Failed to send resource dump parameters as requester is "
+                     "not set";
+        pldm::utils::reportError(
+            "xyz.openbmc_project.bmc.pldm.InternalFailure");
+        return;
+    }
+    auto instanceId = requester->getInstanceId(mctp_eid);
+    std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) +
+                                    PLDM_NEW_FILE_REQ_BYTES + fileSize);
+    auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
+    // Need to revisit this logic at the time of multiple resource dump support
+    uint32_t fileHandle = 1;
+
+    auto rc =
+        encode_new_file_req(instanceId, PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS,
+                            fileHandle, fileSize, request);
+    if (rc != PLDM_SUCCESS)
+    {
+        requester->markFree(mctp_eid, instanceId);
+        std::cerr << "Failed to encode_new_file_req, rc = " << rc << std::endl;
+        return;
+    }
+
+    uint8_t* responseMsg = nullptr;
+    size_t responseMsgSize{};
+
+    auto requesterRc =
+        pldm_send_recv(mctp_eid, mctp_fd, requestMsg.data(), requestMsg.size(),
+                       &responseMsg, &responseMsgSize);
+
+    std::unique_ptr<uint8_t, decltype(std::free)*> responseMsgPtr{responseMsg,
+                                                                  std::free};
+
+    requester->markFree(mctp_eid, instanceId);
+    bool isDecodeNewFileRespFailed = false;
+    if (requesterRc != PLDM_REQUESTER_SUCCESS)
+    {
+        std::cerr << "Failed to send resource dump parameters, rc = "
+                  << requesterRc << std::endl;
+    }
+    else
+    {
+        uint8_t completionCode{};
+        auto responsePtr =
+            reinterpret_cast<struct pldm_msg*>(responseMsgPtr.get());
+
+        rc = decode_new_file_resp(responsePtr, PLDM_NEW_FILE_RESP_BYTES,
+                                  &completionCode);
+
+        if (rc != PLDM_SUCCESS || completionCode != PLDM_SUCCESS)
+        {
+            std::cerr << "Failed to decode_new_file_resp: "
+                      << "rc=" << rc
+                      << ", cc=" << static_cast<unsigned>(completionCode)
+                      << std::endl;
+            isDecodeNewFileRespFailed = true;
+        }
+    }
+
+    if ((requesterRc != PLDM_REQUESTER_SUCCESS) || (isDecodeNewFileRespFailed))
+    {
+        pldm::utils::reportError(
+            "xyz.openbmc_project.bmc.pldm.InternalFailure");
+
+        PropertyValue value{resDumpStatus};
+        DBusMapping dbusMapping{resDumpCurrentObjPath, resDumpProgressIntf,
+                                "Status", "string"};
+        try
+        {
+            pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
+        }
+        catch (const std::exception& e)
+        {
+            std::cerr << "failed to set resource dump operation status, "
+                         "ERROR="
+                      << e.what() << "\n";
+        }
+    }
+}
+
+void DbusToFileHandler::processNewResourceDump(
+    const std::string& vspString, const std::string& resDumpReqPass)
+{
+    // This needs special handling in later point of time. Resource dump without
+    // the vsp string is supposed to be a non-disruptive system dump.
+    if (vspString.empty())
+    {
+        std::cerr << "Empty vsp string"
+                  << "\n";
+        PropertyValue value{resDumpStatus};
+        DBusMapping dbusMapping{resDumpCurrentObjPath, resDumpProgressIntf,
+                                "Status", "string"};
+        try
+        {
+            pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
+        }
+        catch (const std::exception& e)
+        {
+            std::cerr << "failed to set resource dump operation status, "
+                         "ERROR="
+                      << e.what() << "\n";
+        }
+        return;
+    }
+
+    namespace fs = std::filesystem;
+    const fs::path resDumpDirPath = "/var/lib/pldm/resourcedump";
+
+    if (!fs::exists(resDumpDirPath))
+    {
+        fs::create_directories(resDumpDirPath);
+    }
+
+    // Need to reconsider this logic to set the value as "1" when we have the
+    // support to handle multiple resource dumps
+    fs::path resDumpFilePath = resDumpDirPath / "1";
+
+    std::ofstream fileHandle;
+    fileHandle.open(resDumpFilePath, std::ios::out | std::ofstream::binary);
+
+    if (!fileHandle)
+    {
+        std::cerr << "resource dump file open error: " << resDumpFilePath
+                  << "\n";
+        PropertyValue value{resDumpStatus};
+        DBusMapping dbusMapping{resDumpCurrentObjPath, resDumpProgressIntf,
+                                "Status", "string"};
+        try
+        {
+            pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
+        }
+        catch (const std::exception& e)
+        {
+            std::cerr << "failed to set resource dump operation status, "
+                         "ERROR="
+                      << e.what() << "\n";
+        }
+        return;
+    }
+
+    // Fill up the file with resource dump parameters and respective sizes
+    auto fileFunc = [&fileHandle](auto& paramBuf) {
+        uint32_t paramSize = paramBuf.size();
+        fileHandle.write((char*)&paramSize, sizeof(paramSize));
+        fileHandle << paramBuf;
+    };
+    fileFunc(vspString);
+    fileFunc(resDumpReqPass);
+
+    fileHandle.close();
+    size_t fileSize = fs::file_size(resDumpFilePath);
+
+    sendNewFileAvailableCmd(fileSize);
+}
+
+} // namespace oem_ibm
+} // namespace requester
+} // namespace pldm
diff --git a/oem/ibm/requester/dbus_to_file_handler.hpp b/oem/ibm/requester/dbus_to_file_handler.hpp
new file mode 100644
index 0000000..b6e8b5d
--- /dev/null
+++ b/oem/ibm/requester/dbus_to_file_handler.hpp
@@ -0,0 +1,74 @@
+#pragma once
+
+#include "libpldm/platform.h"
+
+#include "pldmd/dbus_impl_requester.hpp"
+
+#include <filesystem>
+#include <fstream>
+#include <map>
+
+using namespace pldm::dbus_api;
+
+namespace pldm
+{
+namespace requester
+{
+namespace oem_ibm
+{
+
+/** @class DbusToFileHandler
+ *  @brief This class can process resource dump parameters and send PLDM
+ *         new file available cmd to the hypervisor. This class can be used
+ *         as a pldm requester in oem-ibm path.
+ */
+class DbusToFileHandler
+{
+  public:
+    DbusToFileHandler(const DbusToFileHandler&) = delete;
+    DbusToFileHandler(DbusToFileHandler&&) = delete;
+    DbusToFileHandler& operator=(const DbusToFileHandler&) = delete;
+    DbusToFileHandler& operator=(DbusToFileHandler&&) = delete;
+    ~DbusToFileHandler() = default;
+
+    /** @brief Constructor
+     *  @param[in] mctp_fd - fd of MCTP communications socket
+     *  @param[in] mctp_eid - MCTP EID of host firmware
+     *  @param[in] requester - pointer to a Requester object
+     *  @param[in] resDumpCurrentObjPath - resource dump current object path
+     */
+    DbusToFileHandler(int mctp_fd, uint8_t mctp_eid,
+                      dbus_api::Requester* requester,
+                      sdbusplus::message::object_path resDumpCurrentObjPath);
+
+    /** @brief Process the new resource dump request
+     *  @param[in] vspString - vsp string
+     *  @param[in] resDumpReqPass - resource dump password
+     */
+    void processNewResourceDump(const std::string& vspString,
+                                const std::string& resDumpReqPass);
+
+  private:
+    /** @brief Send the new file available command request to hypervisor
+     *  @param[in] fileSize - size of the file
+     */
+    void sendNewFileAvailableCmd(uint64_t fileSize);
+
+    /** @brief fd of MCTP communications socket */
+    int mctp_fd;
+
+    /** @brief MCTP EID of host firmware */
+    uint8_t mctp_eid;
+
+    /** @brief Pointer to a Requester object, primarily used to access API to
+     *  obtain PLDM instance id.
+     */
+    dbus_api::Requester* requester;
+
+    /** @brief Hold the current resource dump object path */
+    sdbusplus::message::object_path resDumpCurrentObjPath;
+};
+
+} // namespace oem_ibm
+} // namespace requester
+} // namespace pldm
diff --git a/oem/ibm/test/libpldmresponder_fileio_test.cpp b/oem/ibm/test/libpldmresponder_fileio_test.cpp
index 65998a7..a0b5a5e 100644
--- a/oem/ibm/test/libpldmresponder_fileio_test.cpp
+++ b/oem/ibm/test/libpldmresponder_fileio_test.cpp
@@ -818,6 +818,14 @@
     auto dumpType = dynamic_cast<DumpHandler*>(handler.get());
     ASSERT_TRUE(dumpType != nullptr);
 
+    handler = getHandlerByType(PLDM_FILE_TYPE_RESOURCE_DUMP_PARMS, fileHandle);
+    dumpType = dynamic_cast<DumpHandler*>(handler.get());
+    ASSERT_TRUE(dumpType != nullptr);
+
+    handler = getHandlerByType(PLDM_FILE_TYPE_RESOURCE_DUMP, fileHandle);
+    dumpType = dynamic_cast<DumpHandler*>(handler.get());
+    ASSERT_TRUE(dumpType != nullptr);
+
     handler = getHandlerByType(PLDM_FILE_TYPE_CERT_SIGNING_REQUEST, fileHandle);
     auto certType = dynamic_cast<CertHandler*>(handler.get());
     ASSERT_TRUE(certType != nullptr);