nvml_wrapper/structs/
device.rs

1#[cfg(target_os = "windows")]
2use crate::enum_wrappers::device::DriverModel;
3use crate::enum_wrappers::device::OperationMode;
4#[cfg(feature = "serde")]
5use serde_derive::{Deserialize, Serialize};
6
7/// Returned from `Device.get_confidential_compute_capabilities()`
8#[derive(Debug, Clone, Eq, PartialEq, Hash)]
9#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10pub struct ConfidentialComputeCapabilities {
11    /// The CPU capabilities.
12    pub cpu_caps: ConfidentialComputeCpuCapabilities,
13    /// The GPU capabilities.
14    pub gpus_caps: ConfidentialComputeGpuCapabilities,
15}
16
17/// The possible CPU capabilities for confidential compute (either None, AMD SEV or Intel TDX)
18#[derive(Debug, Clone, Eq, PartialEq, Hash)]
19#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
20pub enum ConfidentialComputeCpuCapabilities {
21    /// No CPU capabilities.
22    None,
23    /// AMD SEV confidential compute capabilities.
24    AmdSev,
25    /// Intel TDX confidential compute capabilities.
26    IntelTdx,
27}
28
29/// The possible GPU capabilities for confidential compute (either not capable or capable)
30#[derive(Debug, Clone, Eq, PartialEq, Hash)]
31#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
32pub enum ConfidentialComputeGpuCapabilities {
33    /// Capable.
34    Capable,
35    /// Not capable.
36    NotCapable,
37}
38
39/// Returned from `Device.confidential_compute_gpu_attestation_report_bytes()`
40#[derive(Debug, Clone, Eq, PartialEq, Hash)]
41#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
42pub struct ConfidentialComputeGpuAttestationReport {
43    /// The size of the attestation report.
44    pub attestation_report_size: u32,
45    /// The attestation report, of size
46    /// `ffi::bindings::NVML_CC_GPU_ATTESTATION_REPORT_SIZE` == 8192 bytes.
47    pub attestation_report: Vec<u8>,
48    /// Whether the CEC attestation report is present.
49    pub is_cec_attestation_report_present: bool,
50    /// The size of the CEC attestation report.
51    pub cec_attestation_report_size: u32,
52    /// The CEC attestation report, of size
53    /// `ffi::bindings::NVML_CC_GPU_CEC_ATTESTATION_REPORT_SIZE` == 4096 bytes.
54    pub cec_attestation_report: Vec<u8>,
55}
56
57/// Returned from `Device.confidential_compute_gpu_certificate()`
58#[derive(Debug, Clone, Eq, PartialEq, Hash)]
59#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
60pub struct ConfidentialComputeGpuCertificate {
61    /// The size of the certificate chain.
62    pub cert_chain_size: u32,
63    /// The size of the attestation certificate chain.
64    pub attestation_cert_chain_size: u32,
65    /// The certificate chain, of size
66    /// `ffi::bindings::NVML_GPU_CERT_CHAIN_SIZE` == 4096 bytes.
67    pub cert_chain: Vec<u8>,
68    /// The attestation certificate chain, of size
69    /// `ffi::bindings::NVML_GPU_ATTESTATION_CERT_CHAIN_SIZE` == 5120 bytes.
70    pub attestation_cert_chain: Vec<u8>,
71}
72
73/// Returned from `Device.auto_boosted_clocks_enabled()`
74#[derive(Debug, Clone, Eq, PartialEq, Hash)]
75#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
76pub struct AutoBoostClocksEnabledInfo {
77    /// Current state of auto boosted clocks for the `Device`
78    pub is_enabled: bool,
79    /// Default auto boosted clocks behavior for the `Device`
80    ///
81    /// The GPU will revert to this default when no applications are using the
82    /// GPU.
83    pub is_enabled_default: bool,
84}
85
86/// Returned from `Device.decoder_utilization()` and
87/// `Device.encoder_utilization()`.
88#[derive(Debug, Clone, Eq, PartialEq, Hash)]
89#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
90pub struct UtilizationInfo {
91    pub utilization: u32,
92    /// Sampling period in μs.
93    pub sampling_period: u32,
94}
95
96/// Returned from `Device.driver_model()`
97#[derive(Debug)]
98#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
99#[cfg(target_os = "windows")]
100pub struct DriverModelState {
101    pub current: DriverModel,
102    pub pending: DriverModel,
103}
104
105/// Returned from `Device.is_ecc_enabled()`
106#[derive(Debug, Clone, Eq, PartialEq, Hash)]
107#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
108pub struct EccModeState {
109    pub currently_enabled: bool,
110    pub pending_enabled: bool,
111}
112
113/// Returned from `Device.gpu_operation_mode()`
114#[derive(Debug)]
115#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
116pub struct OperationModeState {
117    pub current: OperationMode,
118    pub pending: OperationMode,
119}
120
121/// Returned from `Device.power_management_limit_constraints()`
122///
123/// Values are in milliwatts.
124#[derive(Debug, Clone, Eq, PartialEq, Hash)]
125#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
126pub struct PowerManagementConstraints {
127    pub min_limit: u32,
128    pub max_limit: u32,
129}
130
131/// Returned from `Device.encoder_stats()`
132#[derive(Debug, Clone, Eq, PartialEq, Hash)]
133#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
134pub struct EncoderStats {
135    /// The number of active encoder sessions.
136    pub session_count: u32,
137    /// The trailing average FPS of all active encoder sessions.
138    pub average_fps: u32,
139    /// The encode latency in μs.
140    pub average_latency: u32,
141}
142
143/// Returned from `Device.cuda_compute_capability()`
144#[derive(Debug, Clone, Eq, PartialEq, Hash)]
145#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
146pub struct CudaComputeCapability {
147    pub major: i32,
148    pub minor: i32,
149}
150
151/// Returned from `Device.retired_pages()`
152#[derive(Debug, Clone, Eq, PartialEq, Hash)]
153#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
154pub struct RetiredPage {
155    /// The hardware address of the page that was retired.
156    ///
157    /// Note that this does not match the virtual address used in CUDA but does
158    /// match the address information in XID 63.
159    pub address: u64,
160    /// The retirement timestamp.
161    pub timestamp: u64,
162}
163
164/// Populate this newtype with the constants `nvml_wrapper::sys_exports::field_id::*`.
165///
166/// Used in `FieldValue` and `Device.field_values_for()`.
167#[derive(Debug, Clone, Eq, PartialEq, Hash)]
168#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
169pub struct FieldId(pub u32);
170
171/// Returned from `Device.mig_mode()`
172#[derive(Debug, Clone, Eq, PartialEq, Hash)]
173#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
174pub struct MigMode {
175    /// Whether MIG mode is enabled/disabled.
176    pub current: u32,
177    /// Mode set after reboot.
178    pub pending: u32,
179}