blob: 8b09026f7c54957bef777f365e51433e2cad54db [file] [log] [blame]
Tom Josephfb3bc062021-08-17 07:48:11 -07001#pragma once
2
Andrew Jeffery27a022c2022-08-10 23:12:49 +09303#include "libpldm/pldm.h"
Tom Josephfb3bc062021-08-17 07:48:11 -07004
5#include "activation.hpp"
6#include "common/types.hpp"
7#include "device_updater.hpp"
8#include "inventory_manager.hpp"
9#include "pldmd/dbus_impl_requester.hpp"
10#include "requester/handler.hpp"
11#include "update_manager.hpp"
12
13#include <unordered_map>
14#include <vector>
15
16namespace pldm
17{
18
19namespace fw_update
20{
21
22using 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 */
29class Manager
30{
Tom Josephfb3bc062021-08-17 07:48:11 -070031 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