Move to libpldm instance id APIs
Signed-off-by: Rashmica Gupta <rashmica@linux.ibm.com>
Change-Id: I2955097a78c673f65054fa9bff1ef5243da136a2
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
diff --git a/pldm.hpp b/pldm.hpp
index 5d093a1..641153f 100644
--- a/pldm.hpp
+++ b/pldm.hpp
@@ -1,8 +1,10 @@
#pragma once
+
#include "occ_events.hpp"
#include "occ_status.hpp"
#include "utils.hpp"
+#include <libpldm/instance-id.h>
#include <libpldm/pldm.h>
#include <sdbusplus/bus/match.hpp>
@@ -44,7 +46,7 @@
{
public:
Interface() = delete;
- ~Interface() = default;
+ //~Interface() = default;
Interface(const Interface&) = delete;
Interface& operator=(const Interface&) = delete;
Interface(Interface&&) = delete;
@@ -80,7 +82,22 @@
pldmRspTimer(
sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>(
sdpEvent, std::bind(&Interface::pldmRspExpired, this)))
- {}
+ {
+ int rc = pldm_instance_db_init_default(&pldmInstanceIdDb);
+ if (rc)
+ {
+ throw std::system_category().default_error_condition(rc);
+ }
+ }
+
+ ~Interface()
+ {
+ int rc = pldm_instance_db_destroy(pldmInstanceIdDb);
+ if (rc)
+ {
+ std::cout << "pldm_instance_db_destroy failed, rc =" << rc << "\n";
+ }
+ }
/** @brief Fetch the state sensor PDRs and populate the cache with
* sensorId to OCC/SBE instance mapping information and the sensor
@@ -149,6 +166,10 @@
void setTraceThrottle(const bool throttle);
private:
+ /** @brief PLDM instance ID database object used to get instance IDs
+ */
+ pldm_instance_db* pldmInstanceIdDb = nullptr;
+
/** @brief PLDM instance number used in PLDM requests
*/
std::optional<uint8_t> pldmInstanceID;
@@ -303,12 +324,15 @@
return (occInstanceToEffecter.empty() ? false : true);
}
- /** @brief Query PLDM for the MCTP requester instance id
+ /** @brief Get a PLDM requester instance id
*
* @return true if the id was found and false if not
*/
bool getPldmInstanceId();
+ /** @brief Free PLDM requester instance id */
+ void freePldmInstanceId();
+
/** @brief Encode a GetStateSensor command into a PLDM request
* @param[in] instance - OCC instance number
* @param[in] sensorId - OCC Active sensor ID number