PEL: Fill in host command response handler

If notifying the host of a new PEL was successful, then it
will modify the PEL's host transmission state to 'sent' and
add it to the list of sent PELs.

If there was a failure, then a timer will be started so a
retry can be done.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I77000c603a18726d4cdbb3920ca349e69198fb7f
diff --git a/extensions/openpower-pels/host_notifier.cpp b/extensions/openpower-pels/host_notifier.cpp
index 2956b66..b935f7e 100644
--- a/extensions/openpower-pels/host_notifier.cpp
+++ b/extensions/openpower-pels/host_notifier.cpp
@@ -27,7 +27,9 @@
 HostNotifier::HostNotifier(Repository& repo, DataInterfaceBase& dataIface,
                            std::unique_ptr<HostInterface> hostIface) :
     _repo(repo),
-    _dataIface(dataIface), _hostIface(std::move(hostIface))
+    _dataIface(dataIface), _hostIface(std::move(hostIface)),
+    _retryTimer(_hostIface->getEvent(),
+                std::bind(std::mem_fn(&HostNotifier::retryTimerExpired), this))
 {
     // Subscribe to be told about new PELs.
     _repo.subscribeToAdds(subscriptionName,
@@ -130,6 +132,41 @@
 
 void HostNotifier::commandResponse(ResponseStatus status)
 {
+    auto id = _inProgressPEL;
+    _inProgressPEL = 0;
+
+    if (status == ResponseStatus::success)
+    {
+        _retryCount = 0;
+
+        _sentPELs.push_back(id);
+
+        _repo.setPELHostTransState(id, TransmissionState::sent);
+
+        if (!_pelQueue.empty())
+        {
+            doNewLogNotify();
+        }
+    }
+    else
+    {
+        log<level::ERR>("PLDM command response failure",
+                        entry("PEL_ID=0x%X", id));
+        // Retry
+        _pelQueue.push_front(id);
+        _retryTimer.restartOnce(_hostIface->getReceiveRetryDelay());
+    }
+}
+
+void HostNotifier::retryTimerExpired()
+{
+    if (_dataIface.isHostUp())
+    {
+        log<level::INFO>("Attempting command retry",
+                         entry("PEL_ID=0x%X", _pelQueue.front()));
+        _retryCount++;
+        doNewLogNotify();
+    }
 }
 
 } // namespace openpower::pels