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
impl NicDataPlane
Sourcepub fn new(devices: &[(u64, u16)]) -> Result<Self, &'static str>
pub fn new(devices: &[(u64, u16)]) -> Result<Self, &'static str>
Create count queues for each (device_resource, count) entry.
pub fn queue(&self, index: usize) -> Option<&Arc<NetQueue>>
pub fn clone_queue(&self, index: usize) -> Option<Arc<NetQueue>>
Sourcepub fn queue_for(&self, resource: u64, qid: u16) -> Option<Arc<NetQueue>>
pub fn queue_for(&self, resource: u64, qid: u16) -> Option<Arc<NetQueue>>
Resolve (device resource, queue id) to a queue.
Sourcepub fn queue_count_for(&self, resource: u64) -> u16
pub fn queue_count_for(&self, resource: u64) -> u16
Number of queues exposed by a device.
pub fn queue_count(&self) -> usize
Sourcepub fn configure(&self, index: usize, feature_mask: u64, mtu: u32)
pub fn configure(&self, index: usize, feature_mask: u64, mtu: u32)
Apply a driver’s negotiated features and MTU to one queue.
Sourcepub fn configure_device(&self, resource: u64, feature_mask: u64, mtu: u32)
pub fn configure_device(&self, resource: u64, feature_mask: u64, mtu: u32)
Apply features/MTU to every queue of a device.
pub fn push_rx_for(&self, resource: u64, qid: u16, data: &[u8]) -> bool
pub fn pop_rx_for( &self, resource: u64, qid: u16, buf: &mut [u8], ) -> Result<Option<usize>, RxError>
pub fn push_tx_for( &self, resource: u64, qid: u16, data: &[u8], ) -> Result<(), TxError>
pub fn pop_tx_for( &self, resource: u64, qid: u16, buf: &mut [u8], ) -> Result<Option<usize>, TxError>
pub fn set_link_for(&self, resource: u64, qid: u16, up: bool, speed_mbps: u32)
Sourcepub fn push_rx(&self, index: usize, data: &[u8]) -> bool
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.
Sourcepub fn pop_rx(
&self,
index: usize,
buf: &mut [u8],
) -> Result<Option<usize>, RxError>
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.
fn pop_rx_queue( &self, queue: &Arc<NetQueue>, buf: &mut [u8], ) -> Result<Option<usize>, RxError>
Sourcepub fn push_tx(&self, index: usize, data: &[u8]) -> Result<(), TxError>
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).
fn push_tx_queue( &self, queue: &Arc<NetQueue>, data: &[u8], ) -> Result<(), TxError>
Sourcepub fn pop_tx(
&self,
index: usize,
buf: &mut [u8],
) -> Result<Option<usize>, TxError>
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.
fn pop_tx_queue( &self, queue: &Arc<NetQueue>, buf: &mut [u8], ) -> Result<Option<usize>, TxError>
Sourcepub fn notify_rx_consumer(&self, index: usize)
pub fn notify_rx_consumer(&self, index: usize)
Notify the consumer that RX data is available.
Sourcepub fn notify_tx_producer(&self, index: usize)
pub fn notify_tx_producer(&self, index: usize)
Notify the device that TX descriptors are pending.
Sourcepub fn rx_pending(&self, index: usize) -> u32
pub fn rx_pending(&self, index: usize) -> u32
Count RX packets without consuming them.
Sourcepub fn tx_pending(&self, index: usize) -> u32
pub fn tx_pending(&self, index: usize) -> u32
Count TX packets without consuming them.
Auto Trait Implementations§
impl !RefUnwindSafe for NicDataPlane
impl !UnwindSafe for NicDataPlane
impl Forget for NicDataPlane
impl Freeze for NicDataPlane
impl Move for NicDataPlane
impl Send for NicDataPlane
impl Sync for NicDataPlane
impl Unpin for NicDataPlane
impl UnsafeUnpin 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