Skip to content

Commit 351a516

Browse files
committed
[cru/dma] Data taking links should be enabled and up
1 parent 8070933 commit 351a516

File tree

5 files changed

+53
-38
lines changed

5 files changed

+53
-38
lines changed

src/Cru/CruBar.cxx

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ Cru::ReportInfo CruBar::report(bool forConfig)
498498
for (auto& el : linkMap) {
499499
auto& link = el.second;
500500
link.datapathMode = datapathWrapper.getDatapathMode(link);
501-
link.enabled = datapathWrapper.getLinkEnabled(link);
501+
link.enabled = datapathWrapper.isLinkEnabled(link);
502502
link.allowRejection = datapathWrapper.getFlowControl(link.dwrapper);
503503
link.stickyBit = gbt.getStickyBit(link);
504504
link.rxFreq = gbt.getRxClockFrequency(link) / 1e6; // Hz -> Mhz
@@ -534,12 +534,12 @@ Cru::ReportInfo CruBar::report(bool forConfig)
534534
Link userLogicLink;
535535
userLogicLink.dwrapper = mEndpoint;
536536
userLogicLink.dwrapperId = 15;
537-
bool userLogicEnabled = datapathWrapper.getLinkEnabled(userLogicLink);
537+
bool userLogicEnabled = datapathWrapper.isLinkEnabled(userLogicLink);
538538

539539
Link runStatsLink;
540540
runStatsLink.dwrapper = mEndpoint;
541541
runStatsLink.dwrapperId = (mEndpoint == 0) ? 13 : 14;
542-
bool runStatsEnabled = datapathWrapper.getLinkEnabled(runStatsLink);
542+
bool runStatsEnabled = datapathWrapper.isLinkEnabled(runStatsLink);
543543

544544
bool userAndCommonLogicEnabled = datapathWrapper.getUserAndCommonLogicEnabled(mEndpoint);
545545
uint16_t timeFrameLength = getTimeFrameLength();
@@ -913,6 +913,46 @@ std::map<int, Link> CruBar::initializeLinkMap()
913913
return newLinkMap;
914914
}
915915

916+
// Returns a vector of the link ids that should participate in data taking
917+
// A link participates in data taking if it is enabled in the datapath and is not down
918+
std::vector<int> CruBar::getDataTakingLinks()
919+
{
920+
std::vector<int> links;
921+
DatapathWrapper datapathWrapper = DatapathWrapper(mPdaBar);
922+
auto linkMap = initializeLinkMap();
923+
if (mWrapperCount == 0) {
924+
setWrapperCount();
925+
}
926+
Gbt gbt = Gbt(mPdaBar, linkMap, mWrapperCount, mEndpoint);
927+
928+
// Insert GBT links
929+
for (auto const& el : linkMap) {
930+
int id = el.first;
931+
Link link = el.second;
932+
if (!datapathWrapper.isLinkEnabled(link) || gbt.getStickyBit(link) == Cru::LinkStatus::Down) {
933+
continue;
934+
}
935+
links.push_back(id);
936+
}
937+
938+
Cru::Link newLink;
939+
newLink.dwrapper = mEndpoint;
940+
941+
// Insert Run Statistics link
942+
newLink.dwrapperId = (mEndpoint == 0) ? 13 : 14;
943+
if (datapathWrapper.isLinkEnabled(newLink)) {
944+
links.push_back(newLink.dwrapperId);
945+
}
946+
947+
// Insert UL link
948+
newLink.dwrapperId = 15;
949+
if (datapathWrapper.isLinkEnabled(newLink)) {
950+
links.push_back(newLink.dwrapperId);
951+
}
952+
953+
return links;
954+
}
955+
916956
/// Initializes and Populates the linkMap with the GBT configuration parameters
917957
/// Also runs the corresponding configuration
918958
void CruBar::populateLinkMap(std::map<int, Link>& linkMap)

src/Cru/CruBar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class CruBar final : public BarInterfaceBase
111111

112112
std::map<int, Link> initializeLinkMap();
113113

114+
std::vector<int> getDataTakingLinks();
115+
114116
std::shared_ptr<Pda::PdaBar> getPdaBar()
115117
{
116118
return mPdaBar;

src/Cru/CruDmaChannel.cxx

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -72,50 +72,23 @@ CruDmaChannel::CruDmaChannel(const Parameters& parameters)
7272

7373
// Insert links
7474
{
75-
DatapathWrapper dwrapper = DatapathWrapper(getBar2()->getPdaBar());
76-
auto linkMap = getBar2()->initializeLinkMap();
77-
78-
int endpoint = getBar()->getEndpointNumber();
79-
80-
Cru::Link newLink;
81-
newLink.dwrapper = endpoint;
82-
83-
// Insert UL link
84-
newLink.dwrapperId = 15;
85-
if (dwrapper.getLinkEnabled(newLink)) {
86-
linkMap.insert({ 15, newLink });
87-
}
88-
89-
// Insert Run Statistics link
90-
newLink.dwrapperId = (endpoint == 0) ? 13 : 14;
91-
92-
if (dwrapper.getLinkEnabled(newLink)) {
93-
linkMap.insert({ newLink.dwrapperId, newLink });
94-
}
95-
9675
std::stringstream stream;
9776
stream << "Using link(s): ";
9877

99-
for (const auto& el : linkMap) {
100-
auto id = el.first;
101-
auto link = el.second;
102-
if (!dwrapper.getLinkEnabled(link)) {
103-
//log((format("Will not push superpages to link #%1% (disabled)") % id).str(), InfoLogger::InfoLogger::Warning);
104-
continue;
105-
}
106-
107-
stream << id << " ";
78+
auto links = getBar2()->getDataTakingLinks();
79+
for (auto const& link : links) {
80+
stream << link << " ";
10881
//Implicit constructors are deleted for the folly Queue. Workaround to keep the Link struct with a queue * field.
10982
std::shared_ptr<SuperpageQueue> linkQueue = std::make_shared<SuperpageQueue>(LINK_QUEUE_CAPACITY_ALLOCATIONS);
110-
Link newLink = { static_cast<LinkId>(id), 0, linkQueue };
83+
Link newLink = { static_cast<LinkId>(link), 0, linkQueue };
11184
mLinks.push_back(newLink);
11285
}
11386

87+
log(stream.str(), LogInfoOps);
88+
11489
if (mLinks.empty()) {
11590
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("No links are enabled. Check with roc-status. Configure with roc-config."));
11691
}
117-
118-
log(stream.str(), LogInfoOps);
11992
}
12093
}
12194

src/Cru/DatapathWrapper.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void DatapathWrapper::setLinkDisabled(Link link)
5555
}
5656

5757
/// Get particular link's enabled bit
58-
bool DatapathWrapper::getLinkEnabled(Link link)
58+
bool DatapathWrapper::isLinkEnabled(Link link)
5959
{
6060
uint32_t address = getDatapathWrapperBaseAddress(link.dwrapper) +
6161
Cru::Registers::DWRAPPER_GREGS.address +

src/Cru/DatapathWrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class DatapathWrapper
3737
void setLinksEnabled(uint32_t dwrapper, uint32_t mask);
3838
void setLinkEnabled(Link link);
3939
void setLinkDisabled(Link link);
40-
bool getLinkEnabled(Link link);
40+
bool isLinkEnabled(Link link);
4141
void setDatapathMode(Link link, uint32_t mode);
4242
DatapathMode::type getDatapathMode(Link link);
4343
void setPacketArbitration(int wrapperCount, int arbitrationMode = 0);

0 commit comments

Comments
 (0)