pub struct NicDataPlane {
pub queues: Vec<RingPair>,
}Expand description
Multi-queue NIC data plane.
Initialised during NIC driver setup. Each hardware queue gets one
RingPair; the consumer (strate-net) polls all RX rings in round-robin.
Fields§
§queues: Vec<RingPair>One ring pair per RSS queue.
Implementations§
Source§impl NicDataPlane
impl NicDataPlane
Sourcepub fn new(
queue_count: usize,
slot_count: u32,
slot_size: usize,
) -> Result<Self, &'static str>
pub fn new( queue_count: usize, slot_count: u32, slot_size: usize, ) -> Result<Self, &'static str>
Create a new data plane with queue_count ring pairs.
Each ring has slot_count slots of slot_size bytes.
Returns an error if ring allocation fails.
Sourcepub fn push_rx(&self, queue_index: usize, data: &[u8]) -> Result<(), ()>
pub fn push_rx(&self, queue_index: usize, data: &[u8]) -> Result<(), ()>
Push a received packet into the RX ring for queue_index.
Called from the NIC IRQ handler. Returns Err if the ring is full
(backpressure : drop the packet).
Sourcepub fn pop_rx(
&self,
queue_index: usize,
buf: &mut [u8],
) -> Result<Option<usize>, ()>
pub fn pop_rx( &self, queue_index: usize, buf: &mut [u8], ) -> Result<Option<usize>, ()>
Pop a received packet from the RX ring for queue_index.
Called by strate-net. Returns Ok(None) if the ring is empty.
Sourcepub fn push_tx(&self, queue_index: usize, data: &[u8]) -> Result<(), ()>
pub fn push_tx(&self, queue_index: usize, data: &[u8]) -> Result<(), ()>
Push an outbound packet into the TX ring for queue_index.
Called by strate-net. The NIC driver will read from the TX ring and transmit onto the wire.
Sourcepub fn pop_tx(
&self,
queue_index: usize,
buf: &mut [u8],
) -> Result<Option<usize>, ()>
pub fn pop_tx( &self, queue_index: usize, buf: &mut [u8], ) -> Result<Option<usize>, ()>
Pop an outbound packet from the TX ring for queue_index.
Called by the NIC driver. Returns Ok(None) if the ring is empty.
Sourcepub fn notify_rx_consumer(&self, queue_index: usize)
pub fn notify_rx_consumer(&self, queue_index: usize)
Notify the consumer (strate-net) that new RX data is available.
Sourcepub fn notify_tx_producer(&self, queue_index: usize)
pub fn notify_tx_producer(&self, queue_index: usize)
Notify the NIC driver that new TX data is available.
Sourcepub fn queue_count(&self) -> usize
pub fn queue_count(&self) -> usize
Number of queues (ring pairs).
Auto Trait Implementations§
impl Freeze for NicDataPlane
impl RefUnwindSafe for NicDataPlane
impl Send for NicDataPlane
impl Sync for NicDataPlane
impl Unpin for NicDataPlane
impl UnsafeUnpin for NicDataPlane
impl UnwindSafe for NicDataPlane
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more