From c0e2bbb23f51a6ad67b173f5b73d2d3903c22dde Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 8 Aug 2019 08:09:52 -0700 Subject: [PATCH] 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 --- pci/src/msix.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pci/src/msix.rs b/pci/src/msix.rs index e38a3e9e1..986ee080d 100644 --- a/pci/src/msix.rs +++ b/pci/src/msix.rs @@ -53,6 +53,7 @@ pub struct MsixConfig { pub pba_entries: Vec, interrupt_cb: Option>, masked: bool, + enabled: bool, } impl MsixConfig { @@ -70,6 +71,7 @@ impl MsixConfig { pba_entries, interrupt_cb: None, masked: false, + enabled: false, } } @@ -81,10 +83,15 @@ impl MsixConfig { self.masked } + pub fn enabled(&self) -> bool { + self.enabled + } + pub fn set_msg_ctl(&mut self, reg: u16) { let old_masked = self.masked; 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 // important to go through the entire PBA to check if there was any