Skip to main content

NetDevice

Struct NetDevice 

Source
pub struct NetDevice { /* private fields */ }
Expand description

virtio-net frontend.

Implementations§

Source§

impl NetDevice

Source

pub fn new( config: NetConfig, backend: Arc<dyn NetBackend>, interceptor: Arc<dyn FrameInterceptor>, ) -> Self

Build a virtio-net.

Trait Implementations§

Source§

impl Debug for NetDevice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl VirtioDevice for NetDevice

Source§

fn device_type(&self) -> VirtioDeviceType

Device-type discriminant for the MMIO DeviceID register.
Source§

fn avail_features(&self) -> u64

Bitmap of features the device offers. The transport ANDs this with the driver’s acked_features and surfaces the negotiated set.
Source§

fn acked_features(&self) -> u64

Bitmap of features the driver has acknowledged.
Source§

fn set_acked_features(&mut self, value: u64)

Set the driver-acked feature set. The transport calls this once per MMIO DriverFeatures write; implementors typically just store the value.
Source§

fn queue_max_sizes(&self) -> &[u16]

Per-queue maximum descriptor counts. The vector length determines how many vrings the device exposes; the value at each index becomes QueueNumMax for that queue.
Source§

fn queues(&self) -> &[Queue]

Borrow the device’s queue state.
Source§

fn queues_mut(&mut self) -> &mut [Queue]

Borrow the device’s queue state mutably (transport uses this when the driver writes queue-config registers).
Source§

fn read_config(&self, offset: u64, data: &mut [u8])

Read a slice of the device’s config space at offset.
Source§

fn write_config(&mut self, _offset: u64, _data: &[u8])

Write a slice into the device’s config space at offset. Per the virtio spec § 2.4.2, drivers SHOULD not write config-space after DRIVER_OK; the transport gates on this and silently drops post-OK writes via crate::transport::VirtioMmioTransport::accept_config_write.
Source§

fn activate( &mut self, mem: Arc<dyn GuestMemory>, irq: IrqLine, ) -> Result<(), ActivateError>

Take ownership of the resources needed to drive the device live. Called exactly once on the driver’s DRIVER_OK transition. Read more
Source§

fn is_activated(&self) -> bool

true once activate has succeeded.
Source§

fn process_queue(&mut self, queue_index: u16)

Handler invoked on a guest write to the MMIO QueueNotify register. Read more

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more