Implement processor throttle dbus properties

- create processor throttle dbus objects for each OCC (processor)
- update throttle properties based on OCC poll response data
  or safe mode status.

Throttle data will be made available via Redfish

NAME                                       TYPE      SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable        interface -         -            -
.Introspect                                method    -         s            -
org.freedesktop.DBus.Peer                  interface -         -            -
.GetMachineId                              method    -         s            -
.Ping                                      method    -         -            -
org.freedesktop.DBus.Properties            interface -         -            -
.Get                                       method    ss        v            -
.GetAll                                    method    s         a{sv}        -
.Set                                       method    ssv       -            -
.PropertiesChanged                         signal    sa{sv}as  -            -
xyz.openbmc_project.Control.Power.Throttle interface -         -            -
.ThrottleCauses                            property  as        0            emits-change
.Throttled                                 property  b         false        emits-change

Example of throttled processor (due to a power limit):
as 1 "xyz.openbmc_project.Control.Power.Throttle.ThrottleReasons.PowerLimit"

Change-Id: I0af9d82fab9d694427d0adaa45f4a372d25fbc12
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/occ_status.hpp b/occ_status.hpp
index ce3df77..a07c272 100644
--- a/occ_status.hpp
+++ b/occ_status.hpp
@@ -17,6 +17,7 @@
 #include <sdeventplus/event.hpp>
 #include <sdeventplus/utility/timer.hpp>
 #endif
+#include <xyz/openbmc_project/Control/Power/Throttle/server.hpp>
 
 #include <functional>
 
@@ -29,6 +30,9 @@
 namespace Base = sdbusplus::org::open_power::OCC::server;
 using Interface = sdbusplus::server::object_t<Base::Status>;
 
+namespace xyzBase = sdbusplus::xyz::openbmc_project::Control::Power::server;
+using ThrottleInterface = sdbusplus::server::object_t<xyzBase::Throttle>;
+
 // IPMID's host control application
 namespace Control = sdbusplus::org::open_power::Control::server;
 
@@ -50,6 +54,12 @@
 // OCC sysfs name prefix
 const std::string sysfsName = "occ-hwmon";
 
+const uint8_t THROTTLED_NONE = 0x00;
+const uint8_t THROTTLED_POWER = 0x01;
+const uint8_t THROTTLED_THERMAL = 0x02;
+const uint8_t THROTTLED_SAFE = 0x04;
+const uint8_t THROTTLED_ALL = 0xFF;
+
 /** @class Status
  *  @brief Implementation of OCC Active Status
  */
@@ -222,7 +232,6 @@
     {
         return pldmSensorStateReceived;
     }
-
 #endif // POWER10
 
     /** @brief Return the HWMON path for this OCC
@@ -231,10 +240,33 @@
      */
     fs::path getHwmonPath();
 
+    /** @brief Update the processor path associated with this OCC
+     */
+    void updateProcAssociation()
+    {
+        readProcAssociation();
+        if (nullptr != throttleHandle)
+        {
+            throttleHandle.reset();
+        }
+        if (!procPath.empty())
+        {
+            throttleHandle = std::make_unique<ThrottleInterface>(
+                utils::getBus(), procPath.c_str());
+        }
+    }
+
+    /** @brief Update the processor throttle status on dbus
+     */
+    void updateThrottle(const bool isThrottled, const uint8_t reason);
+
   private:
     /** @brief OCC dbus object path */
     std::string path;
 
+    /** @brief Processor path associated with this OCC */
+    std::string procPath;
+
     /** @brief Callback handler to be invoked during property change.
      *         This is a handler in Manager class
      */
@@ -360,6 +392,15 @@
 #ifdef PLDM
     std::function<void(instanceID)> resetCallBack = nullptr;
 #endif
+
+    /** @brief Current throttle reason(s) for this processor */
+    uint8_t throttleCause = THROTTLED_NONE;
+
+    /** @brief Throttle interface for the processor associated with this OCC */
+    std::unique_ptr<ThrottleInterface> throttleHandle;
+
+    /** @brief Read the processor path associated with this OCC */
+    void readProcAssociation();
 };
 
 } // namespace occ