blob: f9138327532b4490990628877a649663f1eb1522 [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"
Jayanth Othayoth3b445592025-02-06 08:29:49 -06005#include "dump_manager_resource.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<
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060022 sdbusplus::com::ibm::Dump::Entry::server::Resource>;
23
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050024using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
25 OriginatedBy::OriginatorTypes;
26
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060027class Manager;
28
29/** @class Entry
30 * @brief Resource Dump Entry implementation.
31 * @details An extension to Dump::Entry class and
32 * A concrete implementation for the
33 * com::ibm::Dump::Entry::Resource DBus API
34 */
Lei YU05ef8162022-11-23 13:49:53 +080035class Entry : virtual public phosphor::dump::Entry, virtual public EntryIfaces
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060036{
37 public:
38 Entry() = delete;
39 Entry(const Entry&) = delete;
40 Entry& operator=(const Entry&) = delete;
41 Entry(Entry&&) = delete;
42 Entry& operator=(Entry&&) = delete;
43 ~Entry() = default;
44
45 /** @brief Constructor for the resource dump Entry Object
46 * @param[in] bus - Bus to attach to.
47 * @param[in] objPath - Object path to attach to
48 * @param[in] dumpId - Dump id.
49 * @param[in] timeStamp - Dump creation timestamp
50 * since the epoch.
51 * @param[in] dumpSize - Dump size in bytes.
52 * @param[in] sourceId - DumpId provided by the source.
Patrick Williams4bc1c2b2021-05-10 14:22:18 -050053 * @param[in] vspStr- Input to host to generate the resource dump.
Dhruvaraj Subhashchandran8f3f94d2024-05-09 14:47:54 -050054 * @param[in] usrChallenge - User Challenge needed by host to validate the
55 * request.
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060056 * @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,
Dhruvaraj Subhashchandran8f3f94d2024-05-09 14:47:54 -050063 std::string vspStr, std::string usrChallenge,
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050064 phosphor::dump::OperationStatus status, std::string originatorId,
65 originatorTypes originatorType, phosphor::dump::Manager& parent) :
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060066 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
Dhruvaraj Subhashchandran64f8da92021-12-08 03:48:23 -060067 std::string(), status, originatorId,
Lei YU05ef8162022-11-23 13:49:53 +080068 originatorType, parent),
69 EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit)
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060070 {
71 sourceDumpId(sourceId);
Patrick Williams4bc1c2b2021-05-10 14:22:18 -050072 vspString(vspStr);
Dhruvaraj Subhashchandran8f3f94d2024-05-09 14:47:54 -050073 userChallenge(usrChallenge);
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060074 // Emit deferred signal.
75 this->openpower::dump::resource::EntryIfaces::emit_object_added();
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060076 };
77
78 /** @brief Method to initiate the offload of dump
79 * @param[in] uri - URI to offload dump.
80 */
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060081 void initiateOffload(std::string uri) override;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060082
83 /** @brief Method to update an existing dump entry
84 * @param[in] timeStamp - Dump creation timestamp
85 * @param[in] dumpSize - Dump size in bytes.
86 * @param[in] sourceId - The id of dump in the origin.
87 */
88 void update(uint64_t timeStamp, uint64_t dumpSize, uint32_t sourceId)
89 {
90 sourceDumpId(sourceId);
91 elapsed(timeStamp);
92 size(dumpSize);
93 // TODO: Handled dump failure case with
94 // #bm-openbmc/2808
95 status(OperationStatus::Completed);
96 completedTime(timeStamp);
97 }
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060098
99 /**
100 * @brief Delete resource dump in host memory and the entry dbus object
101 */
102 void delete_() override;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -0600103};
104
105} // namespace resource
106} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -0600107} // namespace openpower