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> |
| 11 | #include <libpldm/file_io.h> |
| 12 | #include <libpldm/host.h> |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 13 | #include <stdint.h> |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 14 | #include <sys/stat.h> |
| 15 | #include <sys/types.h> |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 16 | #include <unistd.h> |
| 17 | |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 18 | #include <phosphor-logging/lg2.hpp> |
| 19 | |
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 | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 120 | error("File does not exist, path = {FILE_PATH}", "FILE_PATH", |
| 121 | path.string()); |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 122 | encode_rw_file_memory_resp(instanceId, command, PLDM_ERROR, 0, |
| 123 | responsePtr); |
| 124 | return response; |
| 125 | } |
George Liu | 8340957 | 2019-12-24 18:42:54 +0800 | [diff] [blame] | 126 | pldm::utils::CustomFD fd(file); |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 127 | |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 128 | while (length > dma::maxSize) |
| 129 | { |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 130 | auto rc = intf->transferDataHost(fd(), offset, dma::maxSize, address, |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 131 | upstream); |
| 132 | if (rc < 0) |
| 133 | { |
Jinu Joy Thomas | 33705fd | 2019-07-02 16:03:05 +0530 | [diff] [blame] | 134 | encode_rw_file_memory_resp(instanceId, command, PLDM_ERROR, 0, |
| 135 | responsePtr); |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 136 | return response; |
| 137 | } |
| 138 | |
| 139 | offset += dma::maxSize; |
| 140 | length -= dma::maxSize; |
| 141 | address += dma::maxSize; |
| 142 | } |
| 143 | |
Deepak Kodihalli | 15211b4 | 2019-12-14 02:24:49 -0600 | [diff] [blame] | 144 | auto rc = intf->transferDataHost(fd(), offset, length, address, upstream); |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 145 | if (rc < 0) |
| 146 | { |
Jinu Joy Thomas | 33705fd | 2019-07-02 16:03:05 +0530 | [diff] [blame] | 147 | encode_rw_file_memory_resp(instanceId, command, PLDM_ERROR, 0, |
| 148 | responsePtr); |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 149 | return response; |
| 150 | } |
| 151 | |
Jinu Joy Thomas | 33705fd | 2019-07-02 16:03:05 +0530 | [diff] [blame] | 152 | encode_rw_file_memory_resp(instanceId, command, PLDM_SUCCESS, origLength, |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 153 | responsePtr); |
| 154 | return response; |
| 155 | } |
| 156 | |
| 157 | } // namespace dma |
| 158 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 159 | namespace oem_ibm |
| 160 | { |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 161 | static constexpr auto dumpObjPath = "/xyz/openbmc_project/dump/resource/entry/"; |
| 162 | static constexpr auto resDumpEntry = "com.ibm.Dump.Entry.Resource"; |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 163 | |
| 164 | static constexpr auto certObjPath = "/xyz/openbmc_project/certs/ca/"; |
| 165 | static constexpr auto certAuthority = |
| 166 | "xyz.openbmc_project.PLDM.Provider.Certs.Authority.CSR"; |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 167 | class Handler : public CmdHandler |
| 168 | { |
| 169 | public: |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 170 | Handler(oem_platform::Handler* oemPlatformHandler, int hostSockFd, |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 171 | uint8_t hostEid, pldm::InstanceIdDb* instanceIdDb, |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 172 | pldm::requester::Handler<pldm::requester::Request>* handler) : |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 173 | oemPlatformHandler(oemPlatformHandler), |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 174 | hostSockFd(hostSockFd), hostEid(hostEid), instanceIdDb(instanceIdDb), |
| 175 | handler(handler) |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 176 | { |
| 177 | handlers.emplace(PLDM_READ_FILE_INTO_MEMORY, |
| 178 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 179 | return this->readFileIntoMemory(request, payloadLength); |
| 180 | }); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 181 | handlers.emplace(PLDM_WRITE_FILE_FROM_MEMORY, |
| 182 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 183 | return this->writeFileFromMemory(request, payloadLength); |
| 184 | }); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 185 | handlers.emplace(PLDM_WRITE_FILE_BY_TYPE_FROM_MEMORY, |
| 186 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 187 | return this->writeFileByTypeFromMemory(request, payloadLength); |
| 188 | }); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 189 | handlers.emplace(PLDM_READ_FILE_BY_TYPE_INTO_MEMORY, |
| 190 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 191 | return this->readFileByTypeIntoMemory(request, payloadLength); |
| 192 | }); |
| 193 | handlers.emplace(PLDM_READ_FILE_BY_TYPE, |
| 194 | [this](const pldm_msg* request, size_t payloadLength) { |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 195 | return this->readFileByType(request, payloadLength); |
| 196 | }); |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 197 | handlers.emplace(PLDM_WRITE_FILE_BY_TYPE, |
| 198 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 199 | return this->writeFileByType(request, payloadLength); |
| 200 | }); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 201 | handlers.emplace(PLDM_GET_FILE_TABLE, |
| 202 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 203 | return this->getFileTable(request, payloadLength); |
| 204 | }); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 205 | handlers.emplace(PLDM_READ_FILE, |
| 206 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 207 | return this->readFile(request, payloadLength); |
| 208 | }); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 209 | handlers.emplace(PLDM_WRITE_FILE, |
| 210 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 211 | return this->writeFile(request, payloadLength); |
| 212 | }); |
Deepak Kodihalli | 2da1bfe | 2019-12-14 08:28:09 -0600 | [diff] [blame] | 213 | handlers.emplace(PLDM_FILE_ACK, |
| 214 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 215 | return this->fileAck(request, payloadLength); |
| 216 | }); |
George Liu | 89aad71 | 2020-03-12 13:34:51 +0800 | [diff] [blame] | 217 | handlers.emplace(PLDM_HOST_GET_ALERT_STATUS, |
| 218 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 219 | return this->getAlertStatus(request, payloadLength); |
| 220 | }); |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 221 | handlers.emplace(PLDM_NEW_FILE_AVAILABLE, |
| 222 | [this](const pldm_msg* request, size_t payloadLength) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 223 | return this->newFileAvailable(request, payloadLength); |
| 224 | }); |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 225 | |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 226 | resDumpMatcher = std::make_unique<sdbusplus::bus::match_t>( |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 227 | pldm::utils::DBusHandler::getBus(), |
| 228 | sdbusplus::bus::match::rules::interfacesAdded() + |
| 229 | sdbusplus::bus::match::rules::argNpath(0, dumpObjPath), |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 230 | [this, hostSockFd, hostEid, instanceIdDb, |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 231 | handler](sdbusplus::message_t& msg) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 232 | std::map<std::string, |
| 233 | std::map<std::string, std::variant<std::string, uint32_t>>> |
| 234 | interfaces; |
| 235 | sdbusplus::message::object_path path; |
| 236 | msg.read(path, interfaces); |
| 237 | std::string vspstring; |
| 238 | std::string password; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 239 | |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 240 | for (auto& interface : interfaces) |
| 241 | { |
| 242 | if (interface.first == resDumpEntry) |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 243 | { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 244 | for (const auto& property : interface.second) |
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 | if (property.first == "VSPString") |
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 | vspstring = std::get<std::string>(property.second); |
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 | else if (property.first == "Password") |
| 251 | { |
| 252 | password = std::get<std::string>(property.second); |
| 253 | } |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 254 | } |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 255 | dbusToFileHandlers |
| 256 | .emplace_back( |
| 257 | std::make_unique< |
| 258 | pldm::requester::oem_ibm::DbusToFileHandler>( |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 259 | hostSockFd, hostEid, instanceIdDb, path, |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 260 | handler)) |
| 261 | ->processNewResourceDump(vspstring, password); |
| 262 | break; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 263 | } |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 264 | } |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 265 | }); |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 266 | vmiCertMatcher = std::make_unique<sdbusplus::bus::match_t>( |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 267 | pldm::utils::DBusHandler::getBus(), |
| 268 | sdbusplus::bus::match::rules::interfacesAdded() + |
| 269 | sdbusplus::bus::match::rules::argNpath(0, certObjPath), |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 270 | [this, hostSockFd, hostEid, instanceIdDb, |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 271 | handler](sdbusplus::message_t& msg) { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 272 | std::map<std::string, |
| 273 | std::map<std::string, std::variant<std::string, uint32_t>>> |
| 274 | interfaces; |
| 275 | sdbusplus::message::object_path path; |
| 276 | msg.read(path, interfaces); |
| 277 | std::string csr; |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 278 | |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 279 | for (auto& interface : interfaces) |
| 280 | { |
| 281 | if (interface.first == certAuthority) |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 282 | { |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 283 | for (const auto& property : interface.second) |
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 | if (property.first == "CSR") |
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 | csr = std::get<std::string>(property.second); |
| 288 | auto fileHandle = |
| 289 | sdbusplus::message::object_path(path) |
| 290 | .filename(); |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 291 | |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 292 | dbusToFileHandlers |
| 293 | .emplace_back( |
| 294 | std::make_unique<pldm::requester::oem_ibm:: |
| 295 | DbusToFileHandler>( |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 296 | hostSockFd, hostEid, instanceIdDb, path, |
| 297 | handler)) |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 298 | ->newCsrFileAvailable(csr, fileHandle); |
| 299 | break; |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 300 | } |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 301 | } |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 302 | break; |
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 | } |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 305 | }); |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 306 | } |
Tom Joseph | 0c6d22c | 2019-06-26 09:58:41 +0530 | [diff] [blame] | 307 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 308 | /** @brief Handler for readFileIntoMemory command |
| 309 | * |
| 310 | * @param[in] request - pointer to PLDM request payload |
| 311 | * @param[in] payloadLength - length of the message |
| 312 | * |
| 313 | * @return PLDM response message |
| 314 | */ |
| 315 | Response readFileIntoMemory(const pldm_msg* request, size_t payloadLength); |
Sampa Misra | 854e61f | 2019-08-22 04:36:47 -0500 | [diff] [blame] | 316 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 317 | /** @brief Handler for writeFileIntoMemory command |
| 318 | * |
| 319 | * @param[in] request - pointer to PLDM request payload |
| 320 | * @param[in] payloadLength - length of the message |
| 321 | * |
| 322 | * @return PLDM response message |
| 323 | */ |
| 324 | Response writeFileFromMemory(const pldm_msg* request, size_t payloadLength); |
Sampa Misra | 854e61f | 2019-08-22 04:36:47 -0500 | [diff] [blame] | 325 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 326 | /** @brief Handler for writeFileByTypeFromMemory command |
| 327 | * |
| 328 | * @param[in] request - pointer to PLDM request payload |
| 329 | * @param[in] payloadLength - length of the message |
| 330 | * |
| 331 | * @return PLDM response message |
| 332 | */ |
Deepak Kodihalli | f6d3a83 | 2019-11-19 07:00:29 -0600 | [diff] [blame] | 333 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 334 | Response writeFileByTypeFromMemory(const pldm_msg* request, |
| 335 | size_t payloadLength); |
Deepak Kodihalli | 75e02f8 | 2019-11-20 02:51:05 -0600 | [diff] [blame] | 336 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 337 | /** @brief Handler for readFileByTypeIntoMemory command |
| 338 | * |
| 339 | * @param[in] request - pointer to PLDM request payload |
| 340 | * @param[in] payloadLength - length of the message |
| 341 | * |
| 342 | * @return PLDM response message |
| 343 | */ |
| 344 | Response readFileByTypeIntoMemory(const pldm_msg* request, |
| 345 | size_t payloadLength); |
vkaverap | 5b914c3 | 2019-06-30 22:23:54 -0500 | [diff] [blame] | 346 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 347 | /** @brief Handler for writeFileByType command |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 348 | * |
| 349 | * @param[in] request - pointer to PLDM request payload |
| 350 | * @param[in] payloadLength - length of the message |
| 351 | * |
| 352 | * @return PLDM response message |
| 353 | */ |
| 354 | Response readFileByType(const pldm_msg* request, size_t payloadLength); |
vkaverap | 5b914c3 | 2019-06-30 22:23:54 -0500 | [diff] [blame] | 355 | |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 356 | Response writeFileByType(const pldm_msg* request, size_t payloadLength); |
| 357 | |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 358 | /** @brief Handler for GetFileTable command |
| 359 | * |
| 360 | * @param[in] request - pointer to PLDM request payload |
| 361 | * @param[in] payloadLength - length of the message payload |
| 362 | * |
| 363 | * @return PLDM response message |
| 364 | */ |
| 365 | Response getFileTable(const pldm_msg* request, size_t payloadLength); |
| 366 | |
| 367 | /** @brief Handler for readFile command |
| 368 | * |
| 369 | * @param[in] request - PLDM request msg |
| 370 | * @param[in] payloadLength - length of the message payload |
| 371 | * |
| 372 | * @return PLDM response message |
| 373 | */ |
| 374 | Response readFile(const pldm_msg* request, size_t payloadLength); |
| 375 | |
| 376 | /** @brief Handler for writeFile command |
| 377 | * |
| 378 | * @param[in] request - PLDM request msg |
| 379 | * @param[in] payloadLength - length of the message payload |
| 380 | * |
| 381 | * @return PLDM response message |
| 382 | */ |
| 383 | Response writeFile(const pldm_msg* request, size_t payloadLength); |
Deepak Kodihalli | 2da1bfe | 2019-12-14 08:28:09 -0600 | [diff] [blame] | 384 | |
| 385 | Response fileAck(const pldm_msg* request, size_t payloadLength); |
George Liu | 89aad71 | 2020-03-12 13:34:51 +0800 | [diff] [blame] | 386 | |
| 387 | /** @brief Handler for getAlertStatus command |
| 388 | * |
| 389 | * @param[in] request - PLDM request msg |
| 390 | * @param[in] payloadLength - length of the message payload |
| 391 | * |
| 392 | * @return PLDM response message |
| 393 | */ |
| 394 | Response getAlertStatus(const pldm_msg* request, size_t payloadLength); |
Sampa Misra | 1896716 | 2020-01-14 02:31:41 -0600 | [diff] [blame] | 395 | |
| 396 | /** @brief Handler for newFileAvailable command |
| 397 | * |
| 398 | * @param[in] request - PLDM request msg |
| 399 | * @param[in] payloadLength - length of the message payload |
| 400 | * |
| 401 | * @return PLDM response message |
| 402 | */ |
| 403 | Response newFileAvailable(const pldm_msg* request, size_t payloadLength); |
Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 404 | |
| 405 | private: |
| 406 | oem_platform::Handler* oemPlatformHandler; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 407 | int hostSockFd; |
| 408 | uint8_t hostEid; |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 409 | pldm::InstanceIdDb* instanceIdDb; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 410 | using DBusInterfaceAdded = std::vector<std::pair< |
| 411 | std::string, |
| 412 | std::vector<std::pair<std::string, std::variant<std::string>>>>>; |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 413 | std::unique_ptr<pldm::requester::oem_ibm::DbusToFileHandler> |
| 414 | dbusToFileHandler; //!< pointer to send request to Host |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 415 | std::unique_ptr<sdbusplus::bus::match_t> |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 416 | resDumpMatcher; //!< Pointer to capture the interface added signal |
| 417 | //!< for new resource dump |
Patrick Williams | 84b790c | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 418 | std::unique_ptr<sdbusplus::bus::match_t> |
Patrick Williams | 6da4f91 | 2023-05-10 07:50:53 -0500 | [diff] [blame] | 419 | vmiCertMatcher; //!< Pointer to capture the interface added signal |
| 420 | //!< for new csr string |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 421 | /** @brief PLDM request handler */ |
| 422 | pldm::requester::Handler<pldm::requester::Request>* handler; |
| 423 | std::vector<std::unique_ptr<pldm::requester::oem_ibm::DbusToFileHandler>> |
| 424 | dbusToFileHandlers; |
Deepak Kodihalli | bc669f1 | 2019-11-28 08:52:07 -0600 | [diff] [blame] | 425 | }; |
| 426 | |
| 427 | } // namespace oem_ibm |
Jinu Joy Thomas | 7f57f44 | 2019-06-13 20:38:49 +0530 | [diff] [blame] | 428 | } // namespace responder |
| 429 | } // namespace pldm |