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: u8The number of the queue, stored here for our convenience.
regs: SRegisters for this receive queue
rx_descs: BorrowedSliceMappedPages<T, Mutable>Receive descriptors
num_rx_descs: u16The number of receive descriptors in the descriptor ring
rx_cur: u16Current 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>
impl<S: RxQueueRegisters, T: RxDescriptor> RxQueue<S, T>
sourcepub fn poll_queue_and_store_received_packets(
&mut self
) -> Result<(), &'static str>
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.
sourcepub fn return_frame(&mut self) -> Option<ReceivedFrame>
pub fn return_frame(&mut self) -> Option<ReceivedFrame>
Returns the earliest received ethernet frame.