1 #pragma once 2 3 #include "data_interface.hpp" 4 #include "pel.hpp" 5 6 namespace openpower::pels::service_indicators 7 { 8 9 /** 10 * @class Policy 11 * 12 * The base class for service indicator policies. 13 */ 14 class Policy 15 { 16 public: 17 Policy() = delete; 18 virtual ~Policy() = default; 19 Policy(const Policy&) = default; 20 Policy& operator=(const Policy&) = default; 21 Policy(Policy&&) = default; 22 Policy& operator=(Policy&&) = default; 23 24 /** 25 * @brief Constructor 26 * 27 * @param[in] dataIface - The DataInterface object 28 */ 29 explicit Policy(const DataInterfaceBase& dataIface) : _dataIface(dataIface) 30 {} 31 32 /** 33 * @brief Pure virtual function for activating service indicators 34 * based on PEL contents. 35 * 36 * @param[in] pel - The PEL 37 */ 38 virtual void activate(const PEL& pel) = 0; 39 40 protected: 41 /** 42 * @brief Reference to the DataInterface object 43 */ 44 const DataInterfaceBase& _dataIface; 45 }; 46 47 /** 48 * @class LightPath 49 * 50 * This class implements the 'LightPath' IBM policy for 51 * activating LEDs. It has a set of rules to use to choose 52 * which callouts inside PELs should have their LEDs asserted, 53 * and then activates them by writing the Assert property on 54 * LED group D-Bus objects. 55 */ 56 class LightPath : public Policy 57 { 58 public: 59 LightPath() = delete; 60 virtual ~LightPath() = default; 61 LightPath(const LightPath&) = default; 62 LightPath& operator=(const LightPath&) = default; 63 LightPath(LightPath&&) = default; 64 LightPath& operator=(LightPath&&) = default; 65 66 /** 67 * @brief Constructor 68 * 69 * @param[in] dataIface - The DataInterface object 70 */ 71 explicit LightPath(const DataInterfaceBase& dataIface) : Policy(dataIface) 72 {} 73 74 /** 75 * @brief Turns on LEDs for certain FRUs called out in the PEL. 76 * 77 * First it selectively chooses location codes listed in the FRU 78 * callout section that it wants to turn on LEDs for. Next it 79 * looks up the inventory D-Bus paths for the FRU represented by 80 * those location codes, and then looks for associations to the 81 * LED group objects for those inventory paths. After it has 82 * the LED group object, it sets the Asserted property on it. 83 * 84 * It only does the above for PELs that were created by the BMC 85 * or hostboot and have the Serviceable action flag set. 86 * 87 * If there are problems looking up any inventory path or LED 88 * group, then it will stop and not activate any LEDs at all. 89 * 90 * @param[in] pel - The PEL 91 */ 92 void activate(const PEL& pel) override; 93 94 /** 95 * @brief Returns the location codes for the FRU callouts in the 96 * callouts list that need their LEDs turned on. 97 * 98 * This is public so it can be tested. 99 * 100 * @param[in] callouts - The Callout list from a PEL 101 * 102 * @return std::vector<std::string> - The location codes 103 */ 104 std::vector<std::string> getLocationCodes( 105 const std::vector<std::unique_ptr<src::Callout>>& callouts) const; 106 107 /** 108 * @brief Function called to check if the code even needs to 109 * bother looking in the callouts to find LEDs to turn on. 110 * 111 * It will ignore all PELs except for those created by the BMC or 112 * hostboot that have the Serviceable action flag set. 113 * 114 * This is public so it can be tested. 115 * 116 * @param[in] pel - The PEL 117 * 118 * @return bool - If the PEL should be ignored or not. 119 */ 120 bool ignore(const PEL& pel) const; 121 122 private: 123 /** 124 * @brief Returns the inventory D-Bus paths for the passed 125 * in location codes. 126 * 127 * @param[in] locationCodes - The location codes 128 * 129 * @return std::vector<std::string> - The inventory D-Bus paths 130 */ 131 std::vector<std::string> 132 getInventoryPaths(const std::vector<std::string>& locationCodes) const; 133 134 /** 135 * @brief Sets the Functional property on the passed in 136 * inventory paths to false. 137 * 138 * There is code watching for this that will then turn on 139 * any LEDs for that FRU. 140 * 141 * @param[in] inventoryPaths - The inventory D-Bus paths 142 */ 143 void setNotFunctional(const std::vector<std::string>& inventoryPaths) const; 144 145 /** 146 * @brief Sets the critical association on the passed in 147 * inventory paths. 148 * 149 * @param[in] inventoryPaths - The inventory D-Bus paths 150 */ 151 void createCriticalAssociation( 152 const std::vector<std::string>& inventoryPaths) const; 153 154 /** 155 * @brief Checks if the callout priority is one that the policy 156 * may turn on an LED for. 157 * 158 * The priorities it cares about are high, medium, and medium 159 * group A. 160 * 161 * @param[in] priority - The priority value from the PEL 162 * 163 * @return bool - If LightPath cares about a callout with this 164 * priority. 165 */ 166 bool isRequiredPriority(uint8_t priority) const; 167 168 /** 169 * @brief Checks if the callout is either a normal FRU 170 * callout or a symbolic FRU callout with a trusted 171 * location code, which is one of the requirements for 172 * LightPath to turn on an LED. 173 * 174 * @param[in] - callout - The Callout object 175 * 176 * @return bool - If the callout is a hardware callout 177 */ 178 bool isHardwareCallout(const src::Callout& callout) const; 179 }; 180 181 /** 182 * @brief Returns the object for the service indicator policy 183 * implemented on the system. 184 * 185 * @param[in] dataIface - The DataInterface object 186 * 187 * @return std::unique_ptr<Policy> - The policy object 188 * 189 */ 190 std::unique_ptr<Policy> getPolicy(const DataInterfaceBase& dataIface); 191 192 } // namespace openpower::pels::service_indicators 193