Skip to content

Commit 2966e6f

Browse files
committed
[crorc] SP count as member variable instead of scoped static
1 parent 315abd1 commit 2966e6f

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

src/Crorc/CrorcDmaChannel.cxx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,6 @@ bool CrorcDmaChannel::pushSuperpage(Superpage superpage)
242242
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not push superpage, transfer queue was full"));
243243
}
244244

245-
auto busAddress = getBusOffsetAddress(superpage.getOffset());
246-
getBar()->pushSuperpageAddressAndSize(busAddress, superpage.getSize());
247-
248245
mTransferQueue.write(superpage);
249246

250247
return true;
@@ -262,16 +259,15 @@ auto CrorcDmaChannel::popSuperpage() -> Superpage
262259

263260
bool CrorcDmaChannel::isASuperpageAvailable()
264261
{
265-
static uint32_t count = 0xff;
266262
uint32_t newCount = getSuperpageInfoUser()->count;
267263
uint32_t diff;
268264

269-
if (newCount < count) { // handle overflow
265+
if (newCount < mSPAvailCount) { // handle overflow
270266
diff = ((0xff + 1) - 0xff) + newCount;
271267
} else {
272-
diff = newCount - count;
268+
diff = newCount - mSPAvailCount;
273269
}
274-
count = newCount;
270+
mSPAvailCount = newCount;
275271

276272
return diff > 0;
277273
}
@@ -288,13 +284,24 @@ void CrorcDmaChannel::fillSuperpages()
288284
}
289285

290286
// Check for arrivals & handle them
291-
if (!mTransferQueue.isEmpty() && isASuperpageAvailable()) {
287+
if (!mIntermediateQueue.isEmpty() && isASuperpageAvailable()) {
292288

293-
auto superpage = mTransferQueue.frontPtr();
289+
auto superpage = mIntermediateQueue.frontPtr();
294290
superpage->setReceived(getSuperpageInfoUser()->size); // length in bytes
295291
superpage->setReady(true);
296292
mReadyQueue.write(*superpage);
293+
mIntermediateQueue.popFront();
294+
}
295+
296+
// Push single Superpage to the firmware when available
297+
if (mIntermediateQueue.isEmpty() && !mTransferQueue.isEmpty()) {
298+
auto inSuperpage = mTransferQueue.frontPtr();
297299
mTransferQueue.popFront();
300+
301+
auto busAddress = getBusOffsetAddress(inSuperpage->getOffset());
302+
getBar()->pushSuperpageAddressAndSize(busAddress, inSuperpage->getSize());
303+
304+
mIntermediateQueue.write(*inSuperpage);
298305
}
299306
}
300307

src/Crorc/CrorcDmaChannel.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ class CrorcDmaChannel final : public DmaChannelPdaBase
7676
static constexpr size_t DMA_PAGE_SIZE = 8 * 1024;
7777

7878
/// Max amount of superpages in the transfer queue (i.e. pending transfer).
79-
/// CRORC FW only handles a single superpage at a time
80-
static constexpr size_t TRANSFER_QUEUE_CAPACITY = 1;
79+
static constexpr size_t TRANSFER_QUEUE_CAPACITY = 128;
8180
static constexpr size_t TRANSFER_QUEUE_CAPACITY_ALLOCATIONS = TRANSFER_QUEUE_CAPACITY + 1; // folly Queue needs + 1
8281

82+
/// Max amount of superpages in the intermediate queue (i.e. pushed superpage).
83+
/// CRORC FW only handles a single superpage at a time
84+
static constexpr size_t INTERMEDIATE_QUEUE_CAPACITY = 1;
85+
static constexpr size_t INTERMEDIATE_QUEUE_CAPACITY_ALLOCATIONS = INTERMEDIATE_QUEUE_CAPACITY + 1;
86+
8387
/// Max amount of superpages in the ready queue (i.e. finished transfer).
8488
/// This is an arbitrary size, can easily be increased if more headroom is needed.
8589
static constexpr size_t READY_QUEUE_CAPACITY = TRANSFER_QUEUE_CAPACITY;
@@ -120,9 +124,12 @@ class CrorcDmaChannel final : public DmaChannelPdaBase
120124
/// BAR used for DMA engine and configuration
121125
std::shared_ptr<CrorcBar> crorcBar;
122126

123-
/// Queue for superpages that are pushed to the firmware FIFO
127+
/// Queue for superpages that are pushed from the Readout thread
124128
SuperpageQueue mTransferQueue{ TRANSFER_QUEUE_CAPACITY_ALLOCATIONS };
125129

130+
/// Queue for the superpage that is pushed to the firmware
131+
SuperpageQueue mIntermediateQueue{ INTERMEDIATE_QUEUE_CAPACITY_ALLOCATIONS };
132+
126133
/// Queue for superpages that are filled
127134
SuperpageQueue mReadyQueue{ READY_QUEUE_CAPACITY_ALLOCATIONS };
128135

@@ -165,6 +172,9 @@ class CrorcDmaChannel final : public DmaChannelPdaBase
165172
{
166173
return reinterpret_cast<SuperpageInfo*>(mSuperpageInfoAddressUser);
167174
}
175+
176+
// Counter for the available (from the fw) superpages
177+
uint32_t mSPAvailCount = 0xff;
168178
};
169179

170180
} // namespace roc

0 commit comments

Comments
 (0)