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