Gilbert Chen | 6c7fed4 | 2022-02-22 15:40:17 +0000 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include "libpldm/pldm.h" |
| 4 | |
| 5 | #include "common/instance_id.hpp" |
| 6 | #include "common/types.hpp" |
| 7 | #include "platform_manager.hpp" |
| 8 | #include "requester/handler.hpp" |
| 9 | #include "requester/mctp_endpoint_discovery.hpp" |
| 10 | #include "terminus_manager.hpp" |
| 11 | |
| 12 | namespace pldm |
| 13 | { |
| 14 | namespace platform_mc |
| 15 | { |
| 16 | |
| 17 | /** |
| 18 | * @brief Manager |
| 19 | * |
| 20 | * This class handles all the aspect of the PLDM Platform Monitoring and Control |
| 21 | * specification for the MCTP devices |
| 22 | */ |
| 23 | class Manager : public pldm::MctpDiscoveryHandlerIntf |
| 24 | { |
| 25 | public: |
| 26 | Manager() = delete; |
| 27 | Manager(const Manager&) = delete; |
| 28 | Manager(Manager&&) = delete; |
| 29 | Manager& operator=(const Manager&) = delete; |
| 30 | Manager& operator=(Manager&&) = delete; |
| 31 | ~Manager() = default; |
| 32 | |
| 33 | explicit Manager(sdeventplus::Event& event, RequesterHandler& handler, |
| 34 | pldm::InstanceIdDb& instanceIdDb) : |
| 35 | terminusManager(event, handler, instanceIdDb, termini, this), |
| 36 | platformManager(terminusManager, termini) |
| 37 | {} |
| 38 | |
| 39 | /** @brief Helper function to do the actions before discovering terminus |
| 40 | * |
| 41 | * @return coroutine return_value - PLDM completion code |
| 42 | */ |
| 43 | exec::task<int> beforeDiscoverTerminus(); |
| 44 | |
| 45 | /** @brief Helper function to do the actions after discovering terminus |
| 46 | * |
| 47 | * @return coroutine return_value - PLDM completion code |
| 48 | */ |
| 49 | exec::task<int> afterDiscoverTerminus(); |
| 50 | |
| 51 | /** @brief Helper function to invoke registered handlers for |
| 52 | * the added MCTP endpoints |
| 53 | * |
| 54 | * @param[in] mctpInfos - list information of the MCTP endpoints |
| 55 | */ |
| 56 | void handleMctpEndpoints(const MctpInfos& mctpInfos) |
| 57 | { |
| 58 | terminusManager.discoverMctpTerminus(mctpInfos); |
| 59 | } |
| 60 | |
| 61 | /** @brief Helper function to invoke registered handlers for |
| 62 | * the removed MCTP endpoints |
| 63 | * |
| 64 | * @param[in] mctpInfos - list information of the MCTP endpoints |
| 65 | */ |
| 66 | void handleRemovedMctpEndpoints(const MctpInfos& mctpInfos) |
| 67 | { |
| 68 | terminusManager.removeMctpTerminus(mctpInfos); |
| 69 | } |
| 70 | |
| 71 | private: |
| 72 | /** @brief List of discovered termini */ |
| 73 | TerminiMapper termini{}; |
| 74 | |
| 75 | /** @brief Terminus interface for calling the hook functions */ |
| 76 | TerminusManager terminusManager; |
| 77 | |
| 78 | /** @brief Platform interface for calling the hook functions */ |
| 79 | PlatformManager platformManager; |
| 80 | }; |
| 81 | } // namespace platform_mc |
| 82 | } // namespace pldm |