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