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 | |
Patrick Williams | 4bc1c2b | 2021-05-10 14:22:18 -0500 | [diff] [blame] | 11 | #ifndef SDBUSPP_NEW_CAMELCASE |
| 12 | #define vspString vSPString |
| 13 | #endif |
| 14 | |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 15 | namespace openpower |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 16 | { |
| 17 | namespace dump |
| 18 | { |
| 19 | namespace resource |
| 20 | { |
| 21 | template <typename T> |
| 22 | using ServerObject = typename sdbusplus::server::object::object<T>; |
| 23 | |
| 24 | using EntryIfaces = sdbusplus::server::object::object< |
| 25 | sdbusplus::com::ibm::Dump::Entry::server::Resource>; |
| 26 | |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 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 EntryIfaces, virtual public phosphor::dump::Entry |
| 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. |
Patrick Williams | 4bc1c2b | 2021-05-10 14:22:18 -0500 | [diff] [blame] | 53 | * @param[in] vspStr- Input to host to generate the resource dump. |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 54 | * @param[in] pwd - Password needed by host to validate the request. |
| 55 | * @param[in] status - status of the dump. |
| 56 | * @param[in] parent - The dump entry's parent. |
| 57 | */ |
| 58 | Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId, |
| 59 | uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId, |
Patrick Williams | 4bc1c2b | 2021-05-10 14:22:18 -0500 | [diff] [blame] | 60 | std::string vspStr, std::string pwd, |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 61 | phosphor::dump::OperationStatus status, |
| 62 | phosphor::dump::Manager& parent) : |
| 63 | EntryIfaces(bus, objPath.c_str(), true), |
| 64 | phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize, |
| 65 | status, parent) |
| 66 | { |
| 67 | sourceDumpId(sourceId); |
Patrick Williams | 4bc1c2b | 2021-05-10 14:22:18 -0500 | [diff] [blame] | 68 | vspString(vspStr); |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 69 | password(pwd); |
Dhruvaraj Subhashchandran | 2f8e276 | 2021-02-11 07:22:35 -0600 | [diff] [blame] | 70 | // Emit deferred signal. |
| 71 | this->openpower::dump::resource::EntryIfaces::emit_object_added(); |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | /** @brief Method to initiate the offload of dump |
| 75 | * @param[in] uri - URI to offload dump. |
| 76 | */ |
Dhruvaraj Subhashchandran | 2f8e276 | 2021-02-11 07:22:35 -0600 | [diff] [blame] | 77 | void initiateOffload(std::string uri) override; |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 78 | |
| 79 | /** @brief Method to update an existing dump entry |
| 80 | * @param[in] timeStamp - Dump creation timestamp |
| 81 | * @param[in] dumpSize - Dump size in bytes. |
| 82 | * @param[in] sourceId - The id of dump in the origin. |
| 83 | */ |
| 84 | void update(uint64_t timeStamp, uint64_t dumpSize, uint32_t sourceId) |
| 85 | { |
| 86 | sourceDumpId(sourceId); |
| 87 | elapsed(timeStamp); |
| 88 | size(dumpSize); |
| 89 | // TODO: Handled dump failure case with |
| 90 | // #bm-openbmc/2808 |
| 91 | status(OperationStatus::Completed); |
| 92 | completedTime(timeStamp); |
| 93 | } |
Dhruvaraj Subhashchandran | 4c63ce5 | 2020-12-18 02:07:22 -0600 | [diff] [blame] | 94 | |
| 95 | /** |
| 96 | * @brief Delete resource dump in host memory and the entry dbus object |
| 97 | */ |
| 98 | void delete_() override; |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | } // namespace resource |
| 102 | } // namespace dump |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 103 | } // namespace openpower |