#include <CardWrapper.hpp>
Definition at line 29 of file CardWrapper.hpp.
◆ UniqueFlxCard
◆ CardWrapper() [1/3]
dunedaq::flxlibs::CardWrapper::CardWrapper |
( |
const appmodel::FelixInterface * | cfg, |
|
|
std::vector< unsigned int > | enabled_links ) |
CardWrapper Constructor.
- Parameters
-
Definition at line 36 of file CardWrapper.cpp.
51{
53
54 std::ostringstream tnoss;
57
58 std::ostringstream cardoss;
61
64 throw flxlibs::CardError(
ERS_HERE,
"Couldn't create FlxCard object.");
65 }
66}
utilities::ReusableThread m_dma_processor
std::size_t m_dma_memory_size
std::function< void(uint64_t)> m_handle_block_addr
std::atomic< bool > m_run_lock
std::atomic< bool > m_run_marker
std::vector< unsigned int > m_links_enabled
static const std::string m_dma_processor_name
std::string m_card_id_str
void set_name(const std::string &name, int tid)
◆ ~CardWrapper()
dunedaq::flxlibs::CardWrapper::~CardWrapper |
( |
| ) |
|
Definition at line 68 of file CardWrapper.cpp.
69{
74}
#define TLVL_ENTER_EXIT_METHODS
#define TLOG_DEBUG(lvl,...)
◆ CardWrapper() [2/3]
dunedaq::flxlibs::CardWrapper::CardWrapper |
( |
const CardWrapper & | | ) |
|
|
delete |
◆ CardWrapper() [3/3]
dunedaq::flxlibs::CardWrapper::CardWrapper |
( |
CardWrapper && | | ) |
|
|
delete |
◆ allocate_CMEM()
int dunedaq::flxlibs::CardWrapper::allocate_CMEM |
( |
uint8_t | numa, |
|
|
u_long | bsize, |
|
|
u_long * | paddr, |
|
|
u_long * | vaddr ) |
|
private |
Definition at line 187 of file CardWrapper.cpp.
188{
190 int handle;
191 unsigned ret = CMEM_Open();
192 if (!ret) {
193 ret = CMEM_NumaSegmentAllocate(bsize, numa,
const_cast<char*
>(
m_card_id_str.c_str()), &handle);
194
195 }
196 if (!ret) {
197 ret = CMEM_SegmentPhysicalAddress(handle, paddr);
198 }
199 if (!ret) {
200 ret = CMEM_SegmentVirtualAddress(handle, vaddr);
201 }
202 if (ret) {
203
209 "Not enough CMEM memory allocated or the application demands too much CMEM memory.\n"
210 "Fix the CMEM memory reservation in the driver or change the module's configuration."));
211 exit(EXIT_FAILURE);
212 }
213 return handle;
214}
void fatal(const Issue &issue)
◆ bytes_available()
uint64_t dunedaq::flxlibs::CardWrapper::bytes_available |
( |
| ) |
|
|
inlineprivate |
Definition at line 267 of file CardWrapper.cpp.
268{
270}
static constexpr size_t m_block_size
◆ close_card()
void dunedaq::flxlibs::CardWrapper::close_card |
( |
| ) |
|
|
private |
Definition at line 173 of file CardWrapper.cpp.
174{
176 try {
180 } catch (FlxException& ex) {
182 exit(EXIT_FAILURE);
183 }
184}
void error(const Issue &issue)
◆ configure()
void dunedaq::flxlibs::CardWrapper::configure |
( |
| ) |
|
Definition at line 78 of file CardWrapper.cpp.
79{
82 } else {
84
87
91
94
97
100 }
101}
int allocate_CMEM(uint8_t numa, u_long bsize, u_long *paddr, u_long *vaddr)
◆ graceful_stop()
void dunedaq::flxlibs::CardWrapper::graceful_stop |
( |
| ) |
|
Definition at line 121 of file CardWrapper.cpp.
122{
127 std::this_thread::sleep_for(std::chrono::milliseconds(10));
128 }
132 } else {
134 }
135}
void set_running(bool should_run)
bool get_readiness() const
◆ init_DMA()
void dunedaq::flxlibs::CardWrapper::init_DMA |
( |
| ) |
|
|
private |
Definition at line 217 of file CardWrapper.cpp.
218{
219 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"InitDMA issued...";
222 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"flxCard.dma_reset issued.";
224 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"flxCard.soft_reset issued.";
226 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"flxCard.irq_reset_counters issued.";
227
229#if REGMAP_VERSION < 0x500
231#else
233#endif
234 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"flxCard.irq_enable issued.";
235 } else {
237 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"flxCard.irq_disable issued.";
238 }
244}
#define IRQ_DATA_AVAILABLE
◆ open_card()
void dunedaq::flxlibs::CardWrapper::open_card |
( |
| ) |
|
|
private |
Definition at line 151 of file CardWrapper.cpp.
152{
154 try {
157 u_int current_lock_mask =
m_flx_card->get_lock_mask(absolute_card_id);
159 u_int to_lock_mask = u_int(
m_dma_id+1);
160 if (current_lock_mask & to_lock_mask) {
161 ers::fatal(flxlibs::CardError(
ERS_HERE,
"FELIX card's DMA is locked by another process!"));
162 exit(EXIT_FAILURE);
163 }
164 m_flx_card->card_open(
static_cast<int>(absolute_card_id), to_lock_mask);
166 } catch (FlxException& ex) {
168 exit(EXIT_FAILURE);
169 }
170}
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ process_DMA()
void dunedaq::flxlibs::CardWrapper::process_DMA |
( |
| ) |
|
|
private |
Definition at line 281 of file CardWrapper.cpp.
282{
283 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"CardWrapper starts processing blocks...";
285
286
290 std::this_thread::sleep_for(std::chrono::microseconds(5000));
291 } else {
292 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"Stop issued during poll! Returning...";
293 return;
294 }
295 }
296
297
302#if REGMAP_VERSION < 0x500
304#else
306#endif
308 } else {
309 std::this_thread::sleep_for(std::chrono::microseconds(
m_poll_time));
310 }
312 } else {
313 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"Stop issued during waiting for data! Returning...";
314 return;
315 }
316 }
317
318
320 uint64_t bytes = 0;
323
324
327 }
328
329
332 }
333
334
338 }
339
340
344 }
345 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"CardWrapper processor thread finished.";
346}
void read_current_address()
bool m_block_addr_handler_available
uint64_t bytes_available()
◆ read_current_address()
void dunedaq::flxlibs::CardWrapper::read_current_address |
( |
| ) |
|
|
private |
◆ set_block_addr_handler()
void dunedaq::flxlibs::CardWrapper::set_block_addr_handler |
( |
std::function< void(uint64_t)> & | handle | ) |
|
|
inline |
◆ set_running()
void dunedaq::flxlibs::CardWrapper::set_running |
( |
bool | should_run | ) |
|
Definition at line 144 of file CardWrapper.cpp.
145{
147 TLOG_DEBUG(TLVL_WORK_STEPS) <<
"Active state was toggled from " << was_running <<
" to " << should_run;
148}
◆ start()
void dunedaq::flxlibs::CardWrapper::start |
( |
| ) |
|
Definition at line 104 of file CardWrapper.cpp.
105{
109 TLOG() <<
"Block Address handler is not set! Is it intentional?";
110 }
115 } else {
117 }
118}
bool set_work(Function &&f, Args &&... args)
◆ start_DMA()
void dunedaq::flxlibs::CardWrapper::start_DMA |
( |
| ) |
|
|
private |
Definition at line 247 of file CardWrapper.cpp.
248{
250 <<
" dma id:" << std::to_string(
m_dma_id);
254}
static constexpr size_t m_dma_wraparound
◆ stop()
void dunedaq::flxlibs::CardWrapper::stop |
( |
| ) |
|
◆ stop_DMA()
void dunedaq::flxlibs::CardWrapper::stop_DMA |
( |
| ) |
|
|
private |
◆ m_block_addr_handler_available
bool dunedaq::flxlibs::CardWrapper::m_block_addr_handler_available { false } |
|
private |
◆ m_block_size
size_t dunedaq::flxlibs::CardWrapper::m_block_size = 4096 |
|
staticconstexprprivate |
◆ m_block_threshold
size_t dunedaq::flxlibs::CardWrapper::m_block_threshold |
|
private |
◆ m_card_id
uint8_t dunedaq::flxlibs::CardWrapper::m_card_id |
|
private |
◆ m_card_id_str
std::string dunedaq::flxlibs::CardWrapper::m_card_id_str |
|
private |
◆ m_card_mutex
std::mutex dunedaq::flxlibs::CardWrapper::m_card_mutex |
|
private |
◆ m_cmem_handle
int dunedaq::flxlibs::CardWrapper::m_cmem_handle |
|
private |
◆ m_configured
bool dunedaq::flxlibs::CardWrapper::m_configured { false } |
|
private |
◆ m_current_addr
uint64_t dunedaq::flxlibs::CardWrapper::m_current_addr |
|
private |
◆ m_destination
u_long dunedaq::flxlibs::CardWrapper::m_destination |
|
private |
◆ m_dma_id
uint8_t dunedaq::flxlibs::CardWrapper::m_dma_id |
|
private |
◆ m_dma_memory_size
std::size_t dunedaq::flxlibs::CardWrapper::m_dma_memory_size |
|
private |
◆ m_dma_processor
◆ m_dma_processor_name
const std::string dunedaq::flxlibs::CardWrapper::m_dma_processor_name = "flx-dma" |
|
inlinestaticprivate |
◆ m_dma_wraparound
size_t dunedaq::flxlibs::CardWrapper::m_dma_wraparound = FLX_DMA_WRAPAROUND |
|
staticconstexprprivate |
◆ m_flx_card
◆ m_handle_block_addr
std::function<void(uint64_t)> dunedaq::flxlibs::CardWrapper::m_handle_block_addr |
|
private |
◆ m_info_str
std::string dunedaq::flxlibs::CardWrapper::m_info_str |
|
private |
◆ m_interrupt_mode
bool dunedaq::flxlibs::CardWrapper::m_interrupt_mode |
|
private |
◆ m_links_enabled
std::vector<unsigned int> dunedaq::flxlibs::CardWrapper::m_links_enabled |
|
private |
◆ m_logical_unit
uint8_t dunedaq::flxlibs::CardWrapper::m_logical_unit |
|
private |
◆ m_margin_blocks
size_t dunedaq::flxlibs::CardWrapper::m_margin_blocks |
|
private |
◆ m_max_links_per_card
size_t dunedaq::flxlibs::CardWrapper::m_max_links_per_card = 6 |
|
staticconstexprprivate |
◆ m_numa_id
uint8_t dunedaq::flxlibs::CardWrapper::m_numa_id |
|
private |
◆ m_phys_addr
uint64_t dunedaq::flxlibs::CardWrapper::m_phys_addr |
|
private |
◆ m_poll_time
size_t dunedaq::flxlibs::CardWrapper::m_poll_time |
|
private |
◆ m_read_index
unsigned dunedaq::flxlibs::CardWrapper::m_read_index |
|
private |
◆ m_run_lock
std::atomic<bool> dunedaq::flxlibs::CardWrapper::m_run_lock |
|
private |
◆ m_run_marker
std::atomic<bool> dunedaq::flxlibs::CardWrapper::m_run_marker |
|
private |
◆ m_virt_addr
uint64_t dunedaq::flxlibs::CardWrapper::m_virt_addr |
|
private |
The documentation for this class was generated from the following files: