blob: dbf3406a766c764b7028832b9062daa09c012609 [file] [log] [blame]
Jayashankar Padathdb124362021-01-28 21:12:34 -06001#pragma once
2
Andrew Jeffery2abbce72023-10-18 10:17:35 +10303#include "common/instance_id.hpp"
Sampa Misrac0c79482021-06-02 08:01:54 -05004#include "requester/handler.hpp"
Jayashankar Padathdb124362021-01-28 21:12:34 -06005
George Liuc453e162022-12-21 17:16:23 +08006#include <libpldm/platform.h>
7
Jayashankar Padathdb124362021-01-28 21:12:34 -06008#include <filesystem>
9#include <fstream>
10#include <map>
11
Jayashankar Padathdb124362021-01-28 21:12:34 -060012namespace pldm
13{
14namespace requester
15{
16namespace oem_ibm
17{
Jayashankar Padath99fa1862021-11-10 09:45:06 -060018using ResDumpStatus = std::string;
19
Jayashankar Padathdb124362021-01-28 21:12:34 -060020/** @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 */
25class 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 Jefferya330b2f2023-05-04 14:55:37 +093037 * @param[in] instanceIdDb - pointer to a InstanceIdDb object
Jayashankar Padathdb124362021-01-28 21:12:34 -060038 * @param[in] resDumpCurrentObjPath - resource dump current object path
Sampa Misrac0c79482021-06-02 08:01:54 -050039 * @param[in] handler - PLDM request handler
Jayashankar Padathdb124362021-01-28 21:12:34 -060040 */
Sampa Misrac0c79482021-06-02 08:01:54 -050041 DbusToFileHandler(
Andrew Jefferya330b2f2023-05-04 14:55:37 +093042 int mctp_fd, uint8_t mctp_eid, pldm::InstanceIdDb* instanceIdDb,
Sampa Misrac0c79482021-06-02 08:01:54 -050043 sdbusplus::message::object_path resDumpCurrentObjPath,
44 pldm::requester::Handler<pldm::requester::Request>* handler);
Jayashankar Padathdb124362021-01-28 21:12:34 -060045
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 Kaverappa219ace92021-04-01 02:50:11 -050053 /** @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 Padathdb124362021-01-28 21:12:34 -060060 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 Kaverappa219ace92021-04-01 02:50:11 -050066 /** @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 Misrac0c79482021-06-02 08:01:54 -050075 /** @brief report failure that a resource dump has failed
76 */
77 void reportResourceDumpFailure();
78
Pavithra Barithayac047f802021-11-30 01:55:03 -060079 /** @brief method to get the acf file contents */
80 std::string getAcfFileContent();
81
Jayashankar Padathdb124362021-01-28 21:12:34 -060082 /** @brief fd of MCTP communications socket */
83 int mctp_fd;
84
85 /** @brief MCTP EID of host firmware */
86 uint8_t mctp_eid;
87
Andrew Jefferya330b2f2023-05-04 14:55:37 +093088 /** @brief Pointer to an InstanceIdDb used to obtain PLDM instance id. */
89 pldm::InstanceIdDb* instanceIdDb;
Jayashankar Padathdb124362021-01-28 21:12:34 -060090
91 /** @brief Hold the current resource dump object path */
92 sdbusplus::message::object_path resDumpCurrentObjPath;
Sampa Misrac0c79482021-06-02 08:01:54 -050093
94 /** @brief PLDM request handler */
95 pldm::requester::Handler<pldm::requester::Request>* handler;
Jayashankar Padathdb124362021-01-28 21:12:34 -060096};
97
98} // namespace oem_ibm
99} // namespace requester
100} // namespace pldm