Struct nic_queues::RxQueue

source ·
pub struct RxQueue<S: RxQueueRegisters, T: RxDescriptor> {
    pub id: u8,
    pub regs: S,
    pub rx_descs: BorrowedSliceMappedPages<T, Mutable>,
    pub num_rx_descs: u16,
    pub rx_cur: u16,
    pub rx_bufs_in_use: Vec<ReceiveBuffer>,
    pub rx_buffer_size_bytes: u16,
    pub received_frames: VecDeque<ReceivedFrame>,
    pub cpu_id: Option<CpuId>,
    pub rx_buffer_pool: &'static Queue<ReceiveBuffer>,
    pub filter_num: Option<u8>,
}
Expand description

A struct that holds all information for one receive queue. There should be one such object per queue.

Fields§

§id: u8

The number of the queue, stored here for our convenience.

§regs: S

Registers for this receive queue

§rx_descs: BorrowedSliceMappedPages<T, Mutable>

Receive descriptors

§num_rx_descs: u16

The number of receive descriptors in the descriptor ring

§rx_cur: u16

Current receive descriptor index

§rx_bufs_in_use: Vec<ReceiveBuffer>

The list of rx buffers, in which the index in the vector corresponds to the index in rx_descs. For example, rx_bufs_in_use[2] is the receive buffer that will be used when rx_descs[2] is the current rx descriptor (rx_cur = 2).

§rx_buffer_size_bytes: u16§received_frames: VecDeque<ReceivedFrame>

The queue of received Ethernet frames, ready for consumption by a higher layer. Just like a regular FIFO queue, newly-received frames are pushed onto the back and frames are popped off of the front. Each frame is represented by a Vec<ReceiveBuffer>, because a single frame can span multiple receive buffers. TODO: improve this? probably not the best cleanest way to expose received frames to higher layers

§cpu_id: Option<CpuId>

The cpu which this queue is mapped to. This in itself doesn’t guarantee anything, but we use this value when setting the cpu id for interrupts and DCA.

§rx_buffer_pool: &'static Queue<ReceiveBuffer>

Pool where ReceiveBuffers are stored.

§filter_num: Option<u8>

The filter id for the physical NIC filter that is set for this queue

Implementations§

source§

impl<S: RxQueueRegisters, T: RxDescriptor> RxQueue<S, T>

source

pub fn poll_queue_and_store_received_packets( &mut self ) -> Result<(), &'static str>

Polls the queue and removes all received packets from it. The received packets are stored in the receive queue’s received_frames FIFO queue.

source

pub fn return_frame(&mut self) -> Option<ReceivedFrame>

Returns the earliest received ethernet frame.

Auto Trait Implementations§

§

impl<S, T> !RefUnwindSafe for RxQueue<S, T>

§

impl<S, T> Send for RxQueue<S, T>where S: Send, T: Send,

§

impl<S, T> Sync for RxQueue<S, T>where S: Sync, T: Sync,

§

impl<S, T> Unpin for RxQueue<S, T>where S: Unpin, T: Unpin,

§

impl<S, T> !UnwindSafe for RxQueue<S, T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.