Tom Joseph | 0722040 | 2019-05-15 16:30:41 +0530 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 3 | #include "file_io.hpp" |
| 4 | |
Tom Joseph | 0722040 | 2019-05-15 16:30:41 +0530 | [diff] [blame] | 5 | #include "file_table.hpp" |
| 6 | |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 7 | #include <fcntl.h> |
| 8 | #include <sys/mman.h> |
| 9 | #include <sys/stat.h> |
| 10 | #include <sys/types.h> |
| 11 | #include <unistd.h> |
| 12 | |
| 13 | #include <cstring> |
| 14 | #include <fstream> |
| 15 | #include <phosphor-logging/log.hpp> |
| 16 | |
| 17 | #include "libpldm/base.h" |
| 18 | |
| 19 | namespace pldm |
| 20 | { |
| 21 | |
| 22 | namespace responder |
| 23 | { |
| 24 | |
| 25 | namespace fs = std::filesystem; |
| 26 | using namespace phosphor::logging; |
| 27 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 28 | namespace dma |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 29 | { |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 30 | |
| 31 | /** @struct AspeedXdmaOp |
| 32 | * |
| 33 | * Structure representing XDMA operation |
| 34 | */ |
| 35 | struct AspeedXdmaOp |
| 36 | { |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 37 | uint64_t hostAddr; //!< the DMA address on the host side, configured by |
| 38 | //!< PCI subsystem. |
| 39 | uint32_t len; //!< the size of the transfer in bytes, it should be a |
| 40 | //!< multiple of 16 bytes |
Eddie James | c6da21e | 2019-05-29 18:29:58 +0000 | [diff] [blame] | 41 | uint32_t upstream; //!< boolean indicating the direction of the DMA |
| 42 | //!< operation, true means a transfer from BMC to host. |
| 43 | }; |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 44 | |
| 45 | constexpr auto xdmaDev = "/dev/xdma"; |
| 46 | |
Tom Joseph | 5530676 | 2019-05-02 09:11:26 +0530 | [diff] [blame] | 47 | int DMA::transferDataHost(const fs::path& path, uint32_t offset, |
| 48 | uint32_t length, uint64_t address, bool upstream) |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 49 | { |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 50 | static const size_t pageSize = getpagesize(); |
| 51 | uint32_t numPages = length / pageSize; |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 52 | uint32_t pageAlignedLength = numPages * pageSize; |
| 53 | |
| 54 | if (length > pageAlignedLength) |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 55 | { |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 56 | pageAlignedLength += pageSize; |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 57 | } |
| 58 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 59 | auto mmapCleanup = [pageAlignedLength](void* vgaMem) { |
| 60 | munmap(vgaMem, pageAlignedLength); |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | int fd = -1; |
| 64 | int rc = 0; |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 65 | fd = open(xdmaDev, O_RDWR); |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 66 | if (fd < 0) |
| 67 | { |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 68 | rc = -errno; |
| 69 | log<level::ERR>("Failed to open the XDMA device", entry("RC=%d", rc)); |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 70 | return rc; |
| 71 | } |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 72 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 73 | utils::CustomFD xdmaFd(fd); |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 74 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 75 | void* vgaMem; |
| 76 | vgaMem = mmap(nullptr, pageAlignedLength, upstream ? PROT_WRITE : PROT_READ, |
| 77 | MAP_SHARED, xdmaFd(), 0); |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 78 | if (MAP_FAILED == vgaMem) |
| 79 | { |
| 80 | rc = -errno; |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 81 | log<level::ERR>("Failed to mmap the XDMA device", entry("RC=%d", rc)); |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 82 | return rc; |
| 83 | } |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 84 | |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 85 | std::unique_ptr<void, decltype(mmapCleanup)> vgaMemPtr(vgaMem, mmapCleanup); |
| 86 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 87 | if (upstream) |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 88 | { |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 89 | std::ifstream stream(path.string()); |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 90 | stream.seekg(offset); |
Tom Joseph | 9b97925 | 2019-06-19 09:59:18 +0530 | [diff] [blame^] | 91 | |
| 92 | // Writing to the VGA memory should be aligned at page boundary, |
| 93 | // otherwise write data into a buffer aligned at page boundary and |
| 94 | // then write to the VGA memory. |
| 95 | std::vector<char> buffer{}; |
| 96 | buffer.resize(pageAlignedLength); |
| 97 | stream.read(buffer.data(), length); |
| 98 | memcpy(static_cast<char*>(vgaMemPtr.get()), buffer.data(), |
| 99 | pageAlignedLength); |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 100 | |
Tom Joseph | 7a8a724 | 2019-05-29 15:26:38 +0530 | [diff] [blame] | 101 | if (static_cast<uint32_t>(stream.gcount()) != length) |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 102 | { |
| 103 | log<level::ERR>("mismatch between number of characters to read and " |
| 104 | "the length read", |
| 105 | entry("LENGTH=%d", length), |
| 106 | entry("COUNT=%d", stream.gcount())); |
| 107 | return -1; |
| 108 | } |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 109 | } |
| 110 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 111 | AspeedXdmaOp xdmaOp; |
| 112 | xdmaOp.upstream = upstream ? 1 : 0; |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 113 | xdmaOp.hostAddr = address; |
| 114 | xdmaOp.len = length; |
| 115 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 116 | rc = write(xdmaFd(), &xdmaOp, sizeof(xdmaOp)); |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 117 | if (rc < 0) |
| 118 | { |
| 119 | rc = -errno; |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 120 | log<level::ERR>("Failed to execute the DMA operation", |
| 121 | entry("RC=%d", rc), entry("UPSTREAM=%d", upstream), |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 122 | entry("ADDRESS=%lld", address), |
| 123 | entry("LENGTH=%d", length)); |
| 124 | return rc; |
| 125 | } |
| 126 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 127 | if (!upstream) |
| 128 | { |
| 129 | std::ofstream stream(path.string()); |
| 130 | |
| 131 | stream.seekp(offset); |
| 132 | stream.write(static_cast<const char*>(vgaMemPtr.get()), length); |
| 133 | } |
| 134 | |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | } // namespace dma |
| 139 | |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 140 | Response readFileIntoMemory(const uint8_t* request, size_t payloadLength) |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 141 | { |
| 142 | uint32_t fileHandle = 0; |
| 143 | uint32_t offset = 0; |
| 144 | uint32_t length = 0; |
| 145 | uint64_t address = 0; |
| 146 | |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 147 | Response response((sizeof(pldm_msg_hdr) + PLDM_RW_FILE_MEM_RESP_BYTES), 0); |
| 148 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 149 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 150 | if (payloadLength != PLDM_RW_FILE_MEM_REQ_BYTES) |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 151 | { |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 152 | encode_rw_file_memory_resp(0, PLDM_READ_FILE_INTO_MEMORY, |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 153 | PLDM_ERROR_INVALID_LENGTH, 0, responsePtr); |
| 154 | return response; |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 155 | } |
| 156 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 157 | decode_rw_file_memory_req(request, payloadLength, &fileHandle, &offset, |
| 158 | &length, &address); |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 159 | |
Tom Joseph | 0722040 | 2019-05-15 16:30:41 +0530 | [diff] [blame] | 160 | using namespace pldm::filetable; |
| 161 | auto& table = buildFileTable(FILE_TABLE_JSON); |
| 162 | FileEntry value{}; |
| 163 | |
| 164 | try |
| 165 | { |
| 166 | value = table.at(fileHandle); |
| 167 | } |
| 168 | catch (std::exception& e) |
| 169 | { |
| 170 | log<level::ERR>("File handle does not exist in the file table", |
| 171 | entry("HANDLE=%d", fileHandle)); |
| 172 | encode_rw_file_memory_resp(0, PLDM_READ_FILE_INTO_MEMORY, |
| 173 | PLDM_INVALID_FILE_HANDLE, 0, responsePtr); |
| 174 | return response; |
| 175 | } |
| 176 | |
| 177 | if (!fs::exists(value.fsPath)) |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 178 | { |
| 179 | log<level::ERR>("File does not exist", entry("HANDLE=%d", fileHandle)); |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 180 | encode_rw_file_memory_resp(0, PLDM_READ_FILE_INTO_MEMORY, |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 181 | PLDM_INVALID_FILE_HANDLE, 0, responsePtr); |
| 182 | return response; |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 183 | } |
| 184 | |
Tom Joseph | 0722040 | 2019-05-15 16:30:41 +0530 | [diff] [blame] | 185 | auto fileSize = fs::file_size(value.fsPath); |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 186 | if (offset >= fileSize) |
| 187 | { |
| 188 | log<level::ERR>("Offset exceeds file size", entry("OFFSET=%d", offset), |
| 189 | entry("FILE_SIZE=%d", fileSize)); |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 190 | encode_rw_file_memory_resp(0, PLDM_READ_FILE_INTO_MEMORY, |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 191 | PLDM_DATA_OUT_OF_RANGE, 0, responsePtr); |
| 192 | return response; |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | if (offset + length > fileSize) |
| 196 | { |
| 197 | length = fileSize - offset; |
| 198 | } |
| 199 | |
| 200 | if (length % dma::minSize) |
| 201 | { |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 202 | log<level::ERR>("Read length is not a multiple of DMA minSize", |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 203 | entry("LENGTH=%d", length)); |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 204 | encode_rw_file_memory_resp(0, PLDM_READ_FILE_INTO_MEMORY, |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 205 | PLDM_INVALID_READ_LENGTH, 0, responsePtr); |
| 206 | return response; |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 207 | } |
| 208 | |
Tom Joseph | 5530676 | 2019-05-02 09:11:26 +0530 | [diff] [blame] | 209 | using namespace dma; |
| 210 | DMA intf; |
Tom Joseph | 0722040 | 2019-05-15 16:30:41 +0530 | [diff] [blame] | 211 | return transferAll<DMA>(&intf, PLDM_READ_FILE_INTO_MEMORY, value.fsPath, |
| 212 | offset, length, address, true); |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 213 | } |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 214 | |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 215 | Response writeFileFromMemory(const uint8_t* request, size_t payloadLength) |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 216 | { |
| 217 | uint32_t fileHandle = 0; |
| 218 | uint32_t offset = 0; |
| 219 | uint32_t length = 0; |
| 220 | uint64_t address = 0; |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 221 | |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 222 | Response response(sizeof(pldm_msg_hdr) + PLDM_RW_FILE_MEM_RESP_BYTES, 0); |
| 223 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 224 | |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 225 | if (payloadLength != PLDM_RW_FILE_MEM_REQ_BYTES) |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 226 | { |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 227 | encode_rw_file_memory_resp(0, PLDM_WRITE_FILE_FROM_MEMORY, |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 228 | PLDM_ERROR_INVALID_LENGTH, 0, responsePtr); |
| 229 | return response; |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 230 | } |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 231 | |
| 232 | decode_rw_file_memory_req(request, payloadLength, &fileHandle, &offset, |
| 233 | &length, &address); |
| 234 | |
| 235 | if (length % dma::minSize) |
| 236 | { |
| 237 | log<level::ERR>("Write length is not a multiple of DMA minSize", |
| 238 | entry("LENGTH=%d", length)); |
| 239 | encode_rw_file_memory_resp(0, PLDM_WRITE_FILE_FROM_MEMORY, |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 240 | PLDM_INVALID_WRITE_LENGTH, 0, responsePtr); |
| 241 | return response; |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 242 | } |
| 243 | |
Tom Joseph | 0722040 | 2019-05-15 16:30:41 +0530 | [diff] [blame] | 244 | using namespace pldm::filetable; |
| 245 | auto& table = buildFileTable(FILE_TABLE_JSON); |
| 246 | FileEntry value{}; |
| 247 | |
| 248 | try |
| 249 | { |
| 250 | value = table.at(fileHandle); |
| 251 | } |
| 252 | catch (std::exception& e) |
| 253 | { |
| 254 | log<level::ERR>("File handle does not exist in the file table", |
| 255 | entry("HANDLE=%d", fileHandle)); |
| 256 | encode_rw_file_memory_resp(0, PLDM_WRITE_FILE_FROM_MEMORY, |
| 257 | PLDM_INVALID_FILE_HANDLE, 0, responsePtr); |
| 258 | return response; |
| 259 | } |
| 260 | |
| 261 | if (!fs::exists(value.fsPath)) |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 262 | { |
| 263 | log<level::ERR>("File does not exist", entry("HANDLE=%d", fileHandle)); |
| 264 | encode_rw_file_memory_resp(0, PLDM_WRITE_FILE_FROM_MEMORY, |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 265 | PLDM_INVALID_FILE_HANDLE, 0, responsePtr); |
| 266 | return response; |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 267 | } |
| 268 | |
Tom Joseph | 0722040 | 2019-05-15 16:30:41 +0530 | [diff] [blame] | 269 | auto fileSize = fs::file_size(value.fsPath); |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 270 | if (offset >= fileSize) |
| 271 | { |
| 272 | log<level::ERR>("Offset exceeds file size", entry("OFFSET=%d", offset), |
| 273 | entry("FILE_SIZE=%d", fileSize)); |
| 274 | encode_rw_file_memory_resp(0, PLDM_WRITE_FILE_FROM_MEMORY, |
Tom Joseph | 4e48b44 | 2019-06-04 09:23:44 +0530 | [diff] [blame] | 275 | PLDM_DATA_OUT_OF_RANGE, 0, responsePtr); |
| 276 | return response; |
Eddie James | 3b02e27 | 2019-04-22 20:13:55 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Tom Joseph | 5530676 | 2019-05-02 09:11:26 +0530 | [diff] [blame] | 279 | using namespace dma; |
| 280 | DMA intf; |
Tom Joseph | 0722040 | 2019-05-15 16:30:41 +0530 | [diff] [blame] | 281 | return transferAll<DMA>(&intf, PLDM_WRITE_FILE_FROM_MEMORY, value.fsPath, |
| 282 | offset, length, address, false); |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 283 | } |
| 284 | |
Tom Joseph | 1985662 | 2019-06-07 10:18:21 +0530 | [diff] [blame] | 285 | Response getFileTable(const uint8_t* request, size_t payloadLength) |
| 286 | { |
| 287 | uint32_t transferHandle = 0; |
| 288 | uint8_t transferFlag = 0; |
| 289 | uint8_t tableType = 0; |
| 290 | |
| 291 | Response response(sizeof(pldm_msg_hdr) + |
| 292 | PLDM_GET_FILE_TABLE_MIN_RESP_BYTES); |
| 293 | auto responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 294 | |
| 295 | if (payloadLength != PLDM_GET_FILE_TABLE_REQ_BYTES) |
| 296 | { |
| 297 | encode_get_file_table_resp(0, PLDM_ERROR_INVALID_LENGTH, 0, 0, nullptr, |
| 298 | 0, responsePtr); |
| 299 | return response; |
| 300 | } |
| 301 | |
| 302 | auto rc = decode_get_file_table_req(request, payloadLength, &transferHandle, |
| 303 | &transferFlag, &tableType); |
| 304 | if (rc) |
| 305 | { |
| 306 | encode_get_file_table_resp(0, rc, 0, 0, nullptr, 0, responsePtr); |
| 307 | return response; |
| 308 | } |
| 309 | |
| 310 | if (tableType != PLDM_FILE_ATTRIBUTE_TABLE) |
| 311 | { |
| 312 | encode_get_file_table_resp(0, PLDM_INVALID_FILE_TABLE_TYPE, 0, 0, |
| 313 | nullptr, 0, responsePtr); |
| 314 | return response; |
| 315 | } |
| 316 | |
| 317 | using namespace pldm::filetable; |
| 318 | auto table = buildFileTable(FILE_TABLE_JSON); |
| 319 | auto attrTable = table(); |
| 320 | response.resize(response.size() + attrTable.size()); |
| 321 | responsePtr = reinterpret_cast<pldm_msg*>(response.data()); |
| 322 | |
| 323 | if (attrTable.empty()) |
| 324 | { |
| 325 | encode_get_file_table_resp(0, PLDM_FILE_TABLE_UNAVAILABLE, 0, 0, |
| 326 | nullptr, 0, responsePtr); |
| 327 | return response; |
| 328 | } |
| 329 | |
| 330 | encode_get_file_table_resp(0, PLDM_SUCCESS, 0, PLDM_START_AND_END, |
| 331 | attrTable.data(), attrTable.size(), responsePtr); |
| 332 | return response; |
| 333 | } |
| 334 | |
Tom Joseph | f8329ac | 2019-04-11 22:13:22 +0530 | [diff] [blame] | 335 | } // namespace responder |
| 336 | } // namespace pldm |