Skip to content

Commit

Permalink
Merge pull request #29 from DUNE-DAQ/sbhuller/v2.10.0-elink-fix
Browse files Browse the repository at this point in the history
Sbhuller/v2.10.0 elink fix
  • Loading branch information
ShyamB97 authored Apr 21, 2022
2 parents 36c5b25 + aca04a6 commit ffa96ed
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 51 deletions.
41 changes: 25 additions & 16 deletions plugins/FelixCardReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ FelixCardReader::FelixCardReader(const std::string& name)
, m_configured(false)
, m_card_id(0)
, m_logical_unit(0)
, m_links_enabled({0})
, m_num_links(0)
, m_block_size(0)
, m_block_router(nullptr)
Expand Down Expand Up @@ -92,17 +93,12 @@ FelixCardReader::init(const data_t& args)
} catch (const std::exception& ex) {
ers::fatal(InitializationError(ERS_HERE, "Link ID could not be parsed on queue instance name! "));
}
auto link_offset = 0;
if (linkid >= 5) { // RS FIXME: super ugly... queue names should contain tag for exact elink.
link_offset = 5;
}
auto tag = (linkid - link_offset) * m_elink_multiplier;
TLOG_DEBUG(TLVL_WORK_STEPS) << "Creating ElinkModel for target queue: " << target << " elink tag: " << tag;
m_elinks[tag] = createElinkModel(qi.inst);
if (m_elinks[tag] == nullptr) {
TLOG_DEBUG(TLVL_WORK_STEPS) << "Creating ElinkModel for target queue: " << target << " DLH number: " << linkid;
m_elinks[linkid] = createElinkModel(qi.inst);
if (m_elinks[linkid] == nullptr) {
ers::fatal(InitializationError(ERS_HERE, "CreateElink failed to provide an appropriate model for queue!"));
}
m_elinks[tag]->init(args, m_block_queue_capacity);
m_elinks[linkid]->init(args, m_block_queue_capacity);
}
}

Expand Down Expand Up @@ -141,14 +137,18 @@ FelixCardReader::do_configure(const data_t& args)
m_cfg = args.get<felixcardreader::Conf>();
m_card_id = m_cfg.card_id;
m_logical_unit = m_cfg.logical_unit;
m_num_links = m_cfg.num_links;
m_links_enabled = m_cfg.links_enabled;
m_num_links = m_links_enabled.size();
m_block_size = m_cfg.dma_block_size_kb * m_1kb_block_size;
m_chunk_trailer_size = m_cfg.chunk_trailer_size;
bool is_32b_trailer = false;

TLOG(TLVL_BOOKKEEPING) << "Number of elinks specified in configuration: " << m_links_enabled.size();
TLOG(TLVL_BOOKKEEPING) << "Number of data link handlers: " << m_elinks.size();

// Config checks
if (m_num_links != m_elinks.size()) {
ers::fatal(ElinkConfigurationInconsistency(ERS_HERE, m_num_links));
ers::fatal(ElinkConfigurationInconsistency(ERS_HERE, m_links_enabled.size()));
}
if (m_block_size % m_1kb_block_size != 0) {
ers::fatal(BlockSizeConfigurationInconsistency(ERS_HERE, m_block_size));
Expand All @@ -159,13 +159,22 @@ FelixCardReader::do_configure(const data_t& args)
}

// Configure components
TLOG(TLVL_WORK_STEPS) << "Card ID: " << m_card_id;
TLOG(TLVL_WORK_STEPS) << "Configuring components with Block size:" << m_block_size
<< " & trailer size: " << m_chunk_trailer_size;
m_card_wrapper->configure(args);
for (unsigned lid = 0; lid < m_num_links; ++lid) {
auto tag = lid * m_elink_multiplier;
TLOG(TLVL_WORK_STEPS) << "Configuring ElinkHandler with elink tag: " << tag;
m_elinks[tag]->set_ids(m_card_id, m_logical_unit, lid, tag);
// get linkids defined by queues
std::vector<int> linkids;
for(auto& [id, elink] : m_elinks) {
linkids.push_back(id);
}
// loop through all elinkmodels, change the linkids to link tags and configure
for (unsigned i = 0; i < m_num_links; ++i) {
auto elink = m_elinks.extract(linkids[i]);
auto tag = m_links_enabled[i] * m_elink_multiplier;
elink.key() = tag;
m_elinks.insert(std::move(elink));
m_elinks[tag]->set_ids(m_card_id, m_logical_unit, m_links_enabled[i], tag);
m_elinks[tag]->conf(args, m_block_size, is_32b_trailer);
}
}
Expand All @@ -192,7 +201,7 @@ void
FelixCardReader::get_info(opmonlib::InfoCollector& ci, int level)
{
for (unsigned lid = 0; lid < m_num_links; ++lid) {
auto tag = lid * m_elink_multiplier;
auto tag = m_links_enabled[lid] * m_elink_multiplier;
m_elinks[tag]->get_info(ci, level);
}
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/FelixCardReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class FelixCardReader : public dunedaq::appfwk::DAQModule

int m_card_id;
int m_logical_unit;

std::vector<unsigned int> m_links_enabled;
unsigned m_num_links;
std::size_t m_block_size;
int m_chunk_trailer_size;
Expand Down
Loading

0 comments on commit ffa96ed

Please sign in to comment.