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