xref: /openbmc/phosphor-debug-collector/dump-extensions/openpower-dumps/resource_dump_entry.hpp (revision 3b44559f8792611772b9838178e8f8acb127eee8)
1 #pragma once
2 
3 #include "com/ibm/Dump/Entry/Resource/server.hpp"
4 #include "dump_entry.hpp"
5 #include "dump_manager_resource.hpp"
6 
7 #include <sdbusplus/bus.hpp>
8 #include <sdbusplus/server/object.hpp>
9 
10 #include <chrono>
11 
12 namespace openpower
13 {
14 namespace dump
15 {
16 namespace resource
17 {
18 template <typename T>
19 using ServerObject = typename sdbusplus::server::object_t<T>;
20 
21 using EntryIfaces = sdbusplus::server::object_t<
22     sdbusplus::com::ibm::Dump::Entry::server::Resource>;
23 
24 using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
25     OriginatedBy::OriginatorTypes;
26 
27 class 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  */
35 class Entry : virtual public phosphor::dump::Entry, virtual public EntryIfaces
36 {
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.
53      *  @param[in] vspStr- Input to host to generate the resource dump.
54      *  @param[in] usrChallenge - User Challenge needed by host to validate the
55      *             request.
56      *  @param[in] status - status  of the dump.
57      *  @param[in] originatorId - Id of the originator of the dump
58      *  @param[in] originatorType - Originator type
59      *  @param[in] parent - The dump entry's parent.
60      */
Entry(sdbusplus::bus_t & bus,const std::string & objPath,uint32_t dumpId,uint64_t timeStamp,uint64_t dumpSize,const uint32_t sourceId,std::string vspStr,std::string usrChallenge,phosphor::dump::OperationStatus status,std::string originatorId,originatorTypes originatorType,phosphor::dump::Manager & parent)61     Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
62           uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
63           std::string vspStr, std::string usrChallenge,
64           phosphor::dump::OperationStatus status, std::string originatorId,
65           originatorTypes originatorType, phosphor::dump::Manager& parent) :
66         phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
67                               std::string(), status, originatorId,
68                               originatorType, parent),
69         EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit)
70     {
71         sourceDumpId(sourceId);
72         vspString(vspStr);
73         userChallenge(usrChallenge);
74         // Emit deferred signal.
75         this->openpower::dump::resource::EntryIfaces::emit_object_added();
76     };
77 
78     /** @brief Method to initiate the offload of dump
79      *  @param[in] uri - URI to offload dump.
80      */
81     void initiateOffload(std::string uri) override;
82 
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      */
update(uint64_t timeStamp,uint64_t dumpSize,uint32_t sourceId)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     }
98 
99     /**
100      * @brief Delete resource dump in host memory and the entry dbus object
101      */
102     void delete_() override;
103 };
104 
105 } // namespace resource
106 } // namespace dump
107 } // namespace openpower
108