blob: 35b905e2a72839d82c51714d73db88a6fbb124a0 [file] [log] [blame]
Sunny Srivastava867ee752025-04-15 12:24:23 +05301#pragma once
2
Sunny Srivastavac74c8ef2025-04-16 12:45:27 +05303#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
Sunny Srivastava867ee752025-04-15 12:24:23 +053011namespace vpd
12{
13/**
Sunny Srivastavac74c8ef2025-04-16 12:45:27 +053014 * @brief Class to handle OEM specific use case.
Sunny Srivastava867ee752025-04-15 12:24:23 +053015 *
16 * Few pre-requisites needs to be taken case specifically, which will be
17 * encapsulated by this class.
18 */
19class 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.
Sunny Srivastavac74c8ef2025-04-16 12:45:27 +053031 *
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.
Sunny Srivastava867ee752025-04-15 12:24:23 +053038 */
Sunny Srivastavac74c8ef2025-04-16 12:45:27 +053039 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 set timer to detect system VPD over D-Bus.
49 *
50 * System VPD is required before bus name for VPD-Manager is claimed. Once
51 * system VPD is published, VPD for other FRUs should be collected. This API
52 * detects id system VPD is already published on D-Bus and based on that
53 * triggers VPD collection for rest of the FRUs.
54 *
55 * Note: Throws exception in case of any failure. Needs to be handled by the
56 * caller.
57 */
58 void SetTimerToDetectSVPDOnDbus();
59
60 /**
61 * @brief Set timer to detect and set VPD collection status for the system.
62 *
63 * Collection of FRU VPD is triggered in a separate thread. Resulting in
64 * multiple threads at a given time. The API creates a timer which on
65 * regular interval will check if all the threads were collected back and
66 * sets the status of the VPD collection for the system accordingly.
67 *
68 * @throw std::runtime_error
69 */
70 void SetTimerToDetectVpdCollectionStatus();
71
72 /**
73 * @brief API to register callback for "AssetTag" property change.
74 */
75 void registerAssetTagChangeCallback();
76
77 /**
78 * @brief Callback API to be triggered on "AssetTag" property change.
79 *
80 * @param[in] i_msg - The callback message.
81 */
82 void processAssetTagChangeCallback(sdbusplus::message_t& i_msg);
83
84 /**
85 * @brief API to process VPD collection thread failed EEPROMs.
86 */
87 void processFailedEeproms();
88
89 /**
90 * @brief API to check and update PowerVS VPD.
91 *
92 * The API will read the existing data from the DBus and if found
93 * different than what has been read from JSON, it will update the VPD with
94 * JSON data on hardware and DBus both.
95 *
96 * @param[in] i_powerVsJsonObj - PowerVS JSON object.
97 * @param[out] o_failedPathList - List of path failed to update.
98 */
99 void checkAndUpdatePowerVsVpd(const nlohmann::json& i_powerVsJsonObj,
100 std::vector<std::string>& o_failedPathList);
101 /**
102 * @brief API to handle configuration w.r.t. PowerVS systems.
103 *
104 * Some FRUs VPD is specific to powerVS system. The API detects the
105 * powerVS configuration and updates the VPD accordingly.
106 */
107 void ConfigurePowerVsSystem();
108
109 // Parsed system config json object.
110 nlohmann::json m_sysCfgJsonObj{};
111
112 // Shared pointer to worker class
113 std::shared_ptr<Worker>& m_worker;
114
115 // Shared pointer to backup and restore object.
116 std::shared_ptr<BackupAndRestore>& m_backupAndRestoreObj;
117
118 // Shared pointer to GpioMonitor object.
119 std::shared_ptr<GpioMonitor> m_gpioMonitor;
120
121 // Shared pointer to Dbus interface class.
122 const std::shared_ptr<sdbusplus::asio::dbus_interface>& m_interface;
123
124 // Shared pointer to asio context object.
125 const std::shared_ptr<boost::asio::io_context>& m_ioContext;
126
127 // Shared pointer to bus connection.
128 const std::shared_ptr<sdbusplus::asio::connection>& m_asioConnection;
Sunny Srivastava867ee752025-04-15 12:24:23 +0530129};
130} // namespace vpd