Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Dhruvaraj Subhashchandran | a6ab806 | 2020-10-29 15:29:10 -0500 | [diff] [blame] | 3 | #include "xyz/openbmc_project/Common/Progress/server.hpp" |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 4 | #include "xyz/openbmc_project/Dump/Entry/server.hpp" |
| 5 | #include "xyz/openbmc_project/Object/Delete/server.hpp" |
| 6 | #include "xyz/openbmc_project/Time/EpochTime/server.hpp" |
| 7 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 8 | #include <sdbusplus/bus.hpp> |
| 9 | #include <sdbusplus/server/object.hpp> |
| 10 | |
Jayanth Othayoth | 0af74a5 | 2021-04-08 03:55:21 -0500 | [diff] [blame] | 11 | #include <filesystem> |
| 12 | |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 13 | namespace phosphor |
| 14 | { |
| 15 | namespace dump |
| 16 | { |
| 17 | |
| 18 | template <typename T> |
| 19 | using ServerObject = typename sdbusplus::server::object::object<T>; |
| 20 | |
Dhruvaraj Subhashchandran | a6ab806 | 2020-10-29 15:29:10 -0500 | [diff] [blame] | 21 | // TODO Revisit whether sdbusplus::xyz::openbmc_project::Time::server::EpochTime |
| 22 | // still needed in dump entry since start time and completed time are available |
| 23 | // from sdbusplus::xyz::openbmc_project::Common::server::Progress |
| 24 | // #ibm-openbmc/2809 |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 25 | using EntryIfaces = sdbusplus::server::object::object< |
Dhruvaraj Subhashchandran | a6ab806 | 2020-10-29 15:29:10 -0500 | [diff] [blame] | 26 | sdbusplus::xyz::openbmc_project::Common::server::Progress, |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 27 | sdbusplus::xyz::openbmc_project::Dump::server::Entry, |
| 28 | sdbusplus::xyz::openbmc_project::Object::server::Delete, |
| 29 | sdbusplus::xyz::openbmc_project::Time::server::EpochTime>; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 30 | |
Dhruvaraj Subhashchandran | a6ab806 | 2020-10-29 15:29:10 -0500 | [diff] [blame] | 31 | using OperationStatus = |
| 32 | sdbusplus::xyz::openbmc_project::Common::server::Progress::OperationStatus; |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 33 | |
| 34 | class Manager; |
| 35 | |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 36 | /** @class Entry |
Dhruvaraj Subhashchandran | f140f66 | 2020-01-30 00:29:01 -0600 | [diff] [blame] | 37 | * @brief Base Dump Entry implementation. |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 38 | * @details A concrete implementation for the |
| 39 | * xyz.openbmc_project.Dump.Entry DBus API |
| 40 | */ |
| 41 | class Entry : public EntryIfaces |
| 42 | { |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 43 | public: |
| 44 | Entry() = delete; |
| 45 | Entry(const Entry&) = delete; |
| 46 | Entry& operator=(const Entry&) = delete; |
| 47 | Entry(Entry&&) = delete; |
| 48 | Entry& operator=(Entry&&) = delete; |
| 49 | ~Entry() = default; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 50 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 51 | /** @brief Constructor for the Dump Entry Object |
| 52 | * @param[in] bus - Bus to attach to. |
| 53 | * @param[in] objPath - Object path to attach to |
| 54 | * @param[in] dumpId - Dump id. |
| 55 | * @param[in] timeStamp - Dump creation timestamp |
| 56 | * since the epoch. |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 57 | * @param[in] dumpSize - Dump file size in bytes. |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 58 | * @param[in] parent - The dump entry's parent. |
| 59 | */ |
| 60 | Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId, |
Dhruvaraj Subhashchandran | a6ab806 | 2020-10-29 15:29:10 -0500 | [diff] [blame] | 61 | uint64_t timeStamp, uint64_t dumpSize, OperationStatus dumpStatus, |
| 62 | Manager& parent) : |
Patrick Williams | 73f6407 | 2022-04-01 17:04:47 -0500 | [diff] [blame] | 63 | EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::emit_no_signals), |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 64 | parent(parent), id(dumpId) |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 65 | { |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 66 | size(dumpSize); |
Dhruvaraj Subhashchandran | a6ab806 | 2020-10-29 15:29:10 -0500 | [diff] [blame] | 67 | status(dumpStatus); |
| 68 | |
| 69 | // If the object is created after the dump creation keep |
| 70 | // all same as timeStamp |
| 71 | // if the object created before the dump creation, update |
| 72 | // only the start time. Completed and elapsed time will |
| 73 | // be updated once the dump is completed. |
| 74 | if (dumpStatus == OperationStatus::Completed) |
| 75 | { |
| 76 | elapsed(timeStamp); |
| 77 | startTime(timeStamp); |
| 78 | completedTime(timeStamp); |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | elapsed(0); |
| 83 | startTime(timeStamp); |
| 84 | completedTime(0); |
| 85 | } |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 86 | }; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 87 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 88 | /** @brief Delete this d-bus object. |
| 89 | */ |
| 90 | void delete_() override; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 91 | |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 92 | /** @brief Method to initiate the offload of dump |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 93 | * @param[in] uri - URI to offload dump |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 94 | */ |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 95 | void initiateOffload(std::string uri) override |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 96 | { |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 97 | offloadUri(uri); |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 98 | } |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 99 | |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 100 | protected: |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 101 | /** @brief This entry's parent */ |
| 102 | Manager& parent; |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 103 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 104 | /** @brief This entry's id */ |
| 105 | uint32_t id; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | } // namespace dump |
| 109 | } // namespace phosphor |