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/fw-update/device_updater.cpp b/fw-update/device_updater.cpp
index 4009a48..20bca0c 100644
--- a/fw-update/device_updater.cpp
+++ b/fw-update/device_updater.cpp
@@ -19,7 +19,7 @@
void DeviceUpdater::startFwUpdateFlow()
{
- auto instanceId = updateManager->requester.getInstanceId(eid);
+ auto instanceId = updateManager->instanceIdDb.next(eid);
// NumberOfComponents
const auto& applicableComponents =
std::get<ApplicableComponents>(fwDeviceIDRecord);
@@ -48,7 +48,7 @@
sizeof(struct pldm_request_update_req) + compImgSetVerStrInfo.length);
if (rc)
{
- updateManager->requester.markFree(eid, instanceId);
+ updateManager->instanceIdDb.free(eid, instanceId);
error("encode_request_update_req failed, EID = {EID}, RC = {RC}", "EID",
unsigned(eid), "RC", rc);
// Handle error scenario
@@ -107,7 +107,7 @@
{
pldmRequest.reset();
- auto instanceId = updateManager->requester.getInstanceId(eid);
+ auto instanceId = updateManager->instanceIdDb.next(eid);
// TransferFlag
const auto& applicableComponents =
std::get<ApplicableComponents>(fwDeviceIDRecord);
@@ -170,7 +170,7 @@
sizeof(pldm_pass_component_table_req) + compVerStrInfo.length);
if (rc)
{
- updateManager->requester.markFree(eid, instanceId);
+ updateManager->instanceIdDb.free(eid, instanceId);
error("encode_pass_component_table_req failed, EID = {EID}, RC = {RC}",
"EID", unsigned(eid), "RC", rc);
// Handle error scenario
@@ -249,7 +249,7 @@
{
pldmRequest.reset();
- auto instanceId = updateManager->requester.getInstanceId(eid);
+ auto instanceId = updateManager->instanceIdDb.next(eid);
const auto& applicableComponents =
std::get<ApplicableComponents>(fwDeviceIDRecord);
const auto& comp = compImageInfos[applicableComponents[offset]];
@@ -297,7 +297,7 @@
sizeof(pldm_update_component_req) + compVerStrInfo.length);
if (rc)
{
- updateManager->requester.markFree(eid, instanceId);
+ updateManager->instanceIdDb.free(eid, instanceId);
error("encode_update_component_req failed, EID={EID}, RC = {RC}", "EID",
unsigned(eid), "RC", rc);
// Handle error scenario
@@ -631,7 +631,7 @@
void DeviceUpdater::sendActivateFirmwareRequest()
{
pldmRequest.reset();
- auto instanceId = updateManager->requester.getInstanceId(eid);
+ auto instanceId = updateManager->instanceIdDb.next(eid);
Request request(sizeof(pldm_msg_hdr) +
sizeof(struct pldm_activate_firmware_req));
auto requestMsg = reinterpret_cast<pldm_msg*>(request.data());
@@ -641,7 +641,7 @@
sizeof(pldm_activate_firmware_req));
if (rc)
{
- updateManager->requester.markFree(eid, instanceId);
+ updateManager->instanceIdDb.free(eid, instanceId);
error("encode_activate_firmware_req failed, EID={EID}, RC = {RC}",
"EID", unsigned(eid), "RC", rc);
}
diff --git a/fw-update/inventory_manager.cpp b/fw-update/inventory_manager.cpp
index ea80e69..f5a797b 100644
--- a/fw-update/inventory_manager.cpp
+++ b/fw-update/inventory_manager.cpp
@@ -19,7 +19,7 @@
{
for (const auto& eid : eids)
{
- auto instanceId = requester.getInstanceId(eid);
+ auto instanceId = instanceIdDb.next(eid);
Request requestMsg(sizeof(pldm_msg_hdr) +
PLDM_QUERY_DEVICE_IDENTIFIERS_REQ_BYTES);
auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
@@ -27,7 +27,7 @@
instanceId, PLDM_QUERY_DEVICE_IDENTIFIERS_REQ_BYTES, request);
if (rc)
{
- requester.markFree(eid, instanceId);
+ instanceIdDb.free(eid, instanceId);
error(
"encode_query_device_identifiers_req failed, EID={EID}, RC = {RC}",
"EID", unsigned(eid), "RC", rc);
@@ -150,7 +150,7 @@
void InventoryManager::sendGetFirmwareParametersRequest(mctp_eid_t eid)
{
- auto instanceId = requester.getInstanceId(eid);
+ auto instanceId = instanceIdDb.next(eid);
Request requestMsg(sizeof(pldm_msg_hdr) +
PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES);
auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
@@ -158,7 +158,7 @@
instanceId, PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES, request);
if (rc)
{
- requester.markFree(eid, instanceId);
+ instanceIdDb.free(eid, instanceId);
error("encode_get_firmware_parameters_req failed, EID={EID}, RC = {RC}",
"EID", unsigned(eid), "RC", rc);
return;
diff --git a/fw-update/inventory_manager.hpp b/fw-update/inventory_manager.hpp
index 1bca43f..ae5030f 100644
--- a/fw-update/inventory_manager.hpp
+++ b/fw-update/inventory_manager.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "common/types.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include <libpldm/pldm.h>
@@ -33,7 +33,7 @@
/** @brief Constructor
*
* @param[in] handler - PLDM request handler
- * @param[in] requester - Managing instance ID for PLDM requests
+ * @param[in] instanceIdDb - Managing instance ID for PLDM requests
* @param[out] descriptorMap - Populate the firmware identifers for the
* FDs managed by the BMC.
* @param[out] componentInfoMap - Populate the component info for the FDs
@@ -41,10 +41,10 @@
*/
explicit InventoryManager(
pldm::requester::Handler<pldm::requester::Request>& handler,
- pldm::dbus_api::Requester& requester, DescriptorMap& descriptorMap,
+ InstanceIdDb& instanceIdDb, DescriptorMap& descriptorMap,
ComponentInfoMap& componentInfoMap) :
handler(handler),
- requester(requester), descriptorMap(descriptorMap),
+ instanceIdDb(instanceIdDb), descriptorMap(descriptorMap),
componentInfoMap(componentInfoMap)
{}
@@ -93,8 +93,8 @@
/** @brief PLDM request handler */
pldm::requester::Handler<pldm::requester::Request>& handler;
- /** @brief D-Bus API for managing instance ID*/
- pldm::dbus_api::Requester& requester;
+ /** @brief Instance ID database for managing instance ID*/
+ InstanceIdDb& instanceIdDb;
/** @brief Device identifiers of the managed FDs */
DescriptorMap& descriptorMap;
diff --git a/fw-update/manager.hpp b/fw-update/manager.hpp
index 8c2f2e1..46a3285 100644
--- a/fw-update/manager.hpp
+++ b/fw-update/manager.hpp
@@ -4,7 +4,7 @@
#include "common/types.hpp"
#include "device_updater.hpp"
#include "inventory_manager.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include "update_manager.hpp"
@@ -19,8 +19,6 @@
namespace fw_update
{
-using namespace pldm::dbus_api;
-
/** @class Manager
*
* This class handles all the aspects of the PLDM FW update specification for
@@ -42,9 +40,9 @@
*/
explicit Manager(Event& event,
requester::Handler<requester::Request>& handler,
- Requester& requester) :
- inventoryMgr(handler, requester, descriptorMap, componentInfoMap),
- updateManager(event, handler, requester, descriptorMap,
+ pldm::InstanceIdDb& instanceIdDb) :
+ inventoryMgr(handler, instanceIdDb, descriptorMap, componentInfoMap),
+ updateManager(event, handler, instanceIdDb, descriptorMap,
componentInfoMap)
{}
diff --git a/fw-update/test/device_updater_test.cpp b/fw-update/test/device_updater_test.cpp
index 2e237e3..ba2b16f 100644
--- a/fw-update/test/device_updater_test.cpp
+++ b/fw-update/test/device_updater_test.cpp
@@ -1,7 +1,7 @@
#include "common/utils.hpp"
#include "fw-update/device_updater.hpp"
#include "fw-update/package_parser.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include <libpldm/firmware_update.h>
diff --git a/fw-update/test/inventory_manager_test.cpp b/fw-update/test/inventory_manager_test.cpp
index 1f7d142..3876563 100644
--- a/fw-update/test/inventory_manager_test.cpp
+++ b/fw-update/test/inventory_manager_test.cpp
@@ -16,18 +16,15 @@
protected:
InventoryManagerTest() :
event(sdeventplus::Event::get_default()), instanceIdDb(),
- dbusImplRequester(pldm::utils::DBusHandler::getBus(),
- "/xyz/openbmc_project/pldm", instanceIdDb),
- reqHandler(fd, event, dbusImplRequester, false, 90000, seconds(1), 2,
+ reqHandler(fd, event, instanceIdDb, false, 90000, seconds(1), 2,
milliseconds(100)),
- inventoryManager(reqHandler, dbusImplRequester, outDescriptorMap,
+ inventoryManager(reqHandler, instanceIdDb, outDescriptorMap,
outComponentInfoMap)
{}
int fd = -1;
sdeventplus::Event event;
TestInstanceIdDb instanceIdDb;
- pldm::dbus_api::Requester dbusImplRequester;
requester::Handler<requester::Request> reqHandler;
InventoryManager inventoryManager;
DescriptorMap outDescriptorMap{};
diff --git a/fw-update/update_manager.hpp b/fw-update/update_manager.hpp
index 64cf222..00ddc0c 100644
--- a/fw-update/update_manager.hpp
+++ b/fw-update/update_manager.hpp
@@ -3,7 +3,7 @@
#include "common/types.hpp"
#include "device_updater.hpp"
#include "package_parser.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include "watch.hpp"
@@ -24,7 +24,6 @@
using namespace sdeventplus;
using namespace sdeventplus::source;
-using namespace pldm::dbus_api;
using namespace pldm;
using DeviceIDRecordOffset = size_t;
@@ -48,11 +47,11 @@
explicit UpdateManager(
Event& event,
pldm::requester::Handler<pldm::requester::Request>& handler,
- Requester& requester, const DescriptorMap& descriptorMap,
+ InstanceIdDb& instanceIdDb, const DescriptorMap& descriptorMap,
const ComponentInfoMap& componentInfoMap) :
event(event),
- handler(handler), requester(requester), descriptorMap(descriptorMap),
- componentInfoMap(componentInfoMap),
+ handler(handler), instanceIdDb(instanceIdDb),
+ descriptorMap(descriptorMap), componentInfoMap(componentInfoMap),
watch(event.get(),
std::bind_front(&UpdateManager::processPackage, this))
{}
@@ -96,7 +95,7 @@
Event& event; //!< reference to PLDM daemon's main event loop
/** @brief PLDM request handler */
pldm::requester::Handler<pldm::requester::Request>& handler;
- Requester& requester; //!< reference to Requester object
+ InstanceIdDb& instanceIdDb; //!< reference to an InstanceIdDb
private:
/** @brief Device identifiers of the managed FDs */
diff --git a/host-bmc/dbus_to_event_handler.cpp b/host-bmc/dbus_to_event_handler.cpp
index e8f84a6..2c9d92e 100644
--- a/host-bmc/dbus_to_event_handler.cpp
+++ b/host-bmc/dbus_to_event_handler.cpp
@@ -10,7 +10,6 @@
namespace pldm
{
-using namespace pldm::dbus_api;
using namespace pldm::responder;
using namespace pldm::responder::pdr;
using namespace pldm::responder::pdr_utils;
@@ -22,16 +21,16 @@
const std::vector<uint8_t> pdrTypes{PLDM_STATE_SENSOR_PDR};
DbusToPLDMEvent::DbusToPLDMEvent(
- int mctp_fd, uint8_t mctp_eid, Requester& requester,
+ int mctp_fd, uint8_t mctp_eid, pldm::InstanceIdDb& instanceIdDb,
pldm::requester::Handler<pldm::requester::Request>* handler) :
mctp_fd(mctp_fd),
- mctp_eid(mctp_eid), requester(requester), handler(handler)
+ mctp_eid(mctp_eid), instanceIdDb(instanceIdDb), handler(handler)
{}
void DbusToPLDMEvent::sendEventMsg(uint8_t eventType,
const std::vector<uint8_t>& eventDataVec)
{
- auto instanceId = requester.getInstanceId(mctp_eid);
+ auto instanceId = instanceIdDb.next(mctp_eid);
std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) +
PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES +
eventDataVec.size());
@@ -43,7 +42,7 @@
eventDataVec.size() + PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES);
if (rc != PLDM_SUCCESS)
{
- requester.markFree(mctp_eid, instanceId);
+ instanceIdDb.free(mctp_eid, instanceId);
error("Failed to encode_platform_event_message_req, rc = {RC}", "RC",
rc);
return;
diff --git a/host-bmc/dbus_to_event_handler.hpp b/host-bmc/dbus_to_event_handler.hpp
index 886d6b5..87668c2 100644
--- a/host-bmc/dbus_to_event_handler.hpp
+++ b/host-bmc/dbus_to_event_handler.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "libpldmresponder/pdr_utils.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include <libpldm/platform.h>
@@ -41,7 +41,7 @@
* @param[in] handler - PLDM request handler
*/
explicit DbusToPLDMEvent(
- int mctp_fd, uint8_t mctp_eid, pldm::dbus_api::Requester& requester,
+ int mctp_fd, uint8_t mctp_eid, pldm::InstanceIdDb& instanceIdDb,
pldm::requester::Handler<pldm::requester::Request>* handler);
public:
@@ -71,10 +71,10 @@
/** @brief MCTP EID of host firmware */
uint8_t mctp_eid;
- /** @brief reference to Requester object, primarily used to access API to
- * obtain PLDM instance id.
+ /** @brief reference to an Instance ID database object, used to obtain PLDM
+ * instance IDs
*/
- pldm::dbus_api::Requester& requester;
+ pldm::InstanceIdDb& instanceIdDb;
/** @brief D-Bus property changed signal match */
std::vector<std::unique_ptr<sdbusplus::bus::match_t>> stateSensorMatchs;
diff --git a/host-bmc/dbus_to_host_effecters.cpp b/host-bmc/dbus_to_host_effecters.cpp
index 8f54ca2..884662e 100644
--- a/host-bmc/dbus_to_host_effecters.cpp
+++ b/host-bmc/dbus_to_host_effecters.cpp
@@ -255,7 +255,7 @@
{
uint8_t& mctpEid = hostEffecterInfo[effecterInfoIndex].mctpEid;
uint8_t& compEffCnt = hostEffecterInfo[effecterInfoIndex].compEffecterCnt;
- auto instanceId = requester->getInstanceId(mctpEid);
+ auto instanceId = instanceIdDb->next(mctpEid);
std::vector<uint8_t> requestMsg(
sizeof(pldm_msg_hdr) + sizeof(effecterId) + sizeof(compEffCnt) +
@@ -269,7 +269,7 @@
{
error("Message encode failure. PLDM error code = {RC}", "RC", lg2::hex,
rc);
- requester->markFree(mctpEid, instanceId);
+ instanceIdDb->free(mctpEid, instanceId);
return rc;
}
diff --git a/host-bmc/dbus_to_host_effecters.hpp b/host-bmc/dbus_to_host_effecters.hpp
index c5aef12..3690ad8 100644
--- a/host-bmc/dbus_to_host_effecters.hpp
+++ b/host-bmc/dbus_to_host_effecters.hpp
@@ -2,7 +2,7 @@
#include "common/types.hpp"
#include "common/utils.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include <phosphor-logging/lg2.hpp>
@@ -74,7 +74,7 @@
virtual ~HostEffecterParser() = default;
/** @brief Constructor to create a HostEffecterParser object.
- * @param[in] requester - PLDM Requester object pointer
+ * @param[in] instanceIdDb - PLDM InstanceIdDb object pointer
* @param[in] fd - socket fd to communicate to host
* @param[in] repo - PLDM PDR repository
* @param[in] dbusHandler - D-bus Handler
@@ -82,11 +82,11 @@
* @param[in] handler - PLDM request handler
*/
explicit HostEffecterParser(
- pldm::dbus_api::Requester* requester, int fd, const pldm_pdr* repo,
+ pldm::InstanceIdDb* instanceIdDb, int fd, const pldm_pdr* repo,
pldm::utils::DBusHandler* const dbusHandler,
const std::string& jsonPath,
pldm::requester::Handler<pldm::requester::Request>* handler) :
- requester(requester),
+ instanceIdDb(instanceIdDb),
sockFd(fd), pdrRepo(repo), dbusHandler(dbusHandler), handler(handler)
{
try
@@ -173,10 +173,10 @@
uint16_t effecterId);
protected:
- pldm::dbus_api::Requester*
- requester; //!< Reference to Requester to obtain instance id
- int sockFd; //!< Socket fd to send message to host
- const pldm_pdr* pdrRepo; //!< Reference to PDR repo
+ pldm::InstanceIdDb* instanceIdDb; //!< Reference to the InstanceIdDb object
+ //!< to obtain instance id
+ int sockFd; //!< Socket fd to send message to host
+ const pldm_pdr* pdrRepo; //!< Reference to PDR repo
std::vector<EffecterInfo> hostEffecterInfo; //!< Parsed effecter information
std::vector<std::unique_ptr<sdbusplus::bus::match_t>>
effecterInfoMatch; //!< vector to catch the D-Bus property change
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index a5ecced..1b0024c 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -18,7 +18,6 @@
namespace pldm
{
-using namespace pldm::dbus_api;
using namespace pldm::responder::events;
using namespace pldm::utils;
using namespace sdbusplus::bus::match::rules;
@@ -50,12 +49,13 @@
HostPDRHandler::HostPDRHandler(
int mctp_fd, uint8_t mctp_eid, sdeventplus::Event& event, pldm_pdr* repo,
const std::string& eventsJsonsDir, pldm_entity_association_tree* entityTree,
- pldm_entity_association_tree* bmcEntityTree, Requester& requester,
+ pldm_entity_association_tree* bmcEntityTree,
+ pldm::InstanceIdDb& instanceIdDb,
pldm::requester::Handler<pldm::requester::Request>* handler) :
mctp_fd(mctp_fd),
mctp_eid(mctp_eid), event(event), repo(repo),
stateSensorHandler(eventsJsonsDir), entityTree(entityTree),
- bmcEntityTree(bmcEntityTree), requester(requester), handler(handler)
+ bmcEntityTree(bmcEntityTree), instanceIdDb(instanceIdDb), handler(handler)
{
fs::path hostFruJson(fs::path(HOST_JSONS_DIR) / fruJson);
if (fs::exists(hostFruJson))
@@ -172,14 +172,14 @@
{
recordHandle = nextRecordHandle;
}
- auto instanceId = requester.getInstanceId(mctp_eid);
+ auto instanceId = instanceIdDb.next(mctp_eid);
auto rc = encode_get_pdr_req(instanceId, recordHandle, 0,
PLDM_GET_FIRSTPART, UINT16_MAX, 0, request,
PLDM_GET_PDR_REQ_BYTES);
if (rc != PLDM_SUCCESS)
{
- requester.markFree(mctp_eid, instanceId);
+ instanceIdDb.free(mctp_eid, instanceId);
error("Failed to encode_get_pdr_req, rc = {RC}", "RC", rc);
return;
}
@@ -313,7 +313,7 @@
"RC", rc);
return;
}
- auto instanceId = requester.getInstanceId(mctp_eid);
+ auto instanceId = instanceIdDb.next(mctp_eid);
std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) +
PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES +
actualSize);
@@ -324,7 +324,7 @@
actualSize + PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES);
if (rc != PLDM_SUCCESS)
{
- requester.markFree(mctp_eid, instanceId);
+ instanceIdDb.free(mctp_eid, instanceId);
error("Failed to encode_platform_event_message_req, rc = {RC}", "RC",
rc);
return;
@@ -600,7 +600,7 @@
void HostPDRHandler::setHostFirmwareCondition()
{
responseReceived = false;
- auto instanceId = requester.getInstanceId(mctp_eid);
+ auto instanceId = instanceIdDb.next(mctp_eid);
std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) +
PLDM_GET_VERSION_REQ_BYTES);
auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
@@ -610,7 +610,7 @@
{
error("GetPLDMVersion encode failure. PLDM error code = {RC}", "RC",
lg2::hex, rc);
- requester.markFree(mctp_eid, instanceId);
+ instanceIdDb.free(mctp_eid, instanceId);
return;
}
@@ -672,7 +672,7 @@
sensorRearm.byte = 0;
uint8_t tid = std::get<0>(terminusInfo);
- auto instanceId = requester.getInstanceId(mctp_eid);
+ auto instanceId = instanceIdDb.next(mctp_eid);
std::vector<uint8_t> requestMsg(
sizeof(pldm_msg_hdr) +
PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES);
@@ -682,7 +682,7 @@
if (rc != PLDM_SUCCESS)
{
- requester.markFree(mctp_eid, instanceId);
+ instanceIdDb.free(mctp_eid, instanceId);
error(
"Failed to encode_get_state_sensor_readings_req, rc = {RC}",
"RC", rc);
diff --git a/host-bmc/host_pdr_handler.hpp b/host-bmc/host_pdr_handler.hpp
index 64f2442..15ce1ac 100644
--- a/host-bmc/host_pdr_handler.hpp
+++ b/host-bmc/host_pdr_handler.hpp
@@ -4,7 +4,7 @@
#include "common/utils.hpp"
#include "libpldmresponder/event_parser.hpp"
#include "libpldmresponder/pdr_utils.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include <libpldm/base.h>
@@ -83,7 +83,7 @@
* @param[in] eventsJsonDir - directory path which has the config JSONs
* @param[in] entityTree - Pointer to BMC and Host entity association tree
* @param[in] bmcEntityTree - pointer to BMC's entity association tree
- * @param[in] requester - reference to Requester object
+ * @param[in] instanceIdDb - reference to an InstanceIdDb object
* @param[in] handler - PLDM request handler
*/
explicit HostPDRHandler(
@@ -91,7 +91,7 @@
pldm_pdr* repo, const std::string& eventsJsonsDir,
pldm_entity_association_tree* entityTree,
pldm_entity_association_tree* bmcEntityTree,
- pldm::dbus_api::Requester& requester,
+ pldm::InstanceIdDb& instanceIdDb,
pldm::requester::Handler<pldm::requester::Request>* handler);
/** @brief fetch PDRs from host firmware. See @class.
@@ -230,10 +230,10 @@
/** @brief Pointer to BMC's entity association tree */
pldm_entity_association_tree* bmcEntityTree;
- /** @brief reference to Requester object, primarily used to access API to
- * obtain PLDM instance id.
+ /** @brief reference to Instance ID database object, used to obtain PLDM
+ * instance IDs
*/
- pldm::dbus_api::Requester& requester;
+ pldm::InstanceIdDb& instanceIdDb;
/** @brief PLDM request handler */
pldm::requester::Handler<pldm::requester::Request>* handler;
diff --git a/host-bmc/test/dbus_to_host_effecter_test.cpp b/host-bmc/test/dbus_to_host_effecter_test.cpp
index bb9fc13..5c62e31 100644
--- a/host-bmc/test/dbus_to_host_effecter_test.cpp
+++ b/host-bmc/test/dbus_to_host_effecter_test.cpp
@@ -10,7 +10,6 @@
using namespace pldm::host_effecters;
using namespace pldm::utils;
-using namespace pldm::dbus_api;
class MockHostEffecterParser : public HostEffecterParser
{
diff --git a/libpldmresponder/base.cpp b/libpldmresponder/base.cpp
index dd0e94a..e5bbf2f 100644
--- a/libpldmresponder/base.cpp
+++ b/libpldmresponder/base.cpp
@@ -184,7 +184,7 @@
std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) +
PLDM_SET_EVENT_RECEIVER_REQ_BYTES);
auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
- auto instanceId = requester.getInstanceId(eid);
+ auto instanceId = instanceIdDb.next(eid);
uint8_t eventMessageGlobalEnable =
PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE;
uint8_t transportProtocolType = PLDM_TRANSPORT_PROTOCOL_TYPE_MCTP;
@@ -196,7 +196,7 @@
eventReceiverAddressInfo, heartbeatTimer, request);
if (rc != PLDM_SUCCESS)
{
- requester.markFree(eid, instanceId);
+ instanceIdDb.free(eid, instanceId);
error("Failed to encode_set_event_receiver_req, rc = {RC}", "RC",
lg2::hex, rc);
return;
diff --git a/libpldmresponder/base.hpp b/libpldmresponder/base.hpp
index 9a13f2d..2f7c714 100644
--- a/libpldmresponder/base.hpp
+++ b/libpldmresponder/base.hpp
@@ -13,7 +13,6 @@
#include <vector>
-using namespace pldm::dbus_api;
using namespace pldm::responder;
namespace pldm
@@ -25,11 +24,12 @@
class Handler : public CmdHandler
{
public:
- Handler(uint8_t eid, Requester& requester, sdeventplus::Event& event,
+ Handler(uint8_t eid, pldm::InstanceIdDb& instanceIdDb,
+ sdeventplus::Event& event,
pldm::responder::oem_platform::Handler* oemPlatformHandler,
pldm::requester::Handler<pldm::requester::Request>* handler) :
eid(eid),
- requester(requester), event(event),
+ instanceIdDb(instanceIdDb), event(event),
oemPlatformHandler(oemPlatformHandler), handler(handler)
{
handlers.emplace(PLDM_GET_PLDM_TYPES,
@@ -94,10 +94,8 @@
/** @brief MCTP EID of host firmware */
uint8_t eid;
- /** @brief reference to Requester object, primarily used to access API to
- * obtain PLDM instance id.
- */
- Requester& requester;
+ /** @brief An instance ID database for allocating instance IDs. */
+ InstanceIdDb& instanceIdDb;
/** @brief reference of main event loop of pldmd, primarily used to schedule
* work
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index e2e4e52..4c46b9a 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -69,10 +69,10 @@
DBusHandler dbusHandler;
-Handler::Handler(int fd, uint8_t eid, dbus_api::Requester* requester,
+Handler::Handler(int fd, uint8_t eid, pldm::InstanceIdDb* instanceIdDb,
pldm::requester::Handler<pldm::requester::Request>* handler) :
biosConfig(BIOS_JSONS_DIR, BIOS_TABLES_DIR, &dbusHandler, fd, eid,
- requester, handler)
+ instanceIdDb, handler)
{
biosConfig.removeTables();
biosConfig.buildTables();
diff --git a/libpldmresponder/bios.hpp b/libpldmresponder/bios.hpp
index d77e9c8..f72c9e8 100644
--- a/libpldmresponder/bios.hpp
+++ b/libpldmresponder/bios.hpp
@@ -4,8 +4,8 @@
#include "bios_config.hpp"
#include "bios_table.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
#include "pldmd/handler.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include <libpldm/bios.h>
@@ -33,10 +33,10 @@
*
* @param[in] fd - socket descriptor to communicate to host
* @param[in] eid - MCTP EID of host firmware
- * @param[in] requester - pointer to Requester object
+ * @param[in] instanceIdDb - pointer to an InstanceIdDb object
* @param[in] handler - PLDM request handler
*/
- Handler(int fd, uint8_t eid, dbus_api::Requester* requester,
+ Handler(int fd, uint8_t eid, pldm::InstanceIdDb* instanceIdDb,
pldm::requester::Handler<pldm::requester::Request>* handler);
/** @brief Handler for GetDateTime
diff --git a/libpldmresponder/bios_config.cpp b/libpldmresponder/bios_config.cpp
index 716b0dc..69a98f4 100644
--- a/libpldmresponder/bios_config.cpp
+++ b/libpldmresponder/bios_config.cpp
@@ -18,7 +18,6 @@
PHOSPHOR_LOG2_USING;
-using namespace pldm::dbus_api;
using namespace pldm::utils;
namespace pldm
@@ -44,11 +43,11 @@
BIOSConfig::BIOSConfig(
const char* jsonDir, const char* tableDir, DBusHandler* const dbusHandler,
- int fd, uint8_t eid, dbus_api::Requester* requester,
+ int fd, uint8_t eid, pldm::InstanceIdDb* instanceIdDb,
pldm::requester::Handler<pldm::requester::Request>* handler) :
jsonDir(jsonDir),
tableDir(tableDir), dbusHandler(dbusHandler), fd(fd), eid(eid),
- requester(requester), handler(handler)
+ instanceIdDb(instanceIdDb), handler(handler)
{
fs::create_directories(tableDir);
@@ -1042,7 +1041,7 @@
{
#ifdef OEM_IBM
auto rc = pldm::responder::platform::sendBiosAttributeUpdateEvent(
- eid, requester, listOfHandles, handler);
+ eid, instanceIdDb, listOfHandles, handler);
if (rc != PLDM_SUCCESS)
{
return;
diff --git a/libpldmresponder/bios_config.hpp b/libpldmresponder/bios_config.hpp
index 2d07593..6e27642 100644
--- a/libpldmresponder/bios_config.hpp
+++ b/libpldmresponder/bios_config.hpp
@@ -2,7 +2,7 @@
#include "bios_attribute.hpp"
#include "bios_table.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include <libpldm/bios_table.h>
@@ -74,13 +74,13 @@
* @param[in] dbusHandler - Dbus Handler
* @param[in] fd - socket descriptor to communicate to host
* @param[in] eid - MCTP EID of host firmware
- * @param[in] requester - pointer to Requester object
+ * @param[in] instanceIdDb - pointer to an InstanceIdDb object
* @param[in] handler - PLDM request handler
*/
explicit BIOSConfig(
const char* jsonDir, const char* tableDir,
pldm::utils::DBusHandler* const dbusHandler, int fd, uint8_t eid,
- dbus_api::Requester* requester,
+ pldm::InstanceIdDb* instanceIdDb,
pldm::requester::Handler<pldm::requester::Request>* handler);
/** @brief Set attribute value on dbus and attribute value table
@@ -146,10 +146,10 @@
/** @brief MCTP EID of host firmware */
uint8_t eid;
- /** @brief pointer to Requester object, primarily used to access API to
- * obtain PLDM instance id.
+ /** @brief pointer to an Instance ID database object, used to obtain PLDM
+ * instance IDs.
*/
- dbus_api::Requester* requester;
+ pldm::InstanceIdDb* instanceIdDb;
/** @brief PLDM request handler */
pldm::requester::Handler<pldm::requester::Request>* handler;
diff --git a/libpldmresponder/test/libpldmresponder_base_test.cpp b/libpldmresponder/test/libpldmresponder_base_test.cpp
index f1ecfc3..8931f0c 100644
--- a/libpldmresponder/test/libpldmresponder_base_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_base_test.cpp
@@ -18,14 +18,11 @@
{
protected:
TestBaseCommands() :
- instanceIdDb(), requester(pldm::utils::DBusHandler::getBus(),
- "/abc/def", this->instanceIdDb),
- event(sdeventplus::Event::get_default())
+ instanceIdDb(), event(sdeventplus::Event::get_default())
{}
uint8_t mctpEid = 0;
TestInstanceIdDb instanceIdDb;
- Requester requester;
sdeventplus::Event event;
};
@@ -35,7 +32,7 @@
auto request = reinterpret_cast<pldm_msg*>(requestPayload.data());
// payload length will be 0 in this case
size_t requestPayloadLength = 0;
- base::Handler handler(mctpEid, requester, event, nullptr, nullptr);
+ base::Handler handler(mctpEid, instanceIdDb, event, nullptr, nullptr);
auto response = handler.getPLDMTypes(request, requestPayloadLength);
// Need to support OEM type.
auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
@@ -52,7 +49,7 @@
requestPayload{};
auto request = reinterpret_cast<pldm_msg*>(requestPayload.data());
size_t requestPayloadLength = requestPayload.size() - sizeof(pldm_msg_hdr);
- base::Handler handler(mctpEid, requester, event, nullptr, nullptr);
+ base::Handler handler(mctpEid, instanceIdDb, event, nullptr, nullptr);
auto response = handler.getPLDMCommands(request, requestPayloadLength);
auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
uint8_t* payload_ptr = responsePtr->payload;
@@ -69,7 +66,7 @@
request->payload[0] = 0xFF;
size_t requestPayloadLength = requestPayload.size() - sizeof(pldm_msg_hdr);
- base::Handler handler(mctpEid, requester, event, nullptr, nullptr);
+ base::Handler handler(mctpEid, instanceIdDb, event, nullptr, nullptr);
auto response = handler.getPLDMCommands(request, requestPayloadLength);
auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
uint8_t* payload_ptr = responsePtr->payload;
@@ -94,7 +91,7 @@
ASSERT_EQ(0, rc);
- base::Handler handler(mctpEid, requester, event, nullptr, nullptr);
+ base::Handler handler(mctpEid, instanceIdDb, event, nullptr, nullptr);
auto response = handler.getPLDMVersion(request, requestPayloadLength);
auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
@@ -125,7 +122,7 @@
ASSERT_EQ(0, rc);
- base::Handler handler(mctpEid, requester, event, nullptr, nullptr);
+ base::Handler handler(mctpEid, instanceIdDb, event, nullptr, nullptr);
auto response = handler.getPLDMVersion(request, requestPayloadLength - 1);
auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
@@ -150,7 +147,7 @@
auto request = reinterpret_cast<pldm_msg*>(requestPayload.data());
size_t requestPayloadLength = 0;
- base::Handler handler(mctpEid, requester, event, nullptr, nullptr);
+ base::Handler handler(mctpEid, instanceIdDb, event, nullptr, nullptr);
auto response = handler.getTID(request, requestPayloadLength);
auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
diff --git a/oem/ibm/libpldmresponder/file_io.hpp b/oem/ibm/libpldmresponder/file_io.hpp
index 4e2af4f..aa3b9a9 100644
--- a/oem/ibm/libpldmresponder/file_io.hpp
+++ b/oem/ibm/libpldmresponder/file_io.hpp
@@ -170,11 +170,11 @@
{
public:
Handler(oem_platform::Handler* oemPlatformHandler, int hostSockFd,
- uint8_t hostEid, dbus_api::Requester* dbusImplReqester,
+ uint8_t hostEid, pldm::InstanceIdDb* instanceIdDb,
pldm::requester::Handler<pldm::requester::Request>* handler) :
oemPlatformHandler(oemPlatformHandler),
- hostSockFd(hostSockFd), hostEid(hostEid),
- dbusImplReqester(dbusImplReqester), handler(handler)
+ hostSockFd(hostSockFd), hostEid(hostEid), instanceIdDb(instanceIdDb),
+ handler(handler)
{
handlers.emplace(PLDM_READ_FILE_INTO_MEMORY,
[this](const pldm_msg* request, size_t payloadLength) {
@@ -229,7 +229,7 @@
pldm::utils::DBusHandler::getBus(),
sdbusplus::bus::match::rules::interfacesAdded() +
sdbusplus::bus::match::rules::argNpath(0, dumpObjPath),
- [this, hostSockFd, hostEid, dbusImplReqester,
+ [this, hostSockFd, hostEid, instanceIdDb,
handler](sdbusplus::message_t& msg) {
std::map<std::string,
std::map<std::string, std::variant<std::string, uint32_t>>>
@@ -258,7 +258,7 @@
.emplace_back(
std::make_unique<
pldm::requester::oem_ibm::DbusToFileHandler>(
- hostSockFd, hostEid, dbusImplReqester, path,
+ hostSockFd, hostEid, instanceIdDb, path,
handler))
->processNewResourceDump(vspstring, password);
break;
@@ -269,7 +269,7 @@
pldm::utils::DBusHandler::getBus(),
sdbusplus::bus::match::rules::interfacesAdded() +
sdbusplus::bus::match::rules::argNpath(0, certObjPath),
- [this, hostSockFd, hostEid, dbusImplReqester,
+ [this, hostSockFd, hostEid, instanceIdDb,
handler](sdbusplus::message_t& msg) {
std::map<std::string,
std::map<std::string, std::variant<std::string, uint32_t>>>
@@ -295,8 +295,8 @@
.emplace_back(
std::make_unique<pldm::requester::oem_ibm::
DbusToFileHandler>(
- hostSockFd, hostEid, dbusImplReqester,
- path, handler))
+ hostSockFd, hostEid, instanceIdDb, path,
+ handler))
->newCsrFileAvailable(csr, fileHandle);
break;
}
@@ -408,7 +408,7 @@
oem_platform::Handler* oemPlatformHandler;
int hostSockFd;
uint8_t hostEid;
- dbus_api::Requester* dbusImplReqester;
+ pldm::InstanceIdDb* instanceIdDb;
using DBusInterfaceAdded = std::vector<std::pair<
std::string,
std::vector<std::pair<std::string, std::variant<std::string>>>>>;
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
index fd1b0c4..c4befbb 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
@@ -368,7 +368,7 @@
eventClass->sensor_offset = sensorOffset;
eventClass->event_state = eventState;
eventClass->previous_event_state = prevEventState;
- auto instanceId = requester.getInstanceId(mctp_eid);
+ auto instanceId = instanceIdDb.next(mctp_eid);
std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) +
PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES +
sensorEventDataVec.size());
@@ -377,7 +377,7 @@
if (rc != PLDM_SUCCESS)
{
error("Failed to encode state sensor event, rc = {RC}", "RC", rc);
- requester.markFree(mctp_eid, instanceId);
+ instanceIdDb.free(mctp_eid, instanceId);
return;
}
rc = sendEventToHost(requestMsg, instanceId);
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
index 4de6835..520d060 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
@@ -31,12 +31,13 @@
public:
Handler(const pldm::utils::DBusHandler* dBusIntf,
pldm::responder::CodeUpdate* codeUpdate, int mctp_fd,
- uint8_t mctp_eid, pldm::dbus_api::Requester& requester,
+ uint8_t mctp_eid, pldm::InstanceIdDb& instanceIdDb,
sdeventplus::Event& event,
pldm::requester::Handler<pldm::requester::Request>* handler) :
oem_platform::Handler(dBusIntf),
codeUpdate(codeUpdate), platformHandler(nullptr), mctp_fd(mctp_fd),
- mctp_eid(mctp_eid), requester(requester), event(event), handler(handler)
+ mctp_eid(mctp_eid), instanceIdDb(instanceIdDb), event(event),
+ handler(handler)
{
codeUpdate->setVersions();
setEventReceiverCnt = 0;
@@ -192,10 +193,9 @@
/** @brief MCTP EID of host firmware */
uint8_t mctp_eid;
- /** @brief reference to Requester object, primarily used to access API to
- * obtain PLDM instance id.
- */
- pldm::dbus_api::Requester& requester;
+ /** @brief reference to an InstanceIdDb object, used to obtain a PLDM
+ * instance id. */
+ pldm::InstanceIdDb& instanceIdDb;
/** @brief sdeventplus event source */
std::unique_ptr<sdeventplus::source::Defer> assembleImageEvent;
std::unique_ptr<sdeventplus::source::Defer> startUpdateEvent;
diff --git a/oem/ibm/libpldmresponder/platform_oem_ibm.cpp b/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
index e7966a2..022404c 100644
--- a/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
+++ b/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
@@ -20,7 +20,7 @@
namespace platform
{
int sendBiosAttributeUpdateEvent(
- uint8_t eid, dbus_api::Requester* requester,
+ uint8_t eid, pldm::InstanceIdDb* instanceIdDb,
const std::vector<uint16_t>& handles,
pldm::requester::Handler<pldm::requester::Request>* handler)
{
@@ -61,7 +61,7 @@
"EXCEP_NAME", e.name());
}
- auto instanceId = requester->getInstanceId(eid);
+ auto instanceId = instanceIdDb->next(eid);
std::vector<uint8_t> requestMsg(
sizeof(pldm_msg_hdr) + sizeof(pldm_bios_attribute_update_event_req) -
@@ -79,7 +79,7 @@
error(
"BIOS Attribute update event message encode failure. PLDM error code = {RC}",
"RC", lg2::hex, rc);
- requester->markFree(eid, instanceId);
+ instanceIdDb->free(eid, instanceId);
return rc;
}
diff --git a/oem/ibm/libpldmresponder/platform_oem_ibm.hpp b/oem/ibm/libpldmresponder/platform_oem_ibm.hpp
index 94dc2dd..13ec2d5 100644
--- a/oem/ibm/libpldmresponder/platform_oem_ibm.hpp
+++ b/oem/ibm/libpldmresponder/platform_oem_ibm.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include <vector>
@@ -20,12 +20,12 @@
* list of BIOS attribute handles.
*
* @param[in] eid - MCTP EID of host firmware
- * @param[in] requester - pointer to Requester object
+ * @param[in] instanceIdDb - pointer to InstanceIdDb object
* @param[in] handles - List of BIOS attribute handles
* @param[in] handler - PLDM request handler
*/
int sendBiosAttributeUpdateEvent(
- uint8_t eid, dbus_api::Requester* requester,
+ uint8_t eid, pldm::InstanceIdDb* instanceIdDb,
const std::vector<uint16_t>& handles,
pldm::requester::Handler<pldm::requester::Request>* handler);
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;
diff --git a/oem/ibm/test/libpldmresponder_oem_platform_test.cpp b/oem/ibm/test/libpldmresponder_oem_platform_test.cpp
index ca9dd66..bb157f2 100644
--- a/oem/ibm/test/libpldmresponder_oem_platform_test.cpp
+++ b/oem/ibm/test/libpldmresponder_oem_platform_test.cpp
@@ -15,7 +15,6 @@
#include <iostream>
-using namespace pldm::dbus_api;
using namespace pldm::utils;
using namespace pldm::responder;
using namespace pldm::responder::pdr;
@@ -37,10 +36,10 @@
public:
MockOemPlatformHandler(const pldm::utils::DBusHandler* dBusIntf,
pldm::responder::CodeUpdate* codeUpdate, int mctp_fd,
- uint8_t mctp_eid, Requester& requester,
+ uint8_t mctp_eid, pldm::InstanceIdDb& instanceIdDb,
sdeventplus::Event& event) :
oem_ibm_platform::Handler(dBusIntf, codeUpdate, mctp_fd, mctp_eid,
- requester, event, nullptr)
+ instanceIdDb, event, nullptr)
{}
MOCK_METHOD(uint16_t, getNextEffecterId, ());
MOCK_METHOD(uint16_t, getNextSensorId, ());
@@ -56,7 +55,6 @@
TestInstanceIdDb instanceIdDb;
sdbusplus::bus_t bus(sdbusplus::bus::new_default());
- Requester requester(bus, "/abc/def", instanceIdDb);
auto event = sdeventplus::Event::get_default();
std::vector<get_sensor_state_field> stateField;
@@ -66,8 +64,8 @@
std::unique_ptr<oem_platform::Handler> oemPlatformHandler{};
oemPlatformHandler = std::make_unique<oem_ibm_platform::Handler>(
- mockDbusHandler.get(), mockCodeUpdate.get(), 0x1, 0x9, requester, event,
- nullptr);
+ mockDbusHandler.get(), mockCodeUpdate.get(), 0x1, 0x9, instanceIdDb,
+ event, nullptr);
auto rc = oemPlatformHandler->getOemStateSensorReadingsHandler(
entityID_, entityInstance_, stateSetId_, compSensorCnt_, stateField);
@@ -191,7 +189,6 @@
sdbusplus::bus_t bus(sdbusplus::bus::new_default());
std::filesystem::path dbPath;
TestInstanceIdDb instanceIdDb;
- Requester requester(bus, "/abc/def", instanceIdDb);
auto mockDbusHandler = std::make_unique<MockdBusHandler>();
auto event = sdeventplus::Event::get_default();
std::unique_ptr<CodeUpdate> mockCodeUpdate =
@@ -199,7 +196,7 @@
std::unique_ptr<oem_ibm_platform::Handler> mockoemPlatformHandler =
std::make_unique<MockOemPlatformHandler>(mockDbusHandler.get(),
mockCodeUpdate.get(), 0x1, 0x9,
- requester, event);
+ instanceIdDb, event);
Repo inRepo(inPDRRepo);
mockoemPlatformHandler->buildOEMPDR(inRepo);
@@ -298,7 +295,6 @@
sdbusplus::bus_t bus(sdbusplus::bus::new_default());
std::filesystem::path dbPath;
TestInstanceIdDb instanceIdDb;
- Requester requester(bus, "/abc/def", instanceIdDb);
auto mockDbusHandler = std::make_unique<MockdBusHandler>();
auto event = sdeventplus::Event::get_default();
@@ -307,7 +303,7 @@
std::unique_ptr<oem_ibm_platform::Handler> mockoemPlatformHandler =
std::make_unique<MockOemPlatformHandler>(mockDbusHandler.get(),
mockCodeUpdate.get(), 0x1, 0x9,
- requester, event);
+ instanceIdDb, event);
Repo inRepo(inPDRRepo);
mockoemPlatformHandler->buildOEMPDR(inRepo);
ASSERT_EQ(inRepo.empty(), false);
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 5da52f0..320bd89 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -204,7 +204,7 @@
Invoker invoker{};
requester::Handler<requester::Request> reqHandler(
- sockfd, event, dbusImplReq, currentSendbuffSize, verbose);
+ sockfd, event, instanceIdDb, currentSendbuffSize, verbose);
#ifdef LIBPLDMRESPONDER
using namespace pldm::state_sensor;
@@ -229,17 +229,17 @@
{
hostPDRHandler = std::make_shared<HostPDRHandler>(
sockfd, hostEID, event, pdrRepo.get(), EVENTS_JSONS_DIR,
- entityTree.get(), bmcEntityTree.get(), dbusImplReq, &reqHandler);
+ entityTree.get(), bmcEntityTree.get(), instanceIdDb, &reqHandler);
// HostFirmware interface needs access to hostPDR to know if host
// is running
dbusImplHost.setHostPdrObj(hostPDRHandler);
hostEffecterParser =
std::make_unique<pldm::host_effecters::HostEffecterParser>(
- &dbusImplReq, sockfd, pdrRepo.get(), &dbusHandler,
+ &instanceIdDb, sockfd, pdrRepo.get(), &dbusHandler,
HOST_JSONS_DIR, &reqHandler);
dbusToPLDMEventHandler = std::make_unique<DbusToPLDMEvent>(
- sockfd, hostEID, dbusImplReq, &reqHandler);
+ sockfd, hostEID, instanceIdDb, &reqHandler);
}
std::unique_ptr<oem_platform::Handler> oemPlatformHandler{};
@@ -248,16 +248,16 @@
std::make_unique<pldm::responder::CodeUpdate>(&dbusHandler);
codeUpdate->clearDirPath(LID_STAGING_DIR);
oemPlatformHandler = std::make_unique<oem_ibm_platform::Handler>(
- &dbusHandler, codeUpdate.get(), sockfd, hostEID, dbusImplReq, event,
+ &dbusHandler, codeUpdate.get(), sockfd, hostEID, instanceIdDb, event,
&reqHandler);
codeUpdate->setOemPlatformHandler(oemPlatformHandler.get());
invoker.registerHandler(PLDM_OEM, std::make_unique<oem_ibm::Handler>(
oemPlatformHandler.get(), sockfd,
- hostEID, &dbusImplReq, &reqHandler));
+ hostEID, &instanceIdDb, &reqHandler));
#endif
invoker.registerHandler(
PLDM_BIOS, std::make_unique<bios::Handler>(sockfd, hostEID,
- &dbusImplReq, &reqHandler));
+ &instanceIdDb, &reqHandler));
auto fruHandler = std::make_unique<fru::Handler>(
FRU_JSONS_DIR, FRU_MASTER_JSON, pdrRepo.get(), entityTree.get(),
bmcEntityTree.get());
@@ -278,7 +278,7 @@
invoker.registerHandler(PLDM_PLATFORM, std::move(platformHandler));
invoker.registerHandler(
PLDM_BASE,
- std::make_unique<base::Handler>(hostEID, dbusImplReq, event,
+ std::make_unique<base::Handler>(hostEID, instanceIdDb, event,
oemPlatformHandler.get(), &reqHandler));
invoker.registerHandler(PLDM_FRU, std::move(fruHandler));
dbus_api::Pdr dbusImplPdr(bus, "/xyz/openbmc_project/pldm", pdrRepo.get());
@@ -313,7 +313,7 @@
}
std::unique_ptr<fw_update::Manager> fwManager =
- std::make_unique<fw_update::Manager>(event, reqHandler, dbusImplReq);
+ std::make_unique<fw_update::Manager>(event, reqHandler, instanceIdDb);
std::unique_ptr<MctpDiscovery> mctpDiscoveryHandler =
std::make_unique<MctpDiscovery>(bus, fwManager.get());
diff --git a/requester/handler.hpp b/requester/handler.hpp
index ece1382..9fa5c31 100644
--- a/requester/handler.hpp
+++ b/requester/handler.hpp
@@ -3,7 +3,7 @@
#include "config.h"
#include "common/types.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "request.hpp"
#include <libpldm/base.h>
@@ -91,7 +91,7 @@
*
* @param[in] fd - fd of MCTP communications socket
* @param[in] event - reference to PLDM daemon's main event loop
- * @param[in] requester - reference to Requester object
+ * @param[in] instanceIdDb - reference to an InstanceIdDb
* @param[in] currentSendbuffSize - current send buffer size
* @param[in] verbose - verbose tracing flag
* @param[in] instanceIdExpiryInterval - instance ID expiration interval
@@ -99,7 +99,7 @@
* @param[in] responseTimeOut - time to wait between each retry
*/
explicit Handler(
- int fd, sdeventplus::Event& event, pldm::dbus_api::Requester& requester,
+ int fd, sdeventplus::Event& event, pldm::InstanceIdDb& instanceIdDb,
int currentSendbuffSize, bool verbose,
std::chrono::seconds instanceIdExpiryInterval =
std::chrono::seconds(INSTANCE_ID_EXPIRATION_INTERVAL),
@@ -107,7 +107,7 @@
std::chrono::milliseconds responseTimeOut =
std::chrono::milliseconds(RESPONSE_TIME_OUT)) :
fd(fd),
- event(event), requester(requester),
+ event(event), instanceIdDb(instanceIdDb),
currentSendbuffSize(currentSendbuffSize), verbose(verbose),
instanceIdExpiryInterval(instanceIdExpiryInterval),
numRetries(numRetries), responseTimeOut(responseTimeOut)
@@ -174,7 +174,7 @@
auto rc = request->start();
if (rc)
{
- requester.markFree(eid, instanceId);
+ instanceIdDb.free(eid, instanceId);
error("Failure to send the PLDM request message");
return rc;
}
@@ -186,7 +186,7 @@
}
catch (const std::runtime_error& e)
{
- requester.markFree(eid, instanceId);
+ instanceIdDb.free(eid, instanceId);
error(
"Failed to start the instance ID expiry timer. RC = {ERR_EXCEP}",
"ERR_EXCEP", e.what());
@@ -224,7 +224,7 @@
"RC", static_cast<int>(rc));
}
responseHandler(eid, response, respMsgLen);
- requester.markFree(key.eid, key.instanceId);
+ instanceIdDb.free(key.eid, key.instanceId);
handlers.erase(key);
}
else
@@ -233,21 +233,21 @@
// request handler, so freeing up the instance ID, this can be other
// OpenBMC applications relying on PLDM D-Bus apis like
// openpower-occ-control and softoff
- requester.markFree(key.eid, key.instanceId);
+ instanceIdDb.free(key.eid, key.instanceId);
}
}
private:
int fd; //!< file descriptor of MCTP communications socket
sdeventplus::Event& event; //!< reference to PLDM daemon's main event loop
- pldm::dbus_api::Requester& requester; //!< reference to Requester object
- int currentSendbuffSize; //!< current Send Buffer size
- bool verbose; //!< verbose tracing flag
+ pldm::InstanceIdDb& instanceIdDb; //!< reference to an InstanceIdDb
+ int currentSendbuffSize; //!< current Send Buffer size
+ bool verbose; //!< verbose tracing flag
std::chrono::seconds
- instanceIdExpiryInterval; //!< Instance ID expiration interval
- uint8_t numRetries; //!< number of request retries
+ instanceIdExpiryInterval; //!< Instance ID expiration interval
+ uint8_t numRetries; //!< number of request retries
std::chrono::milliseconds
- responseTimeOut; //!< time to wait between each retry
+ responseTimeOut; //!< time to wait between each retry
/** @brief Container for storing the details of the PLDM request
* message, handler for the corresponding PLDM response and the
@@ -276,7 +276,7 @@
if (removeRequestContainer.contains(key))
{
removeRequestContainer[key].reset();
- requester.markFree(key.eid, key.instanceId);
+ instanceIdDb.free(key.eid, key.instanceId);
handlers.erase(key);
removeRequestContainer.erase(key);
}
diff --git a/requester/test/handler_test.cpp b/requester/test/handler_test.cpp
index 69facdb..6251974 100644
--- a/requester/test/handler_test.cpp
+++ b/requester/test/handler_test.cpp
@@ -1,7 +1,7 @@
#include "common/types.hpp"
#include "common/utils.hpp"
#include "mock_request.hpp"
-#include "pldmd/dbus_impl_requester.hpp"
+#include "pldmd/instance_id.hpp"
#include "requester/handler.hpp"
#include "test/test_instance_id.hpp"
@@ -22,17 +22,12 @@
class HandlerTest : public testing::Test
{
protected:
- HandlerTest() :
- event(sdeventplus::Event::get_default()), instanceIdDb(),
- dbusImplReq(pldm::utils::DBusHandler::getBus(),
- "/xyz/openbmc_project/pldm", instanceIdDb)
- {}
+ HandlerTest() : event(sdeventplus::Event::get_default()), instanceIdDb() {}
int fd = 0;
mctp_eid_t eid = 0;
sdeventplus::Event event;
TestInstanceIdDb instanceIdDb;
- pldm::dbus_api::Requester dbusImplReq;
/** @brief This function runs the sd_event_run in a loop till all the events
* in the testcase are dispatched and exits when there are no events
@@ -76,10 +71,11 @@
TEST_F(HandlerTest, singleRequestResponseScenario)
{
- Handler<NiceMock<MockRequest>> reqHandler(
- fd, event, dbusImplReq, false, 90000, seconds(1), 2, milliseconds(100));
+ Handler<NiceMock<MockRequest>> reqHandler(fd, event, instanceIdDb, false,
+ 90000, seconds(1), 2,
+ milliseconds(100));
pldm::Request request{};
- auto instanceId = dbusImplReq.getInstanceId(eid);
+ auto instanceId = instanceIdDb.next(eid);
EXPECT_EQ(instanceId, 0);
auto rc = reqHandler.registerRequest(
eid, instanceId, 0, 0, std::move(request),
@@ -96,10 +92,11 @@
TEST_F(HandlerTest, singleRequestInstanceIdTimerExpired)
{
- Handler<NiceMock<MockRequest>> reqHandler(
- fd, event, dbusImplReq, false, 90000, seconds(1), 2, milliseconds(100));
+ Handler<NiceMock<MockRequest>> reqHandler(fd, event, instanceIdDb, false,
+ 90000, seconds(1), 2,
+ milliseconds(100));
pldm::Request request{};
- auto instanceId = dbusImplReq.getInstanceId(eid);
+ auto instanceId = instanceIdDb.next(eid);
EXPECT_EQ(instanceId, 0);
auto rc = reqHandler.registerRequest(
eid, instanceId, 0, 0, std::move(request),
@@ -114,10 +111,11 @@
TEST_F(HandlerTest, multipleRequestResponseScenario)
{
- Handler<NiceMock<MockRequest>> reqHandler(
- fd, event, dbusImplReq, false, 90000, seconds(2), 2, milliseconds(100));
+ Handler<NiceMock<MockRequest>> reqHandler(fd, event, instanceIdDb, false,
+ 90000, seconds(2), 2,
+ milliseconds(100));
pldm::Request request{};
- auto instanceId = dbusImplReq.getInstanceId(eid);
+ auto instanceId = instanceIdDb.next(eid);
EXPECT_EQ(instanceId, 0);
auto rc = reqHandler.registerRequest(
eid, instanceId, 0, 0, std::move(request),
@@ -125,7 +123,7 @@
EXPECT_EQ(rc, PLDM_SUCCESS);
pldm::Request requestNxt{};
- auto instanceIdNxt = dbusImplReq.getInstanceId(eid);
+ auto instanceIdNxt = instanceIdDb.next(eid);
EXPECT_EQ(instanceIdNxt, 1);
rc = reqHandler.registerRequest(
eid, instanceIdNxt, 0, 0, std::move(requestNxt),