From 5a9cc004f2f62f81a89a2749b3b00ad65d5772d9 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 12 Sep 2018 22:57:21 +0800 Subject: [PATCH] drtio: receive and print unsolicited aux packets Helps with debugging and prevents the aux channel from getting stuck after packets arrive after the timeout. --- artiq/firmware/runtime/rtio_mgt.rs | 9 +++++++++ artiq/firmware/satman/repeater.rs | 13 +++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/artiq/firmware/runtime/rtio_mgt.rs b/artiq/firmware/runtime/rtio_mgt.rs index 093b37d79..ea34792c4 100644 --- a/artiq/firmware/runtime/rtio_mgt.rs +++ b/artiq/firmware/runtime/rtio_mgt.rs @@ -172,6 +172,14 @@ pub mod drtio { Ok(()) } + fn process_unsolicited_aux(linkno: u8) { + match drtioaux::recv_link(linkno) { + Ok(Some(packet)) => warn!("[LINK#{}] unsolicited aux packet: {:?}", linkno, packet), + Ok(None) => (), + Err(_) => warn!("[LINK#{}] aux packet error", linkno) + } + } + fn process_local_errors(linkno: u8) { let errors; let linkidx = linkno as usize; @@ -215,6 +223,7 @@ pub mod drtio { if link_up(linkno) { /* link was previously up */ if link_rx_up(linkno) { + process_unsolicited_aux(linkno); process_local_errors(linkno); process_aux_errors(&io, linkno); } else { diff --git a/artiq/firmware/satman/repeater.rs b/artiq/firmware/satman/repeater.rs index 889e4aba7..9b1f39849 100644 --- a/artiq/firmware/satman/repeater.rs +++ b/artiq/firmware/satman/repeater.rs @@ -40,7 +40,7 @@ impl Repeater { } pub fn service(&mut self, routing_table: &drtio_routing::RoutingTable, rank: u8) { - self.process_errors(); + self.process_local_errors(); match self.state { RepeaterState::Down => { @@ -97,6 +97,7 @@ impl Repeater { } } RepeaterState::Up => { + self.process_unsolicited_aux(); if !rep_link_rx_up(self.repno) { info!("[REP#{}] link is down", self.repno); self.state = RepeaterState::Down; @@ -111,7 +112,15 @@ impl Repeater { } } - fn process_errors(&self) { + fn process_unsolicited_aux(&self) { + match drtioaux::recv_link(self.auxno) { + Ok(Some(packet)) => warn!("[REP#{}] unsolicited aux packet: {:?}", self.repno, packet), + Ok(None) => (), + Err(_) => warn!("[REP#{}] aux packet error", self.repno) + } + } + + fn process_local_errors(&self) { let repno = self.repno as usize; let errors; unsafe {