Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 3 | #include "xyz/openbmc_project/Logging/Entry/server.hpp" |
Deepak Kodihalli | 36db46c | 2017-03-31 06:28:44 -0500 | [diff] [blame] | 4 | #include "xyz/openbmc_project/Object/Delete/server.hpp" |
Matt Spinler | 375ac9b | 2018-05-01 15:20:55 -0500 | [diff] [blame] | 5 | #include "xyz/openbmc_project/Software/Version/server.hpp" |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 6 | |
| 7 | #include <sdbusplus/bus.hpp> |
| 8 | #include <sdbusplus/server/object.hpp> |
Adriana Kobylak | eb5d3f2 | 2021-02-04 14:03:28 -0600 | [diff] [blame] | 9 | #include <sdeventplus/event.hpp> |
| 10 | #include <sdeventplus/source/event.hpp> |
John Wang | 27d8281 | 2019-09-11 16:39:36 +0800 | [diff] [blame] | 11 | #include <xyz/openbmc_project/Association/Definitions/server.hpp> |
Adriana Kobylak | 1ff95ef | 2020-12-03 13:52:19 -0600 | [diff] [blame] | 12 | #include <xyz/openbmc_project/Common/FilePath/server.hpp> |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 13 | |
| 14 | namespace phosphor |
| 15 | { |
| 16 | namespace logging |
| 17 | { |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 18 | |
Deepak Kodihalli | b388da6 | 2017-02-27 00:47:12 -0600 | [diff] [blame] | 19 | using EntryIfaces = sdbusplus::server::object::object< |
| 20 | sdbusplus::xyz::openbmc_project::Logging::server::Entry, |
Deepak Kodihalli | 36db46c | 2017-03-31 06:28:44 -0500 | [diff] [blame] | 21 | sdbusplus::xyz::openbmc_project::Object::server::Delete, |
John Wang | 27d8281 | 2019-09-11 16:39:36 +0800 | [diff] [blame] | 22 | sdbusplus::xyz::openbmc_project::Association::server::Definitions, |
Adriana Kobylak | 1ff95ef | 2020-12-03 13:52:19 -0600 | [diff] [blame] | 23 | sdbusplus::xyz::openbmc_project::Software::server::Version, |
| 24 | sdbusplus::xyz::openbmc_project::Common::server::FilePath>; |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 25 | |
Deepak Kodihalli | 35b4637 | 2017-02-27 04:58:18 -0600 | [diff] [blame] | 26 | using AssociationList = |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 27 | std::vector<std::tuple<std::string, std::string, std::string>>; |
Deepak Kodihalli | 35b4637 | 2017-02-27 04:58:18 -0600 | [diff] [blame] | 28 | |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 29 | namespace internal |
| 30 | { |
Deepak Kodihalli | 8110ca6 | 2017-04-10 02:11:54 -0500 | [diff] [blame] | 31 | class Manager; |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 32 | } |
Deepak Kodihalli | 8110ca6 | 2017-04-10 02:11:54 -0500 | [diff] [blame] | 33 | |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 34 | /** @class Entry |
| 35 | * @brief OpenBMC logging entry implementation. |
| 36 | * @details A concrete implementation for the |
Deepak Kodihalli | b388da6 | 2017-02-27 00:47:12 -0600 | [diff] [blame] | 37 | * xyz.openbmc_project.Logging.Entry and |
John Wang | 27d8281 | 2019-09-11 16:39:36 +0800 | [diff] [blame] | 38 | * xyz.openbmc_project.Associations.Definitions DBus APIs. |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 39 | */ |
Deepak Kodihalli | b388da6 | 2017-02-27 00:47:12 -0600 | [diff] [blame] | 40 | class Entry : public EntryIfaces |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 41 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 42 | public: |
| 43 | Entry() = delete; |
| 44 | Entry(const Entry&) = delete; |
| 45 | Entry& operator=(const Entry&) = delete; |
| 46 | Entry(Entry&&) = delete; |
| 47 | Entry& operator=(Entry&&) = delete; |
| 48 | virtual ~Entry() = default; |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 49 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 50 | /** @brief Constructor to put object onto bus at a dbus path. |
| 51 | * Defer signal registration (pass true for deferSignal to the |
| 52 | * base class) until after the properties are set. |
| 53 | * @param[in] bus - Bus to attach to. |
Matt Spinler | fb978da | 2022-01-21 08:42:24 -0600 | [diff] [blame] | 54 | * @param[in] objectPath - Path to attach at. |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 55 | * @param[in] idErr - The error entry id. |
| 56 | * @param[in] timestampErr - The commit timestamp. |
| 57 | * @param[in] severityErr - The severity of the error. |
| 58 | * @param[in] msgErr - The message of the error. |
| 59 | * @param[in] additionalDataErr - The error metadata. |
| 60 | * @param[in] objects - The list of associations. |
| 61 | * @param[in] fwVersion - The BMC code version. |
Matt Spinler | fb978da | 2022-01-21 08:42:24 -0600 | [diff] [blame] | 62 | * @param[in] filePath - Serialization path |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 63 | * @param[in] parent - The error's parent. |
| 64 | */ |
Matt Spinler | fb978da | 2022-01-21 08:42:24 -0600 | [diff] [blame] | 65 | Entry(sdbusplus::bus::bus& bus, const std::string& objectPath, |
| 66 | uint32_t idErr, uint64_t timestampErr, Level severityErr, |
| 67 | std::string&& msgErr, std::vector<std::string>&& additionalDataErr, |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 68 | AssociationList&& objects, const std::string& fwVersion, |
Matt Spinler | fb978da | 2022-01-21 08:42:24 -0600 | [diff] [blame] | 69 | const std::string& filePath, internal::Manager& parent) : |
| 70 | EntryIfaces(bus, objectPath.c_str(), true), |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 71 | parent(parent) |
| 72 | { |
Matt Spinler | ef952af | 2021-08-19 10:23:05 -0500 | [diff] [blame] | 73 | id(idErr, true); |
| 74 | severity(severityErr, true); |
| 75 | timestamp(timestampErr, true); |
| 76 | updateTimestamp(timestampErr, true); |
| 77 | message(std::move(msgErr), true); |
| 78 | additionalData(std::move(additionalDataErr), true); |
| 79 | associations(std::move(objects), true); |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 80 | // Store a copy of associations in case we need to recreate |
| 81 | assocs = associations(); |
Matt Spinler | ef952af | 2021-08-19 10:23:05 -0500 | [diff] [blame] | 82 | sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolved(false, |
| 83 | true); |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 84 | |
Matt Spinler | ef952af | 2021-08-19 10:23:05 -0500 | [diff] [blame] | 85 | version(fwVersion, true); |
| 86 | purpose(VersionPurpose::BMC, true); |
Matt Spinler | fb978da | 2022-01-21 08:42:24 -0600 | [diff] [blame] | 87 | path(filePath, true); |
Matt Spinler | 375ac9b | 2018-05-01 15:20:55 -0500 | [diff] [blame] | 88 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 89 | // Emit deferred signal. |
| 90 | this->emit_object_added(); |
| 91 | }; |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 92 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 93 | /** @brief Constructor that puts an "empty" error object on the bus, |
| 94 | * with only the id property populated. Rest of the properties |
| 95 | * to be set by the caller. Caller should emit the added signal. |
| 96 | * @param[in] bus - Bus to attach to. |
| 97 | * @param[in] path - Path to attach at. |
| 98 | * @param[in] id - The error entry id. |
| 99 | * @param[in] parent - The error's parent. |
| 100 | */ |
| 101 | Entry(sdbusplus::bus::bus& bus, const std::string& path, uint32_t entryId, |
| 102 | internal::Manager& parent) : |
| 103 | EntryIfaces(bus, path.c_str(), true), |
| 104 | parent(parent) |
| 105 | { |
Matt Spinler | ef952af | 2021-08-19 10:23:05 -0500 | [diff] [blame] | 106 | id(entryId, true); |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 107 | }; |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 108 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 109 | /** @brief Set resolution status of the error. |
| 110 | * @param[in] value - boolean indicating resolution |
| 111 | * status (true = resolved) |
| 112 | * @returns value of 'Resolved' property |
| 113 | */ |
| 114 | bool resolved(bool value) override; |
Deepak Kodihalli | 90abed6 | 2017-03-27 03:56:44 -0500 | [diff] [blame] | 115 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 116 | using sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolved; |
Deepak Kodihalli | 90abed6 | 2017-03-27 03:56:44 -0500 | [diff] [blame] | 117 | |
Vijay Lobo | d354a39 | 2021-06-01 16:21:02 -0500 | [diff] [blame] | 118 | /** @brief Update eventId string of the error. |
| 119 | * @param[in] value - The eventID |
| 120 | * @returns New property value |
| 121 | */ |
| 122 | std::string eventId(std::string value) override; |
| 123 | |
| 124 | using sdbusplus::xyz::openbmc_project::Logging::server::Entry::eventId; |
| 125 | |
Vijay Lobo | 593a4c6 | 2021-06-16 14:25:26 -0500 | [diff] [blame] | 126 | /** @brief Update resolution string of the error. |
| 127 | * @param[in] value - The resolution |
| 128 | * @returns New property value |
| 129 | */ |
| 130 | std::string resolution(std::string value) override; |
| 131 | |
| 132 | using sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolution; |
| 133 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 134 | /** @brief Delete this d-bus object. |
| 135 | */ |
| 136 | void delete_() override; |
Deepak Kodihalli | 36db46c | 2017-03-31 06:28:44 -0500 | [diff] [blame] | 137 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 138 | /** @brief Severity level to check in cap. |
| 139 | * @details Errors with severity lesser than this will be |
| 140 | * considered as low priority and maximum ERROR_INFO_CAP |
| 141 | * number errors of this category will be captured. |
| 142 | */ |
| 143 | static constexpr auto sevLowerLimit = Entry::Level::Informational; |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 144 | |
Adriana Kobylak | eb5d3f2 | 2021-02-04 14:03:28 -0600 | [diff] [blame] | 145 | /** |
| 146 | * @brief Returns the file descriptor to the Entry file. |
| 147 | * @return unix_fd - File descriptor to the Entry file. |
| 148 | */ |
| 149 | sdbusplus::message::unix_fd getEntry() override; |
| 150 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 151 | private: |
| 152 | /** @brief This entry's associations */ |
| 153 | AssociationList assocs = {}; |
Deepak Kodihalli | 8110ca6 | 2017-04-10 02:11:54 -0500 | [diff] [blame] | 154 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 155 | /** @brief This entry's parent */ |
| 156 | internal::Manager& parent; |
Adriana Kobylak | eb5d3f2 | 2021-02-04 14:03:28 -0600 | [diff] [blame] | 157 | |
| 158 | /** |
| 159 | * @brief The event source for closing the Entry file descriptor after it |
| 160 | * has been returned from the getEntry D-Bus method. |
| 161 | */ |
| 162 | std::unique_ptr<sdeventplus::source::Defer> fdCloseEventSource; |
| 163 | |
| 164 | /** |
| 165 | * @brief Closes the file descriptor passed in. |
| 166 | * @details This is called from the event loop to close FDs returned from |
| 167 | * getEntry(). |
| 168 | * @param[in] fd - The file descriptor to close |
| 169 | * @param[in] source - The event source object used |
| 170 | */ |
| 171 | void closeFD(int fd, sdeventplus::source::EventBase& source); |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 172 | }; |
| 173 | |
| 174 | } // namespace logging |
| 175 | } // namespace phosphor |