Gilbert Chen | 6c7fed4 | 2022-02-22 15:40:17 +0000 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Dung Cao | b6d3943 | 2024-06-05 03:46:47 +0000 | [diff] [blame] | 3 | #include "libpldm/fru.h" |
Gilbert Chen | 6c7fed4 | 2022-02-22 15:40:17 +0000 | [diff] [blame] | 4 | #include "libpldm/platform.h" |
| 5 | #include "libpldm/pldm.h" |
| 6 | |
| 7 | #include "terminus.hpp" |
| 8 | #include "terminus_manager.hpp" |
| 9 | |
Gilbert Chen | de2a132 | 2022-05-24 15:35:21 +0100 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
Gilbert Chen | 6c7fed4 | 2022-02-22 15:40:17 +0000 | [diff] [blame] | 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 | |
| 33 | explicit PlatformManager(TerminusManager& terminusManager, |
Eric Yang | 6baafe4 | 2025-01-20 17:13:33 +0800 | [diff] [blame^] | 34 | TerminiMapper& termini, Manager* manager) : |
| 35 | terminusManager(terminusManager), termini(termini), manager(manager) |
Gilbert Chen | 6c7fed4 | 2022-02-22 15:40:17 +0000 | [diff] [blame] | 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 | |
Thu Nguyen | 51d66b5 | 2024-08-06 09:15:55 +0000 | [diff] [blame] | 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 | |
Gilbert Chen | 6c7fed4 | 2022-02-22 15:40:17 +0000 | [diff] [blame] | 51 | private: |
Gilbert Chen | de2a132 | 2022-05-24 15:35:21 +0100 | [diff] [blame] | 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 | */ |
Patrick Williams | 366507c | 2025-02-03 14:28:01 -0500 | [diff] [blame] | 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); |
Gilbert Chen | de2a132 | 2022-05-24 15:35:21 +0100 | [diff] [blame] | 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 | */ |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 93 | exec::task<int> getPDRRepositoryInfo( |
| 94 | const pldm_tid_t tid, uint8_t& repositoryState, uint32_t& recordCount, |
| 95 | uint32_t& repositorySize, uint32_t& largestRecordSize); |
Gilbert Chen | de2a132 | 2022-05-24 15:35:21 +0100 | [diff] [blame] | 96 | |
Thu Nguyen | 51d66b5 | 2024-08-06 09:15:55 +0000 | [diff] [blame] | 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 | |
Gilbert Chen | 77e6fe7 | 2024-08-06 09:23:30 +0000 | [diff] [blame] | 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 | |
Thu Nguyen | 51d66b5 | 2024-08-06 09:15:55 +0000 | [diff] [blame] | 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 | |
Dung Cao | b6d3943 | 2024-06-05 03:46:47 +0000 | [diff] [blame] | 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 | |
Gilbert Chen | 6c7fed4 | 2022-02-22 15:40:17 +0000 | [diff] [blame] | 185 | /** reference of TerminusManager for sending PLDM request to terminus*/ |
| 186 | TerminusManager& terminusManager; |
| 187 | |
| 188 | /** @brief Managed termini list */ |
| 189 | TerminiMapper& termini; |
Eric Yang | 6baafe4 | 2025-01-20 17:13:33 +0800 | [diff] [blame^] | 190 | |
| 191 | /** |
| 192 | * @brief Pointer to the Manager instance, used for sensor polling |
| 193 | * and other platform-level PLDM operations. |
| 194 | */ |
| 195 | Manager* manager; |
Gilbert Chen | 6c7fed4 | 2022-02-22 15:40:17 +0000 | [diff] [blame] | 196 | }; |
| 197 | } // namespace platform_mc |
| 198 | } // namespace pldm |