Skip to content

Commit e8da53f

Browse files
committed
[dma-channel] Interface for Superpage FIFO empty counters
1 parent 879aead commit e8da53f

File tree

8 files changed

+40
-0
lines changed

8 files changed

+40
-0
lines changed

include/ReadoutCard/DmaChannelInterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ class DmaChannelInterface
9696
// Returns the number of dropped packets, as reported by the BAR
9797
virtual int32_t getDroppedPackets() = 0;
9898

99+
// Reports the state of the Superpage FIFOs
100+
virtual bool areSuperpageFifosHealthy() = 0;
101+
99102
/// Stops DMA for the given channel.
100103
/// Called automatically on channel closure.
101104
/// This moves any remaining superpages to the "ready queue", even if they are not filled.

src/Crorc/CrorcDmaChannel.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ int32_t CrorcDmaChannel::getDroppedPackets()
339339
return -1;
340340
}
341341

342+
bool CrorcDmaChannel::areSuperpageFifosHealthy()
343+
{
344+
return true;
345+
}
346+
342347
void CrorcDmaChannel::pushFreeFifoPage(int readyFifoIndex, uintptr_t pageBusAddress, int pageSize)
343348
{
344349
size_t pageWords = pageSize / 4; // Size in 32-bit words

src/Crorc/CrorcDmaChannel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class CrorcDmaChannel final : public DmaChannelPdaBase
5959
virtual bool isTransferQueueEmpty() override;
6060
virtual bool isReadyQueueFull() override;
6161
virtual int32_t getDroppedPackets() override;
62+
virtual bool areSuperpageFifosHealthy() override;
6263

6364
AllowedChannels allowedChannels();
6465

src/Cru/Constants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ static constexpr IntervalRegister LINK_SUPERPAGE_COUNT(0x00000800, SUPERPAGES_RE
6666
// FIFO containing the size of the ready superpages
6767
static constexpr IntervalRegister LINK_SUPERPAGE_SIZE(0x00000840, SUPERPAGES_READY_INTERVAL);
6868

69+
// Counter for the times a link's Superpage FIFO is empty
70+
static constexpr IntervalRegister LINK_SUPERPAGE_FIFO_EMPTY(0x00000880, SUPERPAGES_READY_INTERVAL);
71+
6972
/// Enable/disable links
7073
/// Every bit represents a link. Set a bit to 0 to disable a link.
7174
//static constexpr Register LINKS_ENABLE = 0x604;

src/Cru/CruBar.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ uint32_t CruBar::getSuperpageSize(uint32_t link)
165165
return superpageSize;
166166
}
167167

168+
uint32_t CruBar::getSuperpageFifoEmptyCounter(uint32_t link)
169+
{
170+
if (link >= Cru::MAX_LINKS) {
171+
BOOST_THROW_EXCEPTION(InvalidLinkId() << ErrorInfo::Message("Link ID out of range") << ErrorInfo::LinkId(link));
172+
}
173+
return readRegister(Cru::Registers::LINK_SUPERPAGE_FIFO_EMPTY.get(link).index);
174+
}
175+
168176
/// Signals the CRU DMA engine to start
169177
void CruBar::startDmaEngine()
170178
{

src/Cru/CruBar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class CruBar final : public BarInterfaceBase
6767
void pushSuperpageDescriptor(uint32_t link, uint32_t pages, uintptr_t busAddress);
6868
uint32_t getSuperpageCount(uint32_t link);
6969
uint32_t getSuperpageSize(uint32_t link);
70+
uint32_t getSuperpageFifoEmptyCounter(uint32_t link);
7071
void startDmaEngine();
7172
void stopDmaEngine();
7273
void resetDataGeneratorCounter();

src/Cru/CruDmaChannel.cxx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,24 @@ int32_t CruDmaChannel::getDroppedPackets()
403403
return getBar2()->getDroppedPackets(endpoint);
404404
}
405405

406+
bool CruDmaChannel::areSuperpageFifosHealthy()
407+
{
408+
bool ok = true;
409+
static std::unordered_map<int, uint32_t> counters;
410+
411+
for (const auto& link : mLinks) {
412+
uint32_t emptyCounter = getBar()->getSuperpageFifoEmptyCounter(link.id);
413+
if (counters.count(link.id) && //only check after the counters map has been initialized
414+
counters[link.id] != emptyCounter) {
415+
log((format("Empty counter of Superpage FIFO of link %1% increased") % link.id).str(), LogWarningDevel);
416+
ok = false;
417+
}
418+
counters[link.id] = emptyCounter;
419+
}
420+
421+
return ok;
422+
}
423+
406424
bool CruDmaChannel::injectError()
407425
{
408426
if (!mDataSource == DataSource::Fee) {

src/Cru/CruDmaChannel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class CruDmaChannel final : public DmaChannelPdaBase
5252
virtual bool isTransferQueueEmpty() override;
5353
virtual bool isReadyQueueFull() override;
5454
virtual int32_t getDroppedPackets() override;
55+
virtual bool areSuperpageFifosHealthy() override;
5556

5657
virtual bool injectError() override;
5758
virtual boost::optional<int32_t> getSerial() override;

0 commit comments

Comments
 (0)