Implement PDR.FindStateEffecterPDR DBus API
This commit implements a DBus API defined at
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/31774
to find the stateEffecterPDR based on the entity ID
and stateSetID.
Tested: Unit tests and in witherspoon system
busctl call :1.187 /xyz/openbmc_project/pldm xyz.openbmc_project.PLDM.PDR FindStateEffecterPDR yqq 1 33 196
aay 1 29 1 0 0 0 1 11 0 0 19 0 0 0 1 0 33 0 0 0 0 0 0 0 0 0 1 196 0 1 6
busctl call :1.187 /xyz/openbmc_project/pldm xyz.openbmc_project.PLDM.PDR FindStateEffecterPDR yqq 1 31 129
aay 1 29 3 0 0 0 1 11 0 0 19 0 0 0 3 0 31 0 0 0 0 0 0 0 0 0 1 129 0 1 64
Change-Id: I5c15be5303b511465c36914f5b60a0957cd3857e
Signed-off-by: Pavithra Barithaya <pbaritha@in.ibm.com>
diff --git a/dbus_impl_pdr.hpp b/dbus_impl_pdr.hpp
new file mode 100644
index 0000000..7033526
--- /dev/null
+++ b/dbus_impl_pdr.hpp
@@ -0,0 +1,60 @@
+#pragma once
+
+#include "xyz/openbmc_project/PLDM/PDR/server.hpp"
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server/object.hpp>
+#include <vector>
+
+#include "libpldm/pdr.h"
+#include "libpldm/platform.h"
+
+namespace pldm
+{
+namespace dbus_api
+{
+
+using PdrIntf = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::PLDM::server::PDR>;
+
+/** @class Pdr
+ * @brief OpenBMC PLDM.PDR Implementation
+ * @details A concrete implementation for the
+ * xyz.openbmc_project.PLDM.PDR DBus APIs.
+ */
+class Pdr : public PdrIntf
+{
+ public:
+ Pdr() = delete;
+ Pdr(const Pdr&) = delete;
+ Pdr& operator=(const Pdr&) = delete;
+ Pdr(Pdr&&) = delete;
+ Pdr& operator=(Pdr&&) = delete;
+ virtual ~Pdr() = default;
+
+ /** @brief Constructor to put object onto bus at a dbus path.
+ * @param[in] bus - Bus to attach to.
+ * @param[in] path - Path to attach at.
+ * @param[in] repo - pointer to BMC's primary PDR repo
+ */
+ Pdr(sdbusplus::bus::bus& bus, const std::string& path,
+ const pldm_pdr* repo) :
+ PdrIntf(bus, path.c_str(), repo),
+ pdrRepo(repo){};
+
+ /** @brief Implementation for PdrIntf.FindStateEffecterPDR
+ * @param[in] tid - PLDM terminus ID.
+ * @param[in] entityID - entity that can be associated with PLDM State set.
+ * @param[in] stateSetId - value that identifies PLDM State set.
+ */
+ std::vector<std::vector<uint8_t>>
+ findStateEffecterPDR(uint8_t tid, uint16_t entityID,
+ uint16_t stateSetId) override;
+
+ private:
+ /** @brief pointer to BMC's primary PDR repo */
+ const pldm_pdr* pdrRepo;
+};
+
+} // namespace dbus_api
+} // namespace pldm