Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "libpldm/platform.h" |
| 4 | |
| 5 | #include "pldmd/dbus_impl_requester.hpp" |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 6 | #include "requester/handler.hpp" |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 7 | |
| 8 | #include <filesystem> |
| 9 | #include <fstream> |
| 10 | #include <map> |
| 11 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 12 | namespace pldm |
| 13 | { |
| 14 | namespace requester |
| 15 | { |
| 16 | namespace oem_ibm |
| 17 | { |
| 18 | |
| 19 | /** @class DbusToFileHandler |
| 20 | * @brief This class can process resource dump parameters and send PLDM |
| 21 | * new file available cmd to the hypervisor. This class can be used |
| 22 | * as a pldm requester in oem-ibm path. |
| 23 | */ |
| 24 | class DbusToFileHandler |
| 25 | { |
| 26 | public: |
| 27 | DbusToFileHandler(const DbusToFileHandler&) = delete; |
| 28 | DbusToFileHandler(DbusToFileHandler&&) = delete; |
| 29 | DbusToFileHandler& operator=(const DbusToFileHandler&) = delete; |
| 30 | DbusToFileHandler& operator=(DbusToFileHandler&&) = delete; |
| 31 | ~DbusToFileHandler() = default; |
| 32 | |
| 33 | /** @brief Constructor |
| 34 | * @param[in] mctp_fd - fd of MCTP communications socket |
| 35 | * @param[in] mctp_eid - MCTP EID of host firmware |
| 36 | * @param[in] requester - pointer to a Requester object |
| 37 | * @param[in] resDumpCurrentObjPath - resource dump current object path |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 38 | * @param[in] handler - PLDM request handler |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 39 | */ |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 40 | DbusToFileHandler( |
| 41 | int mctp_fd, uint8_t mctp_eid, dbus_api::Requester* requester, |
| 42 | sdbusplus::message::object_path resDumpCurrentObjPath, |
| 43 | pldm::requester::Handler<pldm::requester::Request>* handler); |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 44 | |
| 45 | /** @brief Process the new resource dump request |
| 46 | * @param[in] vspString - vsp string |
| 47 | * @param[in] resDumpReqPass - resource dump password |
| 48 | */ |
| 49 | void processNewResourceDump(const std::string& vspString, |
| 50 | const std::string& resDumpReqPass); |
| 51 | |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 52 | /** @brief Process the new CSR file available |
| 53 | * @param[in] csr - CSR string |
| 54 | * @param[in] fileHandle - file Handle for new file request |
| 55 | */ |
| 56 | void newCsrFileAvailable(const std::string& csr, |
| 57 | const std::string fileHandle); |
| 58 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 59 | private: |
| 60 | /** @brief Send the new file available command request to hypervisor |
| 61 | * @param[in] fileSize - size of the file |
| 62 | */ |
| 63 | void sendNewFileAvailableCmd(uint64_t fileSize); |
| 64 | |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 65 | /** @brief Send the new file available command request to hypervisor |
| 66 | * @param[in] fileSize - size of the file |
| 67 | * @param[in] fileHandle - file handle |
| 68 | * @param[in] type - file type |
| 69 | */ |
| 70 | void newFileAvailableSendToHost(const uint32_t fileSize, |
| 71 | const uint32_t fileHandle, |
| 72 | const uint16_t type); |
| 73 | |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 74 | /** @brief report failure that a resource dump has failed |
| 75 | */ |
| 76 | void reportResourceDumpFailure(); |
| 77 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 78 | /** @brief fd of MCTP communications socket */ |
| 79 | int mctp_fd; |
| 80 | |
| 81 | /** @brief MCTP EID of host firmware */ |
| 82 | uint8_t mctp_eid; |
| 83 | |
| 84 | /** @brief Pointer to a Requester object, primarily used to access API to |
| 85 | * obtain PLDM instance id. |
| 86 | */ |
| 87 | dbus_api::Requester* requester; |
| 88 | |
| 89 | /** @brief Hold the current resource dump object path */ |
| 90 | sdbusplus::message::object_path resDumpCurrentObjPath; |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 91 | |
| 92 | /** @brief PLDM request handler */ |
| 93 | pldm::requester::Handler<pldm::requester::Request>* handler; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | } // namespace oem_ibm |
| 97 | } // namespace requester |
| 98 | } // namespace pldm |