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