Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Andrew Jeffery | 2abbce7 | 2023-10-18 10:17:35 +1030 | [diff] [blame] | 3 | #include "common/instance_id.hpp" |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 4 | #include "common/types.hpp" |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 5 | #include "requester/handler.hpp" |
| 6 | |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 7 | namespace pldm |
| 8 | { |
| 9 | |
| 10 | namespace 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 | */ |
| 21 | class 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 Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 34 | * @param[in] instanceIdDb - Managing instance ID for PLDM requests |
Manojkiran Eda | 2576aec | 2024-06-17 12:05:17 +0530 | [diff] [blame] | 35 | * @param[out] descriptorMap - Populate the firmware identifiers for the |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 36 | * 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 Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 42 | InstanceIdDb& instanceIdDb, DescriptorMap& descriptorMap, |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 43 | ComponentInfoMap& componentInfoMap) : |
| 44 | handler(handler), |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 45 | instanceIdDb(instanceIdDb), descriptorMap(descriptorMap), |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 46 | componentInfoMap(componentInfoMap) |
| 47 | {} |
| 48 | |
| 49 | /** @brief Discover the firmware identifiers and component details of FDs |
| 50 | * |
| 51 | * Inventory commands QueryDeviceIdentifiers and GetFirmwareParmeters |
| 52 | * commands are sent to every FD and the response is used to populate |
| 53 | * the firmware identifiers and component details of the FDs. |
| 54 | * |
| 55 | * @param[in] eids - MCTP endpoint ID of the FDs |
| 56 | */ |
| 57 | void discoverFDs(const std::vector<mctp_eid_t>& eids); |
| 58 | |
| 59 | /** @brief Handler for QueryDeviceIdentifiers command response |
| 60 | * |
| 61 | * The response of the QueryDeviceIdentifiers is processed and firmware |
| 62 | * identifiers of the FD is updated. GetFirmwareParameters command request |
| 63 | * is sent to the FD. |
| 64 | * |
| 65 | * @param[in] eid - Remote MCTP endpoint |
| 66 | * @param[in] response - PLDM response message |
| 67 | * @param[in] respMsgLen - Response message length |
| 68 | */ |
| 69 | void queryDeviceIdentifiers(mctp_eid_t eid, const pldm_msg* response, |
| 70 | size_t respMsgLen); |
| 71 | |
| 72 | /** @brief Handler for GetFirmwareParameters command response |
| 73 | * |
| 74 | * Handling the response of GetFirmwareParameters command and create |
| 75 | * software version D-Bus objects. |
| 76 | * |
| 77 | * @param[in] eid - Remote MCTP endpoint |
| 78 | * @param[in] response - PLDM response message |
| 79 | * @param[in] respMsgLen - Response message length |
| 80 | */ |
| 81 | void getFirmwareParameters(mctp_eid_t eid, const pldm_msg* response, |
| 82 | size_t respMsgLen); |
| 83 | |
| 84 | private: |
| 85 | /** @brief Send GetFirmwareParameters command request |
| 86 | * |
| 87 | * @param[in] eid - Remote MCTP endpoint |
| 88 | */ |
| 89 | void sendGetFirmwareParametersRequest(mctp_eid_t eid); |
| 90 | |
| 91 | /** @brief PLDM request handler */ |
| 92 | pldm::requester::Handler<pldm::requester::Request>& handler; |
| 93 | |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 94 | /** @brief Instance ID database for managing instance ID*/ |
| 95 | InstanceIdDb& instanceIdDb; |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 96 | |
| 97 | /** @brief Device identifiers of the managed FDs */ |
| 98 | DescriptorMap& descriptorMap; |
| 99 | |
| 100 | /** @brief Component information needed for the update of the managed FDs */ |
| 101 | ComponentInfoMap& componentInfoMap; |
| 102 | }; |
| 103 | |
| 104 | } // namespace fw_update |
| 105 | |
| 106 | } // namespace pldm |