Skip to content

Commit cf48499

Browse files
committed
[cru] Get effective superpage size from the firmware
1 parent 39ea19f commit cf48499

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

src/Cru/Constants.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace Registers
4545
/// * bit 0: Flow control
4646
static constexpr Register DMA_CONTROL(0x00000200);
4747

48-
/// Interval for link BAR addresses
48+
/// Link interval for superpage addresses to push
4949
static constexpr uintptr_t LINK_INTERVAL = 0x10;
5050

5151
/// High address of superpage
@@ -55,13 +55,16 @@ static constexpr IntervalRegister LINK_SUPERPAGE_ADDRESS_HIGH(0x00000204, LINK_I
5555
static constexpr IntervalRegister LINK_SUPERPAGE_ADDRESS_LOW(0x00000208, LINK_INTERVAL);
5656

5757
/// Size of the superpage in 8KiB pages
58-
static constexpr IntervalRegister LINK_SUPERPAGE_SIZE(0x0000020c, LINK_INTERVAL);
58+
static constexpr IntervalRegister LINK_SUPERPAGE_PAGES(0x0000020c, LINK_INTERVAL);
5959

60-
/// Interval for SUPERPAGES_PUSHED addresses
61-
static constexpr uintptr_t SUPERPAGES_PUSHED_INTERVAL = 0x4;
60+
/// Link interval for superpage ready addresses
61+
static constexpr uintptr_t SUPERPAGES_READY_INTERVAL = 0x4;
6262

63-
/// Amount of completely pushed superpages
64-
static constexpr IntervalRegister LINK_SUPERPAGES_PUSHED(0x00000800, SUPERPAGES_PUSHED_INTERVAL);
63+
/// Amount of ready superpages
64+
static constexpr IntervalRegister LINK_SUPERPAGE_COUNT(0x00000800, SUPERPAGES_READY_INTERVAL);
65+
66+
// FIFO containing the size of the ready superpages
67+
static constexpr IntervalRegister LINK_SUPERPAGE_SIZE(0x00000840, SUPERPAGES_READY_INTERVAL);
6568

6669
/// Enable/disable links
6770
/// Every bit represents a link. Set a bit to 0 to disable a link.

src/Cru/CruBar.cxx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,24 @@ void CruBar::pushSuperpageDescriptor(uint32_t link, uint32_t pages, uintptr_t bu
117117
writeRegister(Cru::Registers::LINK_SUPERPAGE_ADDRESS_LOW.get(link).index,
118118
Utilities::getLower32Bits(busAddress));
119119
// Set superpage size. This write signals the push of the descriptor into the link's FIFO.
120-
writeRegister(Cru::Registers::LINK_SUPERPAGE_SIZE.get(link).index, pages);
120+
writeRegister(Cru::Registers::LINK_SUPERPAGE_PAGES.get(link).index, pages);
121121
}
122122

123123
/// Get amount of superpages pushed by a link
124124
/// \param link Link number
125125
uint32_t CruBar::getSuperpageCount(uint32_t link)
126126
{
127-
return readRegister(Cru::Registers::LINK_SUPERPAGES_PUSHED.get(link).index);
127+
return readRegister(Cru::Registers::LINK_SUPERPAGE_COUNT.get(link).index);
128+
}
129+
130+
uint32_t CruBar::getSuperpageSize(uint32_t link)
131+
{
132+
writeRegister(Cru::Registers::LINK_SUPERPAGE_SIZE.get(link).index, 0xbadcafe); // write a dummy value to update the FIFO
133+
uint32_t superpageSizeFifo = readRegister(Cru::Registers::LINK_SUPERPAGE_SIZE.get(link).index);
134+
uint32_t superpageSize = Utilities::getBits(superpageSizeFifo, 0, 23); // [0-23] -> superpage size (in bytes)
135+
//uint32_t superpageIndex = Utilities::getBits(superpageSizeFifo, 24, 31); // [24-31] -> superpage index (0-255) for _testing_
136+
137+
return superpageSize;
128138
}
129139

130140
/// Enables the data emulator

src/Cru/CruBar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class CruBar final : public BarInterfaceBase
6464

6565
void pushSuperpageDescriptor(uint32_t link, uint32_t pages, uintptr_t busAddress);
6666
uint32_t getSuperpageCount(uint32_t link);
67+
uint32_t getSuperpageSize(uint32_t link);
6768
void setDataEmulatorEnabled(bool enabled);
6869
void resetDataGeneratorCounter();
6970
void resetCard();

src/Cru/CruDmaChannel.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,12 @@ void CruDmaChannel::transferSuperpageFromLinkToReady(Link& link)
275275
}
276276

277277
link.queue.front().setReady(true);
278-
link.queue.front().setReceived(link.queue.front().getSize()); //TODO: Update this with the effective superpage size when available
278+
uint32_t superpageSize = getBar()->getSuperpageSize(link.id);
279+
if (superpageSize == 0) { //backwards compatible in case the superpage size register is empty
280+
link.queue.front().setReceived(link.queue.front().getSize()); // force the full superpage size
281+
} else {
282+
link.queue.front().setReceived(getBar()->getSuperpageSize(link.id));
283+
}
279284
mReadyQueue.push_back(link.queue.front());
280285
link.queue.pop_front();
281286
link.superpageCounter++;
@@ -285,8 +290,8 @@ void CruDmaChannel::transferSuperpageFromLinkToReady(Link& link)
285290
void CruDmaChannel::fillSuperpages()
286291
{
287292
// Check for arrivals & handle them
288-
const auto size = mLinks.size();
289-
for (LinkIndex linkIndex = 0; linkIndex < size; ++linkIndex) {
293+
const auto links = mLinks.size();
294+
for (LinkIndex linkIndex = 0; linkIndex < links; ++linkIndex) {
290295
auto& link = mLinks[linkIndex];
291296
uint32_t superpageCount = getBar()->getSuperpageCount(link.id);
292297
auto available = superpageCount > link.superpageCounter;

src/Cru/cru_constants_populate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
'add_pcie_dma_ctrl':'DMA_CONTROL',
88
'add_pcie_dma_desc_h':'LINK_SUPERPAGE_ADDRESS_HIGH',
99
'add_pcie_dma_desc_l':'LINK_SUPERPAGE_ADDRESS_LOW',
10-
'add_pcie_dma_desc_sz':'LINK_SUPERPAGE_SIZE',
11-
'add_pcie_dma_spg0_ack':'LINK_SUPERPAGES_PUSHED',
10+
'add_pcie_dma_desc_sz':'LINK_SUPERPAGE_PAGES',
11+
'add_pcie_dma_spg0_ack':'LINK_SUPERPAGES_COUNT',
1212
'add_pcie_dma_ddg_cfg0':'DATA_GENERATOR_CONTROL',
1313
'add_pcie_dma_ddg_cfg2':'DATA_GENERATOR_INJECT_ERROR',
1414
'add_pcie_dma_data_sel':'DATA_SOURCE_SELECT',

0 commit comments

Comments
 (0)