1 #pragma once 2 3 #include "activation.hpp" 4 #include "common/types.hpp" 5 #include "device_updater.hpp" 6 #include "inventory_manager.hpp" 7 #include "pldmd/dbus_impl_requester.hpp" 8 #include "requester/handler.hpp" 9 #include "update_manager.hpp" 10 11 #include <libpldm/pldm.h> 12 13 #include <unordered_map> 14 #include <vector> 15 16 namespace pldm 17 { 18 19 namespace fw_update 20 { 21 22 using namespace pldm::dbus_api; 23 24 /** @class Manager 25 * 26 * This class handles all the aspects of the PLDM FW update specification for 27 * the MCTP devices 28 */ 29 class Manager 30 { 31 public: 32 Manager() = delete; 33 Manager(const Manager&) = delete; 34 Manager(Manager&&) = delete; 35 Manager& operator=(const Manager&) = delete; 36 Manager& operator=(Manager&&) = delete; 37 ~Manager() = default; 38 39 /** @brief Constructor 40 * 41 * @param[in] handler - PLDM request handler 42 */ 43 explicit Manager(Event& event, 44 requester::Handler<requester::Request>& handler, 45 Requester& requester) : 46 inventoryMgr(handler, requester, descriptorMap, componentInfoMap), 47 updateManager(event, handler, requester, descriptorMap, 48 componentInfoMap) 49 {} 50 51 /** @brief Discover MCTP endpoints that support the PLDM firmware update 52 * specification 53 * 54 * @param[in] eids - Array of MCTP endpoints 55 * 56 * @return return PLDM_SUCCESS on success and PLDM_ERROR otherwise 57 */ 58 void handleMCTPEndpoints(const std::vector<mctp_eid_t>& eids) 59 { 60 inventoryMgr.discoverFDs(eids); 61 } 62 63 /** @brief Handle PLDM request for the commands in the FW update 64 * specification 65 * 66 * @param[in] eid - Remote MCTP Endpoint ID 67 * @param[in] command - PLDM command code 68 * @param[in] request - PLDM request message 69 * @param[in] requestLen - PLDM request message length 70 * @return PLDM response message 71 */ 72 Response handleRequest(mctp_eid_t eid, Command command, 73 const pldm_msg* request, size_t reqMsgLen) 74 { 75 return updateManager.handleRequest(eid, command, request, reqMsgLen); 76 } 77 78 private: 79 /** Descriptor information of all the discovered MCTP endpoints */ 80 DescriptorMap descriptorMap; 81 82 /** Component information of all the discovered MCTP endpoints */ 83 ComponentInfoMap componentInfoMap; 84 85 /** @brief PLDM firmware inventory manager */ 86 InventoryManager inventoryMgr; 87 88 /** @brief PLDM firmware update manager */ 89 UpdateManager updateManager; 90 }; 91 92 } // namespace fw_update 93 94 } // namespace pldm 95