Skip to content

Commit ad28fe8

Browse files
authored
Merge pull request #403 from sy-c/master
v0.41.0
2 parents d1b3cca + 1f1bdb5 commit ad28fe8

File tree

10 files changed

+93
-17
lines changed

10 files changed

+93
-17
lines changed

doc/releaseNotes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ This file describes the main feature changes for released versions of ReadoutCar
2424

2525
## v0.40.2 - 16/02/2023
2626
- Fixed bug with o2-roc-ctp-emulator failing to parse hexadecimal values of the init-orbit option.
27+
28+
## v0.41.0 - 23/02/2023
29+
- Added glitchCounter to roc-status (monitoring + JSON output).
30+
- Added DMA status (enabled / disabled) to roc-status (all output styles, including monitoring).
31+
- Added FEC counter per link to roc-status (stdout + JSON output).

src/CommandLineUtilities/ProgramStatus.cxx

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class ProgramStatus : public Program
7272
std::ostringstream table;
7373
std::string formatHeader;
7474
std::string formatRow;
75-
std::string header;
75+
std::string header1;
76+
std::string header2;
7677
std::string lineFat;
7778
std::string lineThin;
7879

@@ -91,14 +92,15 @@ class ProgramStatus : public Program
9192
}
9293

9394
if (cardType == CardType::type::Crorc) {
94-
formatHeader = " %-9s %-8s %-19s\n";
95-
formatRow = " %-9s %-8s %-19.1f\n";
96-
header = (boost::format(formatHeader) % "Link ID" % "Status" % "Optical power(uW)").str();
97-
lineFat = std::string(header.length(), '=') + '\n';
98-
lineThin = std::string(header.length(), '-') + '\n';
95+
formatHeader = " %-6s %-8s %-11s\n";
96+
formatRow = " %-6s %-8s %-11.1f\n";
97+
header1 = (boost::format(formatHeader) % "Link" % "Status" % "Optical").str();
98+
header2 = (boost::format(formatHeader) % "ID" % "" % "power (uW)").str();
99+
lineFat = std::string(header1.length(), '=') + '\n';
100+
lineThin = std::string(header1.length(), '-') + '\n';
99101

100102
if (!mOptions.jsonOut) {
101-
table << lineFat << header << lineThin;
103+
table << lineFat << header1 << header2 << lineThin;
102104
}
103105

104106
auto params = Parameters::makeParameters(cardId, 0); //status available on BAR0
@@ -176,19 +178,25 @@ class ProgramStatus : public Program
176178
}
177179
}
178180
} else if (cardType == CardType::type::Cru) {
179-
formatHeader = " %-9s %-16s %-10s %-14s %-15s %-10s %-14s %-14s %-8s %-19s %-11s %-7s\n";
180-
formatRow = " %-9s %-16s %-10s %-14s %-15s %-10s %-14.2f %-14.2f %-8s %-19.1f %-11s %-7s\n";
181-
header = (boost::format(formatHeader) % "Link ID" % "GBT Mode Tx/Rx" % "Loopback" % "GBT MUX" % "Datapath Mode" % "Datapath" % "RX freq(MHz)" % "TX freq(MHz)" % "Status" % "Optical power(uW)" % "System ID" % "FEE ID").str();
182-
lineFat = std::string(header.length(), '=') + '\n';
183-
lineThin = std::string(header.length(), '-') + '\n';
181+
if (mOptions.fec) {
182+
formatHeader = " %-6s %-10s %-10s %-14s %-10s %-10s %-8s %-8s %-7s %-7s %-11s %-7s %-7s\n";
183+
formatRow = " %-6s %-10s %-10s %-14s %-10s %-10s %-8.2f %-8.2f %-7s %-7s %-11.1f %-7s %-7s\n";
184+
} else {
185+
formatHeader = " %-6s %-10s %-10s %-14s %-10s %-10s %-8s %-8s %-7s%-0s %-11s %-7s %-7s\n";
186+
formatRow = " %-6s %-10s %-10s %-14s %-10s %-10s %-8.2f %-8.2f %-7s%-0s %-11.1f %-7s %-7s\n";
187+
}
188+
header1 = (boost::format(formatHeader) % "Link" % "GBT Mode" % "Loopback" % "GBT MUX" % "Datapath" % "Datapath" % "RX freq" % "TX freq" % "Status" % (mOptions.fec ? "FEC" : "" ) % "Optical" % "System" % "FEE").str();
189+
header2 = (boost::format(formatHeader) % "ID" % "Tx/Rx" % "" % "" % "mode" % "status" % "(MHz)" % "(MHz)" % "" % "" % "power (uW)" % "ID" % "ID").str();
190+
lineFat = std::string(header1.length(), '=') + '\n';
191+
lineThin = std::string(header2.length(), '-') + '\n';
184192

185193
auto params = Parameters::makeParameters(cardId, 2); //status available on BAR2
186194
params.setLinkMask(Parameters::linkMaskFromString(mOptions.links));
187195
auto bar2 = ChannelFactory().getBar(params);
188196
auto cruBar2 = std::dynamic_pointer_cast<CruBar>(bar2);
189197

190198
if (!mOptions.jsonOut) {
191-
table << lineFat << header << lineThin;
199+
table << lineFat << header1 << header2 << lineThin;
192200
}
193201

194202
Cru::ReportInfo reportInfo = cruBar2->report();
@@ -198,6 +206,7 @@ class ProgramStatus : public Program
198206
std::string userLogic = (reportInfo.userLogicEnabled ? "Enabled" : "Disabled");
199207
std::string runStats = (reportInfo.runStatsEnabled ? "Enabled" : "Disabled");
200208
std::string userAndCommonLogic = (reportInfo.userAndCommonLogicEnabled ? "Enabled" : "Disabled");
209+
std::string dmaStatus = reportInfo.dmaStatus ? "Enabled" : "Disabled";
201210

202211
/* GENERAL PARAMETERS */
203212
if (mOptions.monitoring) {
@@ -210,6 +219,7 @@ class ProgramStatus : public Program
210219
.addValue(reportInfo.runStatsEnabled, "runStats")
211220
.addValue(reportInfo.userAndCommonLogicEnabled, "userAndCommonLogic")
212221
.addValue(reportInfo.timeFrameLength, "timeFrameLength")
222+
.addValue(reportInfo.dmaStatus, "dmaStatus")
213223
.addTag(tags::Key::SerialId, card.serialId.getSerial())
214224
.addTag(tags::Key::Endpoint, card.serialId.getEndpoint())
215225
.addTag(tags::Key::ID, card.sequenceId)
@@ -225,6 +235,7 @@ class ProgramStatus : public Program
225235
root.put("runStats", runStats);
226236
root.put("userAndCommonLogic", userAndCommonLogic);
227237
root.put("timeFrameLength", reportInfo.timeFrameLength);
238+
root.put("dmaStatus", dmaStatus);
228239
} else {
229240
std::cout << "-----------------------------" << std::endl;
230241
std::cout << "CRU ID: " << reportInfo.cruId << std::endl;
@@ -239,6 +250,7 @@ class ProgramStatus : public Program
239250
if (reportInfo.runStatsEnabled) {
240251
std::cout << "Run statistics enabled" << std::endl;
241252
}
253+
std::cout << "DMA: "<< dmaStatus << std::endl;
242254
}
243255

244256
/* ONU PARAMETERS */
@@ -379,6 +391,11 @@ class ProgramStatus : public Program
379391

380392
float rxFreq = link.rxFreq;
381393
float txFreq = link.txFreq;
394+
uint32_t glitchCounter = link.glitchCounter;
395+
std::string fecCounter;
396+
if (mOptions.fec) {
397+
fecCounter = Utilities::toHexString(link.fecCounter);
398+
}
382399

383400
std::string linkStatus;
384401
if (link.stickyBit == Cru::LinkStatus::Up) {
@@ -407,6 +424,7 @@ class ProgramStatus : public Program
407424
.addValue(opticalPower, "opticalPower")
408425
.addValue(systemId, "systemId")
409426
.addValue(feeId, "feeId")
427+
.addValue((int)glitchCounter, "glitchCounter")
410428
.addTag(tags::Key::SerialId, card.serialId.getSerial())
411429
.addTag(tags::Key::Endpoint, card.serialId.getEndpoint())
412430
.addTag(tags::Key::CRU, card.sequenceId)
@@ -427,11 +445,15 @@ class ProgramStatus : public Program
427445
linkNode.put("opticalPower", Utilities::toPreciseString(opticalPower));
428446
linkNode.put("systemId", systemId);
429447
linkNode.put("feeId", feeId);
448+
linkNode.put("glitchCounter", glitchCounter);
449+
if (mOptions.fec) {
450+
linkNode.put("fecCounter", fecCounter);
451+
}
430452

431453
// add the link node to the tree
432454
root.add_child(std::to_string(globalId), linkNode);
433455
} else {
434-
auto format = boost::format(formatRow) % globalId % gbtTxRxMode % loopback % gbtMux % datapathMode % enabled % rxFreq % txFreq % linkStatus % opticalPower % systemId % feeId;
456+
auto format = boost::format(formatRow) % globalId % gbtTxRxMode % loopback % gbtMux % datapathMode % enabled % rxFreq % txFreq % linkStatus % fecCounter % opticalPower % systemId % feeId;
435457
table << format;
436458
}
437459
}
@@ -443,7 +465,7 @@ class ProgramStatus : public Program
443465
if (mOptions.jsonOut) {
444466
pt::write_json(std::cout, root);
445467
} else if (!mOptions.monitoring) {
446-
auto lineFat = std::string(header.length(), '=') + '\n';
468+
auto lineFat = std::string(header1.length(), '=') + '\n';
447469
table << lineFat;
448470
std::cout << table.str();
449471
}

src/Cru/Common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ struct Link {
7171
uint32_t feeId = 0x0;
7272
/*uint32_t systemId = 0x1ff; // invalid, used as "unset" placeholder
7373
uint32_t feeId = 0x1f; // invalid, used as "unset" placeholder*/
74+
uint32_t glitchCounter = 0;
75+
uint32_t fecCounter = 0;
7476

7577
bool operator==(const Link& dlink) const
7678
{
@@ -115,6 +117,7 @@ struct ReportInfo {
115117
bool runStatsEnabled;
116118
bool userAndCommonLogicEnabled;
117119
uint16_t timeFrameLength;
120+
bool dmaStatus;
118121
};
119122

120123
struct OnuStickyStatus {

src/Cru/Constants.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ static constexpr Register GBT_LINK_CLEAR_ERRORS(0x00000038);
254254
static constexpr Register GBT_LINK_RX_CLOCK(0x00000008);
255255
static constexpr Register GBT_LINK_TX_CLOCK(0x00000004);
256256

257+
/// Register for getting the glitch counter
258+
static constexpr Register GBT_LINK_GLITCH_COUNTER(0x00000044);
259+
260+
/// Register for getting the FEC counter
261+
static constexpr Register GBT_LINK_FEC_COUNTER(0x0000001C);
262+
257263
/// Register for selecting the the GBT Multiplexer
258264
static constexpr Register GBT_MUX_SELECT(0x0000001c);
259265
/*static constexpr uint32_t GBT_MUX_TTC(0x0);

src/Cru/CruBar.cxx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,12 @@ uint32_t CruBar::getPonStatusRegister()
406406
return readRegister((Cru::Registers::ONU_USER_LOGIC.address + 0x0c) / 4);
407407
}
408408

409+
bool CruBar::getDmaStatus()
410+
{
411+
mPdaBar->assertBarIndex(2, "Can only get DMA status register from BAR 2");
412+
return readRegister(Cru::Registers::BSP_USER_CONTROL.index) & 0x1; // DMA enabled = bit 0
413+
}
414+
409415
uint32_t CruBar::getOnuAddress()
410416
{
411417
mPdaBar->assertBarIndex(2, "Can only get PON status register from BAR 2");
@@ -503,6 +509,8 @@ Cru::ReportInfo CruBar::report(bool forConfig)
503509
link.stickyBit = gbt.getStickyBit(link);
504510
link.rxFreq = gbt.getRxClockFrequency(link) / 1e6; // Hz -> Mhz
505511
link.txFreq = gbt.getTxClockFrequency(link) / 1e6; // Hz -> Mhz
512+
link.glitchCounter = gbt.getGlitchCounter(link);
513+
link.fecCounter = gbt.getFecCounter(link);
506514
link.systemId = datapathWrapper.getSystemId(link);
507515
link.feeId = datapathWrapper.getFeeId(link);
508516

@@ -544,6 +552,8 @@ Cru::ReportInfo CruBar::report(bool forConfig)
544552
bool userAndCommonLogicEnabled = datapathWrapper.getUserAndCommonLogicEnabled(mEndpoint);
545553
uint16_t timeFrameLength = getTimeFrameLength();
546554

555+
bool dmaStatus = getDmaStatus();
556+
547557
Cru::ReportInfo reportInfo = {
548558
linkMap,
549559
clock,
@@ -557,7 +567,8 @@ Cru::ReportInfo CruBar::report(bool forConfig)
557567
userLogicEnabled,
558568
runStatsEnabled,
559569
userAndCommonLogicEnabled,
560-
timeFrameLength
570+
timeFrameLength,
571+
dmaStatus
561572
};
562573

563574
return reportInfo;

src/Cru/CruBar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class CruBar final : public BarInterfaceBase
135135
uint32_t getFpgaChipLow();
136136
uint32_t getPonStatusRegister();
137137
uint32_t getOnuAddress();
138+
bool getDmaStatus();
138139
bool checkPonUpstreamStatusExpected(uint32_t ponUpstreamRegister, uint32_t onuAddress);
139140
bool checkClockConsistent(std::map<int, Link> linkMap);
140141
void populateLinkMap(std::map<int, Link>& linkMap);

src/Cru/Gbt.cxx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,28 @@ uint32_t Gbt::getTxClockFrequency(Link link) //In Hz
315315
return mPdaBar->readRegister(address / 4);
316316
}
317317

318+
uint32_t Gbt::getGlitchCounter(Link link)
319+
{
320+
uint32_t address = Cru::getWrapperBaseAddress(link.wrapper) +
321+
Cru::Registers::GBT_WRAPPER_BANK_OFFSET.address * (link.bank + 1) +
322+
Cru::Registers::GBT_BANK_LINK_OFFSET.address * (link.id + 1) +
323+
Cru::Registers::GBT_LINK_REGS_OFFSET.address +
324+
Cru::Registers::GBT_LINK_GLITCH_COUNTER.address;
325+
326+
return mPdaBar->readRegister(address / 4);
327+
}
328+
329+
uint32_t Gbt::getFecCounter(Link link)
330+
{
331+
uint32_t address = Cru::getWrapperBaseAddress(link.wrapper) +
332+
Cru::Registers::GBT_WRAPPER_BANK_OFFSET.address * (link.bank + 1) +
333+
Cru::Registers::GBT_BANK_LINK_OFFSET.address * (link.id + 1) +
334+
Cru::Registers::GBT_LINK_REGS_OFFSET.address +
335+
Cru::Registers::GBT_LINK_FEC_COUNTER.address;
336+
337+
return mPdaBar->readRegister(address / 4);
338+
}
339+
318340
void Gbt::resetFifo()
319341
{
320342
mPdaBar->modifyRegister(Cru::Registers::BSP_USER_CONTROL.index, 7, 1, 0x1); // reset TX

src/Cru/Gbt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class Gbt
5151
LinkStatus getStickyBit(Link link);
5252
uint32_t getRxClockFrequency(Link link);
5353
uint32_t getTxClockFrequency(Link link);
54+
uint32_t getGlitchCounter(Link link);
55+
uint32_t getFecCounter(Link link);
5456
void resetFifo();
5557
std::map<int, LoopbackStats> getLoopbackStats(bool reset, GbtPatternMode::type patternMode = GbtPatternMode::type::Counter,
5658
GbtCounterType::type counterType = GbtCounterType::type::ThirtyBit,

src/FirmwareChecker.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ FirmwareChecker::FirmwareChecker() : mCompatibleFirmwareList({
3030
{ "2058c933", "v3.14.0" },
3131
{ "4a412c71", "v3.13.0" },
3232
{ "82b4662d", "MFT PSU" },
33+
{ "6838510f", "v3.17.0" },
34+
{ "8e74a7f8", "v3.17.1" },
3335
/*{ "6a85d30c", "v3.12.0" },
3436
{ "7be5aa1c", "v3.11.0" },
3537
{ "e4a5a46e", "v3.10.0" },
@@ -45,6 +47,8 @@ FirmwareChecker::FirmwareChecker() : mCompatibleFirmwareList({
4547
{ "267f8e5", "v2.9.1" },
4648
{ "cecc295", "v2.9.0" },
4749
{ "221ff280", "v2.10.0" },
50+
{ "cfa0bc9c", "2.10.1" },
51+
{ "2d4c9028", "2.11.0" },
4852
/*{ "59e9955", "v2.8.1" },
4953
{ "f086417", "v2.8.0" },
5054
{ "474f9e1", "v2.7.0" }

src/ReadoutCardVersion.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "ReadoutCard/Version.h"
1313

14-
#define O2_READOUTCARD_VERSION "0.40.2"
14+
#define O2_READOUTCARD_VERSION "0.41.0"
1515

1616
namespace o2
1717
{

0 commit comments

Comments
 (0)