Matt Spinler | f60ac27 | 2019-12-11 13:47:50 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "host_interface.hpp" |
| 4 | #include "pel.hpp" |
| 5 | #include "repository.hpp" |
| 6 | |
| 7 | #include <deque> |
| 8 | |
| 9 | namespace openpower::pels |
| 10 | { |
| 11 | |
| 12 | /** |
| 13 | * @class HostNotifier |
| 14 | * |
| 15 | * This class handles notifying the host firmware of new PELs. |
| 16 | */ |
| 17 | class HostNotifier |
| 18 | { |
| 19 | public: |
| 20 | HostNotifier() = delete; |
| 21 | HostNotifier(const HostNotifier&) = delete; |
| 22 | HostNotifier& operator=(const HostNotifier&) = delete; |
| 23 | HostNotifier(HostNotifier&&) = delete; |
| 24 | HostNotifier& operator=(HostNotifier&&) = delete; |
| 25 | |
| 26 | /** |
| 27 | * @brief Constructor |
| 28 | * |
| 29 | * @param[in] repo - The PEL repository object |
| 30 | * @param[in] dataIface - The data interface object |
| 31 | * @param[in] hostIface - The host interface object |
| 32 | */ |
| 33 | HostNotifier(Repository& repo, DataInterfaceBase& dataIface, |
| 34 | std::unique_ptr<HostInterface> hostIface); |
| 35 | |
| 36 | /** |
| 37 | * @brief Destructor |
| 38 | */ |
| 39 | ~HostNotifier(); |
| 40 | |
| 41 | /** |
| 42 | * @brief Returns the PEL queue size. |
| 43 | * |
| 44 | * For testing. |
| 45 | * |
| 46 | * @return size_t - The queue size |
| 47 | */ |
| 48 | size_t queueSize() const |
| 49 | { |
| 50 | return _pelQueue.size(); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @brief Specifies if the PEL needs to go onto the queue to be |
| 55 | * set to the host. |
| 56 | * |
Matt Spinler | a943b15 | 2019-12-11 14:44:50 -0600 | [diff] [blame^] | 57 | * Only returns false if: |
| 58 | * - Already acked by the host (or they didn't like it) |
| 59 | * - Hidden and the HMC already got it |
| 60 | * - The 'do not report to host' bit is set |
| 61 | * |
Matt Spinler | f60ac27 | 2019-12-11 13:47:50 -0600 | [diff] [blame] | 62 | * @param[in] id - The PEL ID |
| 63 | * |
| 64 | * @return bool - If enqueue is required |
| 65 | */ |
| 66 | bool enqueueRequired(uint32_t id) const; |
| 67 | |
| 68 | private: |
| 69 | /** |
| 70 | * @brief This function gets called by the Repository class |
| 71 | * when a new PEL is added to it. |
| 72 | * |
| 73 | * @param[in] pel - The new PEL |
| 74 | */ |
| 75 | void newLogCallback(const PEL& pel); |
| 76 | |
| 77 | /** |
| 78 | * @brief This function runs on every existing PEL at startup |
| 79 | * and puts the PEL on the queue to send if necessary. |
| 80 | * |
| 81 | * @param[in] pel - The PEL |
| 82 | * |
| 83 | * @return bool - This is an indicator to the Repository::for_each |
| 84 | * function to traverse every PEL. Always false. |
| 85 | */ |
| 86 | bool addPELToQueue(const PEL& pel); |
| 87 | |
| 88 | /** |
| 89 | * @brief Takes the PEL off the front of the queue and issues |
| 90 | * the PLDM send. |
| 91 | */ |
| 92 | void doNewLogNotify(); |
| 93 | |
| 94 | /** |
| 95 | * @brief Called when the host changes state. |
| 96 | * |
| 97 | * @param[in] hostUp - The new host state |
| 98 | */ |
| 99 | void hostStateChange(bool hostUp); |
| 100 | |
| 101 | /** |
| 102 | * @brief The callback function invoked after the asynchronous |
| 103 | * PLDM receive function is complete. |
| 104 | * |
| 105 | * @param[in] status - The response status |
| 106 | */ |
| 107 | void commandResponse(ResponseStatus status); |
| 108 | |
| 109 | /** |
| 110 | * @brief The PEL repository object |
| 111 | */ |
| 112 | Repository& _repo; |
| 113 | |
| 114 | /** |
| 115 | * @brief The data interface object |
| 116 | */ |
| 117 | DataInterfaceBase& _dataIface; |
| 118 | |
| 119 | /** |
| 120 | * @brief Base class pointer for the host command interface |
| 121 | */ |
| 122 | std::unique_ptr<HostInterface> _hostIface; |
| 123 | |
| 124 | /** |
| 125 | * @brief The list of PEL IDs that need to be sent. |
| 126 | */ |
| 127 | std::deque<uint32_t> _pelQueue; |
| 128 | }; |
| 129 | |
| 130 | } // namespace openpower::pels |