1 #pragma once 2 3 #include "backup_restore.hpp" 4 #include "gpio_monitor.hpp" 5 #include "worker.hpp" 6 7 #include <sdbusplus/asio/object_server.hpp> 8 9 #include <memory> 10 11 namespace vpd 12 { 13 /** 14 * @brief Class to handle OEM specific use case. 15 * 16 * Few pre-requisites needs to be taken case specifically, which will be 17 * encapsulated by this class. 18 */ 19 class IbmHandler 20 { 21 public: 22 /** 23 * List of deleted methods. 24 */ 25 IbmHandler(const IbmHandler&) = delete; 26 IbmHandler& operator=(const IbmHandler&) = delete; 27 IbmHandler(IbmHandler&&) = delete; 28 29 /** 30 * @brief Constructor. 31 * 32 * @param[in] o_worker - Reference to worker class object. 33 * @param[in] o_backupAndRestoreObj - Ref to back up and restore class 34 * object. 35 * @param[in] i_iFace - interface to implement. 36 * @param[in] i_ioCon - IO context. 37 * @param[in] i_asioConnection - Dbus Connection. 38 */ 39 IbmHandler( 40 std::shared_ptr<Worker>& o_worker, 41 std::shared_ptr<BackupAndRestore>& o_backupAndRestoreObj, 42 const std::shared_ptr<sdbusplus::asio::dbus_interface>& i_iFace, 43 const std::shared_ptr<boost::asio::io_context>& i_ioCon, 44 const std::shared_ptr<sdbusplus::asio::connection>& i_asioConnection); 45 46 private: 47 /** 48 * @brief API to register callback for Host state change. 49 */ 50 void registerHostStateChangeCallback(); 51 52 /** 53 * @brief API to process host state change callback. 54 * 55 * @param[in] i_msg - Callback message. 56 */ 57 void hostStateChangeCallBack(sdbusplus::message_t& i_msg); 58 59 /** 60 * @brief API to set timer to detect system VPD over D-Bus. 61 * 62 * System VPD is required before bus name for VPD-Manager is claimed. Once 63 * system VPD is published, VPD for other FRUs should be collected. This API 64 * detects id system VPD is already published on D-Bus and based on that 65 * triggers VPD collection for rest of the FRUs. 66 * 67 * Note: Throws exception in case of any failure. Needs to be handled by the 68 * caller. 69 */ 70 void SetTimerToDetectSVPDOnDbus(); 71 72 /** 73 * @brief Set timer to detect and set VPD collection status for the system. 74 * 75 * Collection of FRU VPD is triggered in a separate thread. Resulting in 76 * multiple threads at a given time. The API creates a timer which on 77 * regular interval will check if all the threads were collected back and 78 * sets the status of the VPD collection for the system accordingly. 79 * 80 * @throw std::runtime_error 81 */ 82 void SetTimerToDetectVpdCollectionStatus(); 83 84 /** 85 * @brief API to register callback for "AssetTag" property change. 86 */ 87 void registerAssetTagChangeCallback(); 88 89 /** 90 * @brief Callback API to be triggered on "AssetTag" property change. 91 * 92 * @param[in] i_msg - The callback message. 93 */ 94 void processAssetTagChangeCallback(sdbusplus::message_t& i_msg); 95 96 /** 97 * @brief API to process VPD collection thread failed EEPROMs. 98 */ 99 void processFailedEeproms(); 100 101 /** 102 * @brief API to check and update PowerVS VPD. 103 * 104 * The API will read the existing data from the DBus and if found 105 * different than what has been read from JSON, it will update the VPD with 106 * JSON data on hardware and DBus both. 107 * 108 * @param[in] i_powerVsJsonObj - PowerVS JSON object. 109 * @param[out] o_failedPathList - List of path failed to update. 110 */ 111 void checkAndUpdatePowerVsVpd(const nlohmann::json& i_powerVsJsonObj, 112 std::vector<std::string>& o_failedPathList); 113 /** 114 * @brief API to handle configuration w.r.t. PowerVS systems. 115 * 116 * Some FRUs VPD is specific to powerVS system. The API detects the 117 * powerVS configuration and updates the VPD accordingly. 118 */ 119 void ConfigurePowerVsSystem(); 120 121 /** 122 * @brief API to perform initial setup before manager claims Bus name. 123 * 124 * Before BUS name for VPD-Manager is claimed, fitconfig whould be set for 125 * corret device tree, inventory JSON w.r.t system should be linked and 126 * system VPD should be on DBus. 127 */ 128 void performInitialSetup(); 129 130 /** 131 * @brief API to prime system blueprint. 132 * 133 * The API will traverse the system config JSON and will prime all the FRU 134 * paths which qualifies for priming. 135 */ 136 void primeSystemBlueprint(); 137 138 /** 139 * @brief Function to enable and bring MUX out of idle state. 140 * 141 * This finds all the MUX defined in the system json and enables them by 142 * setting the holdidle parameter to 0. 143 * 144 * @throw std::runtime_error 145 */ 146 void enableMuxChips(); 147 148 // Parsed system config json object. 149 nlohmann::json m_sysCfgJsonObj{}; 150 151 // Shared pointer to worker class 152 std::shared_ptr<Worker>& m_worker; 153 154 // Shared pointer to backup and restore object. 155 std::shared_ptr<BackupAndRestore>& m_backupAndRestoreObj; 156 157 // Shared pointer to GpioMonitor object. 158 std::shared_ptr<GpioMonitor> m_gpioMonitor; 159 160 // Shared pointer to Dbus interface class. 161 const std::shared_ptr<sdbusplus::asio::dbus_interface>& m_interface; 162 163 // Shared pointer to asio context object. 164 const std::shared_ptr<boost::asio::io_context>& m_ioContext; 165 166 // Shared pointer to bus connection. 167 const std::shared_ptr<sdbusplus::asio::connection>& m_asioConnection; 168 }; 169 } // namespace vpd 170