oem-ibm: Implement Host lamp test interface

IBM has a feature called LampTest and what it does is this:
  - BMC would set the state of LEDs to [ON] on all the BMC accessible
    LEDs.
  - For LEDs that are not accessible by BMC, a message is sent to the
    Host, so that the Host can exercise all the LEDs on the connected
    drawers and anything else that the BMC does not have access to.

This commit adds support to send message to Host when BMC has to tell
the Host to exercise LEDs accessible by host.

When Host sees the effector is set, it goes ahead and turns [ON] all
the LEDs for a specified time and automatically restores the states
at timer expiration. BMC does not have to tell the Host to stop the
test and it is part of Host's lamp test requirement.

TESTED: By setting the asserted property of the LED groups object

busctl set-property xyz.openbmc_project.LED.GroupManager
/xyz/openbmc_project/led/groups/lamp_test
xyz.openbmc_project.Led.Group Asserted b true

And verifying that the setEffecterStates call was made to the
remote state effecter to turn on all LEDs

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I990dce28d3017f20c73ff9029fced0e7ac84868f
diff --git a/oem/ibm/host-bmc/host_lamp_test.hpp b/oem/ibm/host-bmc/host_lamp_test.hpp
new file mode 100644
index 0000000..67e5593
--- /dev/null
+++ b/oem/ibm/host-bmc/host_lamp_test.hpp
@@ -0,0 +1,112 @@
+#pragma once
+
+#include "pldmd/dbus_impl_pdr.hpp"
+#include "pldmd/dbus_impl_requester.hpp"
+#include "requester/handler.hpp"
+
+#include <sdbusplus/server/object.hpp>
+#include <xyz/openbmc_project/Led/Group/server.hpp>
+
+#include <string>
+
+using namespace pldm::dbus_api;
+
+namespace pldm
+{
+namespace led
+{
+
+using LEDGroupObj = sdbusplus::server::object_t<
+    sdbusplus::xyz::openbmc_project::Led::server::Group>;
+
+class HostLampTestInterfaces
+{
+  public:
+    virtual ~HostLampTestInterfaces() {}
+
+    virtual uint16_t getEffecterID() = 0;
+    virtual uint8_t setHostStateEffecter(uint16_t effecterID) = 0;
+};
+
+/** @class HostLampTest
+ *  @brief Manages group of Host lamp test LEDs
+ */
+class HostLampTest : public HostLampTestInterfaces, public LEDGroupObj
+{
+  public:
+    HostLampTest() = delete;
+    ~HostLampTest() = default;
+    HostLampTest(const HostLampTest&) = delete;
+    HostLampTest& operator=(const HostLampTest&) = delete;
+    HostLampTest(HostLampTest&&) = delete;
+    HostLampTest& operator=(HostLampTest&&) = delete;
+
+    /** @brief Constructs LED Group
+     *
+     * @param[in] bus           - Handle to system dbus
+     * @param[in] objPath       - The D-Bus path that hosts LED group
+     * @param[in] mctp_fd       - MCTP file descriptor
+     * @param[in] mctp_eid      - MCTP EID
+     * @param[in] instanceIdDb  - InstanceIdDb object to obtain instance id
+     * @param[in] repo          - pointer to BMC's primary PDR repo
+     * @param[in] handler       - PLDM request handler
+     */
+    HostLampTest(sdbusplus::bus_t& bus, const std::string& objPath,
+                 uint8_t mctp_eid, pldm::InstanceIdDb& instanceIdDb,
+                 pldm_pdr* repo,
+                 pldm::requester::Handler<pldm::requester::Request>* handler) :
+        LEDGroupObj(bus, objPath.c_str()),
+        path(objPath), mctp_eid(mctp_eid), instanceIdDb(instanceIdDb),
+        pdrRepo(repo), handler(handler)
+    {}
+
+    /** @brief Property SET Override function
+     *
+     *  @param[in]  value   -  True or False
+     *  @return             -  Success or exception thrown
+     */
+    bool asserted(bool value) override;
+
+    /** @brief Property GET Override function
+     *
+     *  @return             -  True or False
+     */
+    bool asserted() const override;
+
+    /** @brief Get effecterID from PDRs.
+     *
+     *  @return effecterID
+     */
+    uint16_t getEffecterID() override;
+
+    /** @brief Set state effecter states to PHYP.
+     *
+     *  @param[in]  effecterID   -  effecterID
+     *
+     *  @return  rc              -  PLDM completion codes
+     */
+    uint8_t setHostStateEffecter(uint16_t effecterID) override;
+
+  private:
+    /** @brief Path of the group instance */
+    std::string path;
+
+    /** @brief MCTP EID of host firmware */
+    uint8_t mctp_eid;
+
+    /** @brief Reference to the InstanceIdDb object to obtain instance id
+     */
+    pldm::InstanceIdDb& instanceIdDb;
+
+    /** @brief pointer to BMC's primary PDR repo */
+    const pldm_pdr* pdrRepo;
+
+    /** @brief Effecter ID */
+    uint16_t effecterID = 0;
+
+    /** @brief PLDM request handler */
+    pldm::requester::Handler<pldm::requester::Request>* handler;
+};
+
+} // namespace led
+} // namespace pldm