1 #pragma once 2 3 #include "common/instance_id.hpp" 4 #include "common/types.hpp" 5 #include "requester/handler.hpp" 6 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 34 * @param[in] instanceIdDb - Managing instance ID for PLDM requests 35 * @param[out] descriptorMap - Populate the firmware identifiers for the 36 * FDs managed by the BMC. 37 * @param[out] downstreamDescriptorMap - Populate the downstream 38 * identifiers for the FDs managed 39 * by the BMC. 40 * @param[out] componentInfoMap - Populate the component info for the FDs 41 * managed by the BMC. 42 */ InventoryManager(pldm::requester::Handler<pldm::requester::Request> & handler,InstanceIdDb & instanceIdDb,DescriptorMap & descriptorMap,DownstreamDescriptorMap & downstreamDescriptorMap,ComponentInfoMap & componentInfoMap)43 explicit InventoryManager( 44 pldm::requester::Handler<pldm::requester::Request>& handler, 45 InstanceIdDb& instanceIdDb, DescriptorMap& descriptorMap, 46 DownstreamDescriptorMap& downstreamDescriptorMap, 47 ComponentInfoMap& componentInfoMap) : 48 handler(handler), instanceIdDb(instanceIdDb), 49 descriptorMap(descriptorMap), 50 downstreamDescriptorMap(downstreamDescriptorMap), 51 componentInfoMap(componentInfoMap) 52 {} 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 77 /** @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 95 /** @brief Handler for GetDownstreamFirmwareParameters command response 96 * 97 * @param[in] eid - Remote MCTP endpoint 98 * @param[in] response - PLDM response message 99 * @param[in] respMsgLen - Response message length 100 */ 101 void getDownstreamFirmwareParameters( 102 mctp_eid_t eid, const pldm_msg* response, size_t respMsgLen); 103 104 /** @brief Handler for GetFirmwareParameters command response 105 * 106 * Handling the response of GetFirmwareParameters command and create 107 * software version D-Bus objects. 108 * 109 * @param[in] eid - Remote MCTP endpoint 110 * @param[in] response - PLDM response message 111 * @param[in] respMsgLen - Response message length 112 */ 113 void getFirmwareParameters(mctp_eid_t eid, const pldm_msg* response, 114 size_t respMsgLen); 115 116 private: 117 /** 118 * @brief Sends QueryDeviceIdentifiers request 119 * 120 * @param[in] eid - Remote MCTP endpoint 121 */ 122 void sendQueryDeviceIdentifiersRequest(mctp_eid_t eid); 123 124 /** 125 * @brief Sends QueryDownstreamDevices request 126 * 127 * @param[in] eid - Remote MCTP endpoint 128 */ 129 void sendQueryDownstreamDevicesRequest(mctp_eid_t eid); 130 131 /** 132 * @brief Sends QueryDownstreamIdentifiers request 133 * 134 * The request format is defined at Table 16 – QueryDownstreamIdentifiers 135 * command format in DSP0267_1.1.0 136 * 137 * @param[in] eid - Remote MCTP endpoint 138 * @param[in] dataTransferHandle - Data transfer handle 139 * @param[in] transferOperationFlag - Transfer operation flag 140 */ 141 void sendQueryDownstreamIdentifiersRequest( 142 mctp_eid_t eid, uint32_t dataTransferHandle, 143 enum transfer_op_flag transferOperationFlag); 144 145 /** 146 * @brief Sends QueryDownstreamFirmwareParameters request 147 * 148 * @param[in] eid - Remote MCTP endpoint 149 * @param[in] dataTransferHandle - Data transfer handle 150 * @param[in] transferOperationFlag - Transfer operation flag 151 */ 152 void sendGetDownstreamFirmwareParametersRequest( 153 mctp_eid_t eid, uint32_t dataTransferHandle, 154 const enum transfer_op_flag transferOperationFlag); 155 156 /** @brief Send GetFirmwareParameters command request 157 * 158 * @param[in] eid - Remote MCTP endpoint 159 */ 160 void sendGetFirmwareParametersRequest(mctp_eid_t eid); 161 162 /** @brief PLDM request handler */ 163 pldm::requester::Handler<pldm::requester::Request>& handler; 164 165 /** @brief Instance ID database for managing instance ID*/ 166 InstanceIdDb& instanceIdDb; 167 168 /** @brief Device identifiers of the managed FDs */ 169 DescriptorMap& descriptorMap; 170 171 /** @brief Downstream Device identifiers of the managed FDs */ 172 DownstreamDescriptorMap& downstreamDescriptorMap; 173 174 /** @brief Component information needed for the update of the managed FDs */ 175 ComponentInfoMap& componentInfoMap; 176 }; 177 178 } // namespace fw_update 179 180 } // namespace pldm 181