Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "com/ibm/Dump/Entry/Resource/server.hpp" |
| 4 | #include "dump_entry.hpp" |
| 5 | |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 6 | #include <sdbusplus/bus.hpp> |
| 7 | #include <sdbusplus/server/object.hpp> |
| 8 | |
Jayanth Othayoth | 0af74a5 | 2021-04-08 03:55:21 -0500 | [diff] [blame] | 9 | #include <chrono> |
| 10 | |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 11 | namespace openpower |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 12 | { |
| 13 | namespace dump |
| 14 | { |
| 15 | namespace resource |
| 16 | { |
| 17 | template <typename T> |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 18 | using ServerObject = typename sdbusplus::server::object_t<T>; |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 19 | |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 20 | using EntryIfaces = sdbusplus::server::object_t< |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 21 | sdbusplus::com::ibm::Dump::Entry::server::Resource>; |
| 22 | |
Asmitha Karunanithi | 74a1f39 | 2021-10-27 03:23:59 -0500 | [diff] [blame] | 23 | using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server:: |
| 24 | OriginatedBy::OriginatorTypes; |
| 25 | |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 26 | class Manager; |
| 27 | |
| 28 | /** @class Entry |
| 29 | * @brief Resource Dump Entry implementation. |
| 30 | * @details An extension to Dump::Entry class and |
| 31 | * A concrete implementation for the |
| 32 | * com::ibm::Dump::Entry::Resource DBus API |
| 33 | */ |
Lei YU | 05ef816 | 2022-11-23 13:49:53 +0800 | [diff] [blame] | 34 | class Entry : virtual public phosphor::dump::Entry, virtual public EntryIfaces |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 35 | { |
| 36 | public: |
| 37 | Entry() = delete; |
| 38 | Entry(const Entry&) = delete; |
| 39 | Entry& operator=(const Entry&) = delete; |
| 40 | Entry(Entry&&) = delete; |
| 41 | Entry& operator=(Entry&&) = delete; |
| 42 | ~Entry() = default; |
| 43 | |
| 44 | /** @brief Constructor for the resource dump Entry Object |
| 45 | * @param[in] bus - Bus to attach to. |
| 46 | * @param[in] objPath - Object path to attach to |
| 47 | * @param[in] dumpId - Dump id. |
| 48 | * @param[in] timeStamp - Dump creation timestamp |
| 49 | * since the epoch. |
| 50 | * @param[in] dumpSize - Dump size in bytes. |
| 51 | * @param[in] sourceId - DumpId provided by the source. |
Patrick Williams | 4bc1c2b | 2021-05-10 14:22:18 -0500 | [diff] [blame] | 52 | * @param[in] vspStr- Input to host to generate the resource dump. |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 53 | * @param[in] pwd - Password needed by host to validate the request. |
| 54 | * @param[in] status - status of the dump. |
Asmitha Karunanithi | 74a1f39 | 2021-10-27 03:23:59 -0500 | [diff] [blame] | 55 | * @param[in] originatorId - Id of the originator of the dump |
| 56 | * @param[in] originatorType - Originator type |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 57 | * @param[in] parent - The dump entry's parent. |
| 58 | */ |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 59 | Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId, |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 60 | uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId, |
Patrick Williams | 4bc1c2b | 2021-05-10 14:22:18 -0500 | [diff] [blame] | 61 | std::string vspStr, std::string pwd, |
Asmitha Karunanithi | 74a1f39 | 2021-10-27 03:23:59 -0500 | [diff] [blame] | 62 | phosphor::dump::OperationStatus status, std::string originatorId, |
| 63 | originatorTypes originatorType, phosphor::dump::Manager& parent) : |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 64 | phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize, |
Dhruvaraj Subhashchandran | 64f8da9 | 2021-12-08 03:48:23 -0600 | [diff] [blame] | 65 | std::string(), status, originatorId, |
Lei YU | 05ef816 | 2022-11-23 13:49:53 +0800 | [diff] [blame] | 66 | originatorType, parent), |
| 67 | EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit) |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 68 | { |
| 69 | sourceDumpId(sourceId); |
Patrick Williams | 4bc1c2b | 2021-05-10 14:22:18 -0500 | [diff] [blame] | 70 | vspString(vspStr); |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 71 | password(pwd); |
Dhruvaraj Subhashchandran | 2f8e276 | 2021-02-11 07:22:35 -0600 | [diff] [blame] | 72 | // Emit deferred signal. |
| 73 | this->openpower::dump::resource::EntryIfaces::emit_object_added(); |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | /** @brief Method to initiate the offload of dump |
| 77 | * @param[in] uri - URI to offload dump. |
| 78 | */ |
Dhruvaraj Subhashchandran | 2f8e276 | 2021-02-11 07:22:35 -0600 | [diff] [blame] | 79 | void initiateOffload(std::string uri) override; |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 80 | |
| 81 | /** @brief Method to update an existing dump entry |
| 82 | * @param[in] timeStamp - Dump creation timestamp |
| 83 | * @param[in] dumpSize - Dump size in bytes. |
| 84 | * @param[in] sourceId - The id of dump in the origin. |
| 85 | */ |
| 86 | void update(uint64_t timeStamp, uint64_t dumpSize, uint32_t sourceId) |
| 87 | { |
| 88 | sourceDumpId(sourceId); |
| 89 | elapsed(timeStamp); |
| 90 | size(dumpSize); |
| 91 | // TODO: Handled dump failure case with |
| 92 | // #bm-openbmc/2808 |
| 93 | status(OperationStatus::Completed); |
| 94 | completedTime(timeStamp); |
| 95 | } |
Dhruvaraj Subhashchandran | 4c63ce5 | 2020-12-18 02:07:22 -0600 | [diff] [blame] | 96 | |
| 97 | /** |
| 98 | * @brief Delete resource dump in host memory and the entry dbus object |
| 99 | */ |
| 100 | void delete_() override; |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | } // namespace resource |
| 104 | } // namespace dump |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 105 | } // namespace openpower |