1 #pragma once 2 3 #include "terminus.hpp" 4 #include "terminus_manager.hpp" 5 6 #include <libpldm/fru.h> 7 #include <libpldm/platform.h> 8 #include <libpldm/pldm.h> 9 10 #include <vector> 11 12 namespace pldm 13 { 14 15 namespace platform_mc 16 { 17 18 /** 19 * @brief PlatformManager 20 * 21 * PlatformManager class manages the actions outlined in the platform spec. 22 */ 23 class PlatformManager 24 { 25 public: 26 PlatformManager() = delete; 27 PlatformManager(const PlatformManager&) = delete; 28 PlatformManager(PlatformManager&&) = delete; 29 PlatformManager& operator=(const PlatformManager&) = delete; 30 PlatformManager& operator=(PlatformManager&&) = delete; 31 ~PlatformManager() = default; 32 PlatformManager(TerminusManager & terminusManager,TerminiMapper & termini,Manager * manager)33 explicit PlatformManager(TerminusManager& terminusManager, 34 TerminiMapper& termini, Manager* manager) : 35 terminusManager(terminusManager), termini(termini), manager(manager) 36 {} 37 38 /** @brief Initialize terminus which supports PLDM Type 2 39 * 40 * @return coroutine return_value - PLDM completion code 41 */ 42 exec::task<int> initTerminus(); 43 44 /** @brief Helper to get the supported event messages and set event receiver 45 * 46 * @param[in] tid - Destination TID 47 * @return coroutine return_value - PLDM completion code 48 */ 49 exec::task<int> configEventReceiver(pldm_tid_t tid); 50 51 private: 52 /** @brief Fetch all PDRs from terminus. 53 * 54 * @param[in] terminus - The terminus object to store fetched PDRs 55 * @return coroutine return_value - PLDM completion code 56 */ 57 exec::task<int> getPDRs(std::shared_ptr<Terminus> terminus); 58 59 /** @brief Fetch PDR from terminus 60 * 61 * @param[in] tid - Destination TID 62 * @param[in] recordHndl - Record handle 63 * @param[in] dataTransferHndl - Data transfer handle 64 * @param[in] transferOpFlag - Transfer Operation Flag 65 * @param[in] requstCnt - Request Count of data 66 * @param[in] recordChgNum - Record change number 67 * @param[out] nextRecordHndl - Next record handle 68 * @param[out] nextDataTransferHndl - Next data transfer handle 69 * @param[out] transferFlag - Transfer flag 70 * @param[out] responseCnt - Response count of record data 71 * @param[out] recordData - Returned record data 72 * @param[out] transferCrc - CRC value when record data is last part of PDR 73 * @return coroutine return_value - PLDM completion code 74 */ 75 exec::task<int> getPDR( 76 const pldm_tid_t tid, const uint32_t recordHndl, 77 const uint32_t dataTransferHndl, const uint8_t transferOpFlag, 78 const uint16_t requestCnt, const uint16_t recordChgNum, 79 uint32_t& nextRecordHndl, uint32_t& nextDataTransferHndl, 80 uint8_t& transferFlag, uint16_t& responseCnt, 81 std::vector<uint8_t>& recordData, uint8_t& transferCrc); 82 83 /** @brief get PDR repository information. 84 * 85 * @param[in] tid - Destination TID 86 * @param[out] repositoryState - the state of repository 87 * @param[out] recordCount - number of records 88 * @param[out] repositorySize - repository size 89 * @param[out] largestRecordSize - largest record size 90 * * 91 * @return coroutine return_value - PLDM completion code 92 */ 93 exec::task<int> getPDRRepositoryInfo( 94 const pldm_tid_t tid, uint8_t& repositoryState, uint32_t& recordCount, 95 uint32_t& repositorySize, uint32_t& largestRecordSize); 96 97 /** @brief Send setEventReceiver command to destination EID. 98 * 99 * @param[in] tid - Destination TID 100 * @param[in] eventMessageGlobalEnable - Enable/disable event message 101 * generation from the terminus 102 * @param[in] eventReceiverEid - The EID of eventReceiver that terminus 103 * should send event message to 104 * @param[in] protocolType - Provided in the request to help the responder 105 * verify that the content of the eventReceiverAddressInfo field 106 * @param[in] heartbeatTimer - Amount of time in seconds after each 107 * elapsing of which the terminus shall emit a heartbeat event. 108 * @return coroutine return_value - PLDM completion code 109 */ 110 exec::task<int> setEventReceiver( 111 pldm_tid_t tid, 112 pldm_event_message_global_enable eventMessageGlobalEnable, 113 pldm_transport_protocol_type protocolType, uint16_t heartbeatTimer); 114 115 /** @brief send eventMessageBufferSize 116 * @param[in] tid - Destination TID 117 * @param[in] receiverMaxBufferSize 118 * @param[out] terminusBufferSize 119 * @return coroutine return_value - PLDM completion code 120 */ 121 exec::task<int> eventMessageBufferSize(pldm_tid_t tid, 122 uint16_t receiverMaxBufferSize, 123 uint16_t& terminusBufferSize); 124 125 /** @brief send eventMessageSupported 126 * @param[in] tid - Destination TID 127 * @param[in] formatVersion - version of the event format 128 * @param[out] synchronyConfiguration - messaging style most recently 129 * configured via the setEventReceiver command 130 * @param[out] synchronyConfigurationSupported - event messaging styles 131 * supported by the terminus 132 * @param[out] numerEventClassReturned - number of eventClass enumerated 133 * bytes 134 * @param[out] eventClass - vector of eventClass the device can generate 135 * @return coroutine return_value - PLDM completion code 136 */ 137 exec::task<int> eventMessageSupported( 138 pldm_tid_t tid, uint8_t formatVersion, uint8_t& synchronyConfiguration, 139 bitfield8_t& synchronyConfigurationSupported, 140 uint8_t& numerEventClassReturned, std::vector<uint8_t>& eventClass); 141 142 /** @brief Get FRU Record Tables from remote MCTP Endpoint 143 * 144 * @param[in] tid - Destination TID 145 * @param[in] total - Total number of record in table 146 * @param[out] fruData - Returned fru record table data 147 */ 148 exec::task<int> getFRURecordTables(pldm_tid_t tid, const uint16_t& total, 149 std::vector<uint8_t>& fruData); 150 151 /** @brief Fetch FRU Record Data from terminus 152 * 153 * @param[in] tid - Destination TID 154 * @param[in] dataTransferHndl - Data transfer handle 155 * @param[in] transferOpFlag - Transfer Operation Flag 156 * @param[out] nextDataTransferHndl - Next data transfer handle 157 * @param[out] transferFlag - Transfer flag 158 * @param[out] responseCnt - Response count of record data 159 * @param[out] recordData - Returned record data 160 * 161 * @return coroutine return_value - PLDM completion code 162 */ 163 exec::task<int> getFRURecordTable( 164 pldm_tid_t tid, const uint32_t dataTransferHndl, 165 const uint8_t transferOpFlag, uint32_t* nextDataTransferHndl, 166 uint8_t* transferFlag, size_t* responseCnt, 167 std::vector<uint8_t>& recordData); 168 169 /** @brief Get FRU Record Table Metadata from remote MCTP Endpoint 170 * 171 * @param[in] tid - Destination TID 172 * @param[out] total - Total number of record in table 173 */ 174 exec::task<int> getFRURecordTableMetadata(pldm_tid_t tid, uint16_t* total); 175 176 /** @brief Parse record data from FRU table 177 * 178 * @param[in] tid - Destination TID 179 * @param[in] fruData - pointer to FRU record table 180 * @param[in] fruLen - FRU table length 181 */ 182 void updateInventoryWithFru(pldm_tid_t tid, const uint8_t* fruData, 183 const size_t fruLen); 184 185 /** reference of TerminusManager for sending PLDM request to terminus*/ 186 TerminusManager& terminusManager; 187 188 /** @brief Managed termini list */ 189 TerminiMapper& termini; 190 191 /** 192 * @brief Pointer to the Manager instance, used for sensor polling 193 * and other platform-level PLDM operations. 194 */ 195 Manager* manager; 196 }; 197 } // namespace platform_mc 198 } // namespace pldm 199