1 // SPDX-License-Identifier: Apache-2.0 2 3 #pragma once 4 5 #include <libpldm/instance-id.h> 6 #include <libpldm/pldm.h> 7 #include <libpldm/transport.h> 8 9 namespace phosphor 10 { 11 namespace dump 12 { 13 namespace pldm 14 { 15 extern struct pldm_transport* pldmTransport; 16 17 class PLDMInstanceManager 18 { 19 public: 20 PLDMInstanceManager(const PLDMInstanceManager&) = delete; 21 PLDMInstanceManager& operator=(const PLDMInstanceManager&) = delete; 22 PLDMInstanceManager(PLDMInstanceManager&&) noexcept = default; 23 PLDMInstanceManager& operator=(PLDMInstanceManager&&) noexcept = default; 24 25 PLDMInstanceManager(); 26 ~PLDMInstanceManager(); 27 28 private: 29 /** 30 * @brief Instantiates an instance ID database object 31 * 32 * @return void 33 **/ 34 void initPLDMInstanceIdDb(); 35 36 /** 37 * @brief Destroys an instance ID database object 38 * 39 * @return void 40 **/ 41 void destroyPLDMInstanceIdDb(); 42 }; 43 44 /** 45 * @brief setup PLDM transport for sending and receiving messages 46 * 47 * @param[in] eid - MCTP endpoint ID 48 * @return file descriptor on success and throw 49 * exception (xyz::openbmc_project::Common::Error::NotAllowed) on 50 * failures. 51 */ 52 int openPLDM(mctp_eid_t eid); 53 54 /** @brief Opens the MCTP socket for sending and receiving messages. 55 * 56 * @param[in] eid - MCTP endpoint ID 57 */ 58 int openMctpDemuxTransport(mctp_eid_t eid); 59 60 /** @brief Close the PLDM file */ 61 void pldmClose(); 62 63 /** 64 * @brief Returns the PLDM instance ID to use for PLDM commands 65 * 66 * @param[in] tid - the terminus ID the instance ID is associated with 67 * 68 * @return pldm_instance_id_t - The instance ID 69 **/ 70 pldm_instance_id_t getPLDMInstanceID(uint8_t tid); 71 72 /** 73 * @brief Free the PLDM instance ID 74 * 75 * @param[in] tid - the terminus ID the instance ID is associated with 76 * @param[in] instanceID - The PLDM instance ID 77 * 78 * @return void 79 **/ 80 void freePLDMInstanceID(pldm_instance_id_t instanceID, uint8_t tid); 81 82 } // namespace pldm 83 } // namespace dump 84 } // namespace phosphor 85