1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::error::NvmlError;
use crate::ffi::bindings::*;
#[cfg(feature = "serde")]
use serde_derive::{Deserialize, Serialize};
use wrapcenum_derive::EnumWrapper;

/// Represents the NvLink utilization counter packet units.
// Checked against local
#[derive(EnumWrapper, Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[wrap(c_enum = "nvmlNvLinkUtilizationCountUnits_enum")]
pub enum UtilizationCountUnit {
    #[wrap(c_variant = "NVML_NVLINK_COUNTER_UNIT_CYCLES")]
    Cycles,
    #[wrap(c_variant = "NVML_NVLINK_COUNTER_UNIT_PACKETS")]
    Packets,
    #[wrap(c_variant = "NVML_NVLINK_COUNTER_UNIT_BYTES")]
    Bytes,
}

/// Represents queryable NvLink capabilities.
// Checked against local
#[derive(EnumWrapper, Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[wrap(c_enum = "nvmlNvLinkCapability_enum")]
pub enum Capability {
    /// P2P over NVLink is supported.
    #[wrap(c_variant = "NVML_NVLINK_CAP_P2P_SUPPORTED")]
    P2p,
    /// Access to system memory is supported.
    #[wrap(c_variant = "NVML_NVLINK_CAP_SYSMEM_ACCESS")]
    SysMemAccess,
    /// P2P atomics are supported.
    #[wrap(c_variant = "NVML_NVLINK_CAP_P2P_ATOMICS")]
    P2pAtomics,
    /// System memory atomics are supported.
    #[wrap(c_variant = "NVML_NVLINK_CAP_SYSMEM_ATOMICS")]
    SysMemAtomics,
    /// SLI is supported over this link.
    #[wrap(c_variant = "NVML_NVLINK_CAP_SLI_BRIDGE")]
    SliBridge,
    /// Link is supported on this device.
    #[wrap(c_variant = "NVML_NVLINK_CAP_VALID")]
    ValidLink,
}

/// Represents queryable NvLink error counters.
// Checked against local
#[derive(EnumWrapper, Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[wrap(c_enum = "nvmlNvLinkErrorCounter_enum")]
pub enum ErrorCounter {
    /// Data link transmit replay error counter.
    #[wrap(c_variant = "NVML_NVLINK_ERROR_DL_REPLAY")]
    DlReplay,
    /// Data link transmit recovery error counter.
    #[wrap(c_variant = "NVML_NVLINK_ERROR_DL_RECOVERY")]
    DlRecovery,
    /// Data link receive flow control digit CRC error counter.
    #[wrap(c_variant = "NVML_NVLINK_ERROR_DL_CRC_FLIT")]
    DlCrcFlit,
    /// Data link receive data CRC error counter.
    #[wrap(c_variant = "NVML_NVLINK_ERROR_DL_CRC_DATA")]
    DlCrcData,
}