forked from M-Labs/artiq
satman: load TSCs of downstream devices
This commit is contained in:
parent
bc1d3fda6a
commit
663432adbd
|
@ -332,6 +332,7 @@ pub extern fn main() -> i32 {
|
||||||
rep.service();
|
rep.service();
|
||||||
}
|
}
|
||||||
if drtiosat_tsc_loaded() {
|
if drtiosat_tsc_loaded() {
|
||||||
|
info!("TSC loaded");
|
||||||
#[cfg(has_ad9154)]
|
#[cfg(has_ad9154)]
|
||||||
{
|
{
|
||||||
if let Err(e) = board_artiq::jesd204sync::sysref_auto_rtio_align() {
|
if let Err(e) = board_artiq::jesd204sync::sysref_auto_rtio_align() {
|
||||||
|
@ -341,6 +342,9 @@ pub extern fn main() -> i32 {
|
||||||
error!("failed to align SYSREF at DAC: {}", e);
|
error!("failed to align SYSREF at DAC: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for rep in repeaters.iter() {
|
||||||
|
rep.sync_tsc();
|
||||||
|
}
|
||||||
if let Err(e) = drtioaux::send_link(0, &drtioaux::Packet::TSCAck) {
|
if let Err(e) = drtioaux::send_link(0, &drtioaux::Packet::TSCAck) {
|
||||||
error!("aux packet error: {}", e);
|
error!("aux packet error: {}", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl Repeater {
|
||||||
timeout: clock::get_ms() + 100
|
timeout: clock::get_ms() + 100
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info!("[REP#{}] link RX went down during ping", self.repno);
|
error!("[REP#{}] link RX went down during ping", self.repno);
|
||||||
self.state = RepeaterState::Down;
|
self.state = RepeaterState::Down;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,17 @@ impl Repeater {
|
||||||
if rep_link_rx_up(self.repno) {
|
if rep_link_rx_up(self.repno) {
|
||||||
if let Ok(Some(drtioaux::Packet::EchoReply)) = drtioaux::recv_link(self.auxno) {
|
if let Ok(Some(drtioaux::Packet::EchoReply)) = drtioaux::recv_link(self.auxno) {
|
||||||
info!("[REP#{}] remote replied after {} packets", self.repno, ping_count);
|
info!("[REP#{}] remote replied after {} packets", self.repno, ping_count);
|
||||||
// TODO: send TSC, routing table, and rank
|
if !self.sync_tsc() {
|
||||||
|
error!("[REP#{}] remote failed to ack TSC", self.repno);
|
||||||
|
self.state = RepeaterState::Failed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: send routing table and rank
|
||||||
self.state = RepeaterState::Up;
|
self.state = RepeaterState::Up;
|
||||||
} else {
|
} else {
|
||||||
if clock::get_ms() > timeout {
|
if clock::get_ms() > timeout {
|
||||||
if ping_count > 200 {
|
if ping_count > 200 {
|
||||||
info!("[REP#{}] ping failed", self.repno);
|
error!("[REP#{}] ping failed", self.repno);
|
||||||
self.state = RepeaterState::Failed;
|
self.state = RepeaterState::Failed;
|
||||||
} else {
|
} else {
|
||||||
self.state = RepeaterState::SendPing { ping_count: ping_count };
|
self.state = RepeaterState::SendPing { ping_count: ping_count };
|
||||||
|
@ -76,7 +81,7 @@ impl Repeater {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info!("[REP#{}] link RX went down during ping", self.repno);
|
error!("[REP#{}] link RX went down during ping", self.repno);
|
||||||
self.state = RepeaterState::Down;
|
self.state = RepeaterState::Down;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +99,29 @@ impl Repeater {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn sync_tsc(&self) -> bool {
|
||||||
|
let repno = self.repno as usize;
|
||||||
|
unsafe {
|
||||||
|
(csr::DRTIOREP[repno].set_time_write)(1);
|
||||||
|
while (csr::DRTIOREP[repno].set_time_read)() == 1 {}
|
||||||
|
}
|
||||||
|
|
||||||
|
let timeout = clock::get_ms() + 200;
|
||||||
|
loop {
|
||||||
|
if !rep_link_rx_up(self.repno) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if clock::get_ms() > timeout {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// TSCAck is the only aux packet that is sent spontaneously
|
||||||
|
// by the satellite, in response to a TSC set on the RT link.
|
||||||
|
if let Ok(Some(drtioaux::Packet::TSCAck)) = drtioaux::recv_link(self.auxno) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(has_drtio_routing))]
|
#[cfg(not(has_drtio_routing))]
|
||||||
|
@ -101,4 +129,6 @@ impl Repeater {
|
||||||
pub fn new(_repno: u8) -> Repeater { Repeater::default() }
|
pub fn new(_repno: u8) -> Repeater { Repeater::default() }
|
||||||
|
|
||||||
pub fn service(&self) { }
|
pub fn service(&self) { }
|
||||||
|
|
||||||
|
pub fn sync_tsc(&self) { }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue