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