blob: 03383996280bdbc3a43bb88fbcf379d712c392b2 [file] [log] [blame]
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -06001#pragma once
2
3#include "com/ibm/Dump/Entry/Resource/server.hpp"
4#include "dump_entry.hpp"
5
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -06006#include <sdbusplus/bus.hpp>
7#include <sdbusplus/server/object.hpp>
8
Jayanth Othayoth0af74a52021-04-08 03:55:21 -05009#include <chrono>
10
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060011namespace openpower
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060012{
13namespace dump
14{
15namespace resource
16{
17template <typename T>
Patrick Williams9b18bf22022-07-22 19:26:55 -050018using ServerObject = typename sdbusplus::server::object_t<T>;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060019
Patrick Williams9b18bf22022-07-22 19:26:55 -050020using EntryIfaces = sdbusplus::server::object_t<
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060021 sdbusplus::com::ibm::Dump::Entry::server::Resource>;
22
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050023using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
24 OriginatedBy::OriginatorTypes;
25
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060026class Manager;
27
28/** @class Entry
29 * @brief Resource Dump Entry implementation.
30 * @details An extension to Dump::Entry class and
31 * A concrete implementation for the
32 * com::ibm::Dump::Entry::Resource DBus API
33 */
34class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
35{
36 public:
37 Entry() = delete;
38 Entry(const Entry&) = delete;
39 Entry& operator=(const Entry&) = delete;
40 Entry(Entry&&) = delete;
41 Entry& operator=(Entry&&) = delete;
42 ~Entry() = default;
43
44 /** @brief Constructor for the resource dump Entry Object
45 * @param[in] bus - Bus to attach to.
46 * @param[in] objPath - Object path to attach to
47 * @param[in] dumpId - Dump id.
48 * @param[in] timeStamp - Dump creation timestamp
49 * since the epoch.
50 * @param[in] dumpSize - Dump size in bytes.
51 * @param[in] sourceId - DumpId provided by the source.
Patrick Williams4bc1c2b2021-05-10 14:22:18 -050052 * @param[in] vspStr- Input to host to generate the resource dump.
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060053 * @param[in] pwd - Password needed by host to validate the request.
54 * @param[in] status - status of the dump.
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050055 * @param[in] originatorId - Id of the originator of the dump
56 * @param[in] originatorType - Originator type
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060057 * @param[in] parent - The dump entry's parent.
58 */
Patrick Williams9b18bf22022-07-22 19:26:55 -050059 Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060060 uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
Patrick Williams4bc1c2b2021-05-10 14:22:18 -050061 std::string vspStr, std::string pwd,
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050062 phosphor::dump::OperationStatus status, std::string originatorId,
63 originatorTypes originatorType, phosphor::dump::Manager& parent) :
Patrick Williams73f64072022-04-01 17:04:47 -050064 EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit),
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060065 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050066 status, originatorId, originatorType, parent)
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060067 {
68 sourceDumpId(sourceId);
Patrick Williams4bc1c2b2021-05-10 14:22:18 -050069 vspString(vspStr);
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060070 password(pwd);
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060071 // Emit deferred signal.
72 this->openpower::dump::resource::EntryIfaces::emit_object_added();
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060073 };
74
75 /** @brief Method to initiate the offload of dump
76 * @param[in] uri - URI to offload dump.
77 */
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060078 void initiateOffload(std::string uri) override;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060079
80 /** @brief Method to update an existing dump entry
81 * @param[in] timeStamp - Dump creation timestamp
82 * @param[in] dumpSize - Dump size in bytes.
83 * @param[in] sourceId - The id of dump in the origin.
84 */
85 void update(uint64_t timeStamp, uint64_t dumpSize, uint32_t sourceId)
86 {
87 sourceDumpId(sourceId);
88 elapsed(timeStamp);
89 size(dumpSize);
90 // TODO: Handled dump failure case with
91 // #bm-openbmc/2808
92 status(OperationStatus::Completed);
93 completedTime(timeStamp);
94 }
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060095
96 /**
97 * @brief Delete resource dump in host memory and the entry dbus object
98 */
99 void delete_() override;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -0600100};
101
102} // namespace resource
103} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -0600104} // namespace openpower