fw-update: Firmware discovery of MCTP endpoints
Tested:
a) Verified MCTP endpoints are discovered by PLDM and fetching the firmware
inventory commands.
b) PLDM firmware update successful after uploading the package, which depends
on the firmware inventory commands.
c) Verified MCTP endpoints are discovered irrespective of the startup order
with the MCTP control application.
Signed-off-by: Tom Joseph <rushtotom@gmail.com>
Change-Id: I7ee9aed40433a8e5a4ebb8e61f917ec82dde9c35
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index f009e88..d23acf8 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -5,8 +5,10 @@
#include "common/utils.hpp"
#include "dbus_impl_requester.hpp"
+#include "fw-update/manager.hpp"
#include "invoker.hpp"
#include "requester/handler.hpp"
+#include "requester/mctp_endpoint_discovery.hpp"
#include "requester/request.hpp"
#include <err.h>
@@ -63,7 +65,8 @@
static std::optional<Response>
processRxMsg(const std::vector<uint8_t>& requestMsg, Invoker& invoker,
- requester::Handler<requester::Request>& handler)
+ requester::Handler<requester::Request>& handler,
+ fw_update::Manager* fwManager)
{
using type = uint8_t;
uint8_t eid = requestMsg[0];
@@ -84,8 +87,17 @@
sizeof(eid) - sizeof(type);
try
{
- response = invoker.handle(hdrFields.pldm_type, hdrFields.command,
- request, requestLen);
+ if (hdrFields.pldm_type != PLDM_FWUP)
+ {
+ response =
+ invoker.handle(hdrFields.pldm_type, hdrFields.command,
+ request, requestLen);
+ }
+ else
+ {
+ response = fwManager->handleRequest(eid, hdrFields.command,
+ request, requestLen);
+ }
}
catch (const std::out_of_range& e)
{
@@ -168,12 +180,13 @@
auto event = Event::get_default();
auto& bus = pldm::utils::DBusHandler::getBus();
+ sdbusplus::server::manager::manager objManager(
+ bus, "/xyz/openbmc_project/software");
dbus_api::Requester dbusImplReq(bus, "/xyz/openbmc_project/pldm");
Invoker invoker{};
requester::Handler<requester::Request> reqHandler(sockfd, event,
dbusImplReq, verbose);
-
#ifdef LIBPLDMRESPONDER
using namespace pldm::state_sensor;
dbus_api::Host dbusImplHost(bus, "/xyz/openbmc_project/pldm");
@@ -281,8 +294,13 @@
exit(EXIT_FAILURE);
}
- auto callback = [verbose, &invoker, &reqHandler](IO& io, int fd,
- uint32_t revents) {
+ std::unique_ptr<fw_update::Manager> fwManager =
+ std::make_unique<fw_update::Manager>(event, reqHandler, dbusImplReq);
+ std::unique_ptr<MctpDiscovery> mctpDiscoveryHandler =
+ std::make_unique<MctpDiscovery>(bus, fwManager.get());
+
+ auto callback = [verbose, &invoker, &reqHandler,
+ &fwManager](IO& io, int fd, uint32_t revents) {
if (!(revents & EPOLLIN))
{
return;
@@ -327,14 +345,12 @@
if (MCTP_MSG_TYPE_PLDM != requestMsg[1])
{
// Skip this message and continue.
- std::cerr << "Encountered Non-PLDM type message"
- << "\n";
}
else
{
// process message and send response
- auto response =
- processRxMsg(requestMsg, invoker, reqHandler);
+ auto response = processRxMsg(requestMsg, invoker,
+ reqHandler, fwManager.get());
if (response.has_value())
{
if (verbose)