pldmd: Migrate instance ID allocation to pldm::InstanceIdDb

This removes use of `pldm::dbus_api::Requester` from around the
code-base. This makes progress towards removing the DBus API entirely
once all its consumers are converted to the libpldm instance ID APIs.

There was never a good reason for the code using the class to have
knowledge that it was related to DBus anyway, so this is, in-effect, a
double clean up improving separation of concerns.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I2d9397cae1b3c8c251c32e36ca520aad9c9b8cf6
diff --git a/oem/ibm/requester/dbus_to_file_handler.cpp b/oem/ibm/requester/dbus_to_file_handler.cpp
index e71116a..9c2b80a 100644
--- a/oem/ibm/requester/dbus_to_file_handler.cpp
+++ b/oem/ibm/requester/dbus_to_file_handler.cpp
@@ -27,25 +27,25 @@
     "xyz.openbmc_project.Common.Progress.OperationStatus.Failed";
 
 DbusToFileHandler::DbusToFileHandler(
-    int mctp_fd, uint8_t mctp_eid, dbus_api::Requester* requester,
+    int mctp_fd, uint8_t mctp_eid, pldm::InstanceIdDb* instanceIdDb,
     sdbusplus::message::object_path resDumpCurrentObjPath,
     pldm::requester::Handler<pldm::requester::Request>* handler) :
     mctp_fd(mctp_fd),
-    mctp_eid(mctp_eid), requester(requester),
+    mctp_eid(mctp_eid), instanceIdDb(instanceIdDb),
     resDumpCurrentObjPath(resDumpCurrentObjPath), handler(handler)
 {}
 
 void DbusToFileHandler::sendNewFileAvailableCmd(uint64_t fileSize)
 {
-    if (requester == NULL)
+    if (instanceIdDb == NULL)
     {
         error(
-            "Failed to send resource dump parameters as requester is not set");
+            "Failed to send resource dump parameters as instance ID DB is not set");
         pldm::utils::reportError(
             "xyz.openbmc_project.bmc.pldm.InternalFailure");
         return;
     }
-    auto instanceId = requester->getInstanceId(mctp_eid);
+    auto instanceId = instanceIdDb->next(mctp_eid);
     std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) +
                                     PLDM_NEW_FILE_REQ_BYTES);
     auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
@@ -57,7 +57,7 @@
                                   fileHandle, fileSize, request);
     if (rc != PLDM_SUCCESS)
     {
-        requester->markFree(mctp_eid, instanceId);
+        instanceIdDb->free(mctp_eid, instanceId);
         error("Failed to encode_new_file_req, rc = {RC}", "RC", rc);
         return;
     }
@@ -247,14 +247,14 @@
                                                    const uint32_t fileHandle,
                                                    const uint16_t type)
 {
-    if (requester == NULL)
+    if (instanceIdDb == NULL)
     {
         error("Failed to send csr to host.");
         pldm::utils::reportError(
             "xyz.openbmc_project.bmc.pldm.InternalFailure");
         return;
     }
-    auto instanceId = requester->getInstanceId(mctp_eid);
+    auto instanceId = instanceIdDb->next(mctp_eid);
     std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) +
                                     PLDM_NEW_FILE_REQ_BYTES);
     auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
@@ -263,7 +263,7 @@
                                   request);
     if (rc != PLDM_SUCCESS)
     {
-        requester->markFree(mctp_eid, instanceId);
+        instanceIdDb->free(mctp_eid, instanceId);
         error("Failed to encode_new_file_req, rc = {RC}", "RC", rc);
         return;
     }
diff --git a/oem/ibm/requester/dbus_to_file_handler.hpp b/oem/ibm/requester/dbus_to_file_handler.hpp
index 60f1b70..a2ba166 100644
--- a/oem/ibm/requester/dbus_to_file_handler.hpp
+++ b/oem/ibm/requester/dbus_to_file_handler.hpp
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
 #include "requester/handler.hpp"
 
 #include <libpldm/platform.h>
@@ -34,12 +34,12 @@
     /** @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] instanceIdDb - pointer to a InstanceIdDb object
      *  @param[in] resDumpCurrentObjPath - resource dump current object path
      *  @param[in] handler - PLDM request handler
      */
     DbusToFileHandler(
-        int mctp_fd, uint8_t mctp_eid, dbus_api::Requester* requester,
+        int mctp_fd, uint8_t mctp_eid, pldm::InstanceIdDb* instanceIdDb,
         sdbusplus::message::object_path resDumpCurrentObjPath,
         pldm::requester::Handler<pldm::requester::Request>* handler);
 
@@ -85,10 +85,8 @@
     /** @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 Pointer to an InstanceIdDb used to obtain PLDM instance id. */
+    pldm::InstanceIdDb* instanceIdDb;
 
     /** @brief Hold the current resource dump object path */
     sdbusplus::message::object_path resDumpCurrentObjPath;