Skip to content

Commit 02627b8

Browse files
committed
[config] Add allowRejection parameter
1 parent 52bfa16 commit 02627b8

File tree

5 files changed

+56
-28
lines changed

5 files changed

+56
-28
lines changed

include/ReadoutCard/Parameters.h

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,15 @@ class Parameters
9898
/// Type for the gbt mux map parameter
9999
using GbtMuxMapType = std::map<uint32_t, GbtMux::type>;
100100

101+
/// Type for the allow rejection parameter
102+
using AllowRejectionType = bool;
103+
101104
/// Type for the clock parameter
102105
using ClockType = Clock::type;
103106

107+
/// Type for the CRU ID
108+
using CruIdType = Hex::type;
109+
104110
/// Type for the datapath mode parameter
105111
using DatapathModeType = DatapathMode::type;
106112

@@ -125,9 +131,6 @@ class Parameters
125131
/// Type for the STBRD enabled parameter
126132
using StbrdEnabledType = bool;
127133

128-
/// Type for the CRU ID
129-
using CruIdType = Hex::type;
130-
131134
// Setters
132135

133136
/// Sets the CardId parameter
@@ -295,6 +298,14 @@ class Parameters
295298
/// \return Reference to this object for chaining calls
296299
auto setLinkMask(LinkMaskType value) -> Parameters&;
297300

301+
/// Sets the AllowRejection parameter
302+
///
303+
/// If enabled the PON upstream is used.
304+
///
305+
/// \param value The value to set
306+
/// \return Reference to this object for chaining calls
307+
auto setAllowRejection(AllowRejectionType value) -> Parameters&;
308+
298309
/// Sets the Clock Parameter
299310
///
300311
/// The Clock parameter refers to the selection of the TTC or Local clock for the CRU configuration
@@ -303,6 +314,11 @@ class Parameters
303314
/// \return Reference to this object for chaining calls
304315
auto setClock(ClockType value) -> Parameters&;
305316

317+
/// Sets the CruId parameter
318+
///
319+
/// \param value The value to set
320+
/// \return Reference to this object for chaining calls
321+
auto setCruId(CruIdType value) -> Parameters&;
306322

307323
/// Sets the DatapathMode Parameter
308324
///
@@ -356,19 +372,20 @@ class Parameters
356372
/// \return Reference to this object for chaining calls
357373
auto setStbrdEnabled(StbrdEnabledType value) -> Parameters&;
358374

359-
/// Sets the CruId parameter
360-
///
361-
/// \param value The value to set
362-
/// \return Reference to this object for chaining calls
363-
auto setCruId(CruIdType value) -> Parameters&;
364-
365-
366375
// on-throwing getters
367376

377+
/// Gets the AllowRejection parameter
378+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
379+
auto getAllowRejection() const -> boost::optional<AllowRejectionType>;
380+
368381
/// Gets the CardId parameter
369382
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
370383
auto getCardId() const -> boost::optional<CardIdType>;
371384

385+
/// Gets the CruId parameter
386+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
387+
auto getCruId() const -> boost::optional<CruIdType>;
388+
372389
/// Gets the ChannelNumber parameter
373390
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
374391
auto getChannelNumber() const -> boost::optional<ChannelNumberType>;
@@ -449,12 +466,13 @@ class Parameters
449466
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
450467
auto getStbrdEnabled() const -> boost::optional<StbrdEnabledType>;
451468

452-
/// Gets the CruId parameter
453-
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
454-
auto getCruId() const -> boost::optional<CruIdType>;
455-
456469
// Throwing getters
457470

471+
/// Gets the AllowRejection parameter
472+
/// \exception ParameterException The parameter was not present
473+
/// \return The value
474+
auto getAllowRejectionRequired() const -> AllowRejectionType;
475+
458476
/// Gets the CardId parameter
459477
/// \exception ParameterException The parameter was not present
460478
/// \return The value
@@ -530,6 +548,11 @@ class Parameters
530548
/// \return The value
531549
auto getClockRequired() const -> ClockType;
532550

551+
/// Gets the CruId parameter
552+
/// \exception ParameterException The parameter was not present
553+
/// \return The value
554+
auto getCruIdRequired() const -> CruIdType;
555+
533556
/// Gets the DatapathMode Parameter
534557
/// \exception ParameterException The parameter was not present
535558
/// \return The value
@@ -560,11 +583,6 @@ class Parameters
560583
/// \return The value
561584
auto getStbrdEnabledRequired() const -> StbrdEnabledType;
562585

563-
/// Gets the CruId parameter
564-
/// \exception ParameterException The parameter was not present
565-
/// \return The value
566-
auto getCruIdRequired() const -> CruIdType;
567-
568586
// Helper functions
569587

570588
/// Convenience function to make a Parameters object with card ID and channel number, since these are the most

src/CommandLineUtilities/ProgramConfig.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class ProgramConfig: public Program
4040
virtual void addOptions(boost::program_options::options_description& options)
4141
{
4242
options.add_options()
43+
("allow-rejection",
44+
po::bool_switch(&mOptions.allowRejection),
45+
"Flag to allow HBF rejection")
4346
("clock",
4447
po::value<std::string>(&mOptions.clock)->default_value("LOCAL"),
4548
"Clock [LOCAL, TTC]")
@@ -114,15 +117,16 @@ class ProgramConfig: public Program
114117
std::cout << "Configuring with command line arguments" << std::endl;
115118
auto params = Parameters::makeParameters(cardId, 2);
116119
params.setLinkMask(Parameters::linkMaskFromString(mOptions.links));
120+
params.setAllowRejection(mOptions.allowRejection);
117121
params.setClock(Clock::fromString(mOptions.clock));
122+
params.setCruId(mOptions.cruId);
118123
params.setDatapathMode(DatapathMode::fromString(mOptions.datapathMode));
119124
params.setDownstreamData(DownstreamData::fromString(mOptions.downstreamData));
120125
params.setGbtMode(GbtMode::fromString(mOptions.gbtMode));
121126
params.setGbtMux(GbtMux::fromString(mOptions.gbtMux));
122127
params.setLinkLoopbackEnabled(mOptions.linkLoopbackEnabled);
123128
params.setPonUpstreamEnabled(mOptions.ponUpstreamEnabled);
124129
params.setOnuAddress(mOptions.onuAddress);
125-
params.setCruId(mOptions.cruId);
126130

127131
CardConfigurator(params, mOptions.forceConfig);
128132
} else if (!strncmp(mOptions.configFile.c_str(), "file:", 5)) {
@@ -142,15 +146,16 @@ class ProgramConfig: public Program
142146
struct OptionsStruct
143147
{
144148
std::string clock = "local";
149+
std::string configFile = "";
145150
std::string datapathMode = "packet";
146151
std::string downstreamData = "Ctp";
147152
std::string gbtMode = "gbt";
148153
std::string gbtMux = "ttc";
149154
std::string links = "0";
150-
std::string configFile = "";
151-
bool linkLoopbackEnabled = false;
155+
bool allowRejection = false;
152156
bool configAll= false;
153157
bool forceConfig = false;
158+
bool linkLoopbackEnabled = false;
154159
bool ponUpstreamEnabled = false;
155160
uint32_t onuAddress = 0x0;
156161
uint16_t cruId = 0x0;

src/Cru/CruBar.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ using Link = Cru::Link;
3535

3636
CruBar::CruBar(const Parameters& parameters)
3737
: BarInterfaceBase(parameters),
38+
mAllowRejection(parameters.getAllowRejection().get_value_or(false)),
3839
mClock(parameters.getClock().get_value_or(Clock::Local)),
3940
mCruId(parameters.getCruId().get_value_or(0x0)),
4041
mDatapathMode(parameters.getDatapathMode().get_value_or(DatapathMode::Packet)),
@@ -552,7 +553,9 @@ void CruBar::configure()
552553

553554
log("Setting packet arbitration and flow control");
554555
datapathWrapper.setPacketArbitration(mWrapperCount, 0);
555-
datapathWrapper.setFlowControl(0);
556+
if (mAllowRejection) {
557+
datapathWrapper.setFlowControl(0, 1);
558+
}
556559

557560
log("CRU configuration done.");
558561
}

src/Cru/CruBar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class CruBar final : public BarInterfaceBase
118118
FirmwareFeatures parseFirmwareFeatures();
119119
FirmwareFeatures mFeatures;
120120

121+
bool mAllowRejection;
121122
Clock::type mClock;
122123
uint16_t mCruId;
123124
DatapathMode::type mDatapathMode;

src/Parameters.cxx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ namespace AliceO2 {
2929
namespace roc {
3030

3131
/// Variant used for internal storage of parameters
32-
using Variant = boost::variant<size_t, int32_t, bool, Parameters::BufferParametersType, Parameters::CardIdType,
32+
using Variant = boost::variant<size_t, int32_t, bool, Parameters::BufferParametersType, Parameters::CardIdType,
3333
Parameters::GeneratorLoopbackType, Parameters::GeneratorPatternType, Parameters::ReadoutModeType,
34-
Parameters::LinkMaskType, Parameters::ClockType, Parameters::DatapathModeType, Parameters::DownstreamDataType,
35-
Parameters::GbtModeType, Parameters::GbtMuxType, Parameters::GbtMuxMapType, Parameters::PonUpstreamEnabledType,
36-
Parameters::OnuAddressType, Parameters::CruIdType>;
34+
Parameters::LinkMaskType, Parameters::AllowRejectionType, Parameters::ClockType, Parameters::CruIdType,
35+
Parameters::DatapathModeType, Parameters::DownstreamDataType, Parameters::GbtModeType, Parameters::GbtMuxType,
36+
Parameters::GbtMuxMapType, Parameters::PonUpstreamEnabledType,Parameters::OnuAddressType>;
3737

3838
using KeyType = const char*;
3939

@@ -123,7 +123,9 @@ _PARAMETER_FUNCTIONS(GeneratorPattern, "generator_pattern")
123123
_PARAMETER_FUNCTIONS(GeneratorRandomSizeEnabled, "generator_random_size_enabled")
124124
_PARAMETER_FUNCTIONS(ReadoutMode, "readout_mode")
125125
_PARAMETER_FUNCTIONS(LinkMask, "link_mask")
126+
_PARAMETER_FUNCTIONS(AllowRejection, "allow_rejection")
126127
_PARAMETER_FUNCTIONS(Clock, "clock")
128+
_PARAMETER_FUNCTIONS(CruId, "cru_id")
127129
_PARAMETER_FUNCTIONS(DatapathMode, "datapath_mode")
128130
_PARAMETER_FUNCTIONS(DownstreamData, "downstream_data")
129131
_PARAMETER_FUNCTIONS(GbtMode, "gbt_mode")
@@ -133,7 +135,6 @@ _PARAMETER_FUNCTIONS(LinkLoopbackEnabled, "link_loopback_enabled")
133135
_PARAMETER_FUNCTIONS(PonUpstreamEnabled, "pon_upstream_enabled")
134136
_PARAMETER_FUNCTIONS(OnuAddress, "onu_address")
135137
_PARAMETER_FUNCTIONS(StbrdEnabled, "stbrd_enabled")
136-
_PARAMETER_FUNCTIONS(CruId, "cru_id")
137138
#undef _PARAMETER_FUNCTIONS
138139

139140
Parameters::Parameters() : mPimpl(std::make_unique<ParametersPimpl>())

0 commit comments

Comments
 (0)