Commit d89f1aa9 authored by Serguei Kolos's avatar Serguei Kolos
Browse files

Drop data packets received in non-RUNNING state and report them as spurious

parent 865ffb65
......@@ -47,7 +47,19 @@ void DefaultL1AInputHandler::resynchAfterRestart(uint32_t lastL1ID) {
void DefaultL1AInputHandler::dataReceived(const uint8_t* data, uint32_t size, uint8_t status, uint32_t rob_status) {
L1AMessage & l1a = *(L1AMessage*)data;
ERS_DEBUG(4, "L1A message received: l1id = 0x" << std::hex << l1a.ext_l1id << " bcid = 0x" << l1a.bcid);
ERS_DEBUG(4, "L1A message received: l1id = 0x" << std::hex
<< l1a.ext_l1id << " bcid = 0x" << l1a.bcid);
if (not m_running) {
if (not m_links.empty()) {
auto & link = *m_links.begin();
link.m_packets_dropped++;
ers::error(DroppedPacketException(ERS_HERE, link.m_fid,
m_counter + link.m_packets_counter, link.m_packets_dropped,
SpuriousPacketException(ERS_HERE, link.m_fid)));
}
return;
}
if (m_expected_l1id != l1a.ext_l1id) {
if (l1a.l1id) {
......
......@@ -53,6 +53,18 @@ namespace swrod {
const uint8_t *data, uint32_t packet_size,
uint8_t felix_status, uint32_t rob_status) {
ERS_DEBUG(5, "Data packet for the link 0x" << std::hex << link.m_fid
<< " is received, size = " << std::dec << packet_size
<< " packet counter = " << link.m_packets_counter);
if (not m_running) {
link.m_packets_dropped++;
ers::error(DroppedPacketException(ERS_HERE, link.m_fid,
link.m_packets_counter, link.m_packets_dropped,
SpuriousPacketException(ERS_HERE, link.m_fid)));
return;
}
link.m_packets_counter++;
try {
auto [l1id, l1id_mask, bcid] = m_trigger_info_extractor(data, packet_size);
......
......@@ -320,6 +320,16 @@ namespace swrod {
<< " is received, size = " << std::dec << size
<< " packet counter = " << link.m_packets_counter);
#define SWROD_UNLIKELY(x) __builtin_expect(!!(x),0)
if (SWROD_UNLIKELY(not m_running)) {
link.m_packets_dropped++;
ers::error(DroppedPacketException(ERS_HERE, link.m_fid,
link.m_packets_counter, link.m_packets_dropped,
SpuriousPacketException(ERS_HERE, link.m_fid)));
return;
}
uint8_t packet_status = GBTChunk::Status::Ok;
uint16_t bcid = 0xffff;
Slice * slice = 0;
......@@ -338,8 +348,9 @@ namespace swrod {
<< " link is 0x" << std::hex << link.m_fid
<< " expected l1id 0x" << std::hex << link.m_expected_l1id );
if ((slice->m_l1id & l1id_mask) != l1id
|| (bcid != slice->m_bcid && bcid != 0xffff && slice->m_bcid != 0xffff)) {
if (SWROD_UNLIKELY(
(slice->m_l1id & l1id_mask) != l1id
|| (bcid != slice->m_bcid && bcid != 0xffff && slice->m_bcid != 0xffff))) {
handlePacketError(data, size, link, *slice, l1id, l1id_mask, bcid);
// Packets counter may have been changed by the recovery procedure
......
......@@ -145,6 +145,15 @@ ERS_DECLARE_ISSUE_BASE(swrod, DroppedPacketException, Exception,
ERS_EMPTY,
((uint64_t)elink) ((uint64_t)packet_index) ((uint32_t)dropped_number))
/*! \class swrod::SpuriousPacketException
* This issue is used to report unexpected data packets
*/
ERS_DECLARE_ISSUE_BASE(swrod, SpuriousPacketException, Exception,
"Data packet from e-link 0x" << std::hex << elink
<< " has been received while SW ROD was not in RUNNING state",
ERS_EMPTY,
((uint64_t)elink))
/*! \class swrod::SubscriptionException
* This issue is used to report a failure of subscribing to FELIX
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment