From 972979cc10c88279118ee3b4ca9662183def32e1 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Sat, 1 Nov 2025 20:18:05 -0400 Subject: [PATCH] IoUringAssmEngine: Remove dead wood --- .../livoxGen1/ioUringAssemblyEngine.cpp | 102 +++--------------- .../livoxGen1/ioUringAssemblyEngine.h | 30 ------ 2 files changed, 13 insertions(+), 119 deletions(-) diff --git a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp index 74557bb..64a064c 100644 --- a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp +++ b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.cpp @@ -6,98 +6,22 @@ namespace smo { namespace stim_buff { -namespace { struct DummyLivoxEthHeader { - uint8_t version; - uint8_t slot; - uint8_t id; - uint8_t rsvd; + enum : uint32_t { + INVALID_ERR_CODE = 0xFFFFFFFFu + }; + enum : uint8_t { + INVALID_TIMESTAMP_TYPE = 0xFFu, + INVALID_DATA_TYPE = 0xFFu + }; + + uint8_t version, slot, id, rsvd; uint32_t err_code; - uint8_t timestamp_type; - uint8_t data_type; + uint8_t timestamp_type, data_type; uint8_t timestamp[8]; }; -constexpr uint32_t kInvalidErrCode = 0xFFFFFFFFu; -constexpr uint8_t kInvalidTimestampType = 0xFFu; -constexpr uint8_t kInvalidDataType = 0xFFu; -} - -IoUringAssemblyEngine::IoUringAssemblyEngine() -: udpFd(-1), running(false), paused(false), frameCb(nullptr), -desc(nullptr), frameBase(nullptr), frameStrideBytes(0), -timeoutMs(15), frameIndex(0) -{} - -bool IoUringAssemblyEngine::setSocketFromDevice( - const std::shared_ptr& device - ) -{ - if (!device) { return false; } - - // Expect device to expose pcloudDataSocketDesc() - udpFd = device->pcloudDataSocketDesc->native_handle(); - return (udpFd >= 0); -} -bool IoUringAssemblyEngine::start( - FrameAssemblyDesc& descRef, uint8_t* frameBasePtr, - size_t frameStrideBytesArg, uint32_t timeoutMsArg - ) -{ - if (udpFd < 0 || !frameBasePtr || descRef.slots.empty()) - { return false; } - - desc = &descRef; - frameBase = frameBasePtr; - frameStrideBytes = frameStrideBytesArg; - timeoutMs = timeoutMsArg; - paused.store(false); - running.store(true); - // Placeholder: actual io_uring submission/handling would run in a dedicated thread - // For now, assume synchronous loop stub - postReceives(); - handleCqesAndTimeout(); - return true; -} - -void IoUringAssemblyEngine::pause() -{ - paused.store(true); -} - -void IoUringAssemblyEngine::resume() -{ - if (!running.load()) - { return; } - - paused.store(false); - postReceives(); -} - -void IoUringAssemblyEngine::stop() -{ - running.store(false); -} - -void IoUringAssemblyEngine::onFrameComplete(FrameCompleteCallback cb) -{ - frameCb = std::move(cb); -} - -void IoUringAssemblyEngine::postReceives() -{ - // Intentionally left minimal; real implementation will submit N RECVMSG SQEs -} - -void IoUringAssemblyEngine::handleCqesAndTimeout() -{ - // Intentionally left minimal; real implementation will poll CQEs with timeout - cancelIncompleteAndFillDummies(); - if (frameCb) - { frameCb(frameIndex++); } -} - void IoUringAssemblyEngine::cancelIncompleteAndFillDummies() { if (!desc) @@ -108,9 +32,9 @@ void IoUringAssemblyEngine::cancelIncompleteAndFillDummies() // In the real path, decide from CQE accounting whether slot i completed. // Here, demonstrate dummy header insertion API. auto* hdr = reinterpret_cast(desc->slots[i].vaddr); - hdr->err_code = kInvalidErrCode; - hdr->timestamp_type = kInvalidTimestampType; - hdr->data_type = kInvalidDataType; + hdr->err_code = DummyLivoxEthHeader::INVALID_ERR_CODE; + hdr->timestamp_type = DummyLivoxEthHeader::INVALID_TIMESTAMP_TYPE; + hdr->data_type = DummyLivoxEthHeader::INVALID_DATA_TYPE; } } diff --git a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h index 538e6d8..9d15d87 100644 --- a/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h +++ b/stimBuffApis/livoxGen1/ioUringAssemblyEngine.h @@ -19,48 +19,18 @@ namespace stim_buff { class IoUringAssemblyEngine { public: - using FrameCompleteCallback = std::function; - IoUringAssemblyEngine(); ~IoUringAssemblyEngine() = default; - // Configure UDP socket by querying the device's pcloud data socket descriptor - bool setSocketFromDevice(const std::shared_ptr& device); - - // Start posting N RECVMSG SQEs based on the descriptor; timeoutMs defaults to 15ms - bool start( - FrameAssemblyDesc& desc, - uint8_t* frameBase, - size_t frameStrideBytes, - uint32_t timeoutMs = 15); - - void pause(); - void resume(); - void stop(); - - void onFrameComplete(FrameCompleteCallback cb); - // Telemetry helpers static size_t computePointsPerDgram(int returnMode); static size_t computePointsPerFrame(int returnMode, size_t nDgramsPerFrame) { return computePointsPerDgram(returnMode) * nDgramsPerFrame; } private: - int udpFd; - std::atomic running; - std::atomic paused; - FrameCompleteCallback frameCb; - // Cached descriptor for reuse across iterations FrameAssemblyDesc* desc; - uint8_t* frameBase; - size_t frameStrideBytes; - uint32_t timeoutMs; - size_t frameIndex; - // Internal helpers - void postReceives(); - void handleCqesAndTimeout(); void cancelIncompleteAndFillDummies(); };