Skip to content

Commit cc6c484

Browse files
committed
Add PON upstream and ONU address CRU config params
1 parent fef6bac commit cc6c484

File tree

11 files changed

+179
-17
lines changed

11 files changed

+179
-17
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ add_library(ReadoutCard SHARED
9999
src/ExceptionInternal.cxx
100100
src/MemoryMappedFile.cxx
101101
src/Parameters.cxx
102+
src/ParameterTypes/Address.cxx
102103
src/ParameterTypes/Clock.cxx
103104
src/ParameterTypes/DatapathMode.cxx
104105
src/ParameterTypes/DownstreamData.cxx

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ The Parameters that affect the configuration of the CRU and their possible value
139139

140140
`LinkLoopbackEnabled (true | false)`
141141

142+
`PonUpstreamEnabled (true | false)`
143+
144+
`OnuAddress (0x01234567)`
145+
142146
To set any of the above parameters the usual template can be followed.
143147

144148
```
@@ -156,10 +160,17 @@ params.setClock(Parameters::Clock::type::Local);
156160
The above parameters will be set for the enabled links, as specified by the `LinkMask` parameter. See the [LinkMask](#linkmask) section
157161
for more info.
158162

159-
Note that for `LinkLoopbackEnabled` it is sufficient to do the following, as it is simply a boolean.
163+
Note that for `LinkLoopbackEnabled` and `PonUpstreamEnabled` it is sufficient to do the following, as they are simply booleans.
160164

161165
```
162166
params.setLinkLoopbackEnabled(true);
167+
params.setPonUpstreamEnabled(true);
168+
```
169+
170+
Likewise for `OnuAddress`, passing the hex is enough.
171+
172+
```
173+
params.setOnuAddress(0x0badcafe)
163174
```
164175

165176
### Configuration File
@@ -175,6 +186,7 @@ datapathmode
175186
loopback
176187
gbtmode
177188
downstreamdata
189+
ponupstream
178190
```
179191

180192
The "per link" parameters are
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 Address.h
12+
/// \brief Definition of the Address struct
13+
///
14+
/// \author Kostas Alexopoulos ([email protected])
15+
16+
#ifndef ALICEO2_INCLUDE_READOUTCARD_CRU_ADDRESS_H_
17+
#define ALICEO2_INCLUDE_READOUTCARD_CRU_ADDRESS_H_
18+
19+
#include <string>
20+
#include "ReadoutCard/Cru.h"
21+
22+
namespace AliceO2 {
23+
namespace roc {
24+
25+
//Ugly for consistency reasons
26+
struct Address
27+
{
28+
using type = uint32_t;
29+
30+
/// Converts a string to an Address
31+
static Address::type fromString(const std::string& string);
32+
};
33+
34+
} // namespace roc
35+
} // namespace AliceO2
36+
37+
#endif // ALICEO2_INCLUDE_READOUTCARD_CRU_ADDRESS_H_

include/ReadoutCard/Parameters.h

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "ReadoutCard/ParameterTypes/PciAddress.h"
2929
#include "ReadoutCard/ParameterTypes/PciSequenceNumber.h"
3030
#include "ReadoutCard/ParameterTypes/ReadoutMode.h"
31+
#include "ReadoutCard/ParameterTypes/Address.h"
3132

3233
// CRU Specific
3334
#include "ReadoutCard/ParameterTypes/Clock.h"
@@ -115,6 +116,12 @@ class Parameters
115116
/// Type for the link loopback enabled parameter
116117
using LinkLoopbackEnabledType = bool;
117118

119+
/// Type for the PON upstream enabled parameter
120+
using PonUpstreamEnabledType = bool;
121+
122+
/// Type for the ONU address parameter
123+
using OnuAddressType = Address::type;
124+
118125
/// Type for the STBRD enabled parameter
119126
using StbrdEnabledType = bool;
120127

@@ -176,6 +183,20 @@ class Parameters
176183
/// \return Reference to this object for chaining calls
177184
auto setLinkLoopbackEnabled(LinkLoopbackEnabledType value) -> Parameters&;
178185

186+
/// Sets the PonUpstreamEnabled parameter
187+
///
188+
/// If enabled the PON upstream is used.
189+
///
190+
/// \param value The value to set
191+
/// \return Reference to this object for chaining calls
192+
auto setPonUpstreamEnabled(PonUpstreamEnabledType value) -> Parameters&;
193+
194+
/// Sets the OnuAddress parameter
195+
///
196+
/// \param value The value to set
197+
/// \return Reference to this object for chaining calls
198+
auto setOnuAddress(OnuAddressType value) -> Parameters&;
199+
179200
/// Sets the GeneratorDataSize parameter
180201
///
181202
/// It controls the size in bytes of the generated data per DMA page.
@@ -351,10 +372,18 @@ class Parameters
351372
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
352373
auto getGeneratorEnabled() const -> boost::optional<GeneratorEnabledType>;
353374

354-
/// Gets the LinkLoopbacknabled parameter
375+
/// Gets the LinkLoopbackEnabled parameter
355376
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
356377
auto getLinkLoopbackEnabled() const -> boost::optional<LinkLoopbackEnabledType>;
357378

379+
/// Gets the PonUpstreamEnabled parameter
380+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
381+
auto getPonUpstreamEnabled() const -> boost::optional<PonUpstreamEnabledType>;
382+
383+
/// Gets the OnuAddress parameter
384+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
385+
auto getOnuAddress() const -> boost::optional<OnuAddressType>;
386+
358387
/// Gets the GeneratorDataSize parameter
359388
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
360389
auto getGeneratorDataSize() const -> boost::optional<GeneratorDataSizeType>;
@@ -438,6 +467,16 @@ class Parameters
438467
/// \return The value
439468
auto getLinkLoopbackEnabledRequired() const -> LinkLoopbackEnabledType;
440469

470+
/// Gets the PonUpstreamEnabled parameter
471+
/// \exception ParameterException The parameter was not present
472+
/// \return The value
473+
auto getPonUpstreamEnabledRequired() const -> PonUpstreamEnabledType;
474+
475+
/// Gets the OnuAddress parameter
476+
/// \exception ParameterException The parameter was not present
477+
/// \return The value
478+
auto getOnuAddressRequired() const -> OnuAddressType;
479+
441480
/// Gets the GeneratorDataSize parameter
442481
/// \exception ParameterException The parameter was not present
443482
/// \return The value

roc_example.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ gbtmode=WB
2626
# [CTP | PATTERN | MIDTRG]
2727
downstreamdata=MIDTRG
2828

29+
# [true | false]
30+
ponupstream=false
31+
32+
# [0x0badcafe]
33+
onuaddress=0x0badcafe
34+
2935
#############################################
3036
# links
3137
#############################################

src/CardConfigurator.cxx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ namespace roc {
1414
CardConfigurator::CardConfigurator(Parameters::CardIdType cardId, std::string pathToConfigFile, bool forceConfigure)
1515
{
1616
auto parameters = Parameters::makeParameters(cardId, 2); //have to make parameters for this case, bar2
17-
parseConfigFile(pathToConfigFile, parameters);
17+
try {
18+
parseConfigFile(pathToConfigFile, parameters);
19+
} catch (std::string e) {
20+
throw std::runtime_error(e);
21+
}
1822

1923
auto bar2 = ChannelFactory().getBar(parameters);
2024
if (forceConfigure) {
@@ -45,6 +49,8 @@ void CardConfigurator::parseConfigFile(std::string pathToConfigFile, Parameters&
4549
Clock::type clock = Clock::type::Local;
4650
DatapathMode::type datapathMode = DatapathMode::type::Packet;
4751
bool loopback = false;
52+
bool ponUpstream = false;
53+
uint32_t onuAddress = 0x0;
4854
GbtMode::type gbtMode = GbtMode::type::Gbt;
4955
DownstreamData::type downstreamData = DownstreamData::type::Ctp;
5056

@@ -97,13 +103,28 @@ void CardConfigurator::parseConfigFile(std::string pathToConfigFile, Parameters&
97103
} catch(...) {
98104
throw("Invalid or missing loopback property");
99105
}
106+
107+
try {
108+
ponUpstream = configFile.getValue<bool>(globalGroup + ".ponupstream");
109+
} catch(...) {
110+
throw("Invalid or missing ponupstream property");
111+
}
112+
113+
try {
114+
parsedString = configFile.getValue<std::string>(globalGroup + ".onuaddress");
115+
onuAddress = Address::fromString(parsedString);
116+
} catch(...) {
117+
throw("Invalid or missing onuAddress property");
118+
}
100119
}
101120

102-
parameters.setLinkLoopbackEnabled(loopback);
103121
parameters.setClock(clock);
104122
parameters.setDatapathMode(datapathMode);
105123
parameters.setGbtMode(gbtMode);
106124
parameters.setDownstreamData(downstreamData);
125+
parameters.setLinkLoopbackEnabled(loopback);
126+
parameters.setPonUpstreamEnabled(ponUpstream);
127+
parameters.setOnuAddress(onuAddress);
107128

108129
//* Per link *//
109130
for (auto configGroup: ConfigFileBrowser(&configFile, "link")) {

src/CommandLineUtilities/ProgramConfig.cxx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ class ProgramConfig: public Program
6464
("loopback",
6565
po::bool_switch(&mOptions.linkLoopbackEnabled),
6666
"Flag to enable link loopback for DDG")
67+
("pon-upstream",
68+
po::bool_switch(&mOptions.ponUpstreamEnabled),
69+
"Flag to enable use of the PON upstream")
70+
("onu-address",
71+
po::value<uint32_t>(&mOptions.onuAddress)->default_value(0x0),
72+
"ONU address for PON upstream")
6773
("config-all",
6874
po::bool_switch(&mOptions.configAll),
6975
"Flag to configure all cards with default parameters on startup")
@@ -90,7 +96,7 @@ class ProgramConfig: public Program
9096
std::cout << " __== " << card.pciAddress.toString() << " ==__ " << std::endl;
9197
auto params = Parameters::makeParameters(card.pciAddress, 2);
9298
try {
93-
auto cardConfigurator = CardConfigurator(card.pciAddress, mOptions.configFile, mOptions.forceConfig);
99+
CardConfigurator(card.pciAddress, mOptions.configFile, mOptions.forceConfig);
94100
} catch(...) {
95101
std::cout << "Something went badly reading the configuration file..." << std::endl;
96102
}
@@ -111,12 +117,14 @@ class ProgramConfig: public Program
111117
params.setGbtMode(GbtMode::fromString(mOptions.gbtMode));
112118
params.setGbtMux(GbtMux::fromString(mOptions.gbtMux));
113119
params.setLinkLoopbackEnabled(mOptions.linkLoopbackEnabled);
120+
params.setPonUpstreamEnabled(mOptions.ponUpstreamEnabled);
121+
params.setOnuAddress(mOptions.onuAddress);
114122

115-
auto cardConfigurator = CardConfigurator(params, mOptions.forceConfig);
123+
CardConfigurator(params, mOptions.forceConfig);
116124
} else if (!strncmp(mOptions.configFile.c_str(), "file:", 5)) {
117125
std::cout << "Configuring with config file" << std::endl;
118126
try {
119-
auto cardConfigurator = CardConfigurator(cardId, mOptions.configFile, mOptions.forceConfig);
127+
CardConfigurator(cardId, mOptions.configFile, mOptions.forceConfig);
120128
} catch(std::runtime_error e) {
121129
std::cout << "Something went badly reading the configuration file..." << e.what() << std::endl;
122130
}
@@ -139,6 +147,8 @@ class ProgramConfig: public Program
139147
bool linkLoopbackEnabled = false;
140148
bool configAll= false;
141149
bool forceConfig = false;
150+
bool ponUpstreamEnabled = false;
151+
uint32_t onuAddress = 0x0;
142152
}mOptions;
143153

144154
private:

src/Cru/CruBar.cxx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ CruBar::CruBar(const Parameters& parameters)
4141
mGbtMode(parameters.getGbtMode().get_value_or(GbtMode::Gbt)),
4242
mGbtMux(parameters.getGbtMux().get_value_or(GbtMux::Ttc)),
4343
mLinkMask(parameters.getLinkMask().get_value_or(std::set<uint32_t>{0})),
44-
mGbtMuxMap(parameters.getGbtMuxMap().get_value_or(std::map<uint32_t, GbtMux::type>{}))
44+
mGbtMuxMap(parameters.getGbtMuxMap().get_value_or(std::map<uint32_t, GbtMux::type>{})),
45+
mPonUpstream(parameters.getPonUpstreamEnabled().get_value_or(false)),
46+
mOnuAddress(parameters.getOnuAddress().get_value_or(0x0))
4547
{
4648
if (getIndex() == 0) {
4749
mFeatures = parseFirmwareFeatures();
@@ -425,11 +427,15 @@ Cru::ReportInfo CruBar::report()
425427
// setClock: 2 for Local clock, 0 for TTC clock
426428
uint32_t clock = (ttc.getPllClock() == 0 ? Clock::Local : Clock::Ttc);
427429
uint32_t downstreamData = ttc.getDownstreamData();
430+
//bool ponUpstream = true; //TODO: ponUpstream currently irrelevant for configuration
431+
//uint32_t onuAddress = 0xdeadbeef; //TODO: onuAddress currently irrelevant for configuration
428432

429433
Cru::ReportInfo reportInfo = {
430434
linkMap,
431435
clock,
432-
downstreamData
436+
downstreamData,
437+
//ponUpstream
438+
//onuAddress
433439
};
434440

435441
return reportInfo;
@@ -455,9 +461,6 @@ void CruBar::reconfigure()
455461
/// Configures the CRU according to the parameters passed on init
456462
void CruBar::configure()
457463
{
458-
bool ponUpstream = false;
459-
uint32_t onuAddress = 0xbadcafe;
460-
461464
if (mLinkMap.empty()) {
462465
populateLinkMap(mLinkMap);
463466
}
@@ -476,10 +479,10 @@ void CruBar::configure()
476479
log("Calibrating TTC");
477480
ttc.calibrateTtc();
478481

479-
if (ponUpstream) {
480-
//ttc.resetFpll();
481-
if(!ttc.configurePonTx(onuAddress)) {
482-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("PON TX fPLL phase scan failed."));
482+
if (mPonUpstream) {
483+
ttc.resetFpll();
484+
if(!ttc.configurePonTx(mOnuAddress)) {
485+
log("PON TX fPLL phase scan failed", InfoLogger::InfoLogger::Error);
483486
}
484487
}
485488

src/Cru/CruBar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class CruBar final : public BarInterfaceBase
123123
std::map<int, Link> mLinkMap;
124124
std::map<uint32_t, uint32_t> mRegisterMap;
125125
std::map<uint32_t, GbtMux::type> mGbtMuxMap;
126+
bool mPonUpstream;
127+
uint32_t mOnuAddress;
126128

127129
/// Checks if this is the correct BAR. Used to check for BAR 2 for special functions.
128130
void assertBarIndex(int index, std::string message) const

src/ParameterTypes/Address.cxx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 Address.cxx
12+
/// \brief Implementation of the Address struct and supporting functions
13+
///
14+
/// \author Kostas Alexopoulos ([email protected])
15+
16+
#include "ReadoutCard/ParameterTypes/Address.h"
17+
#include "Utilities/Enum.h"
18+
19+
namespace AliceO2 {
20+
namespace roc {
21+
22+
Address::type Address::fromString(const std::string& string)
23+
{
24+
return std::stoul(string, nullptr, 16);
25+
}
26+
27+
} // namespace roc
28+
} // namespace AliceO2

0 commit comments

Comments
 (0)