blob: ae5030f272b484577f83b547a3f7ae57784f412f [file] [log] [blame]
Tom Joseph75356c12021-06-20 03:52:40 -07001#pragma once
2
Tom Joseph75356c12021-06-20 03:52:40 -07003#include "common/types.hpp"
Andrew Jefferya330b2f2023-05-04 14:55:37 +09304#include "pldmd/instance_id.hpp"
Tom Joseph75356c12021-06-20 03:52:40 -07005#include "requester/handler.hpp"
6
George Liuc453e162022-12-21 17:16:23 +08007#include <libpldm/pldm.h>
8
Tom Joseph75356c12021-06-20 03:52:40 -07009namespace pldm
10{
11
12namespace fw_update
13{
14
15/** @class InventoryManager
16 *
17 * InventoryManager class manages the software inventory of firmware devices
18 * managed by the BMC. It discovers the firmware identifiers and the component
19 * details of the FD. Firmware identifiers, component details and update
20 * capabilities of FD are populated by the InventoryManager and is used for the
21 * firmware update of the FDs.
22 */
23class InventoryManager
24{
25 public:
26 InventoryManager() = delete;
27 InventoryManager(const InventoryManager&) = delete;
28 InventoryManager(InventoryManager&&) = delete;
29 InventoryManager& operator=(const InventoryManager&) = delete;
30 InventoryManager& operator=(InventoryManager&&) = delete;
31 ~InventoryManager() = default;
32
33 /** @brief Constructor
34 *
35 * @param[in] handler - PLDM request handler
Andrew Jefferya330b2f2023-05-04 14:55:37 +093036 * @param[in] instanceIdDb - Managing instance ID for PLDM requests
Tom Joseph75356c12021-06-20 03:52:40 -070037 * @param[out] descriptorMap - Populate the firmware identifers for the
38 * FDs managed by the BMC.
39 * @param[out] componentInfoMap - Populate the component info for the FDs
40 * managed by the BMC.
41 */
42 explicit InventoryManager(
43 pldm::requester::Handler<pldm::requester::Request>& handler,
Andrew Jefferya330b2f2023-05-04 14:55:37 +093044 InstanceIdDb& instanceIdDb, DescriptorMap& descriptorMap,
Tom Joseph75356c12021-06-20 03:52:40 -070045 ComponentInfoMap& componentInfoMap) :
46 handler(handler),
Andrew Jefferya330b2f2023-05-04 14:55:37 +093047 instanceIdDb(instanceIdDb), descriptorMap(descriptorMap),
Tom Joseph75356c12021-06-20 03:52:40 -070048 componentInfoMap(componentInfoMap)
49 {}
50
51 /** @brief Discover the firmware identifiers and component details of FDs
52 *
53 * Inventory commands QueryDeviceIdentifiers and GetFirmwareParmeters
54 * commands are sent to every FD and the response is used to populate
55 * the firmware identifiers and component details of the FDs.
56 *
57 * @param[in] eids - MCTP endpoint ID of the FDs
58 */
59 void discoverFDs(const std::vector<mctp_eid_t>& eids);
60
61 /** @brief Handler for QueryDeviceIdentifiers command response
62 *
63 * The response of the QueryDeviceIdentifiers is processed and firmware
64 * identifiers of the FD is updated. GetFirmwareParameters command request
65 * is sent to the FD.
66 *
67 * @param[in] eid - Remote MCTP endpoint
68 * @param[in] response - PLDM response message
69 * @param[in] respMsgLen - Response message length
70 */
71 void queryDeviceIdentifiers(mctp_eid_t eid, const pldm_msg* response,
72 size_t respMsgLen);
73
74 /** @brief Handler for GetFirmwareParameters command response
75 *
76 * Handling the response of GetFirmwareParameters command and create
77 * software version D-Bus objects.
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 getFirmwareParameters(mctp_eid_t eid, const pldm_msg* response,
84 size_t respMsgLen);
85
86 private:
87 /** @brief Send GetFirmwareParameters command request
88 *
89 * @param[in] eid - Remote MCTP endpoint
90 */
91 void sendGetFirmwareParametersRequest(mctp_eid_t eid);
92
93 /** @brief PLDM request handler */
94 pldm::requester::Handler<pldm::requester::Request>& handler;
95
Andrew Jefferya330b2f2023-05-04 14:55:37 +093096 /** @brief Instance ID database for managing instance ID*/
97 InstanceIdDb& instanceIdDb;
Tom Joseph75356c12021-06-20 03:52:40 -070098
99 /** @brief Device identifiers of the managed FDs */
100 DescriptorMap& descriptorMap;
101
102 /** @brief Component information needed for the update of the managed FDs */
103 ComponentInfoMap& componentInfoMap;
104};
105
106} // namespace fw_update
107
108} // namespace pldm