Skip to content
Merged
Show file tree
Hide file tree
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
63 changes: 63 additions & 0 deletions nvml-wrapper/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6455,6 +6455,57 @@
}
}

/**
Get GSP firmware mode. Whether it is enabled and if it is in default mode.

# Errors

* `Uninitialized`, if the library has not been successfully initialized
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `Unknown`, on any unexpected error
* `NotSupported`, if the platform does not support this feature
*/
#[doc(alias = "nvmlDeviceGetGspFirmwareMode")]
pub fn gsp_firmware_mode(&self) -> Result<GspFirmwareMode, NvmlError> {
let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetGspFirmwareMode.as_ref())?;

unsafe {
let mut enabled: c_uint = 0;
let mut default: c_uint = 0;

nvml_try(sym(self.device, &mut enabled, &mut default))?;

Ok(GspFirmwareMode {
enabled: enabled != 0,
default: default != 0,
})
}
}

/**
Get GSP firmware version.

# Errors

* `Uninitialized`, if the library has not been successfully initialized
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `Unknown`, on any unexpected error
* `NotSupported`, if the platform does not support this feature
*/
#[doc(alias = "nvmlDeviceGetGspFirmwareVersion")]
pub fn gsp_firmware_version(&self) -> Result<String, NvmlError> {
let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetGspFirmwareVersion.as_ref())?;

unsafe {
let mut version = vec![0; 80];

nvml_try(sym(self.device, version.as_mut_ptr()))?;
let raw = CStr::from_ptr(version.as_ptr());

Ok(raw.to_str()?.into())
}
}

// NvLink

/**
Expand All @@ -6463,14 +6514,14 @@
NVIDIA does not provide any information as to how to obtain a valid NvLink
value, so you're on your own there.
*/
pub fn link_wrapper_for(&self, link: u32) -> NvLink {

Check warning on line 6517 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Clippy

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6517 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6517 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6517 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (macos-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6517 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (macos-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6517 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6517 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest, stable)

hiding a lifetime that's elided elsewhere is confusing
NvLink { device: self, link }
}

// vGPU

/// Obtain a list of vGPU type (profiles) supported by the device, if any.
pub fn vgpu_supported_types(&self) -> Result<Vec<VgpuType>, NvmlError> {

Check warning on line 6524 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6524 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6524 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (macos-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6524 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (macos-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6524 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6524 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest, stable)

hiding a lifetime that's elided elsewhere is confusing
let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetSupportedVgpus.as_ref())?;
let mut ids = vec![];

Expand All @@ -6490,7 +6541,7 @@
}

/// Obtain a list of vGPU type (profiles) creatable on the device, if any.
pub fn vgpu_creatable_types(&self) -> Result<Vec<VgpuType>, NvmlError> {

Check warning on line 6544 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6544 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6544 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (macos-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6544 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (macos-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6544 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest, stable)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 6544 in nvml-wrapper/src/device.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest, stable)

hiding a lifetime that's elided elsewhere is confusing
let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetCreatableVgpus.as_ref())?;
let mut ids = vec![];

Expand Down Expand Up @@ -7213,6 +7264,18 @@
})
}

#[test]
fn gsp_firmware_mode() {
let nvml = nvml();
test_with_device(3, &nvml, |device| device.gsp_firmware_mode())
}

#[test]
fn gsp_firmware_version() {
let nvml = nvml();
test_with_device(3, &nvml, |device| device.gsp_firmware_version())
}

#[test]
fn field_values_for() {
let nvml = nvml();
Expand Down
8 changes: 8 additions & 0 deletions nvml-wrapper/src/structs/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,11 @@ pub struct MigMode {
/// Mode set after reboot.
pub pending: u32,
}

/// Returned from `Device.gsp_firmware_mode()`
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct GspFirmwareMode {
pub enabled: bool,
pub default: bool,
}
1 change: 1 addition & 0 deletions nvml-wrapper/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ impl ShouldPrint for MigMode {}
impl ShouldPrint for Vec<GpuInstancePlacement> {}
impl ShouldPrint for (VgpuVersion, VgpuVersion) {}
impl ShouldPrint for ProfileInfo {}
impl ShouldPrint for GspFirmwareMode {}

#[cfg(target_os = "windows")]
impl ShouldPrint for DriverModelState {}
Expand Down
Loading