Add HostPDRHandler class
HostPDRHandler has an API to fetch PDRs from the host.
The class HostPDRHandler has a function fetchPDR which basically calls
GetPDR on the host using libpldm's pldm_send_recv API.
The retrieved PDRs are stored in the BMCs primary PDR repo.
Change-Id: Ifd727316caf37d49f17e117b32ee105f6d941e0e
Signed-off-by: Pavithra Barithaya <pbaritha@in.ibm.com>
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/host_pdr_handler.hpp b/host_pdr_handler.hpp
new file mode 100644
index 0000000..b590e7c
--- /dev/null
+++ b/host_pdr_handler.hpp
@@ -0,0 +1,74 @@
+#pragma once
+
+#include "dbus_impl_requester.hpp"
+#include "utils.hpp"
+
+#include <sdeventplus/event.hpp>
+#include <vector>
+
+#include "libpldm/base.h"
+#include "libpldm/platform.h"
+
+using namespace pldm::dbus_api;
+
+namespace pldm
+{
+
+/** @class HostPDRHandler
+ * @brief This class can fetch and process PDRs from host firmware
+ * @details Provides an API to fetch PDRs from the host firmware. Upon
+ * receiving the PDRs, they are stored into the BMC's primary PDR repo.
+ * Adjustments are made to entity association PDRs received from the host,
+ * because they need to be assimilated into the BMC's entity association
+ * tree. A PLDM event containing the record handles of the updated entity
+ * association PDRs is sent to the host.
+ */
+class HostPDRHandler
+{
+ public:
+ HostPDRHandler() = delete;
+ HostPDRHandler(const HostPDRHandler&) = delete;
+ HostPDRHandler(HostPDRHandler&&) = delete;
+ HostPDRHandler& operator=(const HostPDRHandler&) = delete;
+ HostPDRHandler& operator=(HostPDRHandler&&) = delete;
+ ~HostPDRHandler() = default;
+
+ /** @brief Constructor
+ * @param[in] mctp_fd - fd of MCTP communications socket
+ * @param[in] mctp_eid - MCTP EID of host firmware
+ * @param[in] event - reference of main event loop of pldmd
+ * @param[in] repo - pointer to BMC's primary PDR repo
+ * @param[in] requester - reference to Requester object
+ */
+ explicit HostPDRHandler(int mctp_fd, uint8_t mctp_eid,
+ sdeventplus::Event& event, pldm_pdr* repo,
+ Requester& requester) :
+ mctp_fd(mctp_fd),
+ mctp_eid(mctp_eid), event(event), repo(repo), requester(requester)
+ {
+ }
+
+ /** @brief fetch PDRs from host firmware. See @class.
+ * @param[in] recordHandles - list of record handles pointing to host's
+ * PDRs that need to be fetched.
+ */
+ void fetchPDR(const std::vector<uint32_t>& recordHandles);
+
+ private:
+ /** @brief fd of MCTP communications socket */
+ int mctp_fd;
+ /** @brief MCTP EID of host firmware */
+ uint8_t mctp_eid;
+ /** @brief reference of main event loop of pldmd, primarily used to schedule
+ * work.
+ */
+ sdeventplus::Event& event;
+ /** @brief pointer to BMC's primary PDR repo, host PDRs are added here */
+ pldm_pdr* repo;
+ /** @brief reference to Requester object, primarily used to access API to
+ * obtain PLDM instance id.
+ */
+ Requester& requester;
+};
+
+} // namespace pldm