Skip to content

Commit

Permalink
oem-ibm: Add util API for setting the present property
Browse files Browse the repository at this point in the history
This commit adds a common function to set the present property
to true for all the present FRUs.

Signed-off-by: Pavithra Barithaya <[email protected]>
Change-Id: Ia218f0de7883ff399e9dec60f03d88c27afed3e9
  • Loading branch information
Pavithrab7 committed Mar 11, 2024
1 parent c8bcefb commit 5e542be
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,5 +810,25 @@ bool checkIfLogicalBitSet(const uint16_t& containerId)
return !(containerId & 0x8000);
}

void setFruPresence(const std::string& fruObjPath, bool present)
{
pldm::utils::PropertyValue value{present};
pldm::utils::DBusMapping dbusMapping;
dbusMapping.objectPath = fruObjPath;
dbusMapping.interface = "xyz.openbmc_project.Inventory.Item";
dbusMapping.propertyName = "Present";
dbusMapping.propertyType = "bool";
try
{
pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
}
catch (const std::exception& e)
{
error(
"Failed to set the present property on path: '{PATH}' with {ERROR} ",
"PATH", fruObjPath, "ERROR", e);
}
}

} // namespace utils
} // namespace pldm
7 changes: 7 additions & 0 deletions common/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,5 +464,12 @@ bool checkForFruPresence(const std::string& objPath);
* @return true or false based on the logic bit set
*/
bool checkIfLogicalBitSet(const uint16_t& containerId);

/** @brief setting the present property
*
* @param[in] objPath - the object path of the fru
* @param[in] present - status to set either true/false
*/
void setFruPresence(const std::string& fruObjPath, bool present);
} // namespace utils
} // namespace pldm
4 changes: 4 additions & 0 deletions oem/ibm/libpldmresponder/fru_oem_ibm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ void Handler::updateDBusProperty(
entityType == value.entity_type &&
containerId == value.entity_container_id)
{
if (!(pldm::responder::utils::checkIfIBMFru(key)))
{
pldm::utils::setFruPresence(key, true);
}
dbus_map_update(key, "Function0VendorId", vendorId);
dbus_map_update(key, "Function0DeviceId", deviceId);
dbus_map_update(key, "Function0RevisionId", revisionId);
Expand Down
1 change: 1 addition & 0 deletions oem/ibm/libpldmresponder/fru_oem_ibm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "common/utils.hpp"
#include "libpldmresponder/fru.hpp"
#include "libpldmresponder/oem_handler.hpp"
#include "oem/ibm/libpldmresponder/utils.hpp"

#include <libpldm/oem/ibm/fru.h>

Expand Down

0 comments on commit 5e542be

Please sign in to comment.