pub struct StaticPool<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1>where
Align<ALIGN>: ValidAlign,{ /* private fields */ }Expand description
Statically allocated Pool.
Pick SIZE for the largest frame your links carry:
- 1514 for Ethernet. 1518 or 1522 with one or two VLAN tags.
- 9018 or so for Ethernet with jumbo frames.
- 128 or 256 for IEEE 802.15.4 without 6LoWPAN fragmentation. 256 leaves room for the headers to grow when they are decompressed.
Add the largest tx_headroom of
your drivers. A frame and the headroom in front of it share one buffer.
SIZE also caps the MTU of every interface. Going below the protocol minimums
works, but breaks interoperability:
- IPv6 needs 1280 bytes plus the link header (RFC 8200).
- IPv4 hosts must accept 576 bytes plus the link header (RFC 791).
ALIGN can be 1, 2, 4, 8, 16, 32 or 64.
Put it in a static:
use xarxa::{Stack, StaticPool};
static POOL: StaticPool<1514, 16> = StaticPool::new();
let stack = Stack::new(&POOL, 0x1234_5678);The pool is zero-initialized, so a static of it lives in .bss. To put it
in DMA-capable memory, give the static a #[link_section]. That memory
must then be zeroed before the pool is used.
Implementations§
Source§impl<const SIZE: usize, const COUNT: usize, const ALIGN: usize> StaticPool<SIZE, COUNT, ALIGN>where
Align<ALIGN>: ValidAlign,
impl<const SIZE: usize, const COUNT: usize, const ALIGN: usize> StaticPool<SIZE, COUNT, ALIGN>where
Align<ALIGN>: ValidAlign,
Trait Implementations§
Source§impl<const SIZE: usize, const COUNT: usize, const ALIGN: usize> Default for StaticPool<SIZE, COUNT, ALIGN>where
Align<ALIGN>: ValidAlign,
impl<const SIZE: usize, const COUNT: usize, const ALIGN: usize> Default for StaticPool<SIZE, COUNT, ALIGN>where
Align<ALIGN>: ValidAlign,
Source§impl<const SIZE: usize, const COUNT: usize, const ALIGN: usize> Pool for StaticPool<SIZE, COUNT, ALIGN>where
Align<ALIGN>: ValidAlign,
impl<const SIZE: usize, const COUNT: usize, const ALIGN: usize> Pool for StaticPool<SIZE, COUNT, ALIGN>where
Align<ALIGN>: ValidAlign,
impl<const SIZE: usize, const COUNT: usize, const ALIGN: usize> Sync for StaticPool<SIZE, COUNT, ALIGN>where
Align<ALIGN>: ValidAlign,
Auto Trait Implementations§
impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !Freeze for StaticPool<SIZE, COUNT, ALIGN>
impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !RefUnwindSafe for StaticPool<SIZE, COUNT, ALIGN>
impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !Send for StaticPool<SIZE, COUNT, ALIGN>
impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !Unpin for StaticPool<SIZE, COUNT, ALIGN>
impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !UnsafeUnpin for StaticPool<SIZE, COUNT, ALIGN>
impl<const SIZE: usize = 1514, const COUNT: usize = 16, const ALIGN: usize = 1> !UnwindSafe for StaticPool<SIZE, COUNT, ALIGN>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more