diff options
| author | Thales Fragoso <[email protected]> | 2021-06-14 18:06:12 -0300 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-06-16 16:48:35 +0200 |
| commit | 3396a519389837727c17eae2ebf65d5c93f70551 (patch) | |
| tree | 209e8b6628d765079ef539abdd070d23f61171ec /embassy-net/src | |
| parent | 6cecc6d4b54acf84cc9b22996b178cba97970374 (diff) | |
net: Add features for pool size and remove unwrap on smoltcp device
Diffstat (limited to 'embassy-net/src')
| -rw-r--r-- | embassy-net/src/device.rs | 2 | ||||
| -rw-r--r-- | embassy-net/src/packet_pool.rs | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/embassy-net/src/device.rs b/embassy-net/src/device.rs index 5fcb94ac8..fc9d08947 100644 --- a/embassy-net/src/device.rs +++ b/embassy-net/src/device.rs | |||
| @@ -43,8 +43,8 @@ impl<'a> SmolDevice<'a> for DeviceAdapter { | |||
| 43 | type TxToken = TxToken<'a>; | 43 | type TxToken = TxToken<'a>; |
| 44 | 44 | ||
| 45 | fn receive(&'a mut self) -> Option<(Self::RxToken, Self::TxToken)> { | 45 | fn receive(&'a mut self) -> Option<(Self::RxToken, Self::TxToken)> { |
| 46 | let tx_pkt = PacketBox::new(Packet::new())?; | ||
| 46 | let rx_pkt = self.device.receive()?; | 47 | let rx_pkt = self.device.receive()?; |
| 47 | let tx_pkt = PacketBox::new(Packet::new()).unwrap(); // TODO: not sure about unwrap | ||
| 48 | let rx_token = RxToken { pkt: rx_pkt }; | 48 | let rx_token = RxToken { pkt: rx_pkt }; |
| 49 | let tx_token = TxToken { | 49 | let tx_token = TxToken { |
| 50 | device: self.device, | 50 | device: self.device, |
diff --git a/embassy-net/src/packet_pool.rs b/embassy-net/src/packet_pool.rs index 0ec88e649..b43ae2eb2 100644 --- a/embassy-net/src/packet_pool.rs +++ b/embassy-net/src/packet_pool.rs | |||
| @@ -4,8 +4,19 @@ use core::ops::{Deref, DerefMut, Range}; | |||
| 4 | use atomic_pool::{pool, Box}; | 4 | use atomic_pool::{pool, Box}; |
| 5 | 5 | ||
| 6 | pub const MTU: usize = 1516; | 6 | pub const MTU: usize = 1516; |
| 7 | |||
| 8 | #[cfg(feature = "pool-4")] | ||
| 7 | pub const PACKET_POOL_SIZE: usize = 4; | 9 | pub const PACKET_POOL_SIZE: usize = 4; |
| 8 | 10 | ||
| 11 | #[cfg(feature = "pool-8")] | ||
| 12 | pub const PACKET_POOL_SIZE: usize = 8; | ||
| 13 | |||
| 14 | #[cfg(feature = "pool-16")] | ||
| 15 | pub const PACKET_POOL_SIZE: usize = 16; | ||
| 16 | |||
| 17 | #[cfg(feature = "pool-32")] | ||
| 18 | pub const PACKET_POOL_SIZE: usize = 32; | ||
| 19 | |||
| 9 | pool!(pub PacketPool: [Packet; PACKET_POOL_SIZE]); | 20 | pool!(pub PacketPool: [Packet; PACKET_POOL_SIZE]); |
| 10 | pub type PacketBox = Box<PacketPool>; | 21 | pub type PacketBox = Box<PacketPool>; |
| 11 | 22 | ||
