blob: 69ce1c981dbe102f61e37e2eedf578451d47bfaa [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.
Unive Tieneaf79da2024-11-25 09:34:39 +080037 * @param[out] downstreamDescriptorMap - Populate the downstream
38 * identifiers for the FDs managed
39 * by the BMC.
Tom Joseph75356c12021-06-20 03:52:40 -070040 * @param[out] componentInfoMap - Populate the component info for the FDs
41 * managed by the BMC.
42 */
43 explicit InventoryManager(
44 pldm::requester::Handler<pldm::requester::Request>& handler,
Andrew Jefferya330b2f2023-05-04 14:55:37 +093045 InstanceIdDb& instanceIdDb, DescriptorMap& descriptorMap,
Unive Tieneaf79da2024-11-25 09:34:39 +080046 DownstreamDescriptorMap& downstreamDescriptorMap,
Tom Joseph75356c12021-06-20 03:52:40 -070047 ComponentInfoMap& componentInfoMap) :
Patrick Williams16c2a0a2024-08-16 15:20:59 -040048 handler(handler), instanceIdDb(instanceIdDb),
Unive Tieneaf79da2024-11-25 09:34:39 +080049 descriptorMap(descriptorMap),
50 downstreamDescriptorMap(downstreamDescriptorMap),
51 componentInfoMap(componentInfoMap)
Tom Joseph75356c12021-06-20 03:52:40 -070052 {}
53
54 /** @brief Discover the firmware identifiers and component details of FDs
55 *
56 * Inventory commands QueryDeviceIdentifiers and GetFirmwareParmeters
57 * commands are sent to every FD and the response is used to populate
58 * the firmware identifiers and component details of the FDs.
59 *
60 * @param[in] eids - MCTP endpoint ID of the FDs
61 */
62 void discoverFDs(const std::vector<mctp_eid_t>& eids);
63
64 /** @brief Handler for QueryDeviceIdentifiers command response
65 *
66 * The response of the QueryDeviceIdentifiers is processed and firmware
67 * identifiers of the FD is updated. GetFirmwareParameters command request
68 * is sent to the FD.
69 *
70 * @param[in] eid - Remote MCTP endpoint
71 * @param[in] response - PLDM response message
72 * @param[in] respMsgLen - Response message length
73 */
74 void queryDeviceIdentifiers(mctp_eid_t eid, const pldm_msg* response,
75 size_t respMsgLen);
76
Unive Tieneaf79da2024-11-25 09:34:39 +080077 /** @brief Handler for QueryDownstreamDevices command response
78 *
79 * @param[in] eid - Remote MCTP endpoint
80 * @param[in] response - PLDM response message
81 * @param[in] respMsgLen - Response message length
82 */
83 void queryDownstreamDevices(mctp_eid_t eid, const pldm_msg* response,
84 size_t respMsgLen);
85
86 /** @brief Handler for QueryDownstreamIdentifiers command response
87 *
88 * @param[in] eid - Remote MCTP endpoint
89 * @param[in] response - PLDM response message
90 * @param[in] respMsgLen - Response message length
91 */
92 void queryDownstreamIdentifiers(mctp_eid_t eid, const pldm_msg* response,
93 size_t respMsgLen);
94
Tom Joseph75356c12021-06-20 03:52:40 -070095 /** @brief Handler for GetFirmwareParameters command response
96 *
97 * Handling the response of GetFirmwareParameters command and create
98 * software version D-Bus objects.
99 *
100 * @param[in] eid - Remote MCTP endpoint
101 * @param[in] response - PLDM response message
102 * @param[in] respMsgLen - Response message length
103 */
104 void getFirmwareParameters(mctp_eid_t eid, const pldm_msg* response,
105 size_t respMsgLen);
106
107 private:
Unive Tieneaf79da2024-11-25 09:34:39 +0800108 /**
109 * @brief Sends QueryDeviceIdentifiers request
110 *
111 * @param[in] eid - Remote MCTP endpoint
112 */
113 void sendQueryDeviceIdentifiersRequest(mctp_eid_t eid);
114
115 /**
116 * @brief Sends QueryDownstreamDevices request
117 *
118 * @param[in] eid - Remote MCTP endpoint
119 */
120 void sendQueryDownstreamDevicesRequest(mctp_eid_t eid);
121
122 /**
123 * @brief Sends QueryDownstreamIdentifiers request
124 *
125 * The request format is defined at Table 16 – QueryDownstreamIdentifiers
126 * command format in DSP0267_1.1.0
127 *
128 * @param[in] eid - Remote MCTP endpoint
129 * @param[in] dataTransferHandle - Data transfer handle
130 * @param[in] transferOperationFlag - Transfer operation flag
131 */
132 void sendQueryDownstreamIdentifiersRequest(
133 mctp_eid_t eid, uint32_t dataTransferHandle,
134 enum transfer_op_flag transferOperationFlag);
135
Tom Joseph75356c12021-06-20 03:52:40 -0700136 /** @brief Send GetFirmwareParameters command request
137 *
138 * @param[in] eid - Remote MCTP endpoint
139 */
140 void sendGetFirmwareParametersRequest(mctp_eid_t eid);
141
142 /** @brief PLDM request handler */
143 pldm::requester::Handler<pldm::requester::Request>& handler;
144
Andrew Jefferya330b2f2023-05-04 14:55:37 +0930145 /** @brief Instance ID database for managing instance ID*/
146 InstanceIdDb& instanceIdDb;
Tom Joseph75356c12021-06-20 03:52:40 -0700147
148 /** @brief Device identifiers of the managed FDs */
149 DescriptorMap& descriptorMap;
150
Unive Tieneaf79da2024-11-25 09:34:39 +0800151 /** @brief Downstream Device identifiers of the managed FDs */
152 DownstreamDescriptorMap& downstreamDescriptorMap;
153
Tom Joseph75356c12021-06-20 03:52:40 -0700154 /** @brief Component information needed for the update of the managed FDs */
155 ComponentInfoMap& componentInfoMap;
156};
157
158} // namespace fw_update
159
160} // namespace pldm