From 05a544ee1dfb7ece3aeebd2d6e461fded2ad9182 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 9 Jun 2024 19:43:52 +0200 Subject: [PATCH 1/2] Add method to enable/disable function masking for MSI-X Function masking needs to be disabled before any interrupts can be received. --- src/capability/msix.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/capability/msix.rs b/src/capability/msix.rs index 50b3a63..b79c22b 100644 --- a/src/capability/msix.rs +++ b/src/capability/msix.rs @@ -39,6 +39,18 @@ impl MsixCapability { } } + /// Enable/disable masking of all interrupts for this PCI function. + /// + /// Individual interrupt sources can be masked using mask field of the corresponding entry in + /// the MSI-X table. + pub fn set_function_mask(&mut self, mask: bool, access: impl ConfigRegionAccess) { + let mut control = unsafe { access.read(self.address.address, self.address.offset) }; + control.set_bit(30, mask); + unsafe { + access.write(self.address.address, self.address.offset, control); + } + } + /// The index of the BAR that contains the MSI-X table. pub fn table_bar(&self) -> u8 { self.table.get_bits(0..3) as u8 From 65e081885985104eb3f545ccee4bea480abab977 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 9 Jun 2024 21:36:12 +0200 Subject: [PATCH 2/2] Add methods to get the current MSI-X enable and function mask status --- src/capability/msix.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/capability/msix.rs b/src/capability/msix.rs index b79c22b..8cf75a4 100644 --- a/src/capability/msix.rs +++ b/src/capability/msix.rs @@ -39,6 +39,11 @@ impl MsixCapability { } } + pub fn enabled(&self, access: impl ConfigRegionAccess) -> bool { + let control = unsafe { access.read(self.address.address, self.address.offset) }; + control.get_bit(31) + } + /// Enable/disable masking of all interrupts for this PCI function. /// /// Individual interrupt sources can be masked using mask field of the corresponding entry in @@ -51,6 +56,11 @@ impl MsixCapability { } } + pub fn function_mask(&self, access: impl ConfigRegionAccess) -> bool { + let control = unsafe { access.read(self.address.address, self.address.offset) }; + control.get_bit(30) + } + /// The index of the BAR that contains the MSI-X table. pub fn table_bar(&self) -> u8 { self.table.get_bits(0..3) as u8