@@ -20,12 +20,11 @@ mod utilities;
20
20
use log:: info;
21
21
22
22
use smoltcp:: iface:: {
23
- EthernetInterface , EthernetInterfaceBuilder , Neighbor , NeighborCache ,
24
- Route , Routes ,
23
+ Interface , InterfaceBuilder , Neighbor , NeighborCache , Route , Routes ,
24
+ SocketStorage ,
25
25
} ;
26
- use smoltcp:: socket:: { SocketSet , SocketSetItem } ;
27
26
use smoltcp:: time:: Instant ;
28
- use smoltcp:: wire:: { EthernetAddress , IpAddress , IpCidr , Ipv6Cidr } ;
27
+ use smoltcp:: wire:: { HardwareAddress , IpAddress , IpCidr , Ipv6Cidr } ;
29
28
30
29
use stm32h7xx_hal:: gpio;
31
30
use stm32h7xx_hal:: hal:: digital:: v2:: OutputPin ;
@@ -60,27 +59,26 @@ static mut DES_RING: ethernet::DesRing<4, 4> = ethernet::DesRing::new();
60
59
/// Net storage with static initialisation - another global singleton
61
60
pub struct NetStorageStatic < ' a > {
62
61
ip_addrs : [ IpCidr ; 1 ] ,
63
- socket_set_entries : [ Option < SocketSetItem < ' a > > ; 8 ] ,
62
+ socket_storage : [ SocketStorage < ' a > ; 8 ] ,
64
63
neighbor_cache_storage : [ Option < ( IpAddress , Neighbor ) > ; 8 ] ,
65
64
routes_storage : [ Option < ( IpCidr , Route ) > ; 1 ] ,
66
65
}
67
66
static mut STORE : NetStorageStatic = NetStorageStatic {
68
67
// Garbage
69
68
ip_addrs : [ IpCidr :: Ipv6 ( Ipv6Cidr :: SOLICITED_NODE_PREFIX ) ] ,
70
- socket_set_entries : [ None , None , None , None , None , None , None , None ] ,
69
+ socket_storage : [ SocketStorage :: EMPTY ; 8 ] ,
71
70
neighbor_cache_storage : [ None ; 8 ] ,
72
71
routes_storage : [ None ; 1 ] ,
73
72
} ;
74
73
75
74
pub struct Net < ' a > {
76
- iface : EthernetInterface < ' a , ethernet:: EthernetDMA < ' a , 4 , 4 > > ,
77
- sockets : SocketSet < ' a > ,
75
+ iface : Interface < ' a , ethernet:: EthernetDMA < ' a , 4 , 4 > > ,
78
76
}
79
77
impl < ' a > Net < ' a > {
80
78
pub fn new (
81
79
store : & ' static mut NetStorageStatic < ' a > ,
82
80
ethdev : ethernet:: EthernetDMA < ' a , 4 , 4 > ,
83
- ethernet_addr : EthernetAddress ,
81
+ ethernet_addr : HardwareAddress ,
84
82
) -> Self {
85
83
// Set IP address
86
84
store. ip_addrs =
@@ -90,15 +88,15 @@ impl<'a> Net<'a> {
90
88
NeighborCache :: new ( & mut store. neighbor_cache_storage [ ..] ) ;
91
89
let routes = Routes :: new ( & mut store. routes_storage [ ..] ) ;
92
90
93
- let iface = EthernetInterfaceBuilder :: new ( ethdev )
94
- . ethernet_addr ( ethernet_addr )
95
- . neighbor_cache ( neighbor_cache )
96
- . ip_addrs ( & mut store . ip_addrs [ .. ] )
97
- . routes ( routes )
98
- . finalize ( ) ;
99
- let sockets = SocketSet :: new ( & mut store . socket_set_entries [ .. ] ) ;
91
+ let iface =
92
+ InterfaceBuilder :: new ( ethdev , & mut store . socket_storage [ .. ] )
93
+ . hardware_addr ( ethernet_addr )
94
+ . neighbor_cache ( neighbor_cache )
95
+ . ip_addrs ( & mut store . ip_addrs [ .. ] )
96
+ . routes ( routes )
97
+ . finalize ( ) ;
100
98
101
- return Net { iface, sockets } ;
99
+ return Net { iface } ;
102
100
}
103
101
104
102
/// Polls on the ethernet interface. You should refer to the smoltcp
@@ -107,7 +105,7 @@ impl<'a> Net<'a> {
107
105
let timestamp = Instant :: from_millis ( now) ;
108
106
109
107
self . iface
110
- . poll ( & mut self . sockets , timestamp)
108
+ . poll ( timestamp)
111
109
. map ( |_| ( ) )
112
110
. unwrap_or_else ( |e| info ! ( "Poll: {:?}" , e) ) ;
113
111
}
@@ -195,13 +193,11 @@ const APP: () = {
195
193
lan8742a. phy_init ( ) ;
196
194
// The eth_dma should not be used until the PHY reports the link is up
197
195
198
- unsafe {
199
- ethernet:: enable_interrupt ( ) ;
200
- }
196
+ unsafe { ethernet:: enable_interrupt ( ) } ;
201
197
202
198
// unsafe: mutable reference to static storage, we only do this once
203
199
let store = unsafe { & mut STORE } ;
204
- let net = Net :: new ( store, eth_dma, mac_addr) ;
200
+ let net = Net :: new ( store, eth_dma, mac_addr. into ( ) ) ;
205
201
206
202
// 1ms tick
207
203
systick_init ( ctx. core . SYST , ccdr. clocks ) ;
0 commit comments