forked from M-Labs/zynq-rs
netboot: support 100Mbps and 10Mbps eth link speed
check for eth link change during netboot instead of defaulting to 1Gbps
This commit is contained in:
@@ -6,7 +6,7 @@ use libboard_zynq::{devc,
|
||||
eth::Eth,
|
||||
smoltcp::{self,
|
||||
iface::{EthernetInterfaceBuilder, NeighborCache},
|
||||
time::Instant,
|
||||
time::{Duration, Instant},
|
||||
wire::IpCidr},
|
||||
timer};
|
||||
use libconfig::{bootgen, net_settings};
|
||||
@@ -335,6 +335,9 @@ pub fn netboot<File: Read + Seek>(bootgen_file: &mut Option<File>, runtime_start
|
||||
let mut boot_flag = false;
|
||||
|
||||
log::info!("Waiting for connections...");
|
||||
|
||||
let mut last_link_check = Instant::from_millis(0);
|
||||
const LINK_CHECK_INTERVAL: u64 = 500;
|
||||
loop {
|
||||
let timestamp = Instant::from_millis(timer::get_ms() as i64);
|
||||
{
|
||||
@@ -375,5 +378,10 @@ pub fn netboot<File: Read + Seek>(bootgen_file: &mut Option<File>, runtime_start
|
||||
Err(smoltcp::Error::Unrecognized) => (),
|
||||
Err(err) => log::error!("Network error: {}", err),
|
||||
}
|
||||
let dev = interface.device_mut();
|
||||
if dev.is_idle() && timestamp >= last_link_check + Duration::from_millis(LINK_CHECK_INTERVAL) {
|
||||
dev.check_link_change();
|
||||
last_link_check = timestamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user