Skip to content

Commit 390dee3

Browse files
committed
[config] Configurable Time Frame length for the CRU
1 parent 43d755d commit 390dee3

File tree

7 files changed

+40
-5
lines changed

7 files changed

+40
-5
lines changed

cru_template.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ userAndCommonLogicEnabled=true
5959
# 8-bit System ID
6060
systemId=0xfd
6161

62+
# Time Frame Length [0-255]
63+
timeFrameLength=255
64+
6265
#############################################
6366
# links
6467
#############################################

src/CardConfigurator.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void CardConfigurator::parseConfigUri(CardType::type cardType, std::string confi
7272
void CardConfigurator::parseConfigUriCrorc(std::string configUri, Parameters& parameters)
7373
{
7474
bool dynamicOffset = false;
75-
uint32_t timeFrameLength = 0x100;
75+
uint16_t timeFrameLength = 0x100;
7676

7777
std::unique_ptr<o2::configuration::ConfigurationInterface> conf;
7878
try {
@@ -124,6 +124,7 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
124124
bool runStatsEnabled = false;
125125
bool userAndCommonLogicEnabled = false;
126126
uint32_t systemId = 0x0;
127+
uint16_t timeFrameLength = 0x100;
127128

128129
bool enabled = false;
129130
std::string gbtMux = "ttc";
@@ -180,6 +181,8 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
180181
parsedString = subtree.get<std::string>("systemId");
181182
systemId = Hex::fromString(parsedString);
182183

184+
timeFrameLength = subtree.get<int>("timeFrameLength");
185+
183186
parameters.setClock(clock);
184187
parameters.setDatapathMode(datapathMode);
185188
parameters.setGbtMode(gbtMode);
@@ -196,6 +199,7 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
196199
parameters.setRunStatsEnabled(runStatsEnabled);
197200
parameters.setUserAndCommonLogicEnabled(userAndCommonLogicEnabled);
198201
parameters.setSystemId(systemId);
202+
parameters.setTimeFrameLength(timeFrameLength);
199203
} else if (group == "links") { // Configure all links with default values
200204

201205
enabled = subtree.get<bool>("enabled");

src/CommandLineUtilities/ProgramConfig.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ class ProgramConfig : public Program
218218
cfgFile << "userLogicEnabled=" << std::boolalpha << mOptions.userLogicEnabled << "\n";
219219
cfgFile << "runStatsEnabled=" << std::boolalpha << mOptions.runStatsEnabled << "\n";
220220
cfgFile << "userAndCommonLogicEnabled=" << std::boolalpha << mOptions.userAndCommonLogicEnabled << "\n";
221-
cfgFile << "timeFrameLength=" << mOptions.timeFrameLength << "\n";
222-
cfgFile << "timeFrameDetectionEnabled=" << std::boolalpha << !mOptions.timeFrameDetectionDisabled << "\n";
221+
//cfgFile << "timeFrameDetectionEnabled=" << std::boolalpha << !mOptions.timeFrameDetectionDisabled << "\n";
223222
cfgFile << "systemId=" << mOptions.systemId << "\n";
223+
cfgFile << "timeFrameLength=" << mOptions.timeFrameLength << "\n";
224224

225225
cfgFile << "[links]\n";
226226
cfgFile << "enabled=false\n";

src/Cru/Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct ReportInfo {
9999
bool userLogicEnabled;
100100
bool runStatsEnabled;
101101
bool userAndCommonLogicEnabled;
102+
uint16_t timeFrameLength;
102103
};
103104

104105
struct OnuStatus {

src/Cru/Constants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ static constexpr Register USER_LOGIC_RESET(0x00c80000);
358358
static constexpr Register USER_LOGIC_EVSIZE(0x00c80004);
359359
static constexpr Register USER_LOGIC_EVSIZE_RAND(0x00c80008);
360360

361+
/// Register to adjust the TimeFrame length (31 downto 20)
362+
static constexpr Register TIME_FRAME_LENGTH(0x00000c00);
363+
361364
} // namespace Registers
362365
} // namespace Cru
363366
} // namespace roc

src/Cru/CruBar.cxx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ CruBar::CruBar(const Parameters& parameters, std::unique_ptr<RocPciDevice> rocPc
6666
mGbtStatsMode(parameters.getGbtStatsMode().get_value_or(GbtStatsMode::All)),
6767
mGbtHighMask(parameters.getGbtHighMask().get_value_or(0xffffffff)),
6868
mGbtMedMask(parameters.getGbtMedMask().get_value_or(0xffffffff)),
69-
mGbtLowMask(parameters.getGbtLowMask().get_value_or(0xffffffff))
69+
mGbtLowMask(parameters.getGbtLowMask().get_value_or(0xffffffff)),
70+
mTimeFrameLength(parameters.getTimeFrameLength().get_value_or(0x100))
7071
{
7172
if (getIndex() == 0) {
7273
mFeatures = parseFirmwareFeatures();
@@ -540,6 +541,7 @@ Cru::ReportInfo CruBar::report(bool forConfig)
540541
bool runStatsEnabled = datapathWrapper.getLinkEnabled(runStatsLink);
541542

542543
bool userAndCommonLogicEnabled = datapathWrapper.getUserAndCommonLogicEnabled(mEndpoint);
544+
uint16_t timeFrameLength = getTimeFrameLength();
543545

544546
Cru::ReportInfo reportInfo = {
545547
linkMap,
@@ -553,7 +555,8 @@ Cru::ReportInfo CruBar::report(bool forConfig)
553555
gbtEnabled,
554556
userLogicEnabled,
555557
runStatsEnabled,
556-
userAndCommonLogicEnabled
558+
userAndCommonLogicEnabled,
559+
timeFrameLength
557560
};
558561

559562
return reportInfo;
@@ -703,6 +706,7 @@ void CruBar::configure(bool force)
703706
mUserAndCommonLogicEnabled == reportInfo.userAndCommonLogicEnabled &&
704707
mRunStatsEnabled == reportInfo.runStatsEnabled &&
705708
mGbtEnabled == reportInfo.gbtEnabled &&
709+
mTimeFrameLength == reportInfo.timeFrameLength &&
706710
!force) {
707711
log("No need to reconfigure further", LogInfoOps);
708712
return;
@@ -823,6 +827,11 @@ void CruBar::configure(bool force)
823827
datapathWrapper.setDynamicOffset(mEndpoint, mDynamicOffset);
824828
}
825829

830+
if (mTimeFrameLength != reportInfo.timeFrameLength || force) {
831+
log("Setting Time Frame length", LogInfoDevel);
832+
setTimeFrameLength(mTimeFrameLength);
833+
}
834+
826835
log("CRU configuration done", LogInfoOps);
827836
}
828837

@@ -1162,5 +1171,16 @@ std::map<int, Cru::LoopbackStats> CruBar::getGbtLoopbackStats(bool reset)
11621171
return gbt.getLoopbackStats(reset, mGbtPatternMode, mGbtCounterType, mGbtStatsMode, mGbtLowMask, mGbtMedMask, mGbtHighMask);
11631172
}
11641173

1174+
uint16_t CruBar::getTimeFrameLength()
1175+
{
1176+
uint32_t timeFrameLength = readRegister(Cru::Registers::TIME_FRAME_LENGTH.index);
1177+
return (uint16_t)Utilities::getBits(timeFrameLength, 12, 20);
1178+
}
1179+
1180+
void CruBar::setTimeFrameLength(uint16_t timeFrameLength)
1181+
{
1182+
modifyRegister(Cru::Registers::TIME_FRAME_LENGTH.index, 20, 12, timeFrameLength);
1183+
}
1184+
11651185
} // namespace roc
11661186
} // namespace o2

src/Cru/CruBar.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ class CruBar final : public BarInterfaceBase
138138

139139
void setVirtualLinksIds(uint16_t systemId);
140140

141+
uint16_t getTimeFrameLength();
142+
void setTimeFrameLength(uint16_t timeFrameLength);
143+
141144
FirmwareFeatures parseFirmwareFeatures();
142145
FirmwareFeatures mFeatures;
143146

@@ -172,6 +175,7 @@ class CruBar final : public BarInterfaceBase
172175
uint32_t mGbtMedMask;
173176
uint32_t mGbtLowMask;
174177
bool mGbtLoopbackReset;
178+
uint32_t mTimeFrameLength;
175179

176180
int mSerial;
177181
int mEndpoint;

0 commit comments

Comments
 (0)