| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| Sunny Srivastava | 867ee75 | 2025-04-15 12:24:23 +0530 | [diff] [blame] | 3 | #include "ibm_handler.hpp" |
| 4 | |
| Anupama B R | 56e4537 | 2025-06-19 12:54:44 -0500 | [diff] [blame] | 5 | #include "listener.hpp" |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 6 | #include "parser.hpp" |
| 7 | |
| Sunny Srivastava | 78a5042 | 2025-04-25 11:17:56 +0530 | [diff] [blame] | 8 | #include <utility/common_utility.hpp> |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 9 | #include <utility/dbus_utility.hpp> |
| 10 | #include <utility/json_utility.hpp> |
| 11 | #include <utility/vpd_specific_utility.hpp> |
| 12 | |
| Sunny Srivastava | 867ee75 | 2025-04-15 12:24:23 +0530 | [diff] [blame] | 13 | namespace vpd |
| 14 | { |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 15 | IbmHandler::IbmHandler( |
| 16 | std::shared_ptr<Worker>& o_worker, |
| 17 | std::shared_ptr<BackupAndRestore>& o_backupAndRestoreObj, |
| 18 | const std::shared_ptr<sdbusplus::asio::dbus_interface>& i_iFace, |
| Anupama B R | da9806b | 2025-08-29 02:41:10 -0500 | [diff] [blame] | 19 | const std::shared_ptr<sdbusplus::asio::dbus_interface>& i_progressiFace, |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 20 | const std::shared_ptr<boost::asio::io_context>& i_ioCon, |
| 21 | const std::shared_ptr<sdbusplus::asio::connection>& i_asioConnection) : |
| 22 | m_worker(o_worker), m_backupAndRestoreObj(o_backupAndRestoreObj), |
| Anupama B R | da9806b | 2025-08-29 02:41:10 -0500 | [diff] [blame] | 23 | m_interface(i_iFace), m_progressInterface(i_progressiFace), |
| Souvik Roy | a5e18b8 | 2025-09-25 05:59:56 +0000 | [diff] [blame] | 24 | m_ioContext(i_ioCon), m_asioConnection(i_asioConnection), |
| 25 | m_logger(Logger::getLoggerInstance()) |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 26 | { |
| Souvik Roy | c117173 | 2025-10-16 09:27:38 +0000 | [diff] [blame^] | 27 | uint16_t l_errCode{0}; |
| 28 | |
| 29 | // check VPD collection mode |
| 30 | const auto l_vpdCollectionMode = |
| 31 | commonUtility::isFieldModeEnabled() |
| 32 | ? types::VpdCollectionMode::DEFAULT_MODE |
| 33 | : commonUtility::getVpdCollectionMode(l_errCode); |
| 34 | |
| 35 | if (l_errCode) |
| 36 | { |
| 37 | m_logger->logMessage( |
| 38 | "Error while trying to read VPD collection mode: " + |
| 39 | commonUtility::getErrCodeMsg(l_errCode)); |
| 40 | l_errCode = 0; |
| 41 | } |
| 42 | |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 43 | if (dbusUtility::isChassisPowerOn()) |
| 44 | { |
| 45 | // At power on, less number of FRU(s) needs collection. we can scale |
| 46 | // down the threads to reduce CPU utilization. |
| Souvik Roy | c117173 | 2025-10-16 09:27:38 +0000 | [diff] [blame^] | 47 | m_worker = std::make_shared<Worker>( |
| 48 | INVENTORY_JSON_DEFAULT, constants::VALUE_1, l_vpdCollectionMode); |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 49 | } |
| 50 | else |
| 51 | { |
| 52 | // Initialize with default configuration |
| Souvik Roy | c117173 | 2025-10-16 09:27:38 +0000 | [diff] [blame^] | 53 | m_worker = std::make_shared<Worker>(INVENTORY_JSON_DEFAULT, |
| 54 | constants::MAX_THREADS, |
| 55 | l_vpdCollectionMode); |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | // Set up minimal things that is needed before bus name is claimed. |
| Sunny Srivastava | 78a5042 | 2025-04-25 11:17:56 +0530 | [diff] [blame] | 59 | performInitialSetup(); |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 60 | |
| 61 | if (!m_sysCfgJsonObj.empty() && |
| Rekha Aparna | 196e308 | 2025-09-08 20:40:35 -0500 | [diff] [blame] | 62 | jsonUtility::isBackupAndRestoreRequired(m_sysCfgJsonObj, l_errCode)) |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 63 | { |
| 64 | try |
| 65 | { |
| 66 | m_backupAndRestoreObj = |
| 67 | std::make_shared<BackupAndRestore>(m_sysCfgJsonObj); |
| 68 | } |
| 69 | catch (const std::exception& l_ex) |
| 70 | { |
| 71 | logging::logMessage("Back up and restore instantiation failed. {" + |
| 72 | std::string(l_ex.what()) + "}"); |
| 73 | |
| 74 | EventLogger::createSyncPel( |
| 75 | EventLogger::getErrorType(l_ex), types::SeverityType::Warning, |
| 76 | __FILE__, __FUNCTION__, 0, EventLogger::getErrorMsg(l_ex), |
| 77 | std::nullopt, std::nullopt, std::nullopt, std::nullopt); |
| 78 | } |
| 79 | } |
| Rekha Aparna | 196e308 | 2025-09-08 20:40:35 -0500 | [diff] [blame] | 80 | else if (l_errCode) |
| 81 | { |
| 82 | logging::logMessage( |
| 83 | "Failed to check if backup & restore required. Error : " + |
| Rekha Aparna | c6159a2 | 2025-10-09 12:20:20 +0530 | [diff] [blame] | 84 | commonUtility::getErrCodeMsg(l_errCode)); |
| Rekha Aparna | 196e308 | 2025-09-08 20:40:35 -0500 | [diff] [blame] | 85 | } |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 86 | |
| Anupama B R | c7565ed | 2025-06-19 02:08:39 -0500 | [diff] [blame] | 87 | // Instantiate Listener object |
| Anupama B R | 56e4537 | 2025-06-19 12:54:44 -0500 | [diff] [blame] | 88 | m_eventListener = std::make_shared<Listener>(m_worker, m_asioConnection); |
| 89 | m_eventListener->registerAssetTagChangeCallback(); |
| 90 | m_eventListener->registerHostStateChangeCallback(); |
| Souvik Roy | 5c3a156 | 2025-07-02 01:39:44 -0500 | [diff] [blame] | 91 | m_eventListener->registerPresenceChangeCallback(); |
| Anupama B R | c7565ed | 2025-06-19 02:08:39 -0500 | [diff] [blame] | 92 | |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 93 | // Instantiate GpioMonitor class |
| 94 | m_gpioMonitor = |
| 95 | std::make_shared<GpioMonitor>(m_sysCfgJsonObj, m_worker, m_ioContext); |
| 96 | } |
| 97 | |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 98 | void IbmHandler::SetTimerToDetectVpdCollectionStatus() |
| 99 | { |
| 100 | // Keeping max retry for 2 minutes. TODO: Make it configurable based on |
| 101 | // system type. |
| 102 | static constexpr auto MAX_RETRY = 12; |
| 103 | |
| 104 | static boost::asio::steady_timer l_timer(*m_ioContext); |
| 105 | static uint8_t l_timerRetry = 0; |
| 106 | |
| 107 | auto l_asyncCancelled = l_timer.expires_after(std::chrono::seconds(10)); |
| 108 | |
| 109 | (l_asyncCancelled == 0) |
| 110 | ? logging::logMessage("Collection Timer started") |
| 111 | : logging::logMessage("Collection Timer re-started"); |
| 112 | |
| 113 | l_timer.async_wait([this](const boost::system::error_code& ec) { |
| 114 | if (ec == boost::asio::error::operation_aborted) |
| 115 | { |
| 116 | throw std::runtime_error( |
| 117 | "Timer to detect thread collection status was aborted"); |
| 118 | } |
| 119 | |
| 120 | if (ec) |
| 121 | { |
| 122 | throw std::runtime_error( |
| 123 | "Timer to detect thread collection failed"); |
| 124 | } |
| 125 | |
| 126 | if (m_worker->isAllFruCollectionDone()) |
| 127 | { |
| 128 | // cancel the timer |
| 129 | l_timer.cancel(); |
| 130 | processFailedEeproms(); |
| 131 | |
| 132 | // update VPD for powerVS system. |
| 133 | ConfigurePowerVsSystem(); |
| 134 | |
| 135 | std::cout << "m_worker->isSystemVPDOnDBus() completed" << std::endl; |
| Anupama B R | da9806b | 2025-08-29 02:41:10 -0500 | [diff] [blame] | 136 | m_progressInterface->set_property( |
| 137 | "Status", std::string(constants::vpdCollectionCompleted)); |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 138 | |
| 139 | if (m_backupAndRestoreObj) |
| 140 | { |
| 141 | m_backupAndRestoreObj->backupAndRestore(); |
| 142 | } |
| Souvik Roy | 3d4af4a | 2025-06-23 04:45:27 -0500 | [diff] [blame] | 143 | |
| 144 | if (m_eventListener) |
| 145 | { |
| 146 | m_eventListener->registerCorrPropCallBack(); |
| 147 | } |
| Souvik Roy | a5e18b8 | 2025-09-25 05:59:56 +0000 | [diff] [blame] | 148 | |
| 149 | // terminate collection logger |
| 150 | m_logger->terminateVpdCollectionLogging(); |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 151 | } |
| 152 | else |
| 153 | { |
| 154 | auto l_threadCount = m_worker->getActiveThreadCount(); |
| 155 | if (l_timerRetry == MAX_RETRY) |
| 156 | { |
| 157 | l_timer.cancel(); |
| 158 | logging::logMessage("Taking too long. Active thread = " + |
| 159 | std::to_string(l_threadCount)); |
| Souvik Roy | a5e18b8 | 2025-09-25 05:59:56 +0000 | [diff] [blame] | 160 | |
| 161 | // terminate collection logger |
| 162 | m_logger->terminateVpdCollectionLogging(); |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 163 | } |
| 164 | else |
| 165 | { |
| 166 | l_timerRetry++; |
| 167 | logging::logMessage("Collection is in progress for [" + |
| 168 | std::to_string(l_threadCount) + "] FRUs."); |
| 169 | |
| 170 | SetTimerToDetectVpdCollectionStatus(); |
| 171 | } |
| 172 | } |
| 173 | }); |
| 174 | } |
| 175 | |
| 176 | void IbmHandler::checkAndUpdatePowerVsVpd( |
| 177 | const nlohmann::json& i_powerVsJsonObj, |
| 178 | std::vector<std::string>& o_failedPathList) |
| 179 | { |
| 180 | for (const auto& [l_fruPath, l_recJson] : i_powerVsJsonObj.items()) |
| 181 | { |
| 182 | nlohmann::json l_sysCfgJsonObj{}; |
| 183 | if (m_worker.get() != nullptr) |
| 184 | { |
| 185 | l_sysCfgJsonObj = m_worker->getSysCfgJsonObj(); |
| 186 | } |
| 187 | |
| 188 | // The utility method will handle emty JSON case. No explicit |
| 189 | // handling required here. |
| Rekha Aparna | 017567a | 2025-08-13 02:07:06 -0500 | [diff] [blame] | 190 | uint16_t l_errCode = 0; |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 191 | auto l_inventoryPath = jsonUtility::getInventoryObjPathFromJson( |
| Rekha Aparna | 017567a | 2025-08-13 02:07:06 -0500 | [diff] [blame] | 192 | l_sysCfgJsonObj, l_fruPath, l_errCode); |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 193 | |
| 194 | // Mark it as failed if inventory path not found in JSON. |
| 195 | if (l_inventoryPath.empty()) |
| 196 | { |
| Rekha Aparna | 017567a | 2025-08-13 02:07:06 -0500 | [diff] [blame] | 197 | if (l_errCode) |
| 198 | { |
| 199 | logging::logMessage( |
| 200 | "Failed to get inventory object path from JSON for FRU [" + |
| Rekha Aparna | c6159a2 | 2025-10-09 12:20:20 +0530 | [diff] [blame] | 201 | l_fruPath + |
| 202 | "], error : " + commonUtility::getErrCodeMsg(l_errCode)); |
| Rekha Aparna | 017567a | 2025-08-13 02:07:06 -0500 | [diff] [blame] | 203 | } |
| 204 | |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 205 | o_failedPathList.push_back(l_fruPath); |
| 206 | continue; |
| 207 | } |
| 208 | |
| 209 | // check if the FRU is present |
| 210 | if (!dbusUtility::isInventoryPresent(l_inventoryPath)) |
| 211 | { |
| 212 | logging::logMessage( |
| 213 | "Inventory not present, skip updating part number. Path: " + |
| 214 | l_inventoryPath); |
| 215 | continue; |
| 216 | } |
| 217 | |
| 218 | // check if the FRU needs CCIN check before updating PN. |
| 219 | if (l_recJson.contains("CCIN")) |
| 220 | { |
| 221 | const auto& l_ccinFromDbus = |
| 222 | vpdSpecificUtility::getCcinFromDbus(l_inventoryPath); |
| 223 | |
| 224 | // Not an ideal situation as CCIN can't be empty. |
| 225 | if (l_ccinFromDbus.empty()) |
| 226 | { |
| 227 | o_failedPathList.push_back(l_fruPath); |
| 228 | continue; |
| 229 | } |
| 230 | |
| 231 | std::vector<std::string> l_ccinListFromJson = l_recJson["CCIN"]; |
| 232 | |
| 233 | if (find(l_ccinListFromJson.begin(), l_ccinListFromJson.end(), |
| 234 | l_ccinFromDbus) == l_ccinListFromJson.end()) |
| 235 | { |
| 236 | // Don't update PN in this case. |
| 237 | continue; |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | for (const auto& [l_recordName, l_kwdJson] : l_recJson.items()) |
| 242 | { |
| 243 | // Record name can't be CCIN, skip processing as it is there for PN |
| 244 | // update based on CCIN check. |
| 245 | if (l_recordName == constants::kwdCCIN) |
| 246 | { |
| 247 | continue; |
| 248 | } |
| 249 | |
| 250 | for (const auto& [l_kwdName, l_kwdValue] : l_kwdJson.items()) |
| 251 | { |
| 252 | // Is value of type array. |
| 253 | if (!l_kwdValue.is_array()) |
| 254 | { |
| 255 | o_failedPathList.push_back(l_fruPath); |
| 256 | continue; |
| 257 | } |
| 258 | |
| 259 | // Get current FRU Part number. |
| 260 | auto l_retVal = dbusUtility::readDbusProperty( |
| 261 | constants::pimServiceName, l_inventoryPath, |
| 262 | constants::viniInf, constants::kwdFN); |
| 263 | |
| 264 | auto l_ptrToFn = std::get_if<types::BinaryVector>(&l_retVal); |
| 265 | |
| 266 | if (!l_ptrToFn) |
| 267 | { |
| 268 | o_failedPathList.push_back(l_fruPath); |
| 269 | continue; |
| 270 | } |
| 271 | |
| 272 | types::BinaryVector l_binaryKwdValue = |
| 273 | l_kwdValue.get<types::BinaryVector>(); |
| 274 | if (l_binaryKwdValue == (*l_ptrToFn)) |
| 275 | { |
| 276 | continue; |
| 277 | } |
| 278 | |
| 279 | // Update part number only if required. |
| 280 | std::shared_ptr<Parser> l_parserObj = |
| 281 | std::make_shared<Parser>(l_fruPath, l_sysCfgJsonObj); |
| 282 | if (l_parserObj->updateVpdKeyword(std::make_tuple( |
| 283 | l_recordName, l_kwdName, l_binaryKwdValue)) == |
| 284 | constants::FAILURE) |
| 285 | { |
| 286 | o_failedPathList.push_back(l_fruPath); |
| 287 | continue; |
| 288 | } |
| 289 | |
| 290 | // update the Asset interface Spare part number explicitly. |
| 291 | if (!dbusUtility::callPIM(types::ObjectMap{ |
| 292 | {l_inventoryPath, |
| 293 | {{constants::assetInf, |
| 294 | {{"SparePartNumber", |
| 295 | std::string(l_binaryKwdValue.begin(), |
| 296 | l_binaryKwdValue.end())}}}}}})) |
| 297 | { |
| 298 | logging::logMessage( |
| 299 | "Updating Spare Part Number under Asset interface failed for path [" + |
| 300 | l_inventoryPath + "]"); |
| 301 | } |
| 302 | |
| 303 | // Just needed for logging. |
| 304 | std::string l_initialPartNum((*l_ptrToFn).begin(), |
| 305 | (*l_ptrToFn).end()); |
| 306 | std::string l_finalPartNum(l_binaryKwdValue.begin(), |
| 307 | l_binaryKwdValue.end()); |
| 308 | logging::logMessage( |
| 309 | "FRU Part number updated for path [" + l_inventoryPath + |
| 310 | "]" + "From [" + l_initialPartNum + "]" + " to [" + |
| 311 | l_finalPartNum + "]"); |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | void IbmHandler::ConfigurePowerVsSystem() |
| 318 | { |
| 319 | std::vector<std::string> l_failedPathList; |
| 320 | try |
| 321 | { |
| 322 | types::BinaryVector l_imValue = dbusUtility::getImFromDbus(); |
| 323 | if (l_imValue.empty()) |
| 324 | { |
| 325 | throw DbusException("Invalid IM value read from Dbus"); |
| 326 | } |
| 327 | |
| Rekha Aparna | ed09af8 | 2025-10-22 20:34:41 -0500 | [diff] [blame] | 328 | uint16_t l_errCode = 0; |
| 329 | if (!vpdSpecificUtility::isPowerVsConfiguration(l_imValue, l_errCode)) |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 330 | { |
| 331 | // TODO: Should booting be blocked in case of some |
| 332 | // misconfigurations? |
| Rekha Aparna | ed09af8 | 2025-10-22 20:34:41 -0500 | [diff] [blame] | 333 | if (l_errCode) |
| 334 | { |
| 335 | logging::logMessage( |
| 336 | "Failed to check if the system is powerVs Configuration, error : " + |
| 337 | commonUtility::getErrCodeMsg(l_errCode)); |
| 338 | } |
| 339 | |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 340 | return; |
| 341 | } |
| 342 | |
| 343 | const nlohmann::json& l_powerVsJsonObj = |
| Rekha Aparna | adf8526 | 2025-09-09 00:41:00 -0500 | [diff] [blame] | 344 | jsonUtility::getPowerVsJson(l_imValue, l_errCode); |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 345 | |
| 346 | if (l_powerVsJsonObj.empty()) |
| 347 | { |
| Rekha Aparna | c6159a2 | 2025-10-09 12:20:20 +0530 | [diff] [blame] | 348 | throw std::runtime_error("PowerVS Json not found. Error : " + |
| 349 | commonUtility::getErrCodeMsg(l_errCode)); |
| Sunny Srivastava | c74c8ef | 2025-04-16 12:45:27 +0530 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | checkAndUpdatePowerVsVpd(l_powerVsJsonObj, l_failedPathList); |
| 353 | |
| 354 | if (!l_failedPathList.empty()) |
| 355 | { |
| 356 | throw std::runtime_error( |
| 357 | "Part number update failed for following paths: "); |
| 358 | } |
| 359 | } |
| 360 | catch (const std::exception& l_ex) |
| 361 | { |
| 362 | // TODO log appropriate PEL |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | void IbmHandler::processFailedEeproms() |
| 367 | { |
| 368 | if (m_worker.get() != nullptr) |
| 369 | { |
| 370 | // TODO: |
| 371 | // - iterate through list of EEPROMs for which thread creation has |
| 372 | // failed |
| 373 | // - For each failed EEPROM, trigger VPD collection |
| 374 | m_worker->getFailedEepromPaths().clear(); |
| 375 | } |
| 376 | } |
| Sunny Srivastava | 380efbb | 2025-04-25 10:28:30 +0530 | [diff] [blame] | 377 | |
| Sunny Srivastava | 78a5042 | 2025-04-25 11:17:56 +0530 | [diff] [blame] | 378 | void IbmHandler::enableMuxChips() |
| 379 | { |
| 380 | if (m_sysCfgJsonObj.empty()) |
| 381 | { |
| 382 | // config JSON should not be empty at this point of execution. |
| 383 | throw std::runtime_error("Config JSON is empty. Can't enable muxes"); |
| 384 | return; |
| 385 | } |
| 386 | |
| 387 | if (!m_sysCfgJsonObj.contains("muxes")) |
| 388 | { |
| 389 | logging::logMessage("No mux defined for the system in config JSON"); |
| 390 | return; |
| 391 | } |
| 392 | |
| 393 | // iterate over each MUX detail and enable them. |
| 394 | for (const auto& item : m_sysCfgJsonObj["muxes"]) |
| 395 | { |
| 396 | if (item.contains("holdidlepath")) |
| 397 | { |
| 398 | std::string cmd = "echo 0 > "; |
| 399 | cmd += item["holdidlepath"]; |
| 400 | |
| 401 | logging::logMessage("Enabling mux with command = " + cmd); |
| 402 | |
| 403 | commonUtility::executeCmd(cmd); |
| 404 | continue; |
| 405 | } |
| 406 | |
| 407 | logging::logMessage( |
| 408 | "Mux Entry does not have hold idle path. Can't enable the mux"); |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | void IbmHandler::performInitialSetup() |
| 413 | { |
| 414 | try |
| 415 | { |
| Anupama B R | 281e2d4 | 2025-05-05 10:05:13 -0500 | [diff] [blame] | 416 | if (m_worker.get() == nullptr) |
| 417 | { |
| 418 | throw std::runtime_error( |
| 419 | "Worker object not found. Can't perform initial setup."); |
| 420 | } |
| 421 | |
| 422 | m_sysCfgJsonObj = m_worker->getSysCfgJsonObj(); |
| Sunny Srivastava | 78a5042 | 2025-04-25 11:17:56 +0530 | [diff] [blame] | 423 | if (!dbusUtility::isChassisPowerOn()) |
| 424 | { |
| Anupama B R | 281e2d4 | 2025-05-05 10:05:13 -0500 | [diff] [blame] | 425 | m_worker->setDeviceTreeAndJson(); |
| 426 | |
| 427 | // Since the above function setDeviceTreeAndJson can change the json |
| 428 | // which is used, we would need to reacquire the json object again |
| 429 | // here. |
| Sunny Srivastava | 78a5042 | 2025-04-25 11:17:56 +0530 | [diff] [blame] | 430 | m_sysCfgJsonObj = m_worker->getSysCfgJsonObj(); |
| 431 | } |
| 432 | |
| Anupama B R | 95083d4 | 2025-10-27 04:54:58 -0500 | [diff] [blame] | 433 | // Update BMC postion for RBMC prototype system |
| 434 | // Ignore BMC position update in case of any error |
| 435 | uint16_t l_errCode = 0; |
| 436 | if (isRbmcProtoTypeSystem(l_errCode) && l_errCode == 0) |
| 437 | { |
| 438 | size_t l_rbmcPosition = constants::VALUE_1; |
| 439 | if (isMotherboardEepromAccessible()) |
| 440 | { |
| 441 | l_rbmcPosition = constants::VALUE_0; |
| 442 | } |
| 443 | |
| 444 | (void)l_rbmcPosition; |
| 445 | // ToDo: Create Object interface map for position property and |
| 446 | // publish it on DBus. |
| 447 | } |
| 448 | |
| Sunny Srivastava | 78a5042 | 2025-04-25 11:17:56 +0530 | [diff] [blame] | 449 | // Enable all mux which are used for connecting to the i2c on the |
| 450 | // pcie slots for pcie cards. These are not enabled by kernel due to |
| 451 | // an issue seen with Castello cards, where the i2c line hangs on a |
| 452 | // probe. |
| 453 | enableMuxChips(); |
| 454 | |
| 455 | // Nothing needs to be done. Service restarted or BMC re-booted for |
| 456 | // some reason at system power on. |
| Sunny Srivastava | 78a5042 | 2025-04-25 11:17:56 +0530 | [diff] [blame] | 457 | } |
| 458 | catch (const std::exception& l_ex) |
| 459 | { |
| Anupama B R | 4c65fcd | 2025-09-01 08:09:00 -0500 | [diff] [blame] | 460 | m_worker->setCollectionStatusProperty(SYSTEM_VPD_FILE_PATH, |
| 461 | constants::vpdCollectionFailed); |
| Sunny Srivastava | 78a5042 | 2025-04-25 11:17:56 +0530 | [diff] [blame] | 462 | // Any issue in system's inital set up is handled in this catch. Error |
| 463 | // will not propogate to manager. |
| 464 | EventLogger::createSyncPel( |
| 465 | EventLogger::getErrorType(l_ex), types::SeverityType::Critical, |
| 466 | __FILE__, __FUNCTION__, 0, EventLogger::getErrorMsg(l_ex), |
| 467 | std::nullopt, std::nullopt, std::nullopt, std::nullopt); |
| 468 | } |
| 469 | } |
| 470 | |
| Anupama B R | 7127ab4 | 2025-06-26 01:39:08 -0500 | [diff] [blame] | 471 | void IbmHandler::collectAllFruVpd() |
| 472 | { |
| Souvik Roy | a5e18b8 | 2025-09-25 05:59:56 +0000 | [diff] [blame] | 473 | // initialize VPD collection logger |
| 474 | m_logger->initiateVpdCollectionLogging(); |
| 475 | |
| Anupama B R | 7127ab4 | 2025-06-26 01:39:08 -0500 | [diff] [blame] | 476 | // Setting status to "InProgress", before trigeering VPD collection. |
| Anupama B R | da9806b | 2025-08-29 02:41:10 -0500 | [diff] [blame] | 477 | m_progressInterface->set_property( |
| 478 | "Status", std::string(constants::vpdCollectionInProgress)); |
| Anupama B R | 7127ab4 | 2025-06-26 01:39:08 -0500 | [diff] [blame] | 479 | m_worker->collectFrusFromJson(); |
| 480 | SetTimerToDetectVpdCollectionStatus(); |
| 481 | } |
| Anupama B R | 95083d4 | 2025-10-27 04:54:58 -0500 | [diff] [blame] | 482 | |
| 483 | bool IbmHandler::isRbmcProtoTypeSystem( |
| 484 | [[maybe_unused]] uint16_t& o_errCode) const noexcept |
| 485 | { |
| 486 | // TODO: |
| 487 | // Parse the system VPD from EEPROM. |
| 488 | // Check the IM keyword value. If the IM value indicates an RBMC prototype |
| 489 | // system, return true otherwise false. |
| 490 | // In case of any error or IM value not found in the map, set error code and |
| 491 | // return false. |
| 492 | |
| 493 | return false; |
| 494 | } |
| 495 | |
| 496 | bool IbmHandler::isMotherboardEepromAccessible() const noexcept |
| 497 | { |
| 498 | // TODO: Check whether the motherboard EEPROM is accessible. |
| 499 | |
| 500 | return false; |
| 501 | } |
| Sunny Srivastava | 867ee75 | 2025-04-15 12:24:23 +0530 | [diff] [blame] | 502 | } // namespace vpd |