Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Andrew Jeffery | 2abbce7 | 2023-10-18 10:17:35 +1030 | [diff] [blame] | 3 | #include "common/instance_id.hpp" |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 4 | #include "requester/handler.hpp" |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 5 | |
George Liu | c453e16 | 2022-12-21 17:16:23 +0800 | [diff] [blame] | 6 | #include <libpldm/platform.h> |
| 7 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 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 | { |
Jayashankar Padath | 99fa186 | 2021-11-10 09:45:06 -0600 | [diff] [blame] | 18 | using ResDumpStatus = std::string; |
| 19 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 20 | /** @class DbusToFileHandler |
| 21 | * @brief This class can process resource dump parameters and send PLDM |
| 22 | * new file available cmd to the hypervisor. This class can be used |
| 23 | * as a pldm requester in oem-ibm path. |
| 24 | */ |
| 25 | class DbusToFileHandler |
| 26 | { |
| 27 | public: |
| 28 | DbusToFileHandler(const DbusToFileHandler&) = delete; |
| 29 | DbusToFileHandler(DbusToFileHandler&&) = delete; |
| 30 | DbusToFileHandler& operator=(const DbusToFileHandler&) = delete; |
| 31 | DbusToFileHandler& operator=(DbusToFileHandler&&) = delete; |
| 32 | ~DbusToFileHandler() = default; |
| 33 | |
| 34 | /** @brief Constructor |
| 35 | * @param[in] mctp_fd - fd of MCTP communications socket |
| 36 | * @param[in] mctp_eid - MCTP EID of host firmware |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 37 | * @param[in] instanceIdDb - pointer to a InstanceIdDb object |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 38 | * @param[in] resDumpCurrentObjPath - resource dump current object path |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 39 | * @param[in] handler - PLDM request handler |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 40 | */ |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 41 | DbusToFileHandler( |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 42 | int mctp_fd, uint8_t mctp_eid, pldm::InstanceIdDb* instanceIdDb, |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 43 | sdbusplus::message::object_path resDumpCurrentObjPath, |
| 44 | pldm::requester::Handler<pldm::requester::Request>* handler); |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 45 | |
| 46 | /** @brief Process the new resource dump request |
| 47 | * @param[in] vspString - vsp string |
| 48 | * @param[in] resDumpReqPass - resource dump password |
| 49 | */ |
| 50 | void processNewResourceDump(const std::string& vspString, |
| 51 | const std::string& resDumpReqPass); |
| 52 | |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 53 | /** @brief Process the new CSR file available |
| 54 | * @param[in] csr - CSR string |
| 55 | * @param[in] fileHandle - file Handle for new file request |
| 56 | */ |
| 57 | void newCsrFileAvailable(const std::string& csr, |
| 58 | const std::string fileHandle); |
| 59 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 60 | private: |
| 61 | /** @brief Send the new file available command request to hypervisor |
| 62 | * @param[in] fileSize - size of the file |
| 63 | */ |
| 64 | void sendNewFileAvailableCmd(uint64_t fileSize); |
| 65 | |
Varsha Kaverappa | 219ace9 | 2021-04-01 02:50:11 -0500 | [diff] [blame] | 66 | /** @brief Send the new file available command request to hypervisor |
| 67 | * @param[in] fileSize - size of the file |
| 68 | * @param[in] fileHandle - file handle |
| 69 | * @param[in] type - file type |
| 70 | */ |
| 71 | void newFileAvailableSendToHost(const uint32_t fileSize, |
| 72 | const uint32_t fileHandle, |
| 73 | const uint16_t type); |
| 74 | |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 75 | /** @brief report failure that a resource dump has failed |
Riya Dixit | 4f7eec8 | 2024-08-01 15:07:53 -0500 | [diff] [blame] | 76 | * @param[in] str - Resource dump failure type |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 77 | */ |
Riya Dixit | 4f7eec8 | 2024-08-01 15:07:53 -0500 | [diff] [blame] | 78 | void reportResourceDumpFailure(const std::string_view& str); |
Sampa Misra | c0c7948 | 2021-06-02 08:01:54 -0500 | [diff] [blame] | 79 | |
Pavithra Barithaya | c047f80 | 2021-11-30 01:55:03 -0600 | [diff] [blame] | 80 | /** @brief method to get the acf file contents */ |
| 81 | std::string getAcfFileContent(); |
| 82 | |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 83 | /** @brief MCTP EID of host firmware */ |
| 84 | uint8_t mctp_eid; |
| 85 | |
Andrew Jeffery | a330b2f | 2023-05-04 14:55:37 +0930 | [diff] [blame] | 86 | /** @brief Pointer to an InstanceIdDb used to obtain PLDM instance id. */ |
| 87 | pldm::InstanceIdDb* instanceIdDb; |
Jayashankar Padath | db12436 | 2021-01-28 21:12:34 -0600 | [diff] [blame] | 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 |