mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
pci: Add MSI-X helper to check if interrupts are enabled
In order to check if device's interrupts are enabled, this patch adds a helper function to the MsixConfig structure so that at any point in time we can check if an interrupt should be delivered or not. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
4c9759e4fc
commit
c0e2bbb23f
@ -53,6 +53,7 @@ pub struct MsixConfig {
|
|||||||
pub pba_entries: Vec<u64>,
|
pub pba_entries: Vec<u64>,
|
||||||
interrupt_cb: Option<Arc<InterruptDelivery>>,
|
interrupt_cb: Option<Arc<InterruptDelivery>>,
|
||||||
masked: bool,
|
masked: bool,
|
||||||
|
enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MsixConfig {
|
impl MsixConfig {
|
||||||
@ -70,6 +71,7 @@ impl MsixConfig {
|
|||||||
pba_entries,
|
pba_entries,
|
||||||
interrupt_cb: None,
|
interrupt_cb: None,
|
||||||
masked: false,
|
masked: false,
|
||||||
|
enabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,10 +83,15 @@ impl MsixConfig {
|
|||||||
self.masked
|
self.masked
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn enabled(&self) -> bool {
|
||||||
|
self.enabled
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_msg_ctl(&mut self, reg: u16) {
|
pub fn set_msg_ctl(&mut self, reg: u16) {
|
||||||
let old_masked = self.masked;
|
let old_masked = self.masked;
|
||||||
|
|
||||||
self.masked = ((reg >> FUNCTION_MASK_BIT) & 1u16) == 1u16;
|
self.masked = ((reg >> FUNCTION_MASK_BIT) & 1u16) == 1u16;
|
||||||
|
self.enabled = ((reg >> MSIX_ENABLE_BIT) & 1u16) == 1u16;
|
||||||
|
|
||||||
// If the Function Mask bit was set, and has just been cleared, it's
|
// If the Function Mask bit was set, and has just been cleared, it's
|
||||||
// important to go through the entire PBA to check if there was any
|
// important to go through the entire PBA to check if there was any
|
||||||
|
Loading…
x
Reference in New Issue
Block a user