Skip to content

Commit ecde517

Browse files
committed
[cru] Limit DMA links from 0 to 11 per endpoint
1 parent 1557c04 commit ecde517

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

src/Cru/Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Cru
2727
{
2828

2929
/// Maximum amount of available links
30-
static constexpr int MAX_LINKS = 32;
30+
static constexpr int MAX_LINKS = 12;
3131

3232
/// Amount of available superpage descriptors per link
3333
static constexpr int MAX_SUPERPAGE_DESCRIPTORS = 128;

src/Cru/CruBar.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ CruBar::CruBar(const Parameters& parameters, std::unique_ptr<RocPciDevice> rocPc
6767
} else {
6868
mAllowRejection = 0x0;
6969
}
70+
71+
mEndpoint = mRocPciDevice->getSerialId().getEndpoint();
7072
}
7173

7274
CruBar::CruBar(std::shared_ptr<Pda::PdaBar> bar)
@@ -141,7 +143,6 @@ uint32_t CruBar::getSuperpageSize(uint32_t link)
141143
uint32_t superpageSizeIndex = Utilities::getBits(superpageSizeFifo, 24, 31); // [24-31] -> superpage index (0-255)
142144

143145
while (superpageSizeIndex != mSuperpageSizeIndexCounter[link]) { // In case the PCIe bus wasn't fast enough
144-
//std::cout << "[SP INDEX] link " << link << " : " << superpageSizeIndex << " instead of " << mSuperpageSizeIndexCounter[link] << std::endl;
145146
superpageSizeFifo = readRegister(Cru::Registers::LINK_SUPERPAGE_SIZE.get(link).index);
146147
superpageSize = Utilities::getBits(superpageSizeFifo, 0, 23);
147148
superpageSizeIndex = Utilities::getBits(superpageSizeFifo, 24, 31);
@@ -606,7 +607,10 @@ std::map<int, Link> CruBar::initializeLinkMap()
606607
uint32_t address = Cru::getWrapperBaseAddress(wrapper) + Cru::Registers::GBT_WRAPPER_CONF0.address;
607608
uint32_t wrapperConfig = readRegister(address / 4);
608609

609-
for (int bank = 0; bank < 6; bank++) {
610+
for (int bank = mEndpoint * 2; bank < (mEndpoint * 2 + 2); bank++) {
611+
//for (int bank = 0; bank < 4; bank++) { //for 0-23 range
612+
// endpoint 0 -> banks {0,1}
613+
// endpoint 1 -> banks {2,3}
610614
int dwrapper = (bank < 2) ? 0 : 1;
611615
int lpbLSB = (4 * bank) + 4;
612616
int lpbMSB = lpbLSB + 4 - 1;
@@ -638,7 +642,8 @@ std::map<int, Link> CruBar::initializeLinkMap()
638642
std::map<int, Link> newLinkMap;
639643
for (std::size_t i = 0; i < links.size(); i++) {
640644
Link link = links.at(i);
641-
int newPos = (i - link.bank * 6) * 2 + 12 * (int)(link.bank / 2) + (link.bank % 2);
645+
int newPos = (i - (link.bank - mEndpoint * 2) * 6) * 2 + (link.bank % 2);
646+
//int newPos = (i - link.bank * 6) * 2 + + 12 * (int)(link.bank/2) + (link.bank % 2); //for 0-23 range
642647
link.dwrapperId = newPos % 12;
643648
newLinkMap.insert({ newPos, link });
644649
}

src/Cru/CruBar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class CruBar final : public BarInterfaceBase
136136
bool mDynamicOffset;
137137
uint32_t mTriggerWindowSize;
138138

139+
int mEndpoint;
140+
139141
/// Per-link counter to verify superpage sizes received are valid
140142
uint32_t mSuperpageSizeIndexCounter[Cru::MAX_LINKS] = { 0 };
141143

src/Cru/CruDmaChannel.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ CruDmaChannel::CruDmaChannel(const Parameters& parameters)
7777
mLinks.reserve(linkMask.size());
7878
for (uint32_t id : linkMask) {
7979
if (id >= Cru::MAX_LINKS) {
80-
BOOST_THROW_EXCEPTION(InvalidLinkId() << ErrorInfo::Message("CRU does not support given link ID")
80+
BOOST_THROW_EXCEPTION(InvalidLinkId() << ErrorInfo::Message("Each endpoint supports up to 12 links.")
8181
<< ErrorInfo::LinkId(id));
8282
}
8383
stream << id << " ";

src/Parameters.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ auto Parameters::linkMaskFromString(const std::string& string) -> LinkMaskType
180180
{
181181
std::set<uint32_t> links;
182182

183+
auto checkLink = [](int link) {
184+
if (!(link >= 0 && link < 12)) {
185+
BOOST_THROW_EXCEPTION(
186+
ParseException() << ErrorInfo::Message(std::string("Link: " + std::to_string(link) + " out of [0-11] range")));
187+
}
188+
return;
189+
};
190+
183191
try {
184192
// Separate by comma
185193
std::vector<std::string> commaSeparateds;
@@ -195,9 +203,12 @@ auto Parameters::linkMaskFromString(const std::string& string) -> LinkMaskType
195203
auto start = boost::lexical_cast<uint32_t>(dashSeparateds[0]);
196204
auto end = boost::lexical_cast<uint32_t>(dashSeparateds[1]);
197205
for (uint32_t i = start; i <= end; ++i) {
206+
checkLink(i);
198207
links.insert(i);
199208
}
200209
} else {
210+
uint32_t link = boost::lexical_cast<uint32_t>(commaSeparated);
211+
checkLink(link);
201212
links.insert(boost::lexical_cast<uint32_t>(commaSeparated));
202213
}
203214
}

src/RocPciDevice.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "ReadoutCard/CardDescriptor.h"
2525
#include "ReadoutCard/Parameters.h"
2626
#include "ReadoutCard/ParameterTypes/PciAddress.h"
27+
#include "ReadoutCard/ParameterTypes/SerialId.h"
2728
#include "ReadoutCard/PciId.h"
2829

2930
namespace AliceO2
@@ -64,9 +65,9 @@ class RocPciDevice
6465
return mPciDevice;
6566
}
6667

67-
int getSerialId() const //TODO: Could be used for logging?
68+
SerialId getSerialId() const
6869
{
69-
return mDescriptor.serialId.getSerial();
70+
return mDescriptor.serialId;
7071
}
7172

7273
std::shared_ptr<Pda::PdaBar> getBar(int barIndex)

0 commit comments

Comments
 (0)