From 4a152f17fe2bcee7cea7d32fbad9922511ae89ae Mon Sep 17 00:00:00 2001 From: Priyanga Ramasamy Date: Thu, 12 Dec 2024 22:13:52 -0600 Subject: [PATCH] worker::CollectionStatus for each inventory FRU This commit implements CollectionStatus D-bus property under com.ibm.VPD.Collection D-bus interface for each inventory D-bus object path which represents a FRU. The property tells the current status of VPD collection for a given FRU's D-bus object path. The property takes the below enum values: >>>com.ibm.VPD.Collection.Status.Success ------------------------------------- This value is assigned when VPD collection is successful. >>>com.ibm.VPD.Collection.Status.Failure ------------------------------------- VPD collection failure due to VPD exceptions. >>>com.ibm.VPD.Collection.Status.InProgress ---------------------------------------- This value is assigned when VPD collection starts for the given FRU. >>>com.ibm.VPD.Collection.Status.NotStarted ---------------------------------------- This default value is assigned when we hit prime inventory path. Test: 1. VPD parsing failed for /sys/bus/i2c/drivers/at24/0-0051/eeprom due to error: Unable to determine VPD format busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.NotStarted" busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.InProgress" busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.Failure" 2. FRU not found busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0/pcie_card0 com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.NotStarted" busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0/pcie_card0 com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.InProgress" busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0/pcie_card0 com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.Failure" 3. Successful collection of VPD busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.Success" Change-Id: Ia5010a181f720454bb51538d6fcf308daf6b75ca Signed-off-by: Priyanga Ramasamy --- vpd-manager/include/constants.hpp | 13 +++++++ vpd-manager/src/worker.cpp | 61 +++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/vpd-manager/include/constants.hpp b/vpd-manager/include/constants.hpp index 5faf8da8..b9d17028 100644 --- a/vpd-manager/include/constants.hpp +++ b/vpd-manager/include/constants.hpp @@ -192,5 +192,18 @@ static constexpr auto systemdService = "org.freedesktop.systemd1"; static constexpr auto systemdObjectPath = "/org/freedesktop/systemd1"; static constexpr auto systemdManagerInterface = "org.freedesktop.systemd1.Manager"; + +static constexpr auto vpdCollectionInterface = "com.ibm.VPD.Collection"; + +// enumerated values of CollectionStatus D-bus property defined under +// com.ibm.VPD.Collection interface. +static constexpr auto vpdCollectionSuccess = + "com.ibm.VPD.Collection.Status.Success"; +static constexpr auto vpdCollectionFailure = + "com.ibm.VPD.Collection.Status.Failure"; +static constexpr auto vpdCollectionInProgress = + "com.ibm.VPD.Collection.Status.InProgress"; +static constexpr auto vpdCollectionNotStarted = + "com.ibm.VPD.Collection.Status.NotStarted"; } // namespace constants } // namespace vpd diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp index 6fc901d0..6fd42266 100644 --- a/vpd-manager/src/worker.cpp +++ b/vpd-manager/src/worker.cpp @@ -853,6 +853,14 @@ bool Worker::primeInventory(const std::string& i_vpdFilePath) processFunctionalProperty(l_Fru["inventoryPath"], l_interfaces); processEnabledProperty(l_Fru["inventoryPath"], l_interfaces); + // Emplace the default state of FRU VPD collection + types::PropertyMap l_fruCollectionProperty = { + {"CollectionStatus", constants::vpdCollectionNotStarted}}; + + vpdSpecificUtility::insertOrMerge(l_interfaces, + constants::vpdCollectionInterface, + std::move(l_fruCollectionProperty)); + l_objectInterfaceMap.emplace(std::move(l_fruObjectPath), std::move(l_interfaces)); } @@ -1103,6 +1111,7 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap, { const auto& inventoryPath = aFru["inventoryPath"]; sdbusplus::message::object_path fruObjectPath(inventoryPath); + if (aFru.contains("ccin")) { if (!processFruWithCCIN(aFru, parsedVpdMap)) @@ -1139,6 +1148,14 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap, processFunctionalProperty(inventoryPath, interfaces); processEnabledProperty(inventoryPath, interfaces); + // Update collection status as successful + types::PropertyMap l_collectionProperty = { + {"CollectionStatus", constants::vpdCollectionSuccess}}; + + vpdSpecificUtility::insertOrMerge(interfaces, + constants::vpdCollectionInterface, + std::move(l_collectionProperty)); + objectInterfaceMap.emplace(std::move(fruObjectPath), std::move(interfaces)); } @@ -1375,7 +1392,6 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath) std::shared_ptr vpdParser = std::make_shared(i_vpdFilePath, m_parsedJson); - types::VPDMapVariant l_parsedVpd = vpdParser->parse(); // Before returning, as collection is over, check if FRU qualifies for @@ -1421,6 +1437,9 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath) std::tuple Worker::parseAndPublishVPD(const std::string& i_vpdFilePath) { + const std::string& l_inventoryPath = + jsonUtility::getInventoryObjPathFromJson(m_parsedJson, i_vpdFilePath); + try { m_semaphore.acquire(); @@ -1430,6 +1449,24 @@ std::tuple m_activeCollectionThreadCount++; m_mutex.unlock(); + // Set CollectionStatus as InProgress. Since it's an intermediate state + // D-bus set-property call is good enough to update the status. + try + { + const std::string& l_collStatusProp = "CollectionStatus"; + dbusUtility::writeDbusProperty( + jsonUtility::getServiceName(m_parsedJson, l_inventoryPath), + l_inventoryPath, constants::vpdCollectionInterface, + l_collStatusProp, + types::DbusVariantType{constants::vpdCollectionInProgress}); + } + catch (const std::exception& e) + { + logging::logMessage( + "Unable to set CollectionStatus as InProgress for " + + i_vpdFilePath); + } + const types::VPDMapVariant& parsedVpdMap = parseVpdFile(i_vpdFilePath); types::ObjectMap objectInterfaceMap; @@ -1469,14 +1506,32 @@ std::tuple logging::logMessage(ex.what()); } + // update CollectionStatus as Failure + types::ObjectMap l_objectMap; + types::InterfaceMap l_interfaceMap; + types::PropertyMap l_propertyMap; + + l_propertyMap.emplace("CollectionStatus", + constants::vpdCollectionFailure); + l_interfaceMap.emplace(constants::vpdCollectionInterface, + l_propertyMap); + l_objectMap.emplace(l_inventoryPath, l_interfaceMap); + + if (!dbusUtility::callPIM(std::move(l_objectMap))) + { + logging::logMessage( + "Call to PIM Notify method failed to update Collection status as Failure for " + + i_vpdFilePath); + } + // TODO: Figure out a way to clear data in case of any failure at // runtime. // Prime the inventry for FRUs which // are not present/processing had some error. /* if (!primeInventory(i_vpdFilePath)) { - logging::logMessage("Priming of inventory failed for FRU " + - i_vpdFilePath); + logging::logMessage("Priming of inventory failed for FRU " + + i_vpdFilePath); }*/ m_semaphore.release(); return std::make_tuple(false, i_vpdFilePath);