nvidia-gpu: Fix up buffering in MctpRequester

This change does a lot, for better or worse
1. Change MctpRequester to hold both buffers for send and receive
2. This requires changing the callback structure, so the reach is far
3. Changes error reporting to be through std::error_code
4. Collapses the QueuingRequeuster and Requeuster to be MctpRequeuster
5. Doing 4 gets rid of a level indirection and an extra unordered_map
6. Adds proper iid support, which is made significantly easier by 4/5
7. Fixes issues around expiry timer's where we would cancel the timer
   for a given request whenever a new packet would come in to be sent.
   This could cause lockup if a packet truly did time out and an
   interleaved packet finished sending. This moves each queue
   to have its own timer.

This fixes an issue where we were receiving buffers in from clients
and then binding them to receive_calls without ensuring that they
are the correct message, thus when receive was called, it was called
with the last bound buffer to async_receive_from. This would cause a
number of issues, ranging from incorrect device discovery results
to core dumps as well as incorrect sensor readings.

This change moves the receive and send buffers to be owned by
the MctpRequester, and a non-owning view is provided via
callback to the client. All existing clients just decode in place
given that buffer.

Tested: loaded onto nvl32-obmc. Correct number of sensors showed up
and the readings were nominal

Change-Id: I67c843691ca79e9fcccfa16df6d611918f25f6ca
Signed-off-by: Marc Olberding <molberding@nvidia.com>
diff --git a/src/nvidia-gpu/NvidiaGpuPowerPeakReading.cpp b/src/nvidia-gpu/NvidiaGpuPowerPeakReading.cpp
index 06693e6..839dfe4 100644
--- a/src/nvidia-gpu/NvidiaGpuPowerPeakReading.cpp
+++ b/src/nvidia-gpu/NvidiaGpuPowerPeakReading.cpp
@@ -20,7 +20,9 @@
 #include <cstdint>
 #include <functional>
 #include <memory>
+#include <span>
 #include <string>
+#include <system_error>
 
 using namespace std::literals;
 
@@ -50,13 +52,14 @@
     objectServer.remove_interface(telemetryReportInterface);
 }
 
-void NvidiaGpuPowerPeakReading::processResponse(int sendRecvMsgResult)
+void NvidiaGpuPowerPeakReading::processResponse(const std::error_code& ec,
+                                                std::span<const uint8_t> buffer)
 {
-    if (sendRecvMsgResult != 0)
+    if (ec)
     {
         lg2::error(
             "Error updating Peak Power Sensor for eid {EID} and sensor id {SID} : sending message over MCTP failed, rc={RC}",
-            "EID", eid, "SID", sensorId, "RC", sendRecvMsgResult);
+            "EID", eid, "SID", sensorId, "RC", ec.message());
         return;
     }
 
@@ -65,7 +68,7 @@
     uint32_t peakPower = 0;
 
     const int rc =
-        gpu::decodeGetPowerDrawResponse(response, cc, reasonCode, peakPower);
+        gpu::decodeGetPowerDrawResponse(buffer, cc, reasonCode, peakPower);
 
     if (rc != 0 || cc != ocp::accelerator_management::CompletionCode::SUCCESS)
     {
@@ -97,6 +100,8 @@
     }
 
     mctpRequester.sendRecvMsg(
-        eid, request, response,
-        [this](int sendRecvMsgResult) { processResponse(sendRecvMsgResult); });
+        eid, request,
+        [this](const std::error_code& ec, std::span<const uint8_t> buffer) {
+            processResponse(ec, buffer);
+        });
 }