Struct crosvm::crosvm::sys::linux::pci_hotplug_manager::PciHotPlugWorker
source · 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
impl PciHotPlugWorker
fn new( rootbus_controller: Sender<PciRootCommand>, command_receiver: Receiver<WorkerCommand>, response_sender: Sender<WorkerResponse>, manager_evt: Event, kill_evt: &Event ) -> Result<Self, Error>
sourcefn run(&mut self, kill_evt: Event) -> Result<(), Error>
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.
fn handle_manager_command(&mut self) -> Result<(), Error>
sourcefn handle_add_port(
&mut self,
pci_address: PciAddress,
port: PortWorkerStub
) -> Result<WorkerResponse, Error>
fn handle_add_port( &mut self, pci_address: PciAddress, port: PortWorkerStub ) -> Result<WorkerResponse, Error>
Handles add port: Initiate port in EmptyNotReady state.
sourcefn handle_get_port_state(
&self,
pci_address: PciAddress
) -> Result<WorkerResponse, Error>
fn handle_get_port_state( &self, pci_address: PciAddress ) -> Result<WorkerResponse, Error>
Handles get port state: returns the PortState.
sourcefn handle_get_empty_port(&self) -> Result<WorkerResponse, Error>
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.
sourcefn handle_plug_request(
&mut self,
hotplug_command: SignalHotPlugCommand
) -> Result<WorkerResponse, Error>
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.
sourcefn handle_unplug_request(
&mut self,
pci_address: PciAddress
) -> Result<WorkerResponse, Error>
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.
sourcefn handle_port_ready(&mut self, pci_address: PciAddress) -> Result<(), Error>
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
sourcefn handle_plug_complete(&mut self, pci_address: PciAddress) -> Result<(), Error>
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.)
sourcefn handle_unplug_complete(
&mut self,
pci_address: PciAddress
) -> Result<(), Error>
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.)
fn get_port_state(&self, pci_address: PciAddress) -> Result<PortState, Error>
fn set_port_state( &mut self, pci_address: PciAddress, port_state: PortState ) -> Result<(), Error>
fn schedule_plug_event(&mut self, pci_address: PciAddress) -> Result<(), Error>
fn schedule_unplug_event( &mut self, pci_address: PciAddress ) -> Result<(), Error>
fn get_port_mut( &mut self, pci_address: PciAddress ) -> Result<&mut PortWorkerStub, Error>
Auto Trait Implementations§
impl RefUnwindSafe for PciHotPlugWorker
impl Send for PciHotPlugWorker
impl !Sync for PciHotPlugWorker
impl Unpin for PciHotPlugWorker
impl UnwindSafe for PciHotPlugWorker
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.