Dhruvaraj Subhashchandran | 858d1aa | 2021-10-27 03:26:06 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Dhruvaraj Subhashchandran | 5f5c94d | 2021-10-19 07:18:30 -0500 | [diff] [blame] | 3 | #include "sbe_type.hpp" |
| 4 | |
Dhruvaraj Subhashchandran | 858d1aa | 2021-10-27 03:26:06 -0500 | [diff] [blame] | 5 | #include <sdbusplus/server.hpp> |
| 6 | |
| 7 | #include <filesystem> |
| 8 | #include <map> |
| 9 | #include <string> |
| 10 | #include <variant> |
| 11 | namespace openpower::dump::util |
| 12 | { |
| 13 | |
Dhruvaraj Subhashchandran | 5f5c94d | 2021-10-19 07:18:30 -0500 | [diff] [blame] | 14 | constexpr auto SBE_DUMP_TIMEOUT = 4 * 60; // Timeout in seconds |
| 15 | |
Dhruvaraj Subhashchandran | 858d1aa | 2021-10-27 03:26:06 -0500 | [diff] [blame] | 16 | using DumpCreateParams = |
| 17 | std::map<std::string, std::variant<std::string, uint64_t>>; |
| 18 | |
| 19 | /** @struct DumpPtr |
| 20 | * @brief a structure holding the data pointer |
| 21 | * @details This is a RAII container for the dump data |
| 22 | * returned by the SBE |
| 23 | */ |
| 24 | struct DumpDataPtr |
| 25 | { |
| 26 | public: |
| 27 | /** @brief Destructor for the object, free the allocated memory. |
| 28 | */ |
| 29 | ~DumpDataPtr() |
| 30 | { |
| 31 | // The memory is allocated using malloc |
| 32 | free(dataPtr); |
| 33 | } |
| 34 | /** @brief Returns the pointer to the data |
| 35 | */ |
| 36 | uint8_t** getPtr() |
| 37 | { |
| 38 | return &dataPtr; |
| 39 | } |
| 40 | /** @brief Returns the stored data |
| 41 | */ |
| 42 | uint8_t* getData() |
| 43 | { |
| 44 | return dataPtr; |
| 45 | } |
| 46 | |
| 47 | private: |
| 48 | /** The pointer to the data */ |
| 49 | uint8_t* dataPtr = nullptr; |
| 50 | }; |
| 51 | |
| 52 | /** |
| 53 | * @brief Get DBUS service for input interface via mapper call |
| 54 | * |
| 55 | * @param[in] bus - DBUS Bus Object |
| 56 | * @param[in] intf - DBUS Interface |
| 57 | * @param[in] path - DBUS Object Path |
| 58 | * |
| 59 | * @return distinct dbus name for input interface/path |
| 60 | **/ |
Patrick Williams | 9ae780d | 2024-04-26 02:34:31 -0500 | [diff] [blame] | 61 | std::string getService(sdbusplus::bus_t& bus, const std::string& intf, |
Dhruvaraj Subhashchandran | 858d1aa | 2021-10-27 03:26:06 -0500 | [diff] [blame] | 62 | const std::string& path); |
| 63 | |
| 64 | /** |
| 65 | * @brief Set the property value based on the inputs |
| 66 | * |
| 67 | * @param[in] interface - the interface the property is on |
| 68 | * @param[in] propertName - the name of the property |
| 69 | * @param[in] path - the D-Bus path |
| 70 | * @param[in] service - the D-Bus service |
| 71 | * @param[in] bus - the D-Bus object |
| 72 | * @param[in] value - the value to set the property to |
| 73 | */ |
| 74 | template <typename T> |
| 75 | void setProperty(const std::string& interface, const std::string& propertyName, |
Patrick Williams | 9ae780d | 2024-04-26 02:34:31 -0500 | [diff] [blame] | 76 | const std::string& path, sdbusplus::bus_t& bus, const T& value) |
Dhruvaraj Subhashchandran | 858d1aa | 2021-10-27 03:26:06 -0500 | [diff] [blame] | 77 | { |
| 78 | constexpr auto PROPERTY_INTF = "org.freedesktop.DBus.Properties"; |
| 79 | |
| 80 | auto service = getService(bus, interface, path); |
| 81 | auto method = bus.new_method_call(service.c_str(), path.c_str(), |
| 82 | PROPERTY_INTF, "Set"); |
| 83 | method.append(interface, propertyName, value); |
| 84 | auto reply = bus.call(method); |
| 85 | } |
| 86 | |
Dhruvaraj Subhashchandran | 5f5c94d | 2021-10-19 07:18:30 -0500 | [diff] [blame] | 87 | /** |
| 88 | * Request SBE dump from the dump manager |
| 89 | * |
| 90 | * Request SBE dump from the dump manager and register a monitor for observing |
| 91 | * the dump progress. |
| 92 | * |
| 93 | * @param failingUnit The id of the proc containing failed SBE |
| 94 | * @param eid Error log id associated with dump |
| 95 | * @param sbeType Type of the SBE |
| 96 | */ |
| 97 | void requestSBEDump(const uint32_t failingUnit, const uint32_t eid, |
| 98 | SBETypes sbeType); |
| 99 | |
Dhruvaraj Subhashchandran | 858d1aa | 2021-10-27 03:26:06 -0500 | [diff] [blame] | 100 | } // namespace openpower::dump::util |