DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
flxlibs
src
CardWrapper.hpp
Go to the documentation of this file.
1
8
#ifndef FLXLIBS_SRC_CARDWRAPPER_HPP_
9
#define FLXLIBS_SRC_CARDWRAPPER_HPP_
10
11
//#include "flxlibs/felixcardreader/Nljs.hpp"
12
//#include "flxlibs/felixcardreader/Structs.hpp"
13
14
#include "
appmodel/FelixInterface.hpp
"
15
#include "
utilities/ReusableThread.hpp
"
16
17
#include "flxcard/FlxCard.h"
18
#include "packetformat/block_format.hpp"
19
20
#include <nlohmann/json.hpp>
21
22
#include <atomic>
23
#include <memory>
24
#include <mutex>
25
#include <string>
26
27
namespace
dunedaq::flxlibs
{
28
29
class
CardWrapper
30
{
31
public
:
36
CardWrapper
(
const
appmodel::FelixInterface
* cfg, std::vector<unsigned int>);
37
~CardWrapper
();
38
CardWrapper
(
const
CardWrapper
&) =
delete
;
39
CardWrapper
&
operator=
(
const
CardWrapper
&) =
delete
;
40
CardWrapper
(
CardWrapper
&&) =
delete
;
41
CardWrapper
&
operator=
(
CardWrapper
&&) =
delete
;
42
43
void
configure
();
44
void
start
();
45
void
stop
();
46
void
set_running
(
bool
should_run);
47
48
void
graceful_stop
();
49
50
void
set_block_addr_handler
(std::function<
void
(uint64_t)>& handle)
// NOLINT(build/unsigned)
51
{
// NOLINT
52
m_handle_block_addr
= std::bind(handle, std::placeholders::_1);
53
m_block_addr_handler_available
=
true
;
54
}
55
56
private
:
57
58
// Constants
59
static
constexpr
size_t
m_max_links_per_card
= 6;
60
// static constexpr size_t m_margin_blocks = 4;
61
// static constexpr size_t m_block_threshold = 256;
62
static
constexpr
size_t
m_block_size
= 4096;
// felix::packetformat::BLOCKSIZE;
63
static
constexpr
size_t
m_dma_wraparound
= FLX_DMA_WRAPAROUND;
64
65
// Card
66
void
open_card
();
67
void
close_card
();
68
69
// DMA
70
int
allocate_CMEM
(uint8_t numa, u_long bsize, u_long* paddr, u_long* vaddr);
// NOLINT
71
void
init_DMA
();
72
void
start_DMA
();
73
void
stop_DMA
();
74
uint64_t
bytes_available
();
// NOLINT
75
void
read_current_address
();
76
77
// Configuration and internals
78
79
std::atomic<bool>
m_run_marker
;
80
bool
m_configured
{
false
};
81
uint8_t
m_card_id
;
// NOLINT
82
uint8_t
m_logical_unit
;
// NOLINT
83
std::string
m_card_id_str
;
84
uint8_t
m_dma_id
;
// NOLINT
85
size_t
m_margin_blocks
;
// NOLINT
86
size_t
m_block_threshold
;
// NOLINT
87
bool
m_interrupt_mode
;
// NOLINT
88
size_t
m_poll_time
;
// NOLINT
89
uint8_t
m_numa_id
;
// NOLINT
90
std::vector<unsigned int>
m_links_enabled
;
// NOLINT
91
std::string
m_info_str
;
92
93
// Card object
94
using
UniqueFlxCard
= std::unique_ptr<FlxCard>;
95
UniqueFlxCard
m_flx_card
;
96
std::mutex
m_card_mutex
;
97
98
// DMA: CMEM
99
std::size_t
m_dma_memory_size
;
// size of CMEM (driver) memory to allocate
100
int
m_cmem_handle
;
// handle to the DMA memory block
101
uint64_t
m_virt_addr
;
// NOLINT virtual address of the DMA memory block
102
uint64_t
m_phys_addr
;
// NOLINT physical address of the DMA memory block
103
uint64_t
m_current_addr
;
// NOLINT pointer to the current write position for the card
104
unsigned
m_read_index
;
// NOLINT
105
u_long
m_destination
;
// u_long -> FlxCard.h
106
107
// Processor
108
inline
static
const
std::string
m_dma_processor_name
=
"flx-dma"
;
109
std::atomic<bool>
m_run_lock
;
110
utilities::ReusableThread
m_dma_processor
;
111
std::function<void(uint64_t)>
m_handle_block_addr
;
// NOLINT
112
bool
m_block_addr_handler_available
{
false
};
113
void
process_DMA
();
114
};
115
116
}
// namespace dunedaq::flxlibs
117
118
#endif
// FLXLIBS_SRC_CARDWRAPPER_HPP_
ReusableThread.hpp
dunedaq::appmodel::FelixInterface
Definition
FelixInterface.hpp:27
dunedaq::flxlibs::CardWrapper::read_current_address
void read_current_address()
Definition
CardWrapper.cpp:273
dunedaq::flxlibs::CardWrapper::CardWrapper
CardWrapper(const CardWrapper &)=delete
CardWrapper is not copy-constructible.
dunedaq::flxlibs::CardWrapper::stop_DMA
void stop_DMA()
Definition
CardWrapper.cpp:257
dunedaq::flxlibs::CardWrapper::m_phys_addr
uint64_t m_phys_addr
Definition
CardWrapper.hpp:102
dunedaq::flxlibs::CardWrapper::m_dma_processor
utilities::ReusableThread m_dma_processor
Definition
CardWrapper.hpp:110
dunedaq::flxlibs::CardWrapper::m_interrupt_mode
bool m_interrupt_mode
Definition
CardWrapper.hpp:87
dunedaq::flxlibs::CardWrapper::m_max_links_per_card
static constexpr size_t m_max_links_per_card
Definition
CardWrapper.hpp:59
dunedaq::flxlibs::CardWrapper::m_destination
u_long m_destination
Definition
CardWrapper.hpp:105
dunedaq::flxlibs::CardWrapper::m_dma_memory_size
std::size_t m_dma_memory_size
Definition
CardWrapper.hpp:99
dunedaq::flxlibs::CardWrapper::m_margin_blocks
size_t m_margin_blocks
Definition
CardWrapper.hpp:85
dunedaq::flxlibs::CardWrapper::process_DMA
void process_DMA()
Definition
CardWrapper.cpp:281
dunedaq::flxlibs::CardWrapper::m_dma_id
uint8_t m_dma_id
Definition
CardWrapper.hpp:84
dunedaq::flxlibs::CardWrapper::m_current_addr
uint64_t m_current_addr
Definition
CardWrapper.hpp:103
dunedaq::flxlibs::CardWrapper::set_running
void set_running(bool should_run)
Definition
CardWrapper.cpp:144
dunedaq::flxlibs::CardWrapper::m_handle_block_addr
std::function< void(uint64_t)> m_handle_block_addr
Definition
CardWrapper.hpp:111
dunedaq::flxlibs::CardWrapper::CardWrapper
CardWrapper(CardWrapper &&)=delete
CardWrapper is not move-constructible.
dunedaq::flxlibs::CardWrapper::m_run_lock
std::atomic< bool > m_run_lock
Definition
CardWrapper.hpp:109
dunedaq::flxlibs::CardWrapper::m_block_size
static constexpr size_t m_block_size
Definition
CardWrapper.hpp:62
dunedaq::flxlibs::CardWrapper::operator=
CardWrapper & operator=(const CardWrapper &)=delete
CardWrapper is not copy-assignable.
dunedaq::flxlibs::CardWrapper::m_flx_card
UniqueFlxCard m_flx_card
Definition
CardWrapper.hpp:95
dunedaq::flxlibs::CardWrapper::allocate_CMEM
int allocate_CMEM(uint8_t numa, u_long bsize, u_long *paddr, u_long *vaddr)
Definition
CardWrapper.cpp:187
dunedaq::flxlibs::CardWrapper::m_run_marker
std::atomic< bool > m_run_marker
Definition
CardWrapper.hpp:79
dunedaq::flxlibs::CardWrapper::m_block_addr_handler_available
bool m_block_addr_handler_available
Definition
CardWrapper.hpp:112
dunedaq::flxlibs::CardWrapper::m_read_index
unsigned m_read_index
Definition
CardWrapper.hpp:104
dunedaq::flxlibs::CardWrapper::m_numa_id
uint8_t m_numa_id
Definition
CardWrapper.hpp:89
dunedaq::flxlibs::CardWrapper::m_logical_unit
uint8_t m_logical_unit
Definition
CardWrapper.hpp:82
dunedaq::flxlibs::CardWrapper::init_DMA
void init_DMA()
Definition
CardWrapper.cpp:217
dunedaq::flxlibs::CardWrapper::m_poll_time
size_t m_poll_time
Definition
CardWrapper.hpp:88
dunedaq::flxlibs::CardWrapper::m_links_enabled
std::vector< unsigned int > m_links_enabled
Definition
CardWrapper.hpp:90
dunedaq::flxlibs::CardWrapper::m_info_str
std::string m_info_str
Definition
CardWrapper.hpp:91
dunedaq::flxlibs::CardWrapper::~CardWrapper
~CardWrapper()
Definition
CardWrapper.cpp:68
dunedaq::flxlibs::CardWrapper::configure
void configure()
Definition
CardWrapper.cpp:78
dunedaq::flxlibs::CardWrapper::m_configured
bool m_configured
Definition
CardWrapper.hpp:80
dunedaq::flxlibs::CardWrapper::close_card
void close_card()
Definition
CardWrapper.cpp:173
dunedaq::flxlibs::CardWrapper::m_block_threshold
size_t m_block_threshold
Definition
CardWrapper.hpp:86
dunedaq::flxlibs::CardWrapper::m_card_mutex
std::mutex m_card_mutex
Definition
CardWrapper.hpp:96
dunedaq::flxlibs::CardWrapper::bytes_available
uint64_t bytes_available()
Definition
CardWrapper.cpp:267
dunedaq::flxlibs::CardWrapper::graceful_stop
void graceful_stop()
Definition
CardWrapper.cpp:121
dunedaq::flxlibs::CardWrapper::stop
void stop()
Definition
CardWrapper.cpp:138
dunedaq::flxlibs::CardWrapper::m_dma_wraparound
static constexpr size_t m_dma_wraparound
Definition
CardWrapper.hpp:63
dunedaq::flxlibs::CardWrapper::CardWrapper
CardWrapper(const appmodel::FelixInterface *cfg, std::vector< unsigned int >)
CardWrapper Constructor.
Definition
CardWrapper.cpp:36
dunedaq::flxlibs::CardWrapper::operator=
CardWrapper & operator=(CardWrapper &&)=delete
CardWrapper is not move-assignable.
dunedaq::flxlibs::CardWrapper::m_card_id
uint8_t m_card_id
Definition
CardWrapper.hpp:81
dunedaq::flxlibs::CardWrapper::m_cmem_handle
int m_cmem_handle
Definition
CardWrapper.hpp:100
dunedaq::flxlibs::CardWrapper::UniqueFlxCard
std::unique_ptr< FlxCard > UniqueFlxCard
Definition
CardWrapper.hpp:94
dunedaq::flxlibs::CardWrapper::start
void start()
Definition
CardWrapper.cpp:104
dunedaq::flxlibs::CardWrapper::start_DMA
void start_DMA()
Definition
CardWrapper.cpp:247
dunedaq::flxlibs::CardWrapper::m_virt_addr
uint64_t m_virt_addr
Definition
CardWrapper.hpp:101
dunedaq::flxlibs::CardWrapper::set_block_addr_handler
void set_block_addr_handler(std::function< void(uint64_t)> &handle)
Definition
CardWrapper.hpp:50
dunedaq::flxlibs::CardWrapper::m_dma_processor_name
static const std::string m_dma_processor_name
Definition
CardWrapper.hpp:108
dunedaq::flxlibs::CardWrapper::m_card_id_str
std::string m_card_id_str
Definition
CardWrapper.hpp:83
dunedaq::flxlibs::CardWrapper::open_card
void open_card()
Definition
CardWrapper.cpp:151
dunedaq::utilities::ReusableThread
Definition
ReusableThread.hpp:25
FelixInterface.hpp
dunedaq::flxlibs
Definition
AvailableParserOperations.hpp:27
Generated on
for DUNE-DAQ by
1.17.0