Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 1 | #include "system_dump_entry.hpp" |
| 2 | |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 3 | #include "dump_utils.hpp" |
Ramesh Iyyar | 131994b | 2020-12-03 08:35:36 -0600 | [diff] [blame] | 4 | #include "host_transport_exts.hpp" |
Dhruvaraj Subhashchandran | ad50d42 | 2022-01-18 05:54:02 -0600 | [diff] [blame] | 5 | #include "op_dump_consts.hpp" |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 6 | |
Dhruvaraj Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 7 | #include <phosphor-logging/elog-errors.hpp> |
Dhruvaraj Subhashchandran | d1f670f | 2023-06-05 22:19:25 -0500 | [diff] [blame] | 8 | #include <phosphor-logging/lg2.hpp> |
Dhruvaraj Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 9 | #include <xyz/openbmc_project/Common/error.hpp> |
| 10 | |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 11 | namespace openpower |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 12 | { |
| 13 | namespace dump |
| 14 | { |
| 15 | namespace system |
| 16 | { |
Dhruvaraj Subhashchandran | 4c63ce5 | 2020-12-18 02:07:22 -0600 | [diff] [blame] | 17 | // TODO #ibm-openbmc/issues/2859 |
| 18 | // Revisit host transport impelementation |
| 19 | // This value is used to identify the dump in the transport layer to host, |
| 20 | constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 3; |
Dhruvaraj Subhashchandran | 6a54d9a | 2020-12-17 22:24:37 -0600 | [diff] [blame] | 21 | using namespace phosphor::logging; |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 22 | |
| 23 | void Entry::initiateOffload(std::string uri) |
| 24 | { |
Dhruvaraj Subhashchandran | d1f670f | 2023-06-05 22:19:25 -0500 | [diff] [blame] | 25 | lg2::info("System dump offload request id: {ID} uri: {URI} " |
| 26 | "source dumpid: {SOURCE_DUMP_ID}", |
| 27 | "ID", id, "URI", uri, "SOURCE_DUMP_ID", sourceDumpId()); |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 28 | phosphor::dump::Entry::initiateOffload(uri); |
Dhruvaraj Subhashchandran | 59642e2 | 2020-03-19 03:37:44 -0500 | [diff] [blame] | 29 | phosphor::dump::host::requestOffload(sourceDumpId()); |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 30 | } |
| 31 | |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 32 | void Entry::delete_() |
| 33 | { |
| 34 | auto srcDumpID = sourceDumpId(); |
Dhruvaraj Subhashchandran | c1778da | 2022-02-04 01:46:49 -0600 | [diff] [blame] | 35 | auto dumpId = id; |
Dhruvaraj Subhashchandran | 1112bdf | 2022-03-23 04:38:02 -0500 | [diff] [blame] | 36 | |
| 37 | if ((!offloadUri().empty()) && (phosphor::dump::isHostRunning())) |
| 38 | { |
Dhruvaraj Subhashchandran | d1f670f | 2023-06-05 22:19:25 -0500 | [diff] [blame] | 39 | lg2::error("Dump offload is in progress id: {DUMP_ID} " |
| 40 | "srcdumpid: {SRC_DUMP_ID}", |
| 41 | "DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID); |
Dhruvaraj Subhashchandran | 1112bdf | 2022-03-23 04:38:02 -0500 | [diff] [blame] | 42 | elog<sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed>( |
| 43 | xyz::openbmc_project::Common::NotAllowed::REASON( |
| 44 | "Dump offload is in progress")); |
| 45 | } |
| 46 | |
Dhruvaraj Subhashchandran | d1f670f | 2023-06-05 22:19:25 -0500 | [diff] [blame] | 47 | lg2::info("System dump delete id: {DUMP_ID} srcdumpid: {SRC_DUMP_ID}", |
| 48 | "DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID); |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 49 | |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 50 | // Remove host system dump when host is up by using source dump id |
| 51 | // which is present in system dump entry dbus object as a property. |
Dhruvaraj Subhashchandran | ad50d42 | 2022-01-18 05:54:02 -0600 | [diff] [blame] | 52 | if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID)) |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 53 | { |
Dhruvaraj Subhashchandran | 345e56b | 2022-05-17 01:53:19 -0500 | [diff] [blame] | 54 | try |
| 55 | { |
| 56 | phosphor::dump::host::requestDelete(srcDumpID, |
| 57 | TRANSPORT_DUMP_TYPE_IDENTIFIER); |
| 58 | } |
| 59 | catch (const std::exception& e) |
| 60 | { |
Dhruvaraj Subhashchandran | d1f670f | 2023-06-05 22:19:25 -0500 | [diff] [blame] | 61 | lg2::error("Error deleting dump from host id: {DUMP_ID} " |
| 62 | "host id: {SRC_DUMP_ID} error: {ERROR}", |
| 63 | "DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID, "ERROR", e); |
Dhruvaraj Subhashchandran | 345e56b | 2022-05-17 01:53:19 -0500 | [diff] [blame] | 64 | elog<sdbusplus::xyz::openbmc_project::Common::Error::Unavailable>(); |
| 65 | } |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 66 | } |
Dhruvaraj Subhashchandran | 345e56b | 2022-05-17 01:53:19 -0500 | [diff] [blame] | 67 | |
| 68 | // Remove Dump entry D-bus object |
| 69 | phosphor::dump::Entry::delete_(); |
Ramesh Iyyar | 2279386 | 2020-12-04 04:03:03 -0600 | [diff] [blame] | 70 | } |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 71 | } // namespace system |
| 72 | } // namespace dump |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 73 | } // namespace openpower |