struct PciHotPlugWorker {
    event_map: BTreeMap<RawDescriptor, (Event, PciAddress)>,
    port_state_map: BTreeMap<PciAddress, PortState>,
    port_map: BTreeMap<PortKey, PortWorkerStub>,
    manager_evt: Event,
    wait_ctx: WaitContext<Token>,
    command_receiver: Receiver<WorkerCommand>,
    response_sender: Sender<WorkerResponse>,
    rootbus_controller: Sender<PciRootCommand>,
}
Expand description

PciHotPlugWorker is a worker that handles the asynchrony of slot states between crosvm and the guest OS. It is responsible for scheduling the PCIe slot control signals and handle its result.

Fields§

§event_map: BTreeMap<RawDescriptor, (Event, PciAddress)>§port_state_map: BTreeMap<PciAddress, PortState>§port_map: BTreeMap<PortKey, PortWorkerStub>§manager_evt: Event§wait_ctx: WaitContext<Token>§command_receiver: Receiver<WorkerCommand>§response_sender: Sender<WorkerResponse>§rootbus_controller: Sender<PciRootCommand>

Implementations§

source§

impl PciHotPlugWorker

source

fn new( rootbus_controller: Sender<PciRootCommand>, command_receiver: Receiver<WorkerCommand>, response_sender: Sender<WorkerResponse>, manager_evt: Event, kill_evt: &Event ) -> Result<Self, Error>

source

fn run(&mut self, kill_evt: Event) -> Result<(), Error>

Starts the worker. Runs until received kill request, or an error that the worker is in an invalid state.

source

fn handle_manager_command(&mut self) -> Result<(), Error>

source

fn handle_add_port( &mut self, pci_address: PciAddress, port: PortWorkerStub ) -> Result<WorkerResponse, Error>

Handles add port: Initiate port in EmptyNotReady state.

source

fn handle_get_port_state( &self, pci_address: PciAddress ) -> Result<WorkerResponse, Error>

Handles get port state: returns the PortState.

source

fn handle_get_empty_port(&self) -> Result<WorkerResponse, Error>

Handle getting empty port: Find the most empty port, or return error if all are occupied.

source

fn handle_plug_request( &mut self, hotplug_command: SignalHotPlugCommand ) -> Result<WorkerResponse, Error>

Handles plug request: Moves PortState from EmptyNotReady to OccupiedNotReady, Empty(n) to Occupied(n+1), and schedules the next plug event if n == 0.

source

fn handle_unplug_request( &mut self, pci_address: PciAddress ) -> Result<WorkerResponse, Error>

Handles unplug request: Moves PortState from OccupiedNotReady to EmptyNotReady, Occupied(n) to Empty(n % 2 + 1), and schedules the next unplug event if n == 0.

n % 2 + 1: When unplug request is made, it either schedule the unplug event (n == 0 => 1 or n == 1 => 2), or cancels the corresponding plug event that has not started (n == 2 => 1 or n == 3 => 2). Staring at the mapping, it maps n to either 1 or 2 of opposite oddity. n % 2 + 1 is a good shorthand instead of the individual mappings.

source

fn handle_port_ready(&mut self, pci_address: PciAddress) -> Result<(), Error>

Handles port ready: Moves PortState from EmptyNotReady to Empty(0), OccupiedNotReady to Occupied(1), and schedules the next event if port is occupied

source

fn handle_plug_complete(&mut self, pci_address: PciAddress) -> Result<(), Error>

Handles plug complete: Moves PortState from Any(n) to Any(n-1), and schedules the next unplug event unless n == 1. (Any is either Empty or Occupied.)

source

fn handle_unplug_complete( &mut self, pci_address: PciAddress ) -> Result<(), Error>

Handles unplug complete: Moves PortState from Any(n) to Any(n-1), and schedules the next plug event unless n == 1. (Any is either Empty or Occupied.)

source

fn get_port_state(&self, pci_address: PciAddress) -> Result<PortState, Error>

source

fn set_port_state( &mut self, pci_address: PciAddress, port_state: PortState ) -> Result<(), Error>

source

fn schedule_plug_event(&mut self, pci_address: PciAddress) -> Result<(), Error>

source

fn schedule_unplug_event( &mut self, pci_address: PciAddress ) -> Result<(), Error>

source

fn get_port_mut( &mut self, pci_address: PciAddress ) -> Result<&mut PortWorkerStub, Error>

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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>,

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V