diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2017-03-14 18:20:20 +0530 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-04-24 11:22:15 -0500 |
commit | 7306314f605c6232218144db10ae446a367dbe2e (patch) | |
tree | 2f3d1cb69f6622432937dae690bdf3c7a4a795cb | |
parent | 75e15db4629d0ca1f8a418abec2fb45b45babb31 (diff) | |
download | phosphor-net-ipmid-7306314f605c6232218144db10ae446a367dbe2e.tar.gz phosphor-net-ipmid-7306314f605c6232218144db10ae446a367dbe2e.zip |
Implement API to send SOL payload when console data is available
Change-Id: I7869d389b589c59e0c76000da9bfd72b9e67c064
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
-rw-r--r-- | sd_event_loop.cpp | 11 | ||||
-rw-r--r-- | sol/sol_context.cpp | 33 |
2 files changed, 43 insertions, 1 deletions
diff --git a/sd_event_loop.cpp b/sd_event_loop.cpp index 0272e6c..350a96c 100644 --- a/sd_event_loop.cpp +++ b/sd_event_loop.cpp @@ -103,13 +103,22 @@ static int charAccTimerHandler(sd_event_source* s, uint64_t usec, // The instance is hardcoded to 1, in the case of supporting multiple // payload instances we would need to populate it from userdata uint8_t instance = 1; + int rc = 0; auto bufferSize = std::get<sol::Manager&>(singletonPool).dataBuffer.size(); try { if(bufferSize > 0) { - // Send the SOL payload + auto& context = std::get<sol::Manager&>(singletonPool).getContext + (instance); + + rc = context.sendOutboundPayload(); + + if (rc == 0) + { + return 0; + } } std::get<eventloop::EventLoop&>(singletonPool).switchTimer( diff --git a/sol/sol_context.cpp b/sol/sol_context.cpp index ee0eb39..24339f0 100644 --- a/sol/sol_context.cpp +++ b/sol/sol_context.cpp @@ -150,6 +150,39 @@ void Context::prepareResponse(uint8_t ackSeqNum, uint8_t count, bool ack) sendPayload(payloadCache); } +int Context::sendOutboundPayload() +{ + if (payloadCache.size() != 0) + { + std::get<eventloop::EventLoop&>(singletonPool).switchTimer( + payloadInstance, eventloop::Timers::ACCUMULATE, true); + return -1; + } + + auto bufferSize = std::get<sol::Manager&>(singletonPool).dataBuffer.size(); + auto readSize = std::min(bufferSize, MAX_PAYLOAD_SIZE); + + payloadCache.resize(sizeof(Payload) + readSize); + auto response = reinterpret_cast<Payload*>(payloadCache.data()); + response->packetAckSeqNum = 0; + response->acceptedCharCount = 0; + response->outOperation.ack = false; + response->packetSeqNum = seqNums.incOutboundSeqNum(); + + auto handle = std::get<sol::Manager&>(singletonPool).dataBuffer.read(); + std::copy_n(handle, readSize, payloadCache.data() + sizeof(Payload)); + expectedCharCount = readSize; + + std::get<eventloop::EventLoop&>(singletonPool).switchTimer( + payloadInstance, eventloop::Timers::RETRY, true); + std::get<eventloop::EventLoop&>(singletonPool).switchTimer( + payloadInstance, eventloop::Timers::ACCUMULATE, false); + + sendPayload(payloadCache); + + return 0; +} + void Context::resendPayload(bool clear) { |