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