Skip to main content

NicDataPlane

Struct NicDataPlane 

Source
pub struct NicDataPlane {
    pub queues: Vec<Arc<NetQueue>>,
    pub devices: Vec<DeviceQueues>,
}
Expand description

A set of queues for the registered NICs.

Each device owns queue_count queues (software RSS queues today, hardware queues when the driver exposes them). queues stays a flat vector so the legacy syscalls can keep using a small integer index, while devices maps a Nic capability resource to its queue range.

Fields§

§queues: Vec<Arc<NetQueue>>§devices: Vec<DeviceQueues>

Implementations§

Source§

impl NicDataPlane

Source

pub fn new(devices: &[(u64, u16)]) -> Result<Self, &'static str>

Create count queues for each (device_resource, count) entry.

Source

pub fn queue(&self, index: usize) -> Option<&Arc<NetQueue>>

Source

pub fn clone_queue(&self, index: usize) -> Option<Arc<NetQueue>>

Source

pub fn queue_for(&self, resource: u64, qid: u16) -> Option<Arc<NetQueue>>

Resolve (device resource, queue id) to a queue.

Source

pub fn queue_count_for(&self, resource: u64) -> u16

Number of queues exposed by a device.

Source

pub fn queue_count(&self) -> usize

Source

pub fn configure(&self, index: usize, feature_mask: u64, mtu: u32)

Apply a driver’s negotiated features and MTU to one queue.

Source

pub fn configure_device(&self, resource: u64, feature_mask: u64, mtu: u32)

Apply features/MTU to every queue of a device.

Source

pub fn push_rx_for(&self, resource: u64, qid: u16, data: &[u8]) -> bool

Source

pub fn pop_rx_for( &self, resource: u64, qid: u16, buf: &mut [u8], ) -> Result<Option<usize>, RxError>

Source

pub fn push_tx_for( &self, resource: u64, qid: u16, data: &[u8], ) -> Result<(), TxError>

Source

pub fn pop_tx_for( &self, resource: u64, qid: u16, buf: &mut [u8], ) -> Result<Option<usize>, TxError>

Source

pub fn push_rx(&self, index: usize, data: &[u8]) -> bool

Push a received frame into the queue’s RX ring.

Called from the NIC IRQ/poll path. No allocation, no lock.

Source

pub fn pop_rx( &self, index: usize, buf: &mut [u8], ) -> Result<Option<usize>, RxError>

Copy one RX frame into buf and release its slot.

Returns Ok(None) when the ring is empty. If buf is smaller than the frame, the slot is not consumed and BufferTooSmall is returned; this is the non-destructive read contract.

Source

fn pop_rx_queue( &self, queue: &Arc<NetQueue>, buf: &mut [u8], ) -> Result<Option<usize>, RxError>

Source

pub fn push_tx(&self, index: usize, data: &[u8]) -> Result<(), TxError>

Queue one TX frame. Copies into a slot; kick() must be called to notify the device (the legacy syscall does it inline).

Source

fn push_tx_queue( &self, queue: &Arc<NetQueue>, data: &[u8], ) -> Result<(), TxError>

Source

pub fn pop_tx( &self, index: usize, buf: &mut [u8], ) -> Result<Option<usize>, TxError>

Pop one TX frame into buf for transmission. The slot is released immediately: the current drivers copy into their DMA ring, so the slot can be reused as soon as the copy completes.

Source

fn pop_tx_queue( &self, queue: &Arc<NetQueue>, buf: &mut [u8], ) -> Result<Option<usize>, TxError>

Source

pub fn notify_rx_consumer(&self, index: usize)

Notify the consumer that RX data is available.

Source

pub fn notify_tx_producer(&self, index: usize)

Notify the device that TX descriptors are pending.

Source

pub fn rx_pending(&self, index: usize) -> u32

Count RX packets without consuming them.

Source

pub fn tx_pending(&self, index: usize) -> u32

Count TX packets without consuming them.

Update the link state exported in every queue header.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.