11962e087SMatt Spinler #pragma once 21962e087SMatt Spinler 31962e087SMatt Spinler #include "data_interface.hpp" 41962e087SMatt Spinler #include "pel.hpp" 51962e087SMatt Spinler 61962e087SMatt Spinler namespace openpower::pels::service_indicators 71962e087SMatt Spinler { 81962e087SMatt Spinler 91962e087SMatt Spinler /** 101962e087SMatt Spinler * @class Policy 111962e087SMatt Spinler * 121962e087SMatt Spinler * The base class for service indicator policies. 131962e087SMatt Spinler */ 141962e087SMatt Spinler class Policy 151962e087SMatt Spinler { 161962e087SMatt Spinler public: 171962e087SMatt Spinler Policy() = delete; 181962e087SMatt Spinler virtual ~Policy() = default; 191962e087SMatt Spinler Policy(const Policy&) = default; 201962e087SMatt Spinler Policy& operator=(const Policy&) = default; 211962e087SMatt Spinler Policy(Policy&&) = default; 221962e087SMatt Spinler Policy& operator=(Policy&&) = default; 231962e087SMatt Spinler 241962e087SMatt Spinler /** 251962e087SMatt Spinler * @brief Constructor 261962e087SMatt Spinler * 271962e087SMatt Spinler * @param[in] dataIface - The DataInterface object 281962e087SMatt Spinler */ Policy(const DataInterfaceBase & dataIface)291962e087SMatt Spinler explicit Policy(const DataInterfaceBase& dataIface) : _dataIface(dataIface) 30*2544b419SPatrick Williams {} 311962e087SMatt Spinler 321962e087SMatt Spinler /** 331962e087SMatt Spinler * @brief Pure virtual function for activating service indicators 341962e087SMatt Spinler * based on PEL contents. 351962e087SMatt Spinler * 361962e087SMatt Spinler * @param[in] pel - The PEL 371962e087SMatt Spinler */ 381962e087SMatt Spinler virtual void activate(const PEL& pel) = 0; 391962e087SMatt Spinler 401962e087SMatt Spinler protected: 411962e087SMatt Spinler /** 421962e087SMatt Spinler * @brief Reference to the DataInterface object 431962e087SMatt Spinler */ 441962e087SMatt Spinler const DataInterfaceBase& _dataIface; 451962e087SMatt Spinler }; 461962e087SMatt Spinler 471962e087SMatt Spinler /** 481962e087SMatt Spinler * @class LightPath 491962e087SMatt Spinler * 501962e087SMatt Spinler * This class implements the 'LightPath' IBM policy for 511962e087SMatt Spinler * activating LEDs. It has a set of rules to use to choose 521962e087SMatt Spinler * which callouts inside PELs should have their LEDs asserted, 531962e087SMatt Spinler * and then activates them by writing the Assert property on 541962e087SMatt Spinler * LED group D-Bus objects. 551962e087SMatt Spinler */ 561962e087SMatt Spinler class LightPath : public Policy 571962e087SMatt Spinler { 581962e087SMatt Spinler public: 591962e087SMatt Spinler LightPath() = delete; 601962e087SMatt Spinler virtual ~LightPath() = default; 611962e087SMatt Spinler LightPath(const LightPath&) = default; 621962e087SMatt Spinler LightPath& operator=(const LightPath&) = default; 631962e087SMatt Spinler LightPath(LightPath&&) = default; 641962e087SMatt Spinler LightPath& operator=(LightPath&&) = default; 651962e087SMatt Spinler 661962e087SMatt Spinler /** 671962e087SMatt Spinler * @brief Constructor 681962e087SMatt Spinler * 691962e087SMatt Spinler * @param[in] dataIface - The DataInterface object 701962e087SMatt Spinler */ LightPath(const DataInterfaceBase & dataIface)711962e087SMatt Spinler explicit LightPath(const DataInterfaceBase& dataIface) : Policy(dataIface) 72*2544b419SPatrick Williams {} 731962e087SMatt Spinler 741962e087SMatt Spinler /** 751962e087SMatt Spinler * @brief Turns on LEDs for certain FRUs called out in the PEL. 761962e087SMatt Spinler * 771962e087SMatt Spinler * First it selectively chooses location codes listed in the FRU 781962e087SMatt Spinler * callout section that it wants to turn on LEDs for. Next it 791962e087SMatt Spinler * looks up the inventory D-Bus paths for the FRU represented by 801962e087SMatt Spinler * those location codes, and then looks for associations to the 811962e087SMatt Spinler * LED group objects for those inventory paths. After it has 821962e087SMatt Spinler * the LED group object, it sets the Asserted property on it. 831962e087SMatt Spinler * 841962e087SMatt Spinler * It only does the above for PELs that were created by the BMC 851962e087SMatt Spinler * or hostboot and have the Serviceable action flag set. 861962e087SMatt Spinler * 871962e087SMatt Spinler * If there are problems looking up any inventory path or LED 881962e087SMatt Spinler * group, then it will stop and not activate any LEDs at all. 891962e087SMatt Spinler * 901962e087SMatt Spinler * @param[in] pel - The PEL 911962e087SMatt Spinler */ 921962e087SMatt Spinler void activate(const PEL& pel) override; 931962e087SMatt Spinler 941962e087SMatt Spinler /** 9505f0c6dcSMatt Spinler * @brief Returns the location codes for the FRU callouts in the 9605f0c6dcSMatt Spinler * callouts list that need their LEDs turned on. 9705f0c6dcSMatt Spinler * 9805f0c6dcSMatt Spinler * This is public so it can be tested. 9905f0c6dcSMatt Spinler * 10005f0c6dcSMatt Spinler * @param[in] callouts - The Callout list from a PEL 10105f0c6dcSMatt Spinler * 10205f0c6dcSMatt Spinler * @return std::vector<std::string> - The location codes 1031962e087SMatt Spinler */ 1041962e087SMatt Spinler std::vector<std::string> getLocationCodes( 1051962e087SMatt Spinler const std::vector<std::unique_ptr<src::Callout>>& callouts) const; 1061962e087SMatt Spinler 1071962e087SMatt Spinler /** 10805f0c6dcSMatt Spinler * @brief Function called to check if the code even needs to 10905f0c6dcSMatt Spinler * bother looking in the callouts to find LEDs to turn on. 11005f0c6dcSMatt Spinler * 11105f0c6dcSMatt Spinler * It will ignore all PELs except for those created by the BMC or 11205f0c6dcSMatt Spinler * hostboot that have the Serviceable action flag set. 11305f0c6dcSMatt Spinler * 11405f0c6dcSMatt Spinler * This is public so it can be tested. 11505f0c6dcSMatt Spinler * 11605f0c6dcSMatt Spinler * @param[in] pel - The PEL 11705f0c6dcSMatt Spinler * 11805f0c6dcSMatt Spinler * @return bool - If the PEL should be ignored or not. 1191962e087SMatt Spinler */ 1201962e087SMatt Spinler bool ignore(const PEL& pel) const; 1211962e087SMatt Spinler 1221962e087SMatt Spinler private: 1231962e087SMatt Spinler /** 124993168deSMatt Spinler * @brief Returns the inventory D-Bus paths for the passed 125993168deSMatt Spinler * in location codes. 12634a904cfSMatt Spinler * 12734a904cfSMatt Spinler * @param[in] locationCodes - The location codes 12834a904cfSMatt Spinler * 129993168deSMatt Spinler * @return std::vector<std::string> - The inventory D-Bus paths 1301962e087SMatt Spinler */ 1311962e087SMatt Spinler std::vector<std::string> 132993168deSMatt Spinler getInventoryPaths(const std::vector<std::string>& locationCodes) const; 1331962e087SMatt Spinler 1341962e087SMatt Spinler /** 135993168deSMatt Spinler * @brief Sets the Functional property on the passed in 136993168deSMatt Spinler * inventory paths to false. 13734a904cfSMatt Spinler * 138993168deSMatt Spinler * There is code watching for this that will then turn on 139993168deSMatt Spinler * any LEDs for that FRU. 140993168deSMatt Spinler * 141993168deSMatt Spinler * @param[in] inventoryPaths - The inventory D-Bus paths 1421962e087SMatt Spinler */ 143993168deSMatt Spinler void setNotFunctional(const std::vector<std::string>& inventoryPaths) const; 14405f0c6dcSMatt Spinler 14505f0c6dcSMatt Spinler /** 14676198a2eSSumit Kumar * @brief Sets the critical association on the passed in 14776198a2eSSumit Kumar * inventory paths. 14876198a2eSSumit Kumar * 14976198a2eSSumit Kumar * @param[in] inventoryPaths - The inventory D-Bus paths 15076198a2eSSumit Kumar */ 15176198a2eSSumit Kumar void createCriticalAssociation( 15276198a2eSSumit Kumar const std::vector<std::string>& inventoryPaths) const; 15376198a2eSSumit Kumar 15476198a2eSSumit Kumar /** 15505f0c6dcSMatt Spinler * @brief Checks if the callout priority is one that the policy 15605f0c6dcSMatt Spinler * may turn on an LED for. 15705f0c6dcSMatt Spinler * 15805f0c6dcSMatt Spinler * The priorities it cares about are high, medium, and medium 15905f0c6dcSMatt Spinler * group A. 16005f0c6dcSMatt Spinler * 16105f0c6dcSMatt Spinler * @param[in] priority - The priority value from the PEL 16205f0c6dcSMatt Spinler * 16305f0c6dcSMatt Spinler * @return bool - If LightPath cares about a callout with this 16405f0c6dcSMatt Spinler * priority. 16505f0c6dcSMatt Spinler */ 16605f0c6dcSMatt Spinler bool isRequiredPriority(uint8_t priority) const; 16705f0c6dcSMatt Spinler 16805f0c6dcSMatt Spinler /** 16905f0c6dcSMatt Spinler * @brief Checks if the callout is either a normal FRU 17005f0c6dcSMatt Spinler * callout or a symbolic FRU callout with a trusted 17105f0c6dcSMatt Spinler * location code, which is one of the requirements for 17205f0c6dcSMatt Spinler * LightPath to turn on an LED. 17305f0c6dcSMatt Spinler * 17405f0c6dcSMatt Spinler * @param[in] - callout - The Callout object 17505f0c6dcSMatt Spinler * 17605f0c6dcSMatt Spinler * @return bool - If the callout is a hardware callout 17705f0c6dcSMatt Spinler */ 17805f0c6dcSMatt Spinler bool isHardwareCallout(const src::Callout& callout) const; 1791962e087SMatt Spinler }; 1801962e087SMatt Spinler 1811962e087SMatt Spinler /** 1821962e087SMatt Spinler * @brief Returns the object for the service indicator policy 1831962e087SMatt Spinler * implemented on the system. 1841962e087SMatt Spinler * 1851962e087SMatt Spinler * @param[in] dataIface - The DataInterface object 1861962e087SMatt Spinler * 1871962e087SMatt Spinler * @return std::unique_ptr<Policy> - The policy object 1881962e087SMatt Spinler * 1891962e087SMatt Spinler */ 1901962e087SMatt Spinler std::unique_ptr<Policy> getPolicy(const DataInterfaceBase& dataIface); 1911962e087SMatt Spinler 1921962e087SMatt Spinler } // namespace openpower::pels::service_indicators 193