xref: /openbmc/phosphor-debug-collector/dump-extensions/openpower-dumps/system_dump_entry.hpp (revision 05ef81639c1fb7fc2fc78b29ca7e7486a86ddfb2)
18b9b4690SDhruvaraj Subhashchandran #pragma once
28b9b4690SDhruvaraj Subhashchandran 
38b9b4690SDhruvaraj Subhashchandran #include "dump_entry.hpp"
48b9b4690SDhruvaraj Subhashchandran #include "xyz/openbmc_project/Dump/Entry/System/server.hpp"
58b9b4690SDhruvaraj Subhashchandran 
68b9b4690SDhruvaraj Subhashchandran #include <sdbusplus/bus.hpp>
78b9b4690SDhruvaraj Subhashchandran #include <sdbusplus/server/object.hpp>
88b9b4690SDhruvaraj Subhashchandran 
9341d683dSDhruvaraj Subhashchandran namespace openpower
108b9b4690SDhruvaraj Subhashchandran {
118b9b4690SDhruvaraj Subhashchandran namespace dump
128b9b4690SDhruvaraj Subhashchandran {
138b9b4690SDhruvaraj Subhashchandran namespace system
148b9b4690SDhruvaraj Subhashchandran {
158b9b4690SDhruvaraj Subhashchandran template <typename T>
169b18bf2dSPatrick Williams using ServerObject = typename sdbusplus::server::object_t<T>;
178b9b4690SDhruvaraj Subhashchandran 
189b18bf2dSPatrick Williams using EntryIfaces = sdbusplus::server::object_t<
198b9b4690SDhruvaraj Subhashchandran     sdbusplus::xyz::openbmc_project::Dump::Entry::server::System>;
208b9b4690SDhruvaraj Subhashchandran 
2174a1f39cSAsmitha Karunanithi using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
2274a1f39cSAsmitha Karunanithi     OriginatedBy::OriginatorTypes;
2374a1f39cSAsmitha Karunanithi 
248b9b4690SDhruvaraj Subhashchandran class Manager;
258b9b4690SDhruvaraj Subhashchandran 
268b9b4690SDhruvaraj Subhashchandran /** @class Entry
278b9b4690SDhruvaraj Subhashchandran  *  @brief System Dump Entry implementation.
288b9b4690SDhruvaraj Subhashchandran  *  @details A concrete implementation for the
298b9b4690SDhruvaraj Subhashchandran  *  xyz.openbmc_project.Dump.Entry DBus API
308b9b4690SDhruvaraj Subhashchandran  */
31*05ef8163SLei YU class Entry : virtual public phosphor::dump::Entry, virtual public EntryIfaces
328b9b4690SDhruvaraj Subhashchandran {
338b9b4690SDhruvaraj Subhashchandran   public:
348b9b4690SDhruvaraj Subhashchandran     Entry() = delete;
358b9b4690SDhruvaraj Subhashchandran     Entry(const Entry&) = delete;
368b9b4690SDhruvaraj Subhashchandran     Entry& operator=(const Entry&) = delete;
378b9b4690SDhruvaraj Subhashchandran     Entry(Entry&&) = delete;
388b9b4690SDhruvaraj Subhashchandran     Entry& operator=(Entry&&) = delete;
398b9b4690SDhruvaraj Subhashchandran     ~Entry() = default;
408b9b4690SDhruvaraj Subhashchandran 
418b9b4690SDhruvaraj Subhashchandran     /** @brief Constructor for the Dump Entry Object
428b9b4690SDhruvaraj Subhashchandran      *  @param[in] bus - Bus to attach to.
438b9b4690SDhruvaraj Subhashchandran      *  @param[in] objPath - Object path to attach to
448b9b4690SDhruvaraj Subhashchandran      *  @param[in] dumpId - Dump id.
458b9b4690SDhruvaraj Subhashchandran      *  @param[in] timeStamp - Dump creation timestamp
468b9b4690SDhruvaraj Subhashchandran      *             since the epoch.
478b9b4690SDhruvaraj Subhashchandran      *  @param[in] dumpSize - Dump size in bytes.
48a6ab806dSDhruvaraj Subhashchandran      *  @param[in] sourceId - DumpId provided by the source.
49a6ab806dSDhruvaraj Subhashchandran      *  @param[in] status - status  of the dump.
5074a1f39cSAsmitha Karunanithi      *  @param[in] originatorId - Id of the originator of the dump
5174a1f39cSAsmitha Karunanithi      *  @param[in] originatorType - Originator type
528b9b4690SDhruvaraj Subhashchandran      *  @param[in] parent - The dump entry's parent.
538b9b4690SDhruvaraj Subhashchandran      */
Entry(sdbusplus::bus_t & bus,const std::string & objPath,uint32_t dumpId,uint64_t timeStamp,uint64_t dumpSize,const uint32_t sourceId,phosphor::dump::OperationStatus status,std::string originatorId,originatorTypes originatorType,phosphor::dump::Manager & parent)549b18bf2dSPatrick Williams     Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
558b9b4690SDhruvaraj Subhashchandran           uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
5674a1f39cSAsmitha Karunanithi           phosphor::dump::OperationStatus status, std::string originatorId,
5774a1f39cSAsmitha Karunanithi           originatorTypes originatorType, phosphor::dump::Manager& parent) :
588b9b4690SDhruvaraj Subhashchandran         phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
5964f8da9eSDhruvaraj Subhashchandran                               std::string(), status, originatorId,
60*05ef8163SLei YU                               originatorType, parent),
61*05ef8163SLei YU         EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit)
628b9b4690SDhruvaraj Subhashchandran     {
638b9b4690SDhruvaraj Subhashchandran         sourceDumpId(sourceId);
642f8e276cSDhruvaraj Subhashchandran         // Emit deferred signal.
652f8e276cSDhruvaraj Subhashchandran         this->openpower::dump::system::EntryIfaces::emit_object_added();
668b9b4690SDhruvaraj Subhashchandran     };
678b9b4690SDhruvaraj Subhashchandran 
688b9b4690SDhruvaraj Subhashchandran     /** @brief Method to initiate the offload of dump
698b9b4690SDhruvaraj Subhashchandran      *  @param[in] uri - URI to offload dump.
708b9b4690SDhruvaraj Subhashchandran      */
712f8e276cSDhruvaraj Subhashchandran     void initiateOffload(std::string uri) override;
726ccb50e1SDhruvaraj Subhashchandran 
736ccb50e1SDhruvaraj Subhashchandran     /** @brief Method to update an existing dump entry
746ccb50e1SDhruvaraj Subhashchandran      *  @param[in] timeStamp - Dump creation timestamp
756ccb50e1SDhruvaraj Subhashchandran      *  @param[in] dumpSize - Dump size in bytes.
766ccb50e1SDhruvaraj Subhashchandran      *  @param[in] sourceId - DumpId provided by the source.
776ccb50e1SDhruvaraj Subhashchandran      */
update(uint64_t timeStamp,uint64_t dumpSize,const uint32_t sourceId)786ccb50e1SDhruvaraj Subhashchandran     void update(uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId)
796ccb50e1SDhruvaraj Subhashchandran     {
806ccb50e1SDhruvaraj Subhashchandran         elapsed(timeStamp);
816ccb50e1SDhruvaraj Subhashchandran         size(dumpSize);
826ccb50e1SDhruvaraj Subhashchandran         sourceDumpId(sourceId);
83a6ab806dSDhruvaraj Subhashchandran         // TODO: Handled dump failure case with
84a6ab806dSDhruvaraj Subhashchandran         // #bm-openbmc/2808
85a6ab806dSDhruvaraj Subhashchandran         status(OperationStatus::Completed);
86a6ab806dSDhruvaraj Subhashchandran         completedTime(timeStamp);
876ccb50e1SDhruvaraj Subhashchandran     }
882279386bSRamesh Iyyar 
892279386bSRamesh Iyyar     /**
902279386bSRamesh Iyyar      * @brief Delete host system dump and it entry dbus object
912279386bSRamesh Iyyar      */
922279386bSRamesh Iyyar     void delete_() override;
938b9b4690SDhruvaraj Subhashchandran };
948b9b4690SDhruvaraj Subhashchandran 
958b9b4690SDhruvaraj Subhashchandran } // namespace system
968b9b4690SDhruvaraj Subhashchandran } // namespace dump
97341d683dSDhruvaraj Subhashchandran } // namespace openpower
98