blob: be45eb7cdd8bb9ba0ba9527501b9da1f2b4129a8 [file] [log] [blame]
#pragma once
#include "activation.hpp"
#include "common/instance_id.hpp"
#include "common/types.hpp"
#include "device_updater.hpp"
#include "inventory_manager.hpp"
#include "requester/handler.hpp"
#include "requester/mctp_endpoint_discovery.hpp"
#include "update_manager.hpp"
#include <unordered_map>
#include <vector>
namespace pldm
{
namespace fw_update
{
/** @class Manager
*
* This class handles all the aspects of the PLDM FW update specification for
* the MCTP devices
*/
class Manager : public pldm::MctpDiscoveryHandlerIntf
{
public:
Manager() = delete;
Manager(const Manager&) = delete;
Manager(Manager&&) = delete;
Manager& operator=(const Manager&) = delete;
Manager& operator=(Manager&&) = delete;
~Manager() = default;
/** @brief Constructor
*
* @param[in] handler - PLDM request handler
*/
explicit Manager(Event& event,
requester::Handler<requester::Request>& handler,
pldm::InstanceIdDb& instanceIdDb) :
inventoryMgr(handler, instanceIdDb, descriptorMap, componentInfoMap),
updateManager(event, handler, instanceIdDb, descriptorMap,
componentInfoMap)
{}
/** @brief Helper function to invoke registered handlers for
* the added MCTP endpoints
*
* @param[in] mctpInfos - information of discovered MCTP endpoints
*/
void handleMctpEndpoints(const MctpInfos& mctpInfos)
{
std::vector<mctp_eid_t> eids;
for (const auto& mctpInfo : mctpInfos)
{
eids.emplace_back(std::get<mctp_eid_t>(mctpInfo));
}
inventoryMgr.discoverFDs(eids);
}
/** @brief Helper function to invoke registered handlers for
* the removed MCTP endpoints
*
* @param[in] mctpInfos - information of removed MCTP endpoints
*/
void handleRemovedMctpEndpoints(const MctpInfos&)
{
return;
}
/** @brief Handle PLDM request for the commands in the FW update
* specification
*
* @param[in] eid - Remote MCTP Endpoint ID
* @param[in] command - PLDM command code
* @param[in] request - PLDM request message
* @param[in] requestLen - PLDM request message length
* @return PLDM response message
*/
Response handleRequest(mctp_eid_t eid, Command command,
const pldm_msg* request, size_t reqMsgLen)
{
return updateManager.handleRequest(eid, command, request, reqMsgLen);
}
private:
/** Descriptor information of all the discovered MCTP endpoints */
DescriptorMap descriptorMap;
/** Component information of all the discovered MCTP endpoints */
ComponentInfoMap componentInfoMap;
/** @brief PLDM firmware inventory manager */
InventoryManager inventoryMgr;
/** @brief PLDM firmware update manager */
UpdateManager updateManager;
};
} // namespace fw_update
} // namespace pldm