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