forked from M-Labs/artiq-zynq
runtime: use network addresses from config
This commit is contained in:
parent
bbc1ffec8e
commit
33d12801b7
|
@ -13,14 +13,15 @@ use libboard_zynq::{
|
||||||
self as zynq,
|
self as zynq,
|
||||||
smoltcp::{
|
smoltcp::{
|
||||||
self,
|
self,
|
||||||
wire::{EthernetAddress, IpAddress, Ipv4Address, IpCidr},
|
wire::IpCidr,
|
||||||
iface::{NeighborCache, EthernetInterfaceBuilder, Routes},
|
iface::{NeighborCache, EthernetInterfaceBuilder},
|
||||||
time::Instant,
|
time::Instant,
|
||||||
},
|
},
|
||||||
timer::GlobalTimer,
|
timer::GlobalTimer,
|
||||||
};
|
};
|
||||||
use libasync::{smoltcp::{Sockets, TcpStream}, task};
|
use libasync::{smoltcp::{Sockets, TcpStream}, task};
|
||||||
|
|
||||||
|
use crate::net_settings;
|
||||||
use crate::proto_async::*;
|
use crate::proto_async::*;
|
||||||
use crate::kernel;
|
use crate::kernel;
|
||||||
use crate::rpc;
|
use crate::rpc;
|
||||||
|
@ -252,12 +253,11 @@ async fn handle_connection(stream: &TcpStream, control: Rc<RefCell<kernel::Contr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const HWADDR: [u8; 6] = [0, 0x23, 0xab, 0xad, 0x1d, 0xea];
|
|
||||||
const IPADDR: IpAddress = IpAddress::Ipv4(Ipv4Address([192, 168, 1, 52]));
|
|
||||||
|
|
||||||
pub fn main(timer: GlobalTimer) {
|
pub fn main(timer: GlobalTimer) {
|
||||||
let eth = zynq::eth::Eth::default(HWADDR.clone());
|
let net_addresses = net_settings::get_adresses();
|
||||||
|
info!("network addresses: {}", net_addresses);
|
||||||
|
|
||||||
|
let eth = zynq::eth::Eth::default(net_addresses.hardware_addr.0.clone());
|
||||||
const RX_LEN: usize = 8;
|
const RX_LEN: usize = 8;
|
||||||
// Number of transmission buffers (minimum is two because with
|
// Number of transmission buffers (minimum is two because with
|
||||||
// one, duplicate packet transmission occurs)
|
// one, duplicate packet transmission occurs)
|
||||||
|
@ -265,18 +265,32 @@ pub fn main(timer: GlobalTimer) {
|
||||||
let eth = eth.start_rx(RX_LEN);
|
let eth = eth.start_rx(RX_LEN);
|
||||||
let mut eth = eth.start_tx(TX_LEN);
|
let mut eth = eth.start_tx(TX_LEN);
|
||||||
|
|
||||||
let ethernet_addr = EthernetAddress(HWADDR);
|
let neighbor_cache = NeighborCache::new(alloc::collections::BTreeMap::new());
|
||||||
let mut ip_addrs = [IpCidr::new(IPADDR, 24)];
|
let mut iface = match net_addresses.ipv6_addr {
|
||||||
let mut routes_storage = vec![None; 4];
|
Some(addr) => {
|
||||||
let routes = Routes::new(&mut routes_storage[..]);
|
let ip_addrs = [
|
||||||
let mut neighbor_storage = vec![None; 256];
|
IpCidr::new(net_addresses.ipv4_addr, 0),
|
||||||
let neighbor_cache = NeighborCache::new(&mut neighbor_storage[..]);
|
IpCidr::new(net_addresses.ipv6_ll_addr, 0),
|
||||||
let mut iface = EthernetInterfaceBuilder::new(&mut eth)
|
IpCidr::new(addr, 0)
|
||||||
.ethernet_addr(ethernet_addr)
|
];
|
||||||
.ip_addrs(&mut ip_addrs[..])
|
EthernetInterfaceBuilder::new(&mut eth)
|
||||||
.routes(routes)
|
.ethernet_addr(net_addresses.hardware_addr)
|
||||||
|
.ip_addrs(ip_addrs)
|
||||||
.neighbor_cache(neighbor_cache)
|
.neighbor_cache(neighbor_cache)
|
||||||
.finalize();
|
.finalize()
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
let ip_addrs = [
|
||||||
|
IpCidr::new(net_addresses.ipv4_addr, 0),
|
||||||
|
IpCidr::new(net_addresses.ipv6_ll_addr, 0)
|
||||||
|
];
|
||||||
|
EthernetInterfaceBuilder::new(&mut eth)
|
||||||
|
.ethernet_addr(net_addresses.hardware_addr)
|
||||||
|
.ip_addrs(ip_addrs)
|
||||||
|
.neighbor_cache(neighbor_cache)
|
||||||
|
.finalize()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Sockets::init(32);
|
Sockets::init(32);
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,5 @@ pub fn main_core0() {
|
||||||
pl::csr::rtio_core::reset_phy_write(1);
|
pl::csr::rtio_core::reset_phy_write(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("network addresses: {}", net_settings::get_adresses());
|
|
||||||
|
|
||||||
comms::main(timer);
|
comms::main(timer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue