Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 3 | #include "common/types.hpp" |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 4 | #include "pldmd/instance_id.hpp" |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 5 | #include "requester/handler.hpp" |
| 6 | |
George Liu | c453e16 | 2022-12-21 17:16:23 +0800 | [diff] [blame] | 7 | #include <libpldm/pldm.h> |
| 8 | |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 9 | namespace pldm |
| 10 | { |
| 11 | |
| 12 | namespace 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 | */ |
| 23 | class 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 Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 36 | * @param[in] instanceIdDb - Managing instance ID for PLDM requests |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 37 | * @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 Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 44 | InstanceIdDb& instanceIdDb, DescriptorMap& descriptorMap, |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 45 | ComponentInfoMap& componentInfoMap) : |
| 46 | handler(handler), |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 47 | instanceIdDb(instanceIdDb), descriptorMap(descriptorMap), |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 48 | 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 Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 96 | /** @brief Instance ID database for managing instance ID*/ |
| 97 | InstanceIdDb& instanceIdDb; |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 98 | |
| 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 |