Skip to content

Commit 7700fa6

Browse files
committed
[config] Add "UP(was DOWN)" status when resetting the link's sticky bit
1 parent 4a763a2 commit 7700fa6

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

src/CommandLineUtilities/ProgramStatus.cxx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,15 @@ class ProgramStatus: public Program
109109
float rxFreq = link.rxFreq;
110110
float txFreq = link.txFreq;
111111

112-
std::string linkStatus = link.stickyBit ? "UP" : "DOWN" ;
112+
std::string linkStatus;
113+
if (link.stickyBit == Cru::LinkStatus::Up) {
114+
linkStatus = "UP";
115+
} else if (link.stickyBit == Cru::LinkStatus::UpWasDown) {
116+
linkStatus = "UP (was DOWN)";
117+
} else if (link.stickyBit == Cru::LinkStatus::Down) {
118+
linkStatus = "DOWN";
119+
}
120+
113121
float opticalPower = link.opticalPower;
114122

115123
auto format = boost::format(formatRow) % globalId % gbtTxRxMode % loopback % gbtMux % datapathMode % enabled % rxFreq % txFreq % linkStatus % opticalPower;

src/Cru/Common.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ namespace AliceO2 {
2525
namespace roc {
2626
namespace Cru {
2727

28+
enum LinkStatus {
29+
Up,
30+
Down,
31+
UpWasDown
32+
};
33+
2834
struct Link {
2935
int dwrapper = -1;
3036
int wrapper = -1;
@@ -39,7 +45,7 @@ struct Link {
3945
bool loopback = false;
4046
DatapathMode::type datapathMode = DatapathMode::type::Packet;
4147
bool enabled = false;
42-
bool stickyBit = false;
48+
LinkStatus stickyBit = LinkStatus::Down;
4349
float opticalPower = 0.0;
4450
float txFreq = 0x0; //In MHz
4551
float rxFreq = 0x0; //In MHz

src/Cru/Gbt.cxx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
/// \author Kostas Alexopoulos ([email protected])
1515

1616
#include <iostream>
17-
#include "Common.h"
1817
#include "Gbt.h"
1918
#include "Utilities/Util.h"
2019

2120
namespace AliceO2 {
2221
namespace roc {
2322

2423
using Link = Cru::Link;
24+
using LinkStatus = Cru::LinkStatus;
2525

2626
Gbt::Gbt(std::shared_ptr<Pda::PdaBar> pdaBar, std::map<int, Link> &linkMap, int wrapperCount) :
2727
mPdaBar(pdaBar),
@@ -232,26 +232,33 @@ uint32_t Gbt::getAtxPllRegisterAddress(int wrapper, uint32_t reg)
232232
Cru::Registers::GBT_WRAPPER_ATX_PLL.address + 4 * reg;
233233
}
234234

235-
bool Gbt::getStickyBit(Link link)
235+
LinkStatus Gbt::getStickyBit(Link link)
236236
{
237237
uint32_t addr = getStatusAddress(link);
238238
uint32_t data = mPdaBar->readRegister(addr/4);
239239
uint32_t lockedData = Utilities::getBit(~data, 14); //phy up 1 = locked, 0 = down
240240
uint32_t ready = Utilities::getBit(~data, 15); //data layer up 1 = locked, 0 = down
241241
if ((lockedData == 0x0) || (ready == 0x0)) {
242242
resetStickyBit(link);
243+
data = mPdaBar->readRegister(addr/4);
244+
lockedData = Utilities::getBit(~data, 14); //phy up 1 = locked, 0 = down
245+
ready = Utilities::getBit(~data, 15); //data layer up 1 = locked, 0 = down
246+
247+
return (lockedData == 0x1 && ready == 0x1) ? LinkStatus::UpWasDown : LinkStatus::Down;
243248
}
244249

245-
return (lockedData == 0x1 && ready == 0x1) ? true : false;
250+
return (lockedData == 0x1 && ready == 0x1) ? LinkStatus::Up : LinkStatus::UpWasDown;
246251
}
247252

248-
void Gbt::resetStickyBit(Link link) {
253+
void Gbt::resetStickyBit(Link link)
254+
{
249255
uint32_t addr = getClearErrorAddress(link);
250256

251257
mPdaBar->writeRegister(addr/4, 0x0);
252258
}
253259

254-
uint32_t Gbt::getRxClockFrequency(Link link) { //In Hz
260+
uint32_t Gbt::getRxClockFrequency(Link link) //In Hz
261+
{
255262
uint32_t address = Cru::getWrapperBaseAddress(link.wrapper) +
256263
Cru::Registers::GBT_WRAPPER_BANK_OFFSET.address * (link.bank + 1) +
257264
Cru::Registers::GBT_BANK_LINK_OFFSET.address * (link.id + 1) +
@@ -261,7 +268,8 @@ uint32_t Gbt::getRxClockFrequency(Link link) { //In Hz
261268
return mPdaBar->readRegister(address/4);
262269
}
263270

264-
uint32_t Gbt::getTxClockFrequency(Link link) { //In Hz
271+
uint32_t Gbt::getTxClockFrequency(Link link) //In Hz
272+
{
265273
uint32_t address = Cru::getWrapperBaseAddress(link.wrapper) +
266274
Cru::Registers::GBT_WRAPPER_BANK_OFFSET.address * (link.bank + 1) +
267275
Cru::Registers::GBT_BANK_LINK_OFFSET.address * (link.id + 1) +

src/Cru/Gbt.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define ALICEO2_READOUTCARD_CRU_GBT_H_
1818

1919
#include "Pda/PdaBar.h"
20+
#include "Common.h"
2021
#include "Constants.h"
2122
#include "I2c.h"
2223

@@ -26,6 +27,7 @@ namespace roc {
2627
class Gbt {
2728

2829
using Link = Cru::Link;
30+
using LinkStatus = Cru::LinkStatus;
2931

3032
public:
3133
//Gbt(std::shared_ptr<Pda::PdaBar> pdaBar, std::vector<Link> &mLinkList, int wrapperCount);
@@ -39,7 +41,7 @@ class Gbt {
3941
void getGbtModes();
4042
void getGbtMuxes();
4143
void getLoopbacks();
42-
bool getStickyBit(Link link);
44+
LinkStatus getStickyBit(Link link);
4345
uint32_t getRxClockFrequency(Link link);
4446
uint32_t getTxClockFrequency(Link link);
4547

0 commit comments

Comments
 (0)