Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to enable/disable function masking for MSI-X #29

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/capability/msix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ 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
/// 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);
}
}

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
Expand Down