Jayanth Othayoth | d0f0064 | 2017-09-04 06:26:30 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 3 | #include "config.h" |
Jayanth Othayoth | 2496482 | 2017-09-04 22:07:06 -0500 | [diff] [blame] | 4 | |
Dhruvaraj Subhashchandran | fef66a9 | 2020-09-06 13:10:59 -0500 | [diff] [blame] | 5 | #include "dump_manager_bmc.hpp" |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 6 | |
| 7 | #include <cereal/access.hpp> |
Jayanth Othayoth | d0f0064 | 2017-09-04 06:26:30 -0500 | [diff] [blame] | 8 | #include <sdbusplus/bus.hpp> |
| 9 | #include <sdbusplus/server.hpp> |
Dhruvaraj Subhashchandran | e4350f9 | 2023-06-29 05:57:47 -0500 | [diff] [blame] | 10 | #include <xyz/openbmc_project/Dump/Create/server.hpp> |
Jayanth Othayoth | 0af74a5 | 2021-04-08 03:55:21 -0500 | [diff] [blame] | 11 | |
| 12 | #include <filesystem> |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 13 | #include <set> |
Jayanth Othayoth | d0f0064 | 2017-09-04 06:26:30 -0500 | [diff] [blame] | 14 | |
| 15 | namespace phosphor |
| 16 | { |
| 17 | namespace dump |
| 18 | { |
| 19 | namespace elog |
| 20 | { |
| 21 | |
Dhruvaraj Subhashchandran | e4350f9 | 2023-06-29 05:57:47 -0500 | [diff] [blame] | 22 | using Mgr = phosphor::dump::bmc::Manager; |
Jayanth Othayoth | 2496482 | 2017-09-04 22:07:06 -0500 | [diff] [blame] | 23 | using EId = uint32_t; |
| 24 | using ElogList = std::set<EId>; |
Jayanth Othayoth | d0f0064 | 2017-09-04 06:26:30 -0500 | [diff] [blame] | 25 | |
| 26 | /** @class Watch |
Jayanth Othayoth | 2496482 | 2017-09-04 22:07:06 -0500 | [diff] [blame] | 27 | * @brief Adds d-bus signal based watch for elog add and delete. |
Jayanth Othayoth | d0f0064 | 2017-09-04 06:26:30 -0500 | [diff] [blame] | 28 | * @details This implements methods for watching for InternalFailure |
| 29 | * type error message and call appropriate function to initiate dump |
| 30 | */ |
| 31 | class Watch |
| 32 | { |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 33 | public: |
| 34 | Watch() = delete; |
| 35 | ~Watch() = default; |
| 36 | Watch(const Watch&) = delete; |
| 37 | Watch& operator=(const Watch&) = delete; |
Jayanth Othayoth | 4f68fc4 | 2024-11-25 10:04:07 -0600 | [diff] [blame] | 38 | Watch(Watch&&) = delete; |
| 39 | Watch& operator=(Watch&&) = delete; |
Jayanth Othayoth | d0f0064 | 2017-09-04 06:26:30 -0500 | [diff] [blame] | 40 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 41 | /** @brief constructs watch for elog add and delete signals. |
| 42 | * @param[in] bus - The Dbus bus object |
Dhruvaraj Subhashchandran | e4350f9 | 2023-06-29 05:57:47 -0500 | [diff] [blame] | 43 | * @param[in] mgr - Dump Manager object |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 44 | */ |
Dhruvaraj Subhashchandran | e4350f9 | 2023-06-29 05:57:47 -0500 | [diff] [blame] | 45 | Watch(sdbusplus::bus_t& bus, Mgr& mgr); |
Jayanth Othayoth | d0f0064 | 2017-09-04 06:26:30 -0500 | [diff] [blame] | 46 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 47 | private: |
| 48 | friend class cereal::access; |
Jayanth Othayoth | 2496482 | 2017-09-04 22:07:06 -0500 | [diff] [blame] | 49 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 50 | /** @brief Function required by Cereal to perform serialization. |
| 51 | * @tparam Archive - Cereal archive type (binary in our case). |
| 52 | * @param[in] a - reference to Cereal archive. |
| 53 | * @param[in] version - Class version that enables handling |
| 54 | * a serialized data across code levels |
| 55 | */ |
| 56 | template <class Archive> |
| 57 | void serialize(Archive& a, const std::uint32_t version) |
| 58 | { |
Jayanth Othayoth | 4f68fc4 | 2024-11-25 10:04:07 -0600 | [diff] [blame] | 59 | (void)version; // Mark version as unused to avoid warning |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 60 | a(elogList); |
Vishwanatha Subbanna | 3108597 | 2017-10-05 17:06:37 +0530 | [diff] [blame] | 61 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 62 | // TODO: openbmc/phosphor-debug-collector#1 |
| 63 | // Split into load/save so that it enables |
| 64 | // version compare during serialization |
| 65 | } |
Jayanth Othayoth | 2496482 | 2017-09-04 22:07:06 -0500 | [diff] [blame] | 66 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 67 | /** @brief Callback function for error log add. |
| 68 | * @details InternalError type error message initiates |
| 69 | * Internal error type dump request. |
| 70 | * @param[in] msg - Data associated with subscribed signal |
| 71 | */ |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 72 | void addCallback(sdbusplus::message_t& msg); |
Jayanth Othayoth | 2496482 | 2017-09-04 22:07:06 -0500 | [diff] [blame] | 73 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 74 | /** @brief Callback function for error log delete. |
| 75 | * @param[in] msg - Data associated with subscribed signal |
| 76 | */ |
Patrick Williams | 9b18bf2 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 77 | void delCallback(sdbusplus::message_t& msg); |
Jayanth Othayoth | 2496482 | 2017-09-04 22:07:06 -0500 | [diff] [blame] | 78 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 79 | /** @brief get elog ID from elog entry object string. |
| 80 | * @param[in] objectPath - elog entry object path. |
| 81 | * @return - elog id. |
| 82 | */ |
| 83 | inline EId getEid(const std::string& objectPath) |
| 84 | { |
Jayanth Othayoth | 3fc6df4 | 2021-04-08 03:45:24 -0500 | [diff] [blame] | 85 | std::filesystem::path path(objectPath); |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 86 | return std::stoul(path.filename()); |
| 87 | } |
Jayanth Othayoth | d0f0064 | 2017-09-04 06:26:30 -0500 | [diff] [blame] | 88 | |
Dhruvaraj Subhashchandran | e4350f9 | 2023-06-29 05:57:47 -0500 | [diff] [blame] | 89 | /** @brief BMC Dump Manager object. */ |
| 90 | Mgr& mgr; |
Jayanth Othayoth | d0f0064 | 2017-09-04 06:26:30 -0500 | [diff] [blame] | 91 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 92 | /** @brief sdbusplus signal match for elog add */ |
| 93 | sdbusplus::bus::match_t addMatch; |
Jayanth Othayoth | 2496482 | 2017-09-04 22:07:06 -0500 | [diff] [blame] | 94 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 95 | /** @brief sdbusplus signal match for elog delete */ |
| 96 | sdbusplus::bus::match_t delMatch; |
Jayanth Othayoth | 2496482 | 2017-09-04 22:07:06 -0500 | [diff] [blame] | 97 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 98 | /** @brief List of elog ids, which have associated dumps created */ |
| 99 | ElogList elogList; |
Jayanth Othayoth | d0f0064 | 2017-09-04 06:26:30 -0500 | [diff] [blame] | 100 | }; |
| 101 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 102 | } // namespace elog |
| 103 | } // namespace dump |
| 104 | } // namespace phosphor |