Skip to content

Commit 39ea19f

Browse files
committed
[parameters] Rename 'LoopbackMode' to 'DataSource'
1 parent fba70f4 commit 39ea19f

File tree

16 files changed

+145
-143
lines changed

16 files changed

+145
-143
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ add_library(ReadoutCard SHARED
104104
src/ParameterTypes/GbtMode.cxx
105105
src/ParameterTypes/GbtMux.cxx
106106
src/ParameterTypes/Hex.cxx
107-
src/ParameterTypes/LoopbackMode.cxx
107+
src/ParameterTypes/DataSource.cxx
108108
src/ParameterTypes/PciAddress.cxx
109109
src/ParameterTypes/PciSequenceNumber.cxx
110110
src/ParameterTypes/ResetLevel.cxx

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ DMA can be paused and resumed at any time using `stopDma()` and `startDma()`
107107

108108
#### CRU
109109

110-
The loopback parameter for the CRU DMA Channel should be used as follows:
110+
The `Data Source` parameter for the CRU DMA Channel should be used as follows:
111111

112-
| `GeneratorLoopback` | Data Source |
112+
| `DataSource` | Data Source |
113113
| ------------------- | ----------- |
114-
| `None` | FEE (GBT) |
114+
| `Fee` | FEE (GBT) |
115115
| `Ddg` | DDG (GBT) |
116116
| `Internal` | DG |
117117

118118
#### CRORC
119119

120-
| `GeneratorLoopback` | Data Source |
120+
| `DataSource` | Data Source |
121121
| ------------------- | ----------- |
122-
| `None` | FEE (GBT) |
122+
| `Fee` | FEE (GBT) |
123123
| `SIU` | SIU |
124124
| `DIU` | DIU |
125125
| `INTERNAL` | DG |
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 DataSource.h
12+
/// \brief Definition of the DataSource enum and supporting functions.
13+
///
14+
/// \author Pascal Boeschoten ([email protected])
15+
/// \author Kostas Alexopoulos ([email protected])
16+
17+
#ifndef ALICEO2_INCLUDE_READOUTCARD_DATASOURCE_H_
18+
#define ALICEO2_INCLUDE_READOUTCARD_DATASOURCE_H_
19+
20+
#include <string>
21+
22+
namespace AliceO2
23+
{
24+
namespace roc
25+
{
26+
27+
/// Namespace for the ReadoutCard data source enum, and supporting functions
28+
struct DataSource {
29+
/// Data Source
30+
enum type {
31+
Fee = 0, ///< FEE (CRU & CRORC)
32+
Diu = 1, ///< DIU (CRORC)
33+
Siu = 2, ///< SIU (CRORC)
34+
Internal = 3, ///< DG (CRU & CRORC)
35+
Ddg = 4, ///< DDG (CRU)
36+
};
37+
38+
/// Converts a DataSource to a string
39+
static std::string toString(const DataSource::type& mode);
40+
41+
/// Converts a string to a DataSource
42+
static DataSource::type fromString(const std::string& string);
43+
44+
/// Returns true if the data source is external (FEE, DIU, SIU)
45+
static bool isExternal(const DataSource::type& mode);
46+
};
47+
48+
} // namespace roc
49+
} // namespace AliceO2
50+
51+
#endif // ALICEO2_INCLUDE_READOUTCARD_DATASOURCE_H_

include/ReadoutCard/ParameterTypes/LoopbackMode.h

Lines changed: 0 additions & 50 deletions
This file was deleted.

include/ReadoutCard/Parameters.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <boost/optional.hpp>
2424
#include <boost/variant.hpp>
2525
#include "ReadoutCard/ParameterTypes/BufferParameters.h"
26-
#include "ReadoutCard/ParameterTypes/LoopbackMode.h"
26+
#include "ReadoutCard/ParameterTypes/DataSource.h"
2727
#include "ReadoutCard/ParameterTypes/PciAddress.h"
2828
#include "ReadoutCard/ParameterTypes/PciSequenceNumber.h"
2929
#include "ReadoutCard/ParameterTypes/Hex.h"
@@ -73,8 +73,8 @@ class Parameters
7373
/// Type for the DMA page size parameter
7474
using DmaPageSizeType = size_t;
7575

76-
/// Type for the LoopbackMode parameter
77-
using GeneratorLoopbackType = LoopbackMode::type;
76+
/// Type for the DataSource parameter
77+
using DataSourceType = DataSource::type;
7878

7979
/// Type for the link mask parameter
8080
using LinkMaskType = std::set<uint32_t>;
@@ -177,18 +177,18 @@ class Parameters
177177
/// \return Reference to this object for chaining calls
178178
auto setOnuAddress(OnuAddressType value) -> Parameters&;
179179

180-
/// Sets the GeneratorLoopback parameter
180+
/// Sets the DataSource parameter
181181
///
182182
/// Controls the routing of the generated data.
183-
/// Supported loopback modes:
183+
/// Supported data source modes:
184184
/// * C-RORC: all modes
185-
/// * CRU: internal, none (=external)
185+
/// * CRU: internal, fee
186186
///
187187
/// If not set, the driver will default to internal loopback.
188188
///
189189
/// \param value The value to set
190190
/// \return Reference to this object for chaining calls
191-
auto setGeneratorLoopback(GeneratorLoopbackType value) -> Parameters&;
191+
auto setDataSource(DataSourceType value) -> Parameters&;
192192

193193
/// Sets the BufferParameters parameter
194194
///
@@ -336,7 +336,7 @@ class Parameters
336336
auto getOnuAddress() const -> boost::optional<OnuAddressType>;
337337

338338
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
339-
auto getGeneratorLoopback() const -> boost::optional<GeneratorLoopbackType>;
339+
auto getDataSource() const -> boost::optional<DataSourceType>;
340340

341341
/// Gets the BufferParameters parameter
342342
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
@@ -411,10 +411,10 @@ class Parameters
411411
/// \return The value
412412
auto getOnuAddressRequired() const -> OnuAddressType;
413413

414-
/// Gets the GeneratorLoopback parameter
414+
/// Gets the DataSource parameter
415415
/// \exception ParameterException The parameter was not present
416416
/// \return The value
417-
auto getGeneratorLoopbackRequired() const -> GeneratorLoopbackType;
417+
auto getDataSourceRequired() const -> DataSourceType;
418418

419419
/// Gets the BufferParameters parameter
420420
/// \exception ParameterException The parameter was not present

src/CommandLineUtilities/ProgramDmaBench.cxx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ class ProgramDmaBench : public Program
141141
SuffixOption<size_t>::make(&mBufferSize)->default_value("1Gi"),
142142
"Buffer size in bytes. Rounded down to 2 MiB multiple. Minimum of 2 MiB. Use 2 MiB hugepage by default; |"
143143
"if buffer size is a multiple of 1 GiB, will try to use GiB hugepages");
144+
options.add_options()("data-source",
145+
po::value<std::string>(&mOptions.dataSourceString)->default_value("INTERNAL"),
146+
"Data source [FEE, INTERNAL, DIU, SIU, DDG]");
144147
options.add_options()("dma-channel",
145148
po::value<int>(&mOptions.dmaChannel)->default_value(0),
146149
"DMA channel selection (note: C-RORC has channels 0 to 5, CRU only 0)");
@@ -154,9 +157,6 @@ class ProgramDmaBench : public Program
154157
options.add_options()("links",
155158
po::value<std::string>(&mOptions.links)->default_value("0"),
156159
"Links to open. A comma separated list of integers or ranges, e.g. '0,2,5-10'");
157-
options.add_options()("loopback",
158-
po::value<std::string>(&mOptions.loopbackModeString)->default_value("INTERNAL"),
159-
"Generator loopback mode [NONE, INTERNAL, DIU, SIU, DDG]");
160160
options.add_options()("max-rdh-packetcount",
161161
po::value<size_t>(&mOptions.maxRdhPacketCounter)->default_value(255),
162162
"Maximum packet counter expected in the RDH");
@@ -224,9 +224,9 @@ class ProgramDmaBench : public Program
224224
auto cardId = Options::getOptionCardId(map);
225225
auto params = Parameters::makeParameters(cardId, mOptions.dmaChannel);
226226
params.setDmaPageSize(mOptions.dmaPageSize);
227-
params.setGeneratorLoopback(LoopbackMode::fromString(mOptions.loopbackModeString));
227+
params.setDataSource(DataSource::fromString(mOptions.dataSourceString));
228228

229-
mLoopback = params.getGeneratorLoopbackRequired();
229+
mDataSource = params.getDataSourceRequired();
230230

231231
params.setStbrdEnabled(mOptions.stbrd); //Set STBRD for the CRORC
232232

@@ -516,7 +516,7 @@ class ProgramDmaBench : public Program
516516
auto readoutCount = fetchAddDmaPagesReadOut();
517517
size_t pageSize = readoutPage(pageAddress, readoutCount);
518518

519-
if (mOptions.byteCountEnabled && !(mOptions.loopbackModeString == "INTERNAL")) {
519+
if (mOptions.byteCountEnabled && !(mOptions.dataSourceString == "INTERNAL")) {
520520
mByteCount.fetch_add(pageSize, std::memory_order_relaxed);
521521
}
522522
readoutBytes += pageSize;
@@ -557,7 +557,7 @@ class ProgramDmaBench : public Program
557557
for (int i = 0; i < size; ++i) {
558558
auto superpage = mChannel->popSuperpage();
559559
fetchAddSuperpagesReadOut();
560-
if ((mLoopback == LoopbackMode::None) || (mLoopback == LoopbackMode::Ddg)) {
560+
if ((mDataSource == DataSource::Fee) || (mDataSource == DataSource::Ddg)) {
561561
auto superpageAddress = mBufferBaseAddress + superpage.getOffset();
562562
size_t readoutBytes = 0;
563563
while ((readoutBytes < superpage.getReceived()) && !isSigInt()) { // At least one more dma page fits in the superpage
@@ -586,7 +586,7 @@ class ProgramDmaBench : public Program
586586

587587
size_t readoutPage(uintptr_t pageAddress, int64_t readoutCount)
588588
{
589-
size_t pageSize = (mLoopback == LoopbackMode::Internal) ? mPageSize : DataFormat::getOffset(reinterpret_cast<const char*>(pageAddress));
589+
size_t pageSize = (mDataSource == DataSource::Internal) ? mPageSize : DataFormat::getOffset(reinterpret_cast<const char*>(pageAddress));
590590

591591
// Read out to file
592592
printToFile(pageAddress, pageSize, readoutCount);
@@ -596,7 +596,7 @@ class ProgramDmaBench : public Program
596596

597597
// Get link ID if needed
598598
uint32_t linkId = 0; // Use 0 for non-CRU cards
599-
if (mCardType == CardType::Cru && mLoopback != LoopbackMode::Internal) {
599+
if (mCardType == CardType::Cru && mDataSource != DataSource::Internal) {
600600
linkId = DataFormat::getLinkId(reinterpret_cast<const char*>(pageAddress));
601601
if (linkId >= mDataGeneratorCounters.size()) {
602602
BOOST_THROW_EXCEPTION(Exception()
@@ -635,12 +635,12 @@ class ProgramDmaBench : public Program
635635

636636
bool checkErrorsCru(uintptr_t pageAddress, size_t pageSize, int64_t eventNumber, int linkId)
637637
{
638-
if (mLoopback == LoopbackMode::Ddg) {
638+
if (mDataSource == DataSource::Ddg) {
639639
return checkErrorsCruDdg(pageAddress, pageSize, eventNumber, linkId);
640-
} else if (mLoopback == LoopbackMode::Internal) {
640+
} else if (mDataSource == DataSource::Internal) {
641641
return checkErrorsCruInternal(pageAddress, pageSize, eventNumber, linkId);
642642
} else {
643-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("CRU error check: Loopback Mode " + LoopbackMode::toString(mLoopback) + " not supported"));
643+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("CRU error check: Data Source " + DataSource::toString(mDataSource) + " not supported"));
644644
}
645645
}
646646

@@ -1078,7 +1078,7 @@ class ProgramDmaBench : public Program
10781078
std::string links;
10791079
bool bufferFullCheck = false;
10801080
size_t dmaPageSize;
1081-
std::string loopbackModeString;
1081+
std::string dataSourceString;
10821082
std::string timeLimitString;
10831083
uint64_t pausePush;
10841084
uint64_t pauseRead;
@@ -1187,8 +1187,8 @@ class ProgramDmaBench : public Program
11871187
/// Flag to test how quickly the readout buffer gets full in case of error
11881188
bool mBufferFullCheck;
11891189

1190-
/// Loopback mode
1191-
LoopbackMode::type mLoopback;
1190+
/// Data Source
1191+
DataSource::type mDataSource;
11921192
};
11931193

11941194
int main(int argc, char** argv)

0 commit comments

Comments
 (0)