blob: 953d7a4332dfce49714ddd8a9f87877131923f3b [file] [log] [blame]
Tom Joseph75356c12021-06-20 03:52:40 -07001#pragma once
2
Andrew Jeffery2abbce72023-10-18 10:17:35 +10303#include "common/instance_id.hpp"
Tom Joseph75356c12021-06-20 03:52:40 -07004#include "common/types.hpp"
Tom Joseph75356c12021-06-20 03:52:40 -07005#include "requester/handler.hpp"
6
Tom Joseph75356c12021-06-20 03:52:40 -07007namespace pldm
8{
9
10namespace fw_update
11{
12
13/** @class InventoryManager
14 *
15 * InventoryManager class manages the software inventory of firmware devices
16 * managed by the BMC. It discovers the firmware identifiers and the component
17 * details of the FD. Firmware identifiers, component details and update
18 * capabilities of FD are populated by the InventoryManager and is used for the
19 * firmware update of the FDs.
20 */
21class InventoryManager
22{
23 public:
24 InventoryManager() = delete;
25 InventoryManager(const InventoryManager&) = delete;
26 InventoryManager(InventoryManager&&) = delete;
27 InventoryManager& operator=(const InventoryManager&) = delete;
28 InventoryManager& operator=(InventoryManager&&) = delete;
29 ~InventoryManager() = default;
30
31 /** @brief Constructor
32 *
33 * @param[in] handler - PLDM request handler
Andrew Jefferya330b2f2023-05-04 14:55:37 +093034 * @param[in] instanceIdDb - Managing instance ID for PLDM requests
Manojkiran Eda2576aec2024-06-17 12:05:17 +053035 * @param[out] descriptorMap - Populate the firmware identifiers for the
Tom Joseph75356c12021-06-20 03:52:40 -070036 * FDs managed by the BMC.
37 * @param[out] componentInfoMap - Populate the component info for the FDs
38 * managed by the BMC.
39 */
40 explicit InventoryManager(
41 pldm::requester::Handler<pldm::requester::Request>& handler,
Andrew Jefferya330b2f2023-05-04 14:55:37 +093042 InstanceIdDb& instanceIdDb, DescriptorMap& descriptorMap,
Tom Joseph75356c12021-06-20 03:52:40 -070043 ComponentInfoMap& componentInfoMap) :
Patrick Williams16c2a0a2024-08-16 15:20:59 -040044 handler(handler), instanceIdDb(instanceIdDb),
45 descriptorMap(descriptorMap), componentInfoMap(componentInfoMap)
Tom Joseph75356c12021-06-20 03:52:40 -070046 {}
47
48 /** @brief Discover the firmware identifiers and component details of FDs
49 *
50 * Inventory commands QueryDeviceIdentifiers and GetFirmwareParmeters
51 * commands are sent to every FD and the response is used to populate
52 * the firmware identifiers and component details of the FDs.
53 *
54 * @param[in] eids - MCTP endpoint ID of the FDs
55 */
56 void discoverFDs(const std::vector<mctp_eid_t>& eids);
57
58 /** @brief Handler for QueryDeviceIdentifiers command response
59 *
60 * The response of the QueryDeviceIdentifiers is processed and firmware
61 * identifiers of the FD is updated. GetFirmwareParameters command request
62 * is sent to the FD.
63 *
64 * @param[in] eid - Remote MCTP endpoint
65 * @param[in] response - PLDM response message
66 * @param[in] respMsgLen - Response message length
67 */
68 void queryDeviceIdentifiers(mctp_eid_t eid, const pldm_msg* response,
69 size_t respMsgLen);
70
71 /** @brief Handler for GetFirmwareParameters command response
72 *
73 * Handling the response of GetFirmwareParameters command and create
74 * software version D-Bus objects.
75 *
76 * @param[in] eid - Remote MCTP endpoint
77 * @param[in] response - PLDM response message
78 * @param[in] respMsgLen - Response message length
79 */
80 void getFirmwareParameters(mctp_eid_t eid, const pldm_msg* response,
81 size_t respMsgLen);
82
83 private:
84 /** @brief Send GetFirmwareParameters command request
85 *
86 * @param[in] eid - Remote MCTP endpoint
87 */
88 void sendGetFirmwareParametersRequest(mctp_eid_t eid);
89
90 /** @brief PLDM request handler */
91 pldm::requester::Handler<pldm::requester::Request>& handler;
92
Andrew Jefferya330b2f2023-05-04 14:55:37 +093093 /** @brief Instance ID database for managing instance ID*/
94 InstanceIdDb& instanceIdDb;
Tom Joseph75356c12021-06-20 03:52:40 -070095
96 /** @brief Device identifiers of the managed FDs */
97 DescriptorMap& descriptorMap;
98
99 /** @brief Component information needed for the update of the managed FDs */
100 ComponentInfoMap& componentInfoMap;
101};
102
103} // namespace fw_update
104
105} // namespace pldm