Skip to content

Commit 70aed30

Browse files
committed
[onu-status] Introduce onu-status tool
1 parent 843920f commit 70aed30

File tree

7 files changed

+152
-0
lines changed

7 files changed

+152
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ if(PDA_FOUND)
211211
ProgramFlashRead.cxx
212212
ProgramListCards.cxx
213213
ProgramMetrics.cxx
214+
ProgramOnuStatus.cxx
214215
ProgramPacketMonitor.cxx
215216
ProgramPatternPlayer.cxx
216217
ProgramSiuStatus.cxx
@@ -226,6 +227,7 @@ if(PDA_FOUND)
226227
roc-flash-read
227228
roc-list-cards
228229
roc-metrics
230+
roc-onu-status
229231
roc-pkt-monitor
230232
roc-pat-player
231233
roc-siu-status
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file ProgramOnuStatus.cxx
12+
/// \brief Tool that returns the ONU status of RoCs.
13+
///
14+
/// \author Kostas Alexopoulos ([email protected])
15+
16+
#include <iostream>
17+
#include "Cru/CruBar.h"
18+
#include "ReadoutCard/ChannelFactory.h"
19+
#include "CommandLineUtilities/Options.h"
20+
#include "CommandLineUtilities/Program.h"
21+
#include <boost/format.hpp>
22+
#include <boost/property_tree/ptree.hpp>
23+
#include <boost/property_tree/json_parser.hpp>
24+
25+
using namespace AliceO2::roc::CommandLineUtilities;
26+
using namespace AliceO2::roc;
27+
namespace pt = boost::property_tree;
28+
namespace po = boost::program_options;
29+
30+
class ProgramOnuStatus : public Program
31+
{
32+
public:
33+
virtual Description getDescription()
34+
{
35+
return { "Status", "Return ONU status",
36+
"roc-onu-status --id 42:00.0\n"
37+
"roc-onu-status --id 42:00.0 --json" };
38+
}
39+
40+
virtual void addOptions(boost::program_options::options_description& options)
41+
{
42+
Options::addOptionCardId(options);
43+
options.add_options()("json-out",
44+
po::bool_switch(&mOptions.jsonOut),
45+
"Toggle json-formatted output");
46+
}
47+
48+
virtual void run(const boost::program_options::variables_map& map)
49+
{
50+
// initialize ptree
51+
pt::ptree root;
52+
53+
auto cardId = Options::getOptionCardId(map);
54+
auto params = Parameters::makeParameters(cardId, 2); //status available on BAR2
55+
// We care for all of the links
56+
//params.setLinkMask(Parameters::linkMaskFromString("0-23"));
57+
auto bar2 = ChannelFactory().getBar(params);
58+
59+
CardType::type cardType = bar2->getCardType();
60+
if (cardType == CardType::type::Crorc) {
61+
std::cout << "CRORC status report not yet supported" << std::endl;
62+
return;
63+
} else if (cardType != CardType::type::Cru) {
64+
std::cout << "Invalid card type" << std::endl;
65+
return;
66+
}
67+
68+
auto cruBar2 = std::dynamic_pointer_cast<CruBar>(bar2);
69+
70+
Cru::OnuStatus onuStatus = cruBar2->reportOnuStatus();
71+
72+
if (mOptions.jsonOut) {
73+
root.put("ONU address", onuStatus.onuAddress);
74+
root.put("ONU RX40 locked", onuStatus.rx40Locked);
75+
root.put("ONU phase good", onuStatus.phaseGood);
76+
root.put("ONU RX locked", onuStatus.rxLocked);
77+
root.put("ONU operational", onuStatus.operational);
78+
root.put("ONU MGT TX ready", onuStatus.mgtTxReady);
79+
root.put("ONU MGT RX ready", onuStatus.mgtRxReady);
80+
root.put("ONU MGT TX PLL locked", onuStatus.mgtTxPllLocked);
81+
root.put("ONU MGT RX PLL locked", onuStatus.mgtRxPllLocked);
82+
} else {
83+
std::cout << "ONU address: \t\t0x" << std::hex << onuStatus.onuAddress << std::endl;
84+
std::cout << "-----------------------------" << std::endl;
85+
std::cout << "ONU RX40 locked: \t" << std::boolalpha << onuStatus.rx40Locked << std::endl;
86+
std::cout << "ONU phase good: \t" << std::boolalpha << onuStatus.phaseGood << std::endl;
87+
std::cout << "ONU RX locked: \t\t" << std::boolalpha << onuStatus.rxLocked << std::endl;
88+
std::cout << "ONU operational: \t" << std::boolalpha << onuStatus.operational << std::endl;
89+
std::cout << "ONU MGT TX ready: \t" << std::boolalpha << onuStatus.mgtTxReady << std::endl;
90+
std::cout << "ONU MGT RX ready: \t" << std::boolalpha << onuStatus.mgtRxReady << std::endl;
91+
std::cout << "ONU MGT TX PLL locked: \t" << std::boolalpha << onuStatus.mgtTxPllLocked << std::endl;
92+
std::cout << "ONU MGT RX PLL locked: \t" << std::boolalpha << onuStatus.mgtRxPllLocked << std::endl;
93+
}
94+
95+
if (mOptions.jsonOut) {
96+
pt::write_json(std::cout, root);
97+
}
98+
}
99+
100+
private:
101+
struct OptionsStruct {
102+
bool jsonOut = false;
103+
} mOptions;
104+
};
105+
106+
int main(int argc, char** argv)
107+
{
108+
return ProgramOnuStatus().execute(argc, argv);
109+
}

src/Cru/Common.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ struct ReportInfo {
9494
uint32_t triggerWindowSize;
9595
};
9696

97+
struct OnuStatus {
98+
uint32_t onuAddress;
99+
bool rx40Locked;
100+
bool phaseGood;
101+
bool rxLocked;
102+
bool operational;
103+
bool mgtTxReady;
104+
bool mgtRxReady;
105+
bool mgtTxPllLocked;
106+
bool mgtRxPllLocked;
107+
};
108+
97109
struct LinkPacketInfo {
98110
uint32_t accepted;
99111
uint32_t rejected;

src/Cru/CruBar.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,5 +853,11 @@ void CruBar::patternPlayer(Cru::PatternPlayerInfo info)
853853
}
854854
}
855855

856+
Cru::OnuStatus CruBar::reportOnuStatus()
857+
{
858+
Ttc ttc = Ttc(mPdaBar);
859+
return ttc.onuStatus();
860+
}
861+
856862
} // namespace roc
857863
} // namespace AliceO2

src/Cru/CruBar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class CruBar final : public BarInterfaceBase
9090
void setDebugModeEnabled(bool enabled);
9191
bool getDebugModeEnabled();
9292

93+
Cru::OnuStatus reportOnuStatus();
94+
9395
private:
9496
boost::optional<int32_t> getSerialNumber();
9597
uint32_t getTemperatureRaw();

src/Cru/Ttc.cxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,25 @@ bool Ttc::configurePonTx(uint32_t onuAddress)
137137
//TODO: Show calibration status..
138138
}
139139

140+
Cru::OnuStatus Ttc::onuStatus()
141+
{
142+
uint32_t calStatus = mPdaBar->readRegister(Cru::Registers::ONU_USER_LOGIC.index) + 0xc;
143+
uint32_t onuAddress = mPdaBar->readRegister(Cru::Registers::ONU_USER_LOGIC.index) >> 1;
144+
145+
Cru::OnuStatus onuStatus = {
146+
onuAddress,
147+
calStatus & 0x1,
148+
calStatus >> 1 & 0x1,
149+
calStatus >> 2 & 0x1,
150+
calStatus >> 3 & 0x1,
151+
calStatus >> 4 & 0x1,
152+
calStatus >> 5 & 0x1,
153+
calStatus >> 6 & 0x1,
154+
calStatus >> 7 & 0x1
155+
};
156+
return onuStatus;
157+
}
158+
140159
void Ttc::calibrateTtc()
141160
{
142161
// Reset ONU core

src/Cru/Ttc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class Ttc
4141
void setEmulatorHCDIV(uint32_t hcdiv);
4242
void setFixedBCTrigger(std::vector<uint32_t> FBCTVector);
4343

44+
Cru::OnuStatus onuStatus();
45+
4446
private:
4547
void configurePlls(uint32_t clock);
4648
void setRefGen(int frequency = 240);

0 commit comments

Comments
 (0)