Documentation
¶
Overview ¶
Package nscq binds libnvidia-nscq, the NVIDIA NVSwitch Configuration and Query (NSCQ) library.
NSCQ exposes switch state as a tree of paths, such as /{nvswitch}/nvlink/{port}/status/link. A Field pairs a path with the type its callback delivers; Observe reads every value of a Field, and RegisterObserver registers a function that Session.Observe runs:
s, err := nscq.NewSession(nscq.SessionFlagMountDevices)
if err != nil {
return err
}
defer s.Close()
temps, err := nscq.Observe(s, nscq.FieldTemperatureCurrent)
for _, t := range temps {
fmt.Println(t.Device, t.Value)
}
The bindings are generated by github.com/tmc/libgen/cmd/gen-nscq from nscq.h and path.h of NVIDIA/DCGM v4.6.1 (NSCQ API 2.0.0), and load libnvidia-nscq.so.2 at first use; set NSCQ_LIB_PATH to load another file. The headers are fetched, not vendored, from https://github.com/NVIDIA/DCGM/tree/64df9f894541e426e416131a9820cae97aa4dd81/sdk/nvidia/nscq and checked by sha256. To regenerate, run in libgen cmd/gen-nscq/headers/fetch.sh, then go generate in github.com/tmc/lib/nvidia, whose nvgen nscq directive runs gen-nscq; nvgen -diff -output . nscq reports drift without writing. path.h gives no value types, so each Field's type is the one DCGM v4.6.1 reads the path with, cited on the variable. Paths DCGM does not read are not bound.
Obtain observers through RegisterObserver and use the package's declared Field values. The zero values of Observer and Field are not usable.
None of this has run against libnvidia-nscq or an NVSwitch. The callback trampolines are tested by calling them as C would on amd64 and arm64, and the struct layouts against clang for x86_64 Linux; whether the library delivers what DCGM's types say is unverified. Where the library is absent, every call that reaches it returns a *LibraryError, which TestNoLibrary checks on any host without the library; it has passed on darwin/arm64 and on a linux/arm64 GB10 host without libnvidia-nscq.
Validating on an NVSwitch system ¶
NSCQ reads the NVSwitches the host it runs on can open, such as the baseboard switches of an HGX or DGX system. In an NVL72 rack the switches are expected to sit in the switch trays, which a compute tray does not mount, so that there the live test below skips, and fails under NSCQ_REQUIRE_SWITCH (expected; confirm on hardware). On a host with switches and NVIDIA's libnvidia-nscq package installed, run
NSCQ_REQUIRE_LIBRARY=1 NSCQ_REQUIRE_SWITCH=1 go test -count=1 -v github.com/tmc/lib/nvidia/nscq
as a user allowed to open the switch devices. The two variables turn the tests' skips into failures, so a pass means the library loaded, every bound symbol resolved, and TestLiveSwitches mounted at least one switch, found every temperature and link sample attributed to a switch the uuid path reported, and read only known link states. Compare the switches it logs with dcgmi discovery -l. DCGM reads through the same library, so agreement checks these bindings against DCGM's reading of it, not the library itself. Report the driver version, the library path (Path), and the test log.
Index ¶
- Constants
- Variables
- func Close() error
- func Has(symbol string) bool
- func HasObserverDeregister() bool
- func HasObserverObserve() bool
- func HasSessionCreate() bool
- func HasSessionDestroy() bool
- func HasSessionMount() bool
- func HasSessionObserve() bool
- func HasSessionPathObserve() bool
- func HasSessionPathRegisterObserver() bool
- func HasSessionUnmount() bool
- func HasUUIDToLabel() bool
- func Load(path string) error
- func Loaded() bool
- func Path() string
- type BindFailure
- type DeviceType
- type Error
- type Field
- type LibraryAttempt
- type LibraryConflictError
- type LibraryError
- type LinkThroughput
- type NVLinkCurrentInfo
- type NVLinkState
- type NVLinkVoltageInfo
- type NVSwitchPower
- type Observer
- type ObserverFlag
- type PCIeLocation
- type Result
- type Sample
- type Session
- type SessionFlag
- type SymbolError
- type UUID
- type VCLatency
Examples ¶
Constants ¶
const ( APIVersionMajor = 2 APIVersionMinor = 0 APIVersionPatch = 0 )
APIVersionMajor, APIVersionMinor and APIVersionPatch are NSCQ_API_VERSION_CODE in the nscq.h these bindings were generated from. They describe the header, not the library that is loaded.
Variables ¶
var ( // FieldDeviceBlacklisted is /drv/nvswitch/{device}/blacklisted (nscq_nvswitch_device_blacklisted), delivering bool. // Source: DCGM v4.6.1 modules/nvswitch/DcgmNscqManager.cpp:694. FieldDeviceBlacklisted = Field[bool]{"/drv/nvswitch/{device}/blacklisted", onDeviceBool} // FieldPhysID is /{nvswitch}/id/phys_id (nscq_nvswitch_phys_id), delivering uint32_t. // Source: DCGM v4.6.1 modules/nvswitch/DcgmNscqManager.cpp:571 (phys_id_t, uint32_t); FieldDefinitions.h:2008 reads uint64_t. FieldPhysID = Field[uint32]{"/{nvswitch}/id/phys_id", onDeviceUint32} // FieldUUID is /{nvswitch}/id/uuid (nscq_nvswitch_uuid), delivering nscq_uuid_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:1986. FieldUUID = Field[UUID]{"/{nvswitch}/id/uuid", onDeviceUUID} // FieldNVLinkID is /{nvswitch}/id/nvlink (nscq_nvswitch_nvlink_id), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:2052. FieldNVLinkID = Field[uint64]{"/{nvswitch}/id/nvlink", onDeviceUint64} // FieldPCIeLocation is /{nvswitch}/pcie/location (nscq_nvswitch_pcie_location), delivering nscq_pcie_location_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:2279. FieldPCIeLocation = Field[PCIeLocation]{"/{nvswitch}/pcie/location", onDevicePCIeLocation} // FieldResetRequired is /{nvswitch}/status/reset_required (nscq_nvswitch_reset_required), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:2030. FieldResetRequired = Field[uint64]{"/{nvswitch}/status/reset_required", onDeviceUint64} // FieldPower is /{nvswitch}/status/power (nscq_nvswitch_power), delivering nscq_nvswitch_power_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:860. FieldPower = Field[NVSwitchPower]{"/{nvswitch}/status/power", onDeviceNVSwitchPower} // FieldTemperatureCurrent is /{nvswitch}/status/temperature/current (nscq_nvswitch_temperature_current), delivering int32_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:70. FieldTemperatureCurrent = Field[int32]{"/{nvswitch}/status/temperature/current", onDeviceInt32} // FieldTemperatureLimitSlowdown is /{nvswitch}/status/temperature/limit_slowdown (nscq_nvswitch_temperature_limit_slowdown), delivering int32_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:93. FieldTemperatureLimitSlowdown = Field[int32]{"/{nvswitch}/status/temperature/limit_slowdown", onDeviceInt32} // FieldTemperatureLimitShutdown is /{nvswitch}/status/temperature/limit_shutdown (nscq_nvswitch_temperature_limit_shutdown), delivering int32_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:116. FieldTemperatureLimitShutdown = Field[int32]{"/{nvswitch}/status/temperature/limit_shutdown", onDeviceInt32} // FieldThroughputCounters is /{nvswitch}/nvlink/throughput_counters (nscq_nvswitch_nvlink_throughput_counters), delivering nscq_link_throughput_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:138. FieldThroughputCounters = Field[LinkThroughput]{"/{nvswitch}/nvlink/throughput_counters", onDeviceLinkThroughput} // FieldNVLinkVoltageInfo is /{nvswitch}/nvlink/voltage_info (nscq_nvswitch_nvlink_voltage_info), delivering nscq_nvlink_voltage_info_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:793. FieldNVLinkVoltageInfo = Field[NVLinkVoltageInfo]{"/{nvswitch}/nvlink/voltage_info", onDeviceNVLinkVoltageInfo} // FieldNVLinkCurrentInfo is /{nvswitch}/nvlink/current_info (nscq_nvswitch_nvlink_current_info), delivering nscq_nvlink_current_info_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:815. FieldNVLinkCurrentInfo = Field[NVLinkCurrentInfo]{"/{nvswitch}/nvlink/current_info", onDeviceNVLinkCurrentInfo} // FieldPortRemoteDeviceType is /{nvswitch}/nvlink/{port}/remote_device/type (nscq_nvswitch_port_remote_device_type), delivering nscq_device_type_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:2096 reads uint64_t; nscq.h declares nscq_device_type_t (uint8_t) for these values. FieldPortRemoteDeviceType = Field[DeviceType]{"/{nvswitch}/nvlink/{port}/remote_device/type", onPortDeviceType} // FieldPortRemoteDevicePCIeLocation is /{nvswitch}/nvlink/{port}/remote_device/pcie/location (nscq_nvswitch_port_remote_device_pcie_location), delivering nscq_pcie_location_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:2120. FieldPortRemoteDevicePCIeLocation = Field[PCIeLocation]{"/{nvswitch}/nvlink/{port}/remote_device/pcie/location", onPortPCIeLocation} // FieldPortRemoteDeviceLink is /{nvswitch}/nvlink/{port}/remote_device/id/link (nscq_nvswitch_port_remote_device_link), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:2212. FieldPortRemoteDeviceLink = Field[uint64]{"/{nvswitch}/nvlink/{port}/remote_device/id/link", onPortUint64} // FieldPortRemoteDeviceNVLink is /{nvswitch}/nvlink/{port}/remote_device/id/nvlink (nscq_nvswitch_port_remote_device_nvlink), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:2235. FieldPortRemoteDeviceNVLink = Field[uint64]{"/{nvswitch}/nvlink/{port}/remote_device/id/nvlink", onPortUint64} // FieldPortRemoteDeviceUUID is /{nvswitch}/nvlink/{port}/remote_device/id/uuid (nscq_nvswitch_port_remote_device_uuid), delivering nscq_uuid_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:2257. FieldPortRemoteDeviceUUID = Field[UUID]{"/{nvswitch}/nvlink/{port}/remote_device/id/uuid", onPortUUID} // FieldPortLinkStatus is /{nvswitch}/nvlink/{port}/status/link (nscq_nvswitch_port_link_status), delivering nscq_nvlink_state_t. // Source: DCGM v4.6.1 modules/nvswitch/DcgmNscqManager.cpp:781 (nscq_nvlink_state_t); FieldDefinitions.h:2074 reads uint64_t. FieldPortLinkStatus = Field[NVLinkState]{"/{nvswitch}/nvlink/{port}/status/link", onPortNVLinkState} // FieldPortReplayCount is /{nvswitch}/nvlink/{port}/status/error/replay_count (nscq_nvswitch_port_error_replay_count), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:315. FieldPortReplayCount = Field[uint64]{"/{nvswitch}/nvlink/{port}/status/error/replay_count", onPortUint64} // FieldPortRecoveryCount is /{nvswitch}/nvlink/{port}/status/error/recovery_count (nscq_nvswitch_port_error_recovery_count), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:338. FieldPortRecoveryCount = Field[uint64]{"/{nvswitch}/nvlink/{port}/status/error/recovery_count", onPortUint64} // FieldPortFlitErrorCount is /{nvswitch}/nvlink/{port}/status/error/flit_err_count (nscq_nvswitch_port_error_flit_err_count), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:361. FieldPortFlitErrorCount = Field[uint64]{"/{nvswitch}/nvlink/{port}/status/error/flit_err_count", onPortUint64} // FieldPortLaneCRCErrorCount is /{nvswitch}/nvlink/{port}/status/error/lane_crc_err_count_aggregate (nscq_nvswitch_port_error_lane_crc_err_count_aggregate), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:383. FieldPortLaneCRCErrorCount = Field[uint64]{"/{nvswitch}/nvlink/{port}/status/error/lane_crc_err_count_aggregate", onPortUint64} // FieldPortLaneECCErrorCount is /{nvswitch}/nvlink/{port}/status/error/lane_ecc_err_count_aggregate (nscq_nvswitch_port_error_lane_ecc_err_count_aggregate), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:407. FieldPortLaneECCErrorCount = Field[uint64]{"/{nvswitch}/nvlink/{port}/status/error/lane_ecc_err_count_aggregate", onPortUint64} // FieldLaneCRCErrorCount is /{nvswitch}/nvlink/{port}/{lane}/status/error/crc_err_count (nscq_nvswitch_port_lane_crc_err_count), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:610. FieldLaneCRCErrorCount = Field[uint64]{"/{nvswitch}/nvlink/{port}/{lane}/status/error/crc_err_count", onLaneUint64} // FieldLaneECCErrorCount is /{nvswitch}/nvlink/{port}/{lane}/status/error/ecc_err_count (nscq_nvswitch_port_lane_ecc_err_count), delivering uint64_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:702. FieldLaneECCErrorCount = Field[uint64]{"/{nvswitch}/nvlink/{port}/{lane}/status/error/ecc_err_count", onLaneUint64} // FieldVCLatency is /{nvswitch}/nvlink/{port}/{vc}/latency (nscq_nvswitch_port_vc_latency), delivering nscq_vc_latency_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:952. FieldVCLatency = Field[VCLatency]{"/{nvswitch}/nvlink/{port}/{vc}/latency", onLaneVCLatency} // FieldPortThroughputCounters is /{nvswitch}/nvlink/{port}/throughput_counters (nscq_nvswitch_nvlink_port_throughput_counters), delivering nscq_link_throughput_t. // Source: DCGM v4.6.1 modules/nvswitch/FieldDefinitions.h:430. FieldPortThroughputCounters = Field[LinkThroughput]{"/{nvswitch}/nvlink/{port}/throughput_counters", onPortLinkThroughput} )
Fields observable with Observe and RegisterObserver.
path.h declares every path's string but not what its callback receives, so each value type here comes from a consumer of the library, cited on the variable. None has been checked against a live NVSwitch.
var ErrClosed = errors.New("nscq: closed")
ErrClosed is returned by a method of a closed Session or Observer.
Functions ¶
func Close ¶
func Close() error
Close unloads the library and clears all bound function pointers.
The function pointers are package-level state, so Close must not be called concurrently with any other call into this package: doing so is a use-after-free. It is intended for test teardown, not for reclaiming a live library.
func Has ¶
Has reports whether the named C symbol resolved in the loaded library, loading it first if necessary. It returns false if the library failed to load. Use it to gate on capabilities before calling into them.
func HasObserverDeregister ¶
func HasObserverDeregister() bool
HasObserverDeregister reports whether nscq_observer_deregister resolved in the loaded library.
func HasObserverObserve ¶
func HasObserverObserve() bool
HasObserverObserve reports whether nscq_observer_observe resolved in the loaded library.
func HasSessionCreate ¶
func HasSessionCreate() bool
HasSessionCreate reports whether nscq_session_create resolved in the loaded library.
func HasSessionDestroy ¶
func HasSessionDestroy() bool
HasSessionDestroy reports whether nscq_session_destroy resolved in the loaded library.
func HasSessionMount ¶
func HasSessionMount() bool
HasSessionMount reports whether nscq_session_mount resolved in the loaded library.
func HasSessionObserve ¶
func HasSessionObserve() bool
HasSessionObserve reports whether nscq_session_observe resolved in the loaded library.
func HasSessionPathObserve ¶
func HasSessionPathObserve() bool
HasSessionPathObserve reports whether nscq_session_path_observe resolved in the loaded library.
func HasSessionPathRegisterObserver ¶
func HasSessionPathRegisterObserver() bool
HasSessionPathRegisterObserver reports whether nscq_session_path_register_observer resolved in the loaded library.
func HasSessionUnmount ¶
func HasSessionUnmount() bool
HasSessionUnmount reports whether nscq_session_unmount resolved in the loaded library.
func HasUUIDToLabel ¶
func HasUUIDToLabel() bool
HasUUIDToLabel reports whether nscq_uuid_to_label resolved in the loaded library.
func Load ¶
Load opens the shared library from path, or from the default search list when path is empty, and binds all symbols. Callers that need to direct loading should call Load before any other function; otherwise the first call loads from the default search list.
Load is idempotent: calling it again with the same path, or with an empty path, returns nil. Calling it with a different path after a successful load returns *LibraryConflictError rather than replacing the library. After a failed load, Load retries.
Types ¶
type BindFailure ¶
BindFailure names a symbol the loaded library exports but that could not be bound, and why.
func BindFailures ¶
func BindFailures() []BindFailure
BindFailures returns the symbols the loaded library exports that could not be bound, sorted by symbol name, or nil if every exported symbol bound. Calling one of these reports *SymbolError with the same Err.
A load that reports no error can still leave symbols unbound: the library is fine and the signatures are not representable here. Call this after Load to find that out at once rather than one call site at a time. It does not trigger a load, and returns nil if none has happened.
type DeviceType ¶
type DeviceType uint8
DeviceType is nscq_device_type_t, the kind of device at the far end of an NVLink port.
const ( DeviceTypeGPU DeviceType = 1 // NSCQ_NVLINK_DEVICE_TYPE_GPU DeviceTypeSwitch DeviceType = 2 // NSCQ_NVLINK_DEVICE_TYPE_SWITCH )
func (DeviceType) String ¶
func (x DeviceType) String() string
String returns the name of the constant, or the number if it has none.
type Error ¶
type Error struct {
// Op is the C entry point that failed.
Op string
// Result is the negative nscq_rc_t it returned.
Result Result
}
Error reports an NSCQ call that returned an error result.
type Field ¶
type Field[T any] struct { // contains filtered or unexported fields }
A Field is an NSCQ path whose callback delivers values of type T. The package declares one variable per path it can observe.
type LibraryAttempt ¶
LibraryAttempt records one failed attempt to open the shared library.
type LibraryConflictError ¶
type LibraryConflictError struct {
Loaded string
Requested string
// Implicit reports that the loaded library was opened lazily and no
// successful Load has since acknowledged it. A
// caller that sees this called some
// other function first, and that call took the default search list.
Implicit bool
}
LibraryConflictError reports a Load call naming a different library than the one already loaded. Only one library is loaded per process.
func (*LibraryConflictError) Error ¶
func (e *LibraryConflictError) Error() string
Error reports the conflicting library paths, and whether the library that is already loaded got there without a Load call.
type LibraryError ¶
type LibraryError struct {
Library string
Env string
Path string
Attempts []LibraryAttempt
Hint string
}
LibraryError reports that libnvidia-nscq could not be opened. Attempts lists every name tried in order. Path is set when an explicit path, from Load or NSCQ_LIB_PATH, was requested and failed. Hint reports pkg-config discovery results and query failures, when discovery ran.
func (*LibraryError) Error ¶
func (e *LibraryError) Error() string
Error describes the library load attempts and their errors.
func (*LibraryError) Unwrap ¶
func (e *LibraryError) Unwrap() []error
Unwrap returns the error from each attempt.
type LinkThroughput ¶
LinkThroughput represents nscq_link_throughput_t.
type NVLinkCurrentInfo ¶
NVLinkCurrentInfo represents nscq_nvlink_current_info_t.
type NVLinkState ¶
type NVLinkState int8
NVLinkState is nscq_nvlink_state_t, the state of an NVLink port.
const ( NVLinkStateUnknown NVLinkState = -1 // NSCQ_NVLINK_STATE_UNKNOWN NVLinkStateOff NVLinkState = 0 // NSCQ_NVLINK_STATE_OFF NVLinkStateSafe NVLinkState = 1 // NSCQ_NVLINK_STATE_SAFE NVLinkStateActive NVLinkState = 2 // NSCQ_NVLINK_STATE_ACTIVE NVLinkStateError NVLinkState = 3 // NSCQ_NVLINK_STATE_ERROR NVLinkStateSleep NVLinkState = 4 // NSCQ_NVLINK_STATE_SLEEP )
func (NVLinkState) String ¶
func (x NVLinkState) String() string
String returns the name of the constant, or the number if it has none.
type NVLinkVoltageInfo ¶
type NVLinkVoltageInfo struct {
VoltageMvolt uint32
}
NVLinkVoltageInfo represents nscq_nvlink_voltage_info_t.
type NVSwitchPower ¶
NVSwitchPower represents nscq_nvswitch_power_t.
type Observer ¶
type Observer struct {
// contains filtered or unexported fields
}
An Observer is a function registered on a path of a Session (nscq_observer_t).
func RegisterObserver ¶
func RegisterObserver[T any](s *Session, f Field[T], flags ObserverFlag, fn func(Sample[T])) (*Observer, error)
RegisterObserver registers fn to receive f's values (nscq_session_path_register_observer). fn is called during s.Observe and o.Observe, on the calling goroutine, while s is locked: it must not call methods of s or of its observers.
type ObserverFlag ¶
type ObserverFlag uint32
ObserverFlag is a flag for RegisterObserver.
const (
ObserverFlagWatch ObserverFlag = 1 // NSCQ_SESSION_PATH_REGISTER_OBSERVER_WATCH
)
type PCIeLocation ¶
PCIeLocation represents nscq_pcie_location_t.
type Result ¶
type Result int8
Result is nscq_rc_t, the status of an NSCQ call or of one callback. Zero is success, a positive value is a warning (success with a caveat), and a negative value is an error.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/nscq"
)
func main() {
for _, r := range []nscq.Result{nscq.ResultSuccess, nscq.ResultWarningRDTInitFailure, nscq.ResultErrorTimeout, -42} {
fmt.Println(r, r.IsError(), r.IsWarning())
}
}
Output: ResultSuccess false false ResultWarningRDTInitFailure false true ResultErrorTimeout true false Result(-42) true false
const ( ResultErrorUnspecified Result = -128 // NSCQ_RC_ERROR_UNSPECIFIED ResultErrorExt Result = -127 // NSCQ_RC_ERROR_EXT ResultErrorTimeout Result = -8 // NSCQ_RC_ERROR_TIMEOUT ResultErrorDrv Result = -7 // NSCQ_RC_ERROR_DRV ResultErrorUnsupportedDrv Result = -6 // NSCQ_RC_ERROR_UNSUPPORTED_DRV ResultErrorUnexpectedValue Result = -5 // NSCQ_RC_ERROR_UNEXPECTED_VALUE ResultErrorOverflow Result = -4 // NSCQ_RC_ERROR_OVERFLOW ResultErrorResourceNotMountable Result = -3 // NSCQ_RC_ERROR_RESOURCE_NOT_MOUNTABLE ResultErrorInvalidUUID Result = -2 // NSCQ_RC_ERROR_INVALID_UUID ResultErrorNotImplemented Result = -1 // NSCQ_RC_ERROR_NOT_IMPLEMENTED ResultSuccess Result = 0 // NSCQ_RC_SUCCESS ResultWarningRDTInitFailure Result = 1 // NSCQ_RC_WARNING_RDT_INIT_FAILURE )
type Sample ¶
type Sample[T any] struct { // Device is the {nvswitch} or {device} the value belongs to. Device UUID // Port is the {port} index, for paths that have one. Port uint32 // Lane is the {lane} or {vc} index, for paths that have one. Lane uint32 // Result is the status the library reported for this value. Result Result // Value is the value. It is the zero value when Result is an error. Value T }
A Sample is one value delivered for a Field.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
A Session is an NSCQ session (nscq_session_t): a set of mounted NVSwitch devices whose paths can be observed.
A Session is safe for concurrent use; its calls into the library are serialized.
func NewSession ¶
func NewSession(flags SessionFlag) (*Session, error)
NewSession creates a session (nscq_session_create). SessionFlagMountDevices mounts every device the library finds.
func (*Session) Close ¶
Close deregisters the session's observers and destroys the session (nscq_session_destroy). Closing a closed session does nothing.
func (*Session) Mount ¶
Mount adds the device u identifies to the session (nscq_session_mount). It passes no flags: nscq.h defines none.
type SessionFlag ¶
type SessionFlag uint32
SessionFlag is a flag for NewSession.
const (
SessionFlagMountDevices SessionFlag = 1 // NSCQ_SESSION_CREATE_MOUNT_DEVICES
)
type SymbolError ¶
SymbolError reports that a symbol is not callable.
Err distinguishes the two ways that happens. A nil Err means the loaded library does not export the symbol, which is what an installation older than the symbol looks like. A non-nil Err means the library does export it and the binding itself failed; the library is not at fault.
func (*SymbolError) Error ¶
func (e *SymbolError) Error() string
Error reports the uncallable library symbol and, when the symbol was present but could not be bound, why.
func (*SymbolError) Unwrap ¶
func (e *SymbolError) Unwrap() error
Unwrap returns the reason the symbol could not be bound, or nil when the loaded library does not export it.
type UUID ¶
type UUID struct {
Bytes [16]uint8
}
UUID represents nscq_uuid_t.
func (UUID) Label ¶
Label returns the library's label for the device u identifies (nscq_uuid_to_label). It passes no flags: nscq.h defines none.
func (UUID) String ¶
String formats u as 8-4-4-4-12 hexadecimal digits.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/nscq"
)
func main() {
u := nscq.UUID{Bytes: [16]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}}
fmt.Println(u)
}
Output: 01234567-89ab-cdef-0123-456789abcdef