Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Andrew Jeffery | 27a022c | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 3 | #include "libpldm/pldm.h" |
Tom Joseph | 75356c1 | 2021-06-20 03:52:40 -0700 | [diff] [blame] | 4 | |
| 5 | #include "common/types.hpp" |
| 6 | #include "pldmd/dbus_impl_requester.hpp" |
| 7 | #include "requester/handler.hpp" |
| 8 | |
| 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 |
| 36 | * @param[in] requester - Managing instance ID for PLDM requests |
| 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, |
| 44 | pldm::dbus_api::Requester& requester, DescriptorMap& descriptorMap, |
| 45 | ComponentInfoMap& componentInfoMap) : |
| 46 | handler(handler), |
| 47 | requester(requester), descriptorMap(descriptorMap), |
| 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 | |
| 96 | /** @brief D-Bus API for managing instance ID*/ |
| 97 | pldm::dbus_api::Requester& requester; |
| 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 |