pub struct NetQueue {Show 16 fields
pub qid: u16,
pub dev_id: u64,
pub ring_id: RingId,
ring: Arc<SharedRing>,
vas: Vec<u64>,
phys: Vec<u64>,
header: *mut NetQueueHeader,
pub event: Arc<QueueEvent>,
pub irq: AtomicU8,
pub port: AtomicU64,
pub features: AtomicU64,
pub alive: AtomicU8,
mapped: AtomicBool,
mapped_base: AtomicU64,
mapped_owner: AtomicU64,
pending_rx: SpinLock<Option<NetFrameDesc>>,
}Expand description
One shared RX/TX queue pair for a network device.
Fields§
§qid: u16§dev_id: u64§ring_id: RingId§ring: Arc<SharedRing>§vas: Vec<u64>Kernel virtual address of each page, in mapping order.
phys: Vec<u64>Physical address of each page, in mapping order.
header: *mut NetQueueHeader§event: Arc<QueueEvent>§irq: AtomicU8IRQ vector bound to this queue (0xFF = polling).
port: AtomicU64IPC port bound to this queue (0 = none).
features: AtomicU64Feature mask negotiated with the device.
alive: AtomicU8Serialises queue teardown against the IRQ handler.
mapped: AtomicBoolTrue once the region has been mapped into a userspace strate.
mapped_base: AtomicU64User virtual base of the mapping, 0 when unmapped.
mapped_owner: AtomicU64Task that owns the mapping, 0 when unmapped.
pending_rx: SpinLock<Option<NetFrameDesc>>Descriptor popped by a consumer whose buffer was too small. It must be returned before the next descriptor to preserve ordering.
Implementations§
Source§impl NetQueue
impl NetQueue
Sourcepub fn new(
dev_id: u64,
qid: u16,
feature_mask: u64,
mtu: u32,
epoch: u32,
) -> Result<Arc<Self>, &'static str>
pub fn new( dev_id: u64, qid: u16, feature_mask: u64, mtu: u32, epoch: u32, ) -> Result<Arc<Self>, &'static str>
Allocate and initialise a queue region.
pub fn header(&self) -> &NetQueueHeader
pub fn header_mut_ptr(&self) -> *mut NetQueueHeader
pub fn region(&self) -> &Arc<SharedRing> ⓘ
Sourcepub fn try_map(&self, owner: u64) -> bool
pub fn try_map(&self, owner: u64) -> bool
Reserve the single userspace mapping for owner. Returns false if
another live task owns it. A mapping left behind by a dead task is
reclaimed (hot-restart).
Sourcepub fn unmap_reservation(&self)
pub fn unmap_reservation(&self)
Release the mapping reservation after a failed map.
Sourcepub fn set_mapped_base(&self, base: u64)
pub fn set_mapped_base(&self, base: u64)
Record the user base of a successful mapping.
Sourcepub fn take_mapped_base(&self) -> u64
pub fn take_mapped_base(&self) -> u64
Take the user base of the mapping (0 if none).
pub fn phys_pages(&self) -> &[u64]
pub fn is_alive(&self) -> bool
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Mark the queue dead and wake any waiter. The region is released when
the last Arc<NetQueue> is dropped.
Sourcefn ptr_at(&self, offset: usize) -> Option<*mut u8>
fn ptr_at(&self, offset: usize) -> Option<*mut u8>
Translate a byte offset in the region to its kernel VA.
Sourcepub fn phys_at(&self, offset: usize) -> Option<u64>
pub fn phys_at(&self, offset: usize) -> Option<u64>
Physical address of a byte offset in the region.
Sourcepub fn rx_slot_phys(&self, slot: u32) -> Option<u64>
pub fn rx_slot_phys(&self, slot: u32) -> Option<u64>
Physical address of an RX slot (for programming DMA).
Sourcepub fn tx_slot_phys(&self, slot: u32) -> Option<u64>
pub fn tx_slot_phys(&self, slot: u32) -> Option<u64>
Physical address of a TX slot.
Sourcepub fn push_rx(&self, frame: &[u8]) -> bool
pub fn push_rx(&self, frame: &[u8]) -> bool
Copy a frame into an RX slot and publish it.
Called from the IRQ/poll path. Returns false if the ring or the
slot pool is full.
Sourcepub fn pop_rx(&self) -> Option<NetFrameDesc>
pub fn pop_rx(&self) -> Option<NetFrameDesc>
Pop one RX descriptor (stack side). A descriptor previously returned
with putback_rx is served first to preserve ordering.
Sourcepub fn putback_rx(&self, desc: NetFrameDesc)
pub fn putback_rx(&self, desc: NetFrameDesc)
Put back an RX descriptor whose consumer buffer was too small.
Sourcepub fn release_rx(&self, slot: u32)
pub fn release_rx(&self, slot: u32)
Release an RX slot after the stack copied its payload.
Sourcepub fn push_tx(&self, desc: NetFrameDesc) -> bool
pub fn push_tx(&self, desc: NetFrameDesc) -> bool
Publish a TX descriptor after the stack filled the slot.
Sourcepub fn pop_tx(&self) -> Option<NetFrameDesc>
pub fn pop_tx(&self) -> Option<NetFrameDesc>
Pop one TX descriptor (kernel/device side).
Sourcepub fn release_tx(&self, slot: u32)
pub fn release_tx(&self, slot: u32)
Release a transmitted TX slot.
Sourcepub fn feature_mask(&self) -> u64
pub fn feature_mask(&self) -> u64
Current feature mask.
Sourcepub fn configure(&self, mask: u64, mtu: u32)
pub fn configure(&self, mask: u64, mtu: u32)
Negotiate features and MTU after the driver has probed the device.
Sourcepub fn set_features(&self, mask: u64)
pub fn set_features(&self, mask: u64)
Enable features after negotiation.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for NetQueue
impl !RefUnwindSafe for NetQueue
impl !UnwindSafe for NetQueue
impl Forget for NetQueue
impl Move for NetQueue
impl Unpin for NetQueue
impl UnsafeUnpin for NetQueue
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