Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Deepak Kodihalli | d130e1a | 2020-06-17 05:55:32 -0500 | [diff] [blame] | 3 | #include "common/utils.hpp" |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 4 | #include "oem/ibm/requester/dbus_to_file_handler.hpp" |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 5 | #include "oem_ibm_handler.hpp" |
Deepak Kodihalli | 1521f6d | 2020-06-16 08:51:02 -0500 | [diff] [blame] | 6 | #include "pldmd/handler.hpp" |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 7 | #include "requester/handler.hpp" |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 8 | |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 9 | #include <fcntl.h> |
George Liu | c453e16 | 2022-12-21 17:16:23 +0800 | [diff] [blame] | 10 | #include <libpldm/base.h> |
Andrew Jeffery | 21f128d | 2024-01-15 15:34:26 +1030 | [diff] [blame] | 11 | #include <libpldm/oem/ibm/file_io.h> |
| 12 | #include <libpldm/oem/ibm/host.h> |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 13 | #include <sys/stat.h> |
| 14 | #include <sys/types.h> |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 15 | #include <unistd.h> |
| 16 | |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 17 | #include <phosphor-logging/lg2.hpp> |
| 18 | |
Pavithra Barithaya | b3b84b4 | 2024-08-23 11:43:57 +0530 | [diff] [blame^] | 19 | #include <cstdint> |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 20 | #include <filesystem> |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 21 | #include <iostream> |
Priyanga | 8b97665 | 2019-06-27 11:30:33 -0500 | [diff] [blame] | 22 | #include <vector> |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 23 | |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 24 | PHOSPHOR_LOG2_USING; |
| 25 | |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 26 | namespace pldm |
| 27 | { |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 28 | namespace responder |
| 29 | { |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 30 | namespace dma |
| 31 | { |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 32 | // The minimum data size of dma transfer in bytes |
| 33 | constexpr uint32_t minSize = 16; |
| 34 | |
Deepak Kodihalli | 4c164b0 | 2020-03-07 03:23:31 -0600 | [diff] [blame] | 35 | constexpr size_t maxSize = DMA_MAXSIZE; |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 36 | |
| 37 | namespace fs = std::filesystem; |
| 38 | |
| 39 | /** |
| 40 | * @class DMA |
| 41 | * |
| 42 | * Expose API to initiate transfer of data by DMA |
| 43 | * |
| 44 | * This class only exposes the public API transferDataHost to transfer data |
| 45 | * between BMC and host using DMA. This allows for mocking the transferDataHost |
| 46 | * for unit testing purposes. |
| 47 | */ |
| 48 | class DMA |
| 49 | { |
| 50 | public: |
| 51 | /** @brief API to transfer data between BMC and host using DMA |
| 52 | * |
| 53 | * @param[in] path - pathname of the file to transfer data from or to |
| 54 | * @param[in] offset - offset in the file |
| 55 | * @param[in] length - length of the data to transfer |
| 56 | * @param[in] address - DMA address on the host |
| 57 | * @param[in] upstream - indicates direction of the transfer; true indicates |
| 58 | * transfer to the host |
| 59 | * |
| 60 | * @return returns 0 on success, negative errno on failure |
| 61 | */ |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 62 | int transferDataHost(int fd, uint32_t offset, uint32_t length, |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 63 | uint64_t address, bool upstream); |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 64 | |
| 65 | /** @brief API to transfer data on to unix socket from host using DMA |
| 66 | * |
| 67 | * @param[in] path - pathname of the file to transfer data from or to |
| 68 | * @param[in] length - length of the data to transfer |
| 69 | * @param[in] address - DMA address on the host |
| 70 | * |
| 71 | * @return returns 0 on success, negative errno on failure |
| 72 | */ |
| 73 | int transferHostDataToSocket(int fd, uint32_t length, uint64_t address); |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | /** @brief Transfer the data between BMC and host using DMA. |
| 77 | * |
| 78 | * There is a max size for each DMA operation, transferAll API abstracts this |
| 79 | * and the requested length is broken down into multiple DMA operations if the |
| 80 | * length exceed max size. |
| 81 | * |
| 82 | * @tparam[in] T - DMA interface type |
| 83 | * @param[in] intf - interface passed to invoke DMA transfer |
| 84 | * @param[in] command - PLDM command |
| 85 | * @param[in] path - pathname of the file to transfer data from or to |
| 86 | * @param[in] offset - offset in the file |
| 87 | * @param[in] length - length of the data to transfer |
| 88 | * @param[in] address - DMA address on the host |
| 89 | * @param[in] upstream - indicates direction of the transfer; true indicates |
| 90 | * transfer to the host |
Jinu Joy Thomas | 33705fd | 2019-07-02 16:03:05 +0530 | [diff] [blame] | 91 | * @param[in] instanceId - Message's instance id |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 92 | * @return PLDM response message |
| 93 | */ |
| 94 | |
| 95 | template <class DMAInterface> |
| 96 | Response transferAll(DMAInterface* intf, uint8_t command, fs::path& path, |
| 97 | uint32_t offset, uint32_t length, uint64_t address, |
Jinu Joy Thomas | 33705fd | 2019-07-02 16:03:05 +0530 | [diff] [blame] | 98 | bool upstream, uint8_t instanceId) |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 99 | { |
| 100 | uint32_t origLength = length; |
| 101 | Response response(sizeof(pldm_msg_hdr) + PLDM_RW_FILE_MEM_RESP_BYTES, 0); |
| 102 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 103 | |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 104 | int flags{}; |
| 105 | if (upstream) |
| 106 | { |
| 107 | flags = O_RDONLY; |
| 108 | } |
| 109 | else if (fs::exists(path)) |
| 110 | { |
| 111 | flags = O_RDWR; |
| 112 | } |
| 113 | else |
| 114 | { |
| 115 | flags = O_WRONLY; |
| 116 | } |
| 117 | int file = open(path.string().c_str(), flags); |
| 118 | if (file == -1) |
| 119 | { |
Riya Dixit | 1e5c81e | 2024-05-03 07:54:00 -0500 | [diff] [blame] | 120 | error("File at path '{PATH}' does not exist", "PATH", path); |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 121 | encode_rw_file_memory_resp(instanceId, command, PLDM_ERROR, 0, |
| 122 | responsePtr); |
| 123 | return response; |
| 124 | } |
George Liu | 8340957 | 2019-12-24 18:42:54 +0800 | [diff] [blame] | 125 | pldm::utils::CustomFD fd(file); |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 126 | |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 127 | while (length > dma::maxSize) |
| 128 | { |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 129 | auto rc = intf->transferDataHost(fd(), offset, dma::maxSize, address, |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 130 | upstream); |
| 131 | if (rc < 0) |
| 132 | { |
Jinu Joy Thomas | 33705fd | 2019-07-02 16:03:05 +0530 | [diff] [blame] | 133 | encode_rw_file_memory_resp(instanceId, command, PLDM_ERROR, 0, |
| 134 | responsePtr); |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 135 | return response; |
| 136 | } |
| 137 | |
| 138 | offset += dma::maxSize; |
| 139 | length -= dma::maxSize; |
| 140 | address += dma::maxSize; |
| 141 | } |
| 142 | |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 143 | auto rc = intf->transferDataHost(fd(), offset, length, address, upstream); |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 144 | if (rc < 0) |
| 145 | { |
Jinu Joy Thomas | 33705fd | 2019-07-02 16:03:05 +0530 | [diff] [blame] | 146 | encode_rw_file_memory_resp(instanceId, command, PLDM_ERROR, 0, |
| 147 | responsePtr); |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 148 | return response; |
| 149 | } |
| 150 | |
Jinu Joy Thomas | 33705fd | 2019-07-02 16:03:05 +0530 | [diff] [blame] | 151 | encode_rw_file_memory_resp(instanceId, command, PLDM_SUCCESS, origLength, |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 152 | responsePtr); |
| 153 | return response; |
| 154 | } |
| 155 | |
| 156 | } // namespace dma |
| 157 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 158 | namespace oem_ibm |
| 159 | { |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 160 | static constexpr auto dumpObjPath = "/xyz/openbmc_project/dump/resource/entry/"; |
| 161 | static constexpr auto resDumpEntry = "com.ibm.Dump.Entry.Resource"; |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 162 | |
| 163 | static constexpr auto certObjPath = "/xyz/openbmc_project/certs/ca/"; |
| 164 | static constexpr auto certAuthority = |
| 165 | "xyz.openbmc_project.PLDM.Provider.Certs.Authority.CSR"; |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 166 | class Handler : public CmdHandler |
| 167 | { |
| 168 | public: |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 169 | Handler(oem_platform::Handler* oemPlatformHandler, int hostSockFd, |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 170 | uint8_t hostEid, pldm::InstanceIdDb* instanceIdDb, |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 171 | pldm::requester::Handler<pldm::requester::Request>* handler) : |
Andrew Jeffery | 7d85286 | 2024-07-25 20:43:36 +0930 | [diff] [blame] | 172 | oemPlatformHandler(oemPlatformHandler) |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 173 | { |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 174 | handlers.emplace( |
| 175 | PLDM_READ_FILE_INTO_MEMORY, |
| 176 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 177 | return this->readFileIntoMemory(request, payloadLength); |
| 178 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 179 | handlers.emplace( |
| 180 | PLDM_WRITE_FILE_FROM_MEMORY, |
| 181 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 182 | return this->writeFileFromMemory(request, payloadLength); |
| 183 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 184 | handlers.emplace( |
| 185 | PLDM_WRITE_FILE_BY_TYPE_FROM_MEMORY, |
| 186 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 187 | return this->writeFileByTypeFromMemory(request, payloadLength); |
| 188 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 189 | handlers.emplace( |
| 190 | PLDM_READ_FILE_BY_TYPE_INTO_MEMORY, |
| 191 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 192 | return this->readFileByTypeIntoMemory(request, payloadLength); |
| 193 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 194 | handlers.emplace( |
| 195 | PLDM_READ_FILE_BY_TYPE, |
| 196 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 197 | return this->readFileByType(request, payloadLength); |
| 198 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 199 | handlers.emplace( |
| 200 | PLDM_WRITE_FILE_BY_TYPE, |
| 201 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 202 | return this->writeFileByType(request, payloadLength); |
| 203 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 204 | handlers.emplace( |
| 205 | PLDM_GET_FILE_TABLE, |
| 206 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 207 | return this->getFileTable(request, payloadLength); |
| 208 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 209 | handlers.emplace( |
| 210 | PLDM_READ_FILE, |
| 211 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 212 | return this->readFile(request, payloadLength); |
| 213 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 214 | handlers.emplace( |
| 215 | PLDM_WRITE_FILE, |
| 216 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 217 | return this->writeFile(request, payloadLength); |
| 218 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 219 | handlers.emplace( |
| 220 | PLDM_FILE_ACK, |
| 221 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 222 | return this->fileAck(request, payloadLength); |
| 223 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 224 | handlers.emplace( |
| 225 | PLDM_HOST_GET_ALERT_STATUS, |
| 226 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 227 | return this->getAlertStatus(request, payloadLength); |
| 228 | }); |
Delphine CC Chiu | d2e4899 | 2023-12-05 16:29:51 +0800 | [diff] [blame] | 229 | handlers.emplace( |
| 230 | PLDM_NEW_FILE_AVAILABLE, |
| 231 | [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 232 | return this->newFileAvailable(request, payloadLength); |
| 233 | }); |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 234 | |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 235 | resDumpMatcher = std::make_unique<sdbusplus::bus::match_t>( |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 236 | pldm::utils::DBusHandler::getBus(), |
| 237 | sdbusplus::bus::match::rules::interfacesAdded() + |
| 238 | sdbusplus::bus::match::rules::argNpath(0, dumpObjPath), |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 239 | [this, hostSockFd, hostEid, instanceIdDb, |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 240 | handler](sdbusplus::message_t& msg) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 241 | std::map< |
| 242 | std::string, |
| 243 | std::map<std::string, std::variant<std::string, uint32_t>>> |
| 244 | interfaces; |
| 245 | sdbusplus::message::object_path path; |
| 246 | msg.read(path, interfaces); |
| 247 | std::string vspstring; |
| 248 | std::string password; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 249 | |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 250 | for (const auto& interface : interfaces) |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 251 | { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 252 | if (interface.first == resDumpEntry) |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 253 | { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 254 | for (const auto& property : interface.second) |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 255 | { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 256 | if (property.first == "VSPString") |
| 257 | { |
| 258 | vspstring = |
| 259 | std::get<std::string>(property.second); |
| 260 | } |
| 261 | else if (property.first == "Password") |
| 262 | { |
| 263 | password = |
| 264 | std::get<std::string>(property.second); |
| 265 | } |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 266 | } |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 267 | dbusToFileHandlers |
| 268 | .emplace_back( |
| 269 | std::make_unique<pldm::requester::oem_ibm:: |
| 270 | DbusToFileHandler>( |
| 271 | hostSockFd, hostEid, instanceIdDb, path, |
| 272 | handler)) |
| 273 | ->processNewResourceDump(vspstring, password); |
| 274 | break; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 275 | } |
| 276 | } |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 277 | }); |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 278 | vmiCertMatcher = std::make_unique<sdbusplus::bus::match_t>( |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 279 | pldm::utils::DBusHandler::getBus(), |
| 280 | sdbusplus::bus::match::rules::interfacesAdded() + |
| 281 | sdbusplus::bus::match::rules::argNpath(0, certObjPath), |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 282 | [this, hostSockFd, hostEid, instanceIdDb, |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 283 | handler](sdbusplus::message_t& msg) { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 284 | std::map< |
| 285 | std::string, |
| 286 | std::map<std::string, std::variant<std::string, uint32_t>>> |
| 287 | interfaces; |
| 288 | sdbusplus::message::object_path path; |
| 289 | msg.read(path, interfaces); |
| 290 | std::string csr; |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 291 | |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 292 | for (const auto& interface : interfaces) |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 293 | { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 294 | if (interface.first == certAuthority) |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 295 | { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 296 | for (const auto& property : interface.second) |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 297 | { |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 298 | if (property.first == "CSR") |
| 299 | { |
| 300 | csr = std::get<std::string>(property.second); |
| 301 | auto fileHandle = |
| 302 | sdbusplus::message::object_path(path) |
| 303 | .filename(); |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 304 | |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 305 | dbusToFileHandlers |
| 306 | .emplace_back(std::make_unique< |
| 307 | pldm::requester::oem_ibm:: |
| 308 | DbusToFileHandler>( |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 309 | hostSockFd, hostEid, instanceIdDb, path, |
| 310 | handler)) |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 311 | ->newCsrFileAvailable(csr, fileHandle); |
| 312 | break; |
| 313 | } |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 314 | } |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 315 | break; |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 316 | } |
| 317 | } |
Patrick Williams | 16c2a0a | 2024-08-16 15:20:59 -0400 | [diff] [blame] | 318 | }); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 319 | } |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 320 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 321 | /** @brief Handler for readFileIntoMemory command |
| 322 | * |
| 323 | * @param[in] request - pointer to PLDM request payload |
| 324 | * @param[in] payloadLength - length of the message |
| 325 | * |
| 326 | * @return PLDM response message |
| 327 | */ |
| 328 | Response readFileIntoMemory(const pldm_msg* request, size_t payloadLength); |
Sampa Misra | 854e61f | 2019-08-22 04:36:47 -0500 | [diff] [blame] | 329 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 330 | /** @brief Handler for writeFileIntoMemory command |
| 331 | * |
| 332 | * @param[in] request - pointer to PLDM request payload |
| 333 | * @param[in] payloadLength - length of the message |
| 334 | * |
| 335 | * @return PLDM response message |
| 336 | */ |
| 337 | Response writeFileFromMemory(const pldm_msg* request, size_t payloadLength); |
Sampa Misra | 854e61f | 2019-08-22 04:36:47 -0500 | [diff] [blame] | 338 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 339 | /** @brief Handler for writeFileByTypeFromMemory command |
| 340 | * |
| 341 | * @param[in] request - pointer to PLDM request payload |
| 342 | * @param[in] payloadLength - length of the message |
| 343 | * |
| 344 | * @return PLDM response message |
| 345 | */ |
Deepak Kodihalli | f6d3a83 | 2019-11-19 07:00:29 -0600 | [diff] [blame] | 346 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 347 | Response writeFileByTypeFromMemory(const pldm_msg* request, |
| 348 | size_t payloadLength); |
Deepak Kodihalli | 75e02f8 | 2019-11-20 02:51:05 -0600 | [diff] [blame] | 349 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 350 | /** @brief Handler for readFileByTypeIntoMemory command |
| 351 | * |
| 352 | * @param[in] request - pointer to PLDM request payload |
| 353 | * @param[in] payloadLength - length of the message |
| 354 | * |
| 355 | * @return PLDM response message |
| 356 | */ |
| 357 | Response readFileByTypeIntoMemory(const pldm_msg* request, |
| 358 | size_t payloadLength); |
vkaverap | 5b914c3 | 2019-06-30 22:23:54 -0500 | [diff] [blame] | 359 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 360 | /** @brief Handler for writeFileByType command |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 361 | * |
| 362 | * @param[in] request - pointer to PLDM request payload |
| 363 | * @param[in] payloadLength - length of the message |
| 364 | * |
| 365 | * @return PLDM response message |
| 366 | */ |
| 367 | Response readFileByType(const pldm_msg* request, size_t payloadLength); |
vkaverap | 5b914c3 | 2019-06-30 22:23:54 -0500 | [diff] [blame] | 368 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 369 | Response writeFileByType(const pldm_msg* request, size_t payloadLength); |
| 370 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 371 | /** @brief Handler for GetFileTable command |
| 372 | * |
| 373 | * @param[in] request - pointer to PLDM request payload |
| 374 | * @param[in] payloadLength - length of the message payload |
| 375 | * |
| 376 | * @return PLDM response message |
| 377 | */ |
| 378 | Response getFileTable(const pldm_msg* request, size_t payloadLength); |
| 379 | |
| 380 | /** @brief Handler for readFile command |
| 381 | * |
| 382 | * @param[in] request - PLDM request msg |
| 383 | * @param[in] payloadLength - length of the message payload |
| 384 | * |
| 385 | * @return PLDM response message |
| 386 | */ |
| 387 | Response readFile(const pldm_msg* request, size_t payloadLength); |
| 388 | |
| 389 | /** @brief Handler for writeFile command |
| 390 | * |
| 391 | * @param[in] request - PLDM request msg |
| 392 | * @param[in] payloadLength - length of the message payload |
| 393 | * |
| 394 | * @return PLDM response message |
| 395 | */ |
| 396 | Response writeFile(const pldm_msg* request, size_t payloadLength); |
Deepak Kodihalli | 2da1bfe | 2019-12-14 08:28:09 -0600 | [diff] [blame] | 397 | |
| 398 | Response fileAck(const pldm_msg* request, size_t payloadLength); |
George Liu | 89aad71 | 2020-03-12 13:34:51 +0800 | [diff] [blame] | 399 | |
| 400 | /** @brief Handler for getAlertStatus command |
| 401 | * |
| 402 | * @param[in] request - PLDM request msg |
| 403 | * @param[in] payloadLength - length of the message payload |
| 404 | * |
| 405 | * @return PLDM response message |
| 406 | */ |
| 407 | Response getAlertStatus(const pldm_msg* request, size_t payloadLength); |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 408 | |
| 409 | /** @brief Handler for newFileAvailable command |
| 410 | * |
| 411 | * @param[in] request - PLDM request msg |
| 412 | * @param[in] payloadLength - length of the message payload |
| 413 | * |
| 414 | * @return PLDM response message |
| 415 | */ |
| 416 | Response newFileAvailable(const pldm_msg* request, size_t payloadLength); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 417 | |
| 418 | private: |
| 419 | oem_platform::Handler* oemPlatformHandler; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 420 | using DBusInterfaceAdded = std::vector<std::pair< |
| 421 | std::string, |
| 422 | std::vector<std::pair<std::string, std::variant<std::string>>>>>; |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 423 | std::unique_ptr<pldm::requester::oem_ibm::DbusToFileHandler> |
| 424 | dbusToFileHandler; //!< pointer to send request to Host |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 425 | std::unique_ptr<sdbusplus::bus::match_t> |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 426 | resDumpMatcher; //!< Pointer to capture the interface added signal |
| 427 | //!< for new resource dump |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 428 | std::unique_ptr<sdbusplus::bus::match_t> |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 429 | vmiCertMatcher; //!< Pointer to capture the interface added signal |
| 430 | //!< for new csr string |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 431 | /** @brief PLDM request handler */ |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 432 | std::vector<std::unique_ptr<pldm::requester::oem_ibm::DbusToFileHandler>> |
| 433 | dbusToFileHandlers; |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 434 | }; |
| 435 | |
| 436 | } // namespace oem_ibm |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 437 | } // namespace responder |
| 438 | } // namespace pldm |