Skip to content

Commit ba41bec

Browse files
committed
added CRU option dropBadRdhEnabled
1 parent e281572 commit ba41bec

File tree

14 files changed

+82
-3
lines changed

14 files changed

+82
-3
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ The Parameters that affect the configuration of the CRU, their possible values (
211211

212212
`UserLogicEnabled (true | false) [false]`
213213

214+
`DropBadRdhEnabled (true | false) [false]`
215+
214216
To set any of the above parameters the usual template can be followed.
215217

216218
```
@@ -228,7 +230,7 @@ params.setClock(Parameters::Clock::type::Local);
228230
The above parameters will be set for the enabled links, as specified by the `LinkMask` parameter. See the [LinkMask](#linkmask) section
229231
for more info.
230232

231-
Note that for `AllowRejection`, `LinkLoopbackEnabled`, `PonUpstreamEnabled`, `DynamicOffsetEnabled`, `GbtEnabled` and `UserLogicEnabled` it is sufficient to do the following, as they are simply booleans.
233+
Note that for `AllowRejection`, `LinkLoopbackEnabled`, `PonUpstreamEnabled`, `DynamicOffsetEnabled`, `GbtEnabled`, `UserLogicEnabled`, `DropBadRdhEnabled` it is sufficient to do the following, as they are simply booleans.
232234

233235
```
234236
params.setAllowRejection(true);
@@ -269,6 +271,7 @@ dynamicOffsetEnabled
269271
triggerWindowSize
270272
gbtEnabled
271273
UserLogicEnabled
274+
DropBadRdhEnabled
272275
```
273276

274277
The "per link" parameters are

cru_template.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ systemId=0xfd
6262
# Time Frame Length [0-255]
6363
timeFrameLength=255
6464

65+
# Drop packets with bad RDH
66+
dropBadRdhEnabled=false
67+
6568
#############################################
6669
# links
6770
#############################################

cru_template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"runStatsEnabled": "false",
1717
"userAndCommonLogicEnabled": "false",
1818
"systemId": "0x0",
19-
"timeFrameLength": "256"
19+
"timeFrameLength": "256",
20+
"dropBadRdhEnabled": "false"
2021
},
2122
"links": {
2223
"enabled": "false",

include/ReadoutCard/Parameters.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ class Parameters
162162
// Type for the Time Frame Length parameter
163163
using TimeFrameLengthType = uint32_t;
164164

165+
/// Type for the Drop RDH enabled parameter
166+
using DropBadRdhEnabledType = bool;
167+
165168
/// Type for the Time Frame Detection enabled parameter
166169
using TimeFrameDetectionEnabledType = bool;
167170

@@ -477,6 +480,12 @@ class Parameters
477480
/// \return Reference to this object for chaining calls
478481
auto setTimeFrameLength(TimeFrameLengthType value) -> Parameters&;
479482

483+
/// Sets the DropBadRdhEnabled parameter
484+
///
485+
/// \param value The value to set
486+
/// \return Reference to this object for chaining calls
487+
auto setDropBadRdhEnabled(DropBadRdhEnabledType value) -> Parameters&;
488+
480489
/// Sets the TimeFrameDetectionEnabled parameter
481490
///
482491
/// \param value The value to set
@@ -634,6 +643,10 @@ class Parameters
634643
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
635644
auto getTimeFrameLength() const -> boost::optional<TimeFrameLengthType>;
636645

646+
/// Gets the DropBadRdhEnabled parameter
647+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
648+
auto getDropBadRdhEnabled() const -> boost::optional<DropBadRdhEnabledType>;
649+
637650
/// Gets the TimeFrameDetectionEnabled parameter
638651
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
639652
auto getTimeFrameDetectionEnabled() const -> boost::optional<TimeFrameDetectionEnabledType>;
@@ -817,6 +830,11 @@ class Parameters
817830
/// \return The value
818831
auto getTimeFrameLengthRequired() const -> TimeFrameLengthType;
819832

833+
/// Gets the DropBadRdhEnabled parameter
834+
/// \exception ParameterException The parameter was not present
835+
/// \return The value
836+
auto getDropBadRdhEnabledRequired() const -> DropBadRdhEnabledType;
837+
820838
/// Gets the TimeFrameDetectionEnabled parameter
821839
/// \exception ParameterException The parameter was not present
822840
/// \return The value

src/CardConfigurator.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
142142
bool userAndCommonLogicEnabled = false;
143143
uint32_t systemId = 0x0;
144144
uint16_t timeFrameLength = 0x100;
145+
bool dropBadRdhEnabled = false;
145146

146147
bool enabled = false;
147148
std::string gbtMux = "ttc";
@@ -198,6 +199,7 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
198199
systemId = Hex::fromString(parsedString);
199200

200201
timeFrameLength = subtree.get<int>("timeFrameLength");
202+
dropBadRdhEnabled = subtree.get<bool>("dropBadRdhEnabled");
201203

202204
parameters.setClock(clock);
203205
parameters.setDatapathMode(datapathMode);
@@ -216,6 +218,8 @@ void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& para
216218
parameters.setUserAndCommonLogicEnabled(userAndCommonLogicEnabled);
217219
parameters.setSystemId(systemId);
218220
parameters.setTimeFrameLength(timeFrameLength);
221+
parameters.setDropBadRdhEnabled(dropBadRdhEnabled);
222+
219223
} else if (group == "links") { // Configure all links with default values
220224

221225
enabled = subtree.get<bool>("enabled");

src/CommandLineUtilities/ProgramConfig.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ std::string getStatusReport(Parameters::CardIdType cardId)
116116
std::string userLogic = (reportInfo.userLogicEnabled ? "Enabled" : "Disabled");
117117
std::string runStats = (reportInfo.runStatsEnabled ? "Enabled" : "Disabled");
118118
std::string userAndCommonLogic = (reportInfo.userAndCommonLogicEnabled ? "Enabled" : "Disabled");
119+
std::string dropBadRdh = (reportInfo.dropBadRdhEnabled ? "Enabled" : "Disabled");
119120

120121
table << "-----------------------------" << std::endl;
121122
table << "CRU ID: " << reportInfo.cruId << std::endl;
@@ -130,6 +131,9 @@ std::string getStatusReport(Parameters::CardIdType cardId)
130131
if (reportInfo.runStatsEnabled) {
131132
table << "Run statistics enabled" << std::endl;
132133
}
134+
if (reportInfo.dropBadRdhEnabled) {
135+
table << "Drop packets with bad RDH enabled" << std::endl;
136+
}
133137

134138
Cru::OnuStatus onuStatus = cruBar2->reportOnuStatus(0);
135139

@@ -315,6 +319,9 @@ class ProgramConfig : public Program
315319
options.add_options()("status-report",
316320
po::value<std::string>(&mOptions.statusReport),
317321
"Sets file where to output card status (similar to roc-status). Can be stdout, infologger, or a file name. The file name can be preceded with + for appending the file. Name can contain special escape sequences %t (timestamp) %T (date/time) or %i (card ID). Infologger reports are set with error code 4805.");
322+
options.add_options()("drop-bad-rdh",
323+
po::bool_switch(&mOptions.dropBadRdhEnabled),
324+
"Flag to enable dropping of packets with bad RDH");
318325
Options::addOptionCardId(options);
319326
}
320327

@@ -480,6 +487,7 @@ class ProgramConfig : public Program
480487
params.setTimeFrameDetectionEnabled(!mOptions.timeFrameDetectionDisabled);
481488
params.setSystemId(strtoul(mOptions.systemId.c_str(), NULL, 16));
482489
params.setFeeId(strtoul(mOptions.feeId.c_str(), NULL, 16));
490+
params.setDropBadRdhEnabled(mOptions.dropBadRdhEnabled);
483491

484492
// Generate a configuration file base on the parameters provided
485493
if (mOptions.genConfigFile != "") { //TODO: To be updated for the CRORC
@@ -506,6 +514,7 @@ class ProgramConfig : public Program
506514
//cfgFile << "timeFrameDetectionEnabled=" << std::boolalpha << !mOptions.timeFrameDetectionDisabled << "\n";
507515
cfgFile << "systemId=" << mOptions.systemId << "\n";
508516
cfgFile << "timeFrameLength=" << mOptions.timeFrameLength << "\n";
517+
cfgFile << "dropBadRdhEnabled=" << std::boolalpha << mOptions.dropBadRdhEnabled << "\n";
509518

510519
cfgFile << "[links]\n";
511520
cfgFile << "enabled=false\n";
@@ -589,6 +598,7 @@ class ProgramConfig : public Program
589598
std::string statusReport = ""; // when set, output roc status to file
590599
/*std::string systemId = "0x1ff"; // TODO: Default values that can be used to check if params have been specified
591600
std::string feeId = "0x1f";*/
601+
bool dropBadRdhEnabled = false;
592602
} mOptions;
593603

594604
private:

src/CommandLineUtilities/ProgramStatus.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ class ProgramStatus : public Program
211211
std::string runStats = (reportInfo.runStatsEnabled ? "Enabled" : "Disabled");
212212
std::string userAndCommonLogic = (reportInfo.userAndCommonLogicEnabled ? "Enabled" : "Disabled");
213213
std::string dmaStatus = reportInfo.dmaStatus ? "Enabled" : "Disabled";
214+
std::string dropBadRdh = (reportInfo.dropBadRdhEnabled ? "Enabled" : "Disabled");
214215

215216
/* GENERAL PARAMETERS */
216217
if (mOptions.monitoring) {
@@ -240,6 +241,7 @@ class ProgramStatus : public Program
240241
root.put("userAndCommonLogic", userAndCommonLogic);
241242
root.put("timeFrameLength", reportInfo.timeFrameLength);
242243
root.put("dmaStatus", dmaStatus);
244+
root.put("dropBadRdh", dropBadRdh);
243245
} else {
244246
std::cout << "-----------------------------" << std::endl;
245247
std::cout << "CRU ID: " << reportInfo.cruId << std::endl;
@@ -255,6 +257,9 @@ class ProgramStatus : public Program
255257
std::cout << "Run statistics enabled" << std::endl;
256258
}
257259
std::cout << "DMA: "<< dmaStatus << std::endl;
260+
if (reportInfo.dropBadRdhEnabled) {
261+
std::cout << "Drop packets with bad RDH enabled" << std::endl;
262+
}
258263
}
259264

260265
/* ONU PARAMETERS */

src/Cru/Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ struct ReportInfo {
126126
bool userAndCommonLogicEnabled;
127127
uint16_t timeFrameLength;
128128
bool dmaStatus;
129+
bool dropBadRdhEnabled;
129130
};
130131

131132
struct OnuStickyStatus {

src/Cru/Constants.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ static constexpr Register DWRAPPER_TOTAL_PACKETS_PER_SEC(0x0000002c);
327327
/// Register to set the trigger window size in gbt words
328328
static constexpr Register DWRAPPER_TRIGGER_SIZE(0x00000034);
329329

330+
/// Register to enable dropping of packets with bad RDH
331+
static constexpr Register DWRAPPER_DROP_BAD_RDH(0x00000038);
332+
333+
330334
static constexpr Register DATALINK_PACKETS_REJECTED(0x00000008);
331335
static constexpr Register DATALINK_PACKETS_ACCEPTED(0x0000000c);
332336
static constexpr Register DATALINK_PACKETS_FORCED(0x00000010);

src/Cru/CruBar.cxx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ CruBar::CruBar(const Parameters& parameters, std::unique_ptr<RocPciDevice> rocPc
6868
mGbtHighMask(parameters.getGbtHighMask().get_value_or(0xffffffff)),
6969
mGbtMedMask(parameters.getGbtMedMask().get_value_or(0xffffffff)),
7070
mGbtLowMask(parameters.getGbtLowMask().get_value_or(0xffffffff)),
71-
mTimeFrameLength(parameters.getTimeFrameLength().get_value_or(0x100))
71+
mTimeFrameLength(parameters.getTimeFrameLength().get_value_or(0x100)),
72+
mDropBadRdhEnabled(parameters.getDropBadRdhEnabled().get_value_or(false))
7273
{
7374
if (getIndex() == 0) {
7475
mFeatures = parseFirmwareFeatures();
@@ -559,6 +560,7 @@ Cru::ReportInfo CruBar::report(bool forConfig)
559560

560561
bool userAndCommonLogicEnabled = datapathWrapper.getUserAndCommonLogicEnabled(mEndpoint);
561562
uint16_t timeFrameLength = getTimeFrameLength();
563+
bool dropBadRdhEnabled = datapathWrapper.getDropBadRdhEnabled(mEndpoint);
562564

563565
bool dmaStatus = getDmaStatus();
564566

@@ -579,6 +581,7 @@ Cru::ReportInfo CruBar::report(bool forConfig)
579581
reportInfo.userAndCommonLogicEnabled = userAndCommonLogicEnabled;
580582
reportInfo.timeFrameLength = timeFrameLength;
581583
reportInfo.dmaStatus = dmaStatus;
584+
reportInfo.dropBadRdhEnabled = dropBadRdhEnabled;
582585

583586
return reportInfo;
584587
}
@@ -744,6 +747,7 @@ void CruBar::configure(bool force)
744747
mRunStatsEnabled == reportInfo.runStatsEnabled &&
745748
mGbtEnabled == reportInfo.gbtEnabled &&
746749
mTimeFrameLength == reportInfo.timeFrameLength &&
750+
mDropBadRdhEnabled == reportInfo.dropBadRdhEnabled &&
747751
!force) {
748752
log("No need to reconfigure further", LogInfoDevel_(4600));
749753
return;
@@ -875,6 +879,11 @@ void CruBar::configure(bool force)
875879
setTimeFrameLength(mTimeFrameLength);
876880
}
877881

882+
if (mDropBadRdhEnabled != reportInfo.dropBadRdhEnabled || force) {
883+
log("Drop packets with bad RDH enabled: " + Utilities::toBoolString(mDropBadRdhEnabled), LogInfoDevel_(4605));
884+
datapathWrapper.setDropBadRdhEnabled(mDropBadRdhEnabled, mEndpoint);
885+
}
886+
878887
log("CRU configuration done", LogInfoDevel_(4600));
879888
}
880889

0 commit comments

Comments
 (0)