blob: b590e7c5797c4a5ca4a7ae37bd2486ee916f15df [file] [log] [blame]
Pavithra Barithaya51efaf82020-04-02 02:42:27 -05001#pragma once
2
3#include "dbus_impl_requester.hpp"
4#include "utils.hpp"
5
6#include <sdeventplus/event.hpp>
7#include <vector>
8
9#include "libpldm/base.h"
10#include "libpldm/platform.h"
11
12using namespace pldm::dbus_api;
13
14namespace pldm
15{
16
17/** @class HostPDRHandler
18 * @brief This class can fetch and process PDRs from host firmware
19 * @details Provides an API to fetch PDRs from the host firmware. Upon
20 * receiving the PDRs, they are stored into the BMC's primary PDR repo.
21 * Adjustments are made to entity association PDRs received from the host,
22 * because they need to be assimilated into the BMC's entity association
23 * tree. A PLDM event containing the record handles of the updated entity
24 * association PDRs is sent to the host.
25 */
26class HostPDRHandler
27{
28 public:
29 HostPDRHandler() = delete;
30 HostPDRHandler(const HostPDRHandler&) = delete;
31 HostPDRHandler(HostPDRHandler&&) = delete;
32 HostPDRHandler& operator=(const HostPDRHandler&) = delete;
33 HostPDRHandler& operator=(HostPDRHandler&&) = delete;
34 ~HostPDRHandler() = default;
35
36 /** @brief Constructor
37 * @param[in] mctp_fd - fd of MCTP communications socket
38 * @param[in] mctp_eid - MCTP EID of host firmware
39 * @param[in] event - reference of main event loop of pldmd
40 * @param[in] repo - pointer to BMC's primary PDR repo
41 * @param[in] requester - reference to Requester object
42 */
43 explicit HostPDRHandler(int mctp_fd, uint8_t mctp_eid,
44 sdeventplus::Event& event, pldm_pdr* repo,
45 Requester& requester) :
46 mctp_fd(mctp_fd),
47 mctp_eid(mctp_eid), event(event), repo(repo), requester(requester)
48 {
49 }
50
51 /** @brief fetch PDRs from host firmware. See @class.
52 * @param[in] recordHandles - list of record handles pointing to host's
53 * PDRs that need to be fetched.
54 */
55 void fetchPDR(const std::vector<uint32_t>& recordHandles);
56
57 private:
58 /** @brief fd of MCTP communications socket */
59 int mctp_fd;
60 /** @brief MCTP EID of host firmware */
61 uint8_t mctp_eid;
62 /** @brief reference of main event loop of pldmd, primarily used to schedule
63 * work.
64 */
65 sdeventplus::Event& event;
66 /** @brief pointer to BMC's primary PDR repo, host PDRs are added here */
67 pldm_pdr* repo;
68 /** @brief reference to Requester object, primarily used to access API to
69 * obtain PLDM instance id.
70 */
71 Requester& requester;
72};
73
74} // namespace pldm