PEL: Add API to get the PLDM instance ID
In order to send a PLDM command, one must get the instance ID parameter
to use for that command from the PLDM daemon via a D-Bus method.
Implement this API in the DataInterface class, though leave the body of
it stubbed out until the PLDM daemon switches to using async D-Bus
operations as right now the logging daemon and PLDM daemon can deadlock
with each calling into the other.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I592e7bad922c725edee67003e9957388df5f195c
diff --git a/extensions/openpower-pels/data_interface.cpp b/extensions/openpower-pels/data_interface.cpp
index 7342dc0..6ad8b6e 100644
--- a/extensions/openpower-pels/data_interface.cpp
+++ b/extensions/openpower-pels/data_interface.cpp
@@ -35,6 +35,7 @@
constexpr auto objectMapper = "/xyz/openbmc_project/object_mapper";
constexpr auto systemInv = "/xyz/openbmc_project/inventory/system";
constexpr auto hostState = "/xyz/openbmc_project/state/host0";
+constexpr auto pldm = "/xyz/openbmc_project/pldm";
} // namespace object_path
namespace interface
@@ -43,6 +44,7 @@
constexpr auto objectMapper = "xyz.openbmc_project.ObjectMapper";
constexpr auto invAsset = "xyz.openbmc_project.Inventory.Decorator.Asset";
constexpr auto osStatus = "xyz.openbmc_project.State.OperatingSystem.Status";
+constexpr auto pldmRequester = "xyz.openbmc_project.PLDM.Requester";
} // namespace interface
using namespace sdbusplus::xyz::openbmc_project::State::OperatingSystem::server;
@@ -140,7 +142,7 @@
}
DBusService DataInterface::getService(const std::string& objectPath,
- const std::string& interface)
+ const std::string& interface) const
{
auto method = _bus.new_method_call(service_name::objectMapper,
object_path::objectMapper,
@@ -222,6 +224,26 @@
}
}
+uint8_t DataInterface::getPLDMInstanceID(uint8_t eid) const
+{
+ return 0;
+// Don't use until PLDM switches to async D-Bus.
+#if 0
+ auto service = getService(object_path::pldm, interface::pldmRequester);
+
+ auto method =
+ _bus.new_method_call(service.c_str(), object_path::pldm,
+ interface::pldmRequester, "GetInstanceId");
+ method.append(eid);
+ auto reply = _bus.call(method);
+
+ uint8_t instanceID = 0;
+ reply.read(instanceID);
+
+ return instanceID;
+#endif
+}
+
void DataInterface::readBMCFWVersion()
{
std::ifstream versionFile{BMC_VERSION_FILE};
diff --git a/extensions/openpower-pels/data_interface.hpp b/extensions/openpower-pels/data_interface.hpp
index ff0aa75..35e220c 100644
--- a/extensions/openpower-pels/data_interface.hpp
+++ b/extensions/openpower-pels/data_interface.hpp
@@ -63,6 +63,20 @@
return _hostUp;
}
+ /**
+ * @brief Returns the PLDM instance ID to use for PLDM commands
+ *
+ * The base class implementation just returns zero.
+ *
+ * @param[in] eid - The PLDM EID
+ *
+ * @return uint8_t - The instance ID
+ */
+ virtual uint8_t getPLDMInstanceID(uint8_t eid) const
+ {
+ return 0;
+ }
+
using HostStateChangeFunc = std::function<void(bool)>;
/**
@@ -192,6 +206,15 @@
*/
explicit DataInterface(sdbusplus::bus::bus& bus);
+ /**
+ * @brief Returns the PLDM instance ID to use for PLDM commands
+ *
+ * @param[in] eid - The PLDM EID
+ *
+ * @return uint8_t - The instance ID
+ */
+ uint8_t getPLDMInstanceID(uint8_t eid) const override;
+
private:
/**
* @brief Reads the machine type/model and SN from D-Bus.
@@ -236,7 +259,7 @@
* @param[in] interface - The D-Bus interface
*/
DBusService getService(const std::string& objectPath,
- const std::string& interface);
+ const std::string& interface) const;
/**
* @brief Wrapper for the 'GetAll' properties method call
*