Skip to content

Commit fadf191

Browse files
committed
[status] Add FEC reporting
1 parent 625908b commit fadf191

File tree

10 files changed

+108
-15
lines changed

10 files changed

+108
-15
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,25 @@ metric format for the CRORC and the CRU is different, as different parameters ar
608608
| `tags::Key::ID` | ID of the card |
609609
| `tags::Key::Type` | `tags::Value::CRU` |
610610
611+
###### Metric: `"fec"`
612+
613+
| Value name | Value | Type |
614+
| ---------------------------- | -------------------------- | ------ |
615+
| `"clearFecCrcErrors"` | 0/1 (Good/Bad) | int |
616+
| `"latchFecCrcErrors"` | 0/1 (Good/Bad) | int |
617+
| `"slowControlFramingLocked"` | 0/1 (Good/Bad) | int |
618+
| `"fecSingleErrorCount"` | 8-bit counter (0x0 = good) | int |
619+
| `"fecDoubleErrorCount"` | 8-bit counter (0x0 = good) | int |
620+
| `"crcErrorCount"` | 8-bit counter (0x0 = good) | int |
621+
622+
| Tag key | Value |
623+
| --------------------- | --------------------- |
624+
| `tags::Key::SerialId` | Serial ID of the card |
625+
| `tags::Key::Endpoint` | Endpoint of the card |
626+
| `tags::Key::ID` | ID of the card |
627+
| `tags::Key::Type` | `tags::Value::CRU` |
628+
629+
611630
###### Metric: `"link"`
612631
613632
| Value name | Value | Type |

src/CommandLineUtilities/ProgramCtpEmulator.cxx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,15 @@ class ProgramCtpEmulator : public Program
104104
triggerMode = converter.fromString(mOptions.triggerModeString);
105105

106106
auto cruBar2 = std::dynamic_pointer_cast<CruBar>(bar2);
107-
cruBar2->emulateCtp({
108-
mOptions.bcMax,
109-
mOptions.hbDrop,
110-
mOptions.hbKeep,
111-
mOptions.hbMax,
112-
triggerMode,
113-
mOptions.triggerFrequency,
114-
mOptions.generateEox,
115-
mOptions.generateSingleTrigger,
116-
mOptions.orbitInit
117-
});
107+
cruBar2->emulateCtp({ mOptions.bcMax,
108+
mOptions.hbDrop,
109+
mOptions.hbKeep,
110+
mOptions.hbMax,
111+
triggerMode,
112+
mOptions.triggerFrequency,
113+
mOptions.generateEox,
114+
mOptions.generateSingleTrigger,
115+
mOptions.orbitInit });
118116
}
119117

120118
private:

src/CommandLineUtilities/ProgramStatus.cxx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class ProgramStatus : public Program
5858
options.add_options()("onu-status",
5959
po::bool_switch(&mOptions.onu),
6060
"Toggle ONU status output");
61+
options.add_options()("fec-status",
62+
po::bool_switch(&mOptions.fec),
63+
"Toggle FEC status output");
6164
options.add_options()("links",
6265
po::value<std::string>(&mOptions.links)->default_value("0-11"),
6366
"Links to show (all by default)");
@@ -304,6 +307,43 @@ class ProgramStatus : public Program
304307
}
305308
}
306309

310+
/* FEC PARAMETERS */
311+
if (mOptions.fec) {
312+
Cru::FecStatus fecStatus = cruBar2->reportFecStatus();
313+
314+
if (mOptions.monitoring) {
315+
monitoring->send(Metric{ "fec" }
316+
.addValue(fecStatus.clearFecCrcError, "clearFecCrcErrors")
317+
.addValue(fecStatus.latchFecCrcError, "latchFecCrcErrors")
318+
.addValue(fecStatus.slowControlFramingLocked, "slowControlFramingLocked")
319+
.addValue(fecStatus.fecSingleErrorCount, "fecSingleErrorCount")
320+
.addValue(fecStatus.fecDoubleErrorCount, "fecDoubleErrorCount")
321+
.addValue(fecStatus.crcErrorCount, "crcErrorCount")
322+
.addTag(tags::Key::SerialId, card.serialId.getSerial())
323+
.addTag(tags::Key::Endpoint, card.serialId.getEndpoint())
324+
.addTag(tags::Key::ID, card.sequenceId)
325+
.addTag(tags::Key::Type, tags::Value::CRU));
326+
} else if (mOptions.jsonOut) {
327+
root.put("clearFecCrcErrors", fecStatus.clearFecCrcError);
328+
root.put("latchFecCrcErrors", fecStatus.latchFecCrcError);
329+
root.put("slowControlFramingLocked", fecStatus.slowControlFramingLocked);
330+
root.put("fecSingleErrorCount", fecStatus.fecSingleErrorCount);
331+
root.put("fecDoubleErrorCount", fecStatus.fecDoubleErrorCount);
332+
root.put("crcErrorCount", fecStatus.crcErrorCount);
333+
} else {
334+
std::cout << "=====================================" << std::endl;
335+
std::cout << "Clear FEC & CRC errors: \t" << std::boolalpha << fecStatus.clearFecCrcError << std::endl;
336+
std::cout << "Latch FEC & CRC errors: \t" << std::boolalpha << fecStatus.latchFecCrcError << std::endl;
337+
std::cout << "Slow Control Framing locked: \t" << std::boolalpha << fecStatus.slowControlFramingLocked << std::endl;
338+
std::cout << "FEC single error count: \t"
339+
<< "0x" << std::hex << fecStatus.fecSingleErrorCount << std::endl;
340+
std::cout << "FEC double error count: \t"
341+
<< "0x" << std::hex << fecStatus.fecDoubleErrorCount << std::endl;
342+
std::cout << "CRC error count: \t\t"
343+
<< "0x" << std::hex << fecStatus.crcErrorCount << std::endl;
344+
}
345+
}
346+
307347
/* PARAMETERS PER LINK */
308348
for (const auto& el : reportInfo.linkMap) {
309349
auto link = el.second;
@@ -409,6 +449,7 @@ class ProgramStatus : public Program
409449
bool jsonOut = false;
410450
bool monitoring = false;
411451
bool onu = false;
452+
bool fec = false;
412453
} mOptions;
413454
};
414455

src/Cru/Common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ struct OnuStatus {
116116
int ponQualityStatus;
117117
};
118118

119+
struct FecStatus {
120+
bool clearFecCrcError;
121+
bool latchFecCrcError;
122+
bool slowControlFramingLocked;
123+
uint8_t fecSingleErrorCount;
124+
uint8_t fecDoubleErrorCount;
125+
uint8_t crcErrorCount;
126+
};
127+
119128
struct LinkPacketInfo {
120129
uint32_t accepted;
121130
uint32_t rejected;

src/Cru/Constants.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,16 @@ static constexpr Register CLOCK_ONU_FPLL(0x00248000);
201201
static constexpr Register CLOCK_PLL_CONTROL_ONU(0x00240018);
202202
static constexpr Register ONU_USER_LOGIC(0x0022a000);
203203

204-
// Registers for setting the Ref Gen
204+
/// Register for getting FEC status
205+
static constexpr Register ONU_FEC_COUNTERS(0x0022200c);
206+
207+
/// Registers for setting the Ref Gen
205208
static constexpr Register ONU_USER_REFGEN(0x0022c000);
206209
static constexpr Register REFGEN0_OFFSET(0x00000000);
207210
static constexpr Register REFGEN1_OFFSET(0x00000004);
208211
static constexpr Register ONU_MGT_STICKYS(0x00222014);
209212

210-
// Registers for getting LTU info
213+
/// Registers for getting LTU info
211214
static constexpr Register LTU_HBTRIG_CNT(0x00200004);
212215
static constexpr Register LTU_PHYSTRIG_CNT(0x00200008);
213216
static constexpr Register LTU_EOX_SOX_CNT(0x0020000c);

src/Cru/CruBar.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,12 @@ Cru::OnuStatus CruBar::reportOnuStatus()
10531053
return ttc.onuStatus();
10541054
}
10551055

1056+
Cru::FecStatus CruBar::reportFecStatus()
1057+
{
1058+
Ttc ttc = Ttc(mPdaBar, mSerial);
1059+
return ttc.fecStatus();
1060+
}
1061+
10561062
void CruBar::toggleUserLogicLink(bool userLogicEnabled)
10571063
{
10581064
Link userLogicLink;

src/Cru/CruBar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class CruBar final : public BarInterfaceBase
9797
boost::optional<std::string> getUserLogicVersion();
9898

9999
Cru::OnuStatus reportOnuStatus();
100+
Cru::FecStatus reportFecStatus();
100101
std::map<int, Link> initializeLinkMap();
101102

102103
std::shared_ptr<Pda::PdaBar> getPdaBar()

src/Cru/Ttc.cxx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "Constants.h"
1818
#include "I2c.h"
1919
#include "Ttc.h"
20+
#include "Utilities/Util.h"
2021
#include "register_maps/Si5345-RevD_local_pll1_zdb-Registers.h"
2122
#include "register_maps/Si5345-RevD_local_pll2_zdb-Registers.h"
2223
#include "register_maps/Si5345-RevD_ttc_pll1_zdb-Registers.h"
@@ -30,6 +31,7 @@ namespace roc
3031

3132
using LinkStatus = Cru::LinkStatus;
3233
using OnuStatus = Cru::OnuStatus;
34+
using FecStatus = Cru::FecStatus;
3335

3436
Ttc::Ttc(std::shared_ptr<BarInterface> bar, int serial) : mBar(bar), mSerial(serial)
3537
{
@@ -163,7 +165,7 @@ OnuStatus Ttc::onuStatus()
163165
uint32_t calStatus = mBar->readRegister(Cru::Registers::ONU_USER_LOGIC.index + 0xc / 4);
164166
uint32_t onuAddress = mBar->readRegister(Cru::Registers::ONU_USER_LOGIC.index) >> 1;
165167

166-
Cru::OnuStatus onuStatus = {
168+
return {
167169
onuAddress,
168170
(calStatus & 0x1) == 1, // comparisons to bool
169171
(calStatus >> 1 & 0x1) == 1,
@@ -177,8 +179,19 @@ OnuStatus Ttc::onuStatus()
177179
getPonQuality(),
178180
getPonQualityStatus()
179181
};
182+
}
180183

181-
return onuStatus;
184+
FecStatus Ttc::fecStatus()
185+
{
186+
uint32_t fecStatus = mBar->readRegister(Cru::Registers::ONU_FEC_COUNTERS.index);
187+
return {
188+
Utilities::getBit(fecStatus, 0) == 1,
189+
Utilities::getBit(fecStatus, 1) == 1,
190+
Utilities::getBit(fecStatus, 7) == 1,
191+
(uint8_t)Utilities::getBits(fecStatus, 8, 15),
192+
(uint8_t)Utilities::getBits(fecStatus, 16, 23),
193+
(uint8_t)Utilities::getBits(fecStatus, 24, 31)
194+
};
182195
}
183196

184197
void Ttc::calibrateTtc()

src/Cru/Ttc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace roc
1818
class Ttc
1919
{
2020
using OnuStatus = Cru::OnuStatus;
21+
using FecStatus = Cru::FecStatus;
2122
using LinkStatus = Cru::LinkStatus;
2223

2324
public:
@@ -50,6 +51,7 @@ class Ttc
5051
void setFixedBCTrigger(std::vector<uint32_t> FBCTVector);
5152

5253
OnuStatus onuStatus();
54+
FecStatus fecStatus();
5355

5456
private:
5557
void configurePlls(uint32_t clock);

src/Cru/cru_constants_populate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
'add_onu_user_logic':'ONU_USER_LOGIC',
9797
'add_onu_user_refgen':'ONU_USER_REFGEN',
9898
'add_onu_mgt_stickys':'ONU_MGT_STICKYS',
99+
'add_onu_fec_counters':'ONU_FEC_COUNTERS',
99100
'add_refgen0_offset':'REFGEN0_OFFSET',
100101
'add_refgen1_offset':'REFGEN1_OFFSET',
101102
#'add_refgen2_offset':'I2C_COMMAND',

0 commit comments

Comments
 (0)