Skip to content

Commit 391e0ce

Browse files
committed
[cru] Automatically use only enabled links
1 parent 74613ad commit 391e0ce

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

src/Cru/CruDmaChannel.cxx

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,31 +77,20 @@ CruDmaChannel::CruDmaChannel(const Parameters& parameters)
7777

7878
std::stringstream stream;
7979
stream << "Using link(s): ";
80-
auto linkMask = parameters.getLinkMask().value_or(Parameters::LinkMaskType{ 0 });
81-
mLinks.reserve(linkMask.size());
82-
for (uint32_t id : linkMask) {
83-
if (id >= Cru::MAX_LINKS) {
84-
BOOST_THROW_EXCEPTION(InvalidLinkId() << ErrorInfo::Message("Each endpoint supports up to 16 links.")
85-
<< ErrorInfo::LinkId(id));
86-
}
8780

88-
if (id == 15) {
89-
Cru::Link userLogicLink;
90-
userLogicLink.dwrapper = getBar()->getEndpointNumber();
91-
userLogicLink.dwrapperId = 15;
92-
if (!dwrapper.getLinkEnabled(userLogicLink)) {
93-
log((format("Will not push superpages to link #%1% (disabled)") % id).str(), InfoLogger::InfoLogger::Warning);
94-
continue;
95-
}
96-
} else if (id > 11 && id < 15) {
97-
log((format("Will not push superpages to link #%1% (unsupported)") % id).str(), InfoLogger::InfoLogger::Warning);
81+
Cru::Link userLogicLink;
82+
userLogicLink.dwrapper = getBar()->getEndpointNumber();
83+
userLogicLink.dwrapperId = 15;
84+
if (dwrapper.getLinkEnabled(userLogicLink)) {
85+
linkMap.insert({ 15, userLogicLink });
86+
}
87+
88+
for (const auto& el : linkMap) {
89+
auto id = el.first;
90+
auto link = el.second;
91+
if (!dwrapper.getLinkEnabled(link)) {
92+
//log((format("Will not push superpages to link #%1% (disabled)") % id).str(), InfoLogger::InfoLogger::Warning);
9893
continue;
99-
} else {
100-
// If the link is not enabled, skip it
101-
if (!dwrapper.getLinkEnabled(linkMap.at(id))) {
102-
log((format("Will not push superpages to link #%1% (disabled)") % id).str(), InfoLogger::InfoLogger::Warning);
103-
continue;
104-
}
10594
}
10695

10796
stream << id << " ";
@@ -110,6 +99,11 @@ CruDmaChannel::CruDmaChannel(const Parameters& parameters)
11099
Link newLink = { static_cast<LinkId>(id), 0, linkQueue };
111100
mLinks.push_back(newLink);
112101
}
102+
103+
if (mLinks.empty()) {
104+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("No links are enabled. Check with roc-status. Configure with roc-config."));
105+
}
106+
113107
log(stream.str());
114108
}
115109
}

0 commit comments

Comments
 (0)