blob: 9515dc24e80bbc836d659e78c9f9884d94680a43 [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"
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -05005#include "xyz/openbmc_project/Common/OriginatedBy/server.hpp"
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -06006
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -06007#include <sdbusplus/bus.hpp>
8#include <sdbusplus/server/object.hpp>
9
Jayanth Othayoth0af74a52021-04-08 03:55:21 -050010#include <chrono>
11
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060012namespace openpower
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060013{
14namespace dump
15{
16namespace resource
17{
18template <typename T>
Patrick Williams9b18bf22022-07-22 19:26:55 -050019using ServerObject = typename sdbusplus::server::object_t<T>;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060020
Patrick Williams9b18bf22022-07-22 19:26:55 -050021using EntryIfaces = sdbusplus::server::object_t<
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050022 sdbusplus::xyz::openbmc_project::Common::server::OriginatedBy,
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060023 sdbusplus::com::ibm::Dump::Entry::server::Resource>;
24
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050025using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
26 OriginatedBy::OriginatorTypes;
27
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060028class Manager;
29
30/** @class Entry
31 * @brief Resource Dump Entry implementation.
32 * @details An extension to Dump::Entry class and
33 * A concrete implementation for the
34 * com::ibm::Dump::Entry::Resource DBus API
35 */
36class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
37{
38 public:
39 Entry() = delete;
40 Entry(const Entry&) = delete;
41 Entry& operator=(const Entry&) = delete;
42 Entry(Entry&&) = delete;
43 Entry& operator=(Entry&&) = delete;
44 ~Entry() = default;
45
46 /** @brief Constructor for the resource dump Entry Object
47 * @param[in] bus - Bus to attach to.
48 * @param[in] objPath - Object path to attach to
49 * @param[in] dumpId - Dump id.
50 * @param[in] timeStamp - Dump creation timestamp
51 * since the epoch.
52 * @param[in] dumpSize - Dump size in bytes.
53 * @param[in] sourceId - DumpId provided by the source.
Patrick Williams4bc1c2b2021-05-10 14:22:18 -050054 * @param[in] vspStr- Input to host to generate the resource dump.
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060055 * @param[in] pwd - Password needed by host to validate the request.
56 * @param[in] status - status of the dump.
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050057 * @param[in] originatorId - Id of the originator of the dump
58 * @param[in] originatorType - Originator type
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060059 * @param[in] parent - The dump entry's parent.
60 */
Patrick Williams9b18bf22022-07-22 19:26:55 -050061 Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060062 uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
Patrick Williams4bc1c2b2021-05-10 14:22:18 -050063 std::string vspStr, std::string pwd,
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050064 phosphor::dump::OperationStatus status, std::string originatorId,
65 originatorTypes originatorType, phosphor::dump::Manager& parent) :
Patrick Williams73f64072022-04-01 17:04:47 -050066 EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit),
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060067 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050068 status, originatorId, originatorType, parent)
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060069 {
70 sourceDumpId(sourceId);
Patrick Williams4bc1c2b2021-05-10 14:22:18 -050071 vspString(vspStr);
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060072 password(pwd);
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060073 // Emit deferred signal.
74 this->openpower::dump::resource::EntryIfaces::emit_object_added();
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060075 };
76
77 /** @brief Method to initiate the offload of dump
78 * @param[in] uri - URI to offload dump.
79 */
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060080 void initiateOffload(std::string uri) override;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060081
82 /** @brief Method to update an existing dump entry
83 * @param[in] timeStamp - Dump creation timestamp
84 * @param[in] dumpSize - Dump size in bytes.
85 * @param[in] sourceId - The id of dump in the origin.
86 */
87 void update(uint64_t timeStamp, uint64_t dumpSize, uint32_t sourceId)
88 {
89 sourceDumpId(sourceId);
90 elapsed(timeStamp);
91 size(dumpSize);
92 // TODO: Handled dump failure case with
93 // #bm-openbmc/2808
94 status(OperationStatus::Completed);
95 completedTime(timeStamp);
96 }
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060097
98 /**
99 * @brief Delete resource dump in host memory and the entry dbus object
100 */
101 void delete_() override;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -0600102};
103
104} // namespace resource
105} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -0600106} // namespace openpower