dpll_netlink

package
v0.0.0-...-c26e4c6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PinOperstateActive indicates the pin is qualified and actively used by the DPLL.
	PinOperstateActive = 1
	// PinOperstateStandby indicates the pin is qualified but not actively used by the DPLL.
	PinOperstateStandby = 2
	// PinOperstateNoSignal indicates the pin does not have a valid signal.
	PinOperstateNoSignal = 3
	// PinOperstateQualFailed indicates the pin signal failed qualification
	// (e.g. frequency or phase monitor).
	PinOperstateQualFailed = 4
)

Defines possible operational states of a pin with respect to its parent DPLL device. Unlike pin state (administrative intent), operstate reflects actual hardware status.

View Source
const (
	DpllAttributes = iota
	DpllID
	DpllModuleName
	DpllAttPadding
	DpllClockID
	DpllMode
	DpllModeSupported
	DpllLockStatus
	DpllTemp
	DpllType
	DpllLockStatusError
	DpllClockQualityLevel
	DpllPhaseOffsetMonitor
	DpllPhaseOffsetAverageFactor
	// DpllFrequencyMonitor is the netlink attribute ID for the frequency-monitor
	// feature flag on a DPLL device (uses the feature-state enum).
	DpllFrequencyMonitor
)

DpllAttributes provides the dpll_a attribute-set

View Source
const (
	// attribute-set dpll_a_pin
	DpllPinTypes = iota
	DpllPinID
	DpllPinParentID
	DpllPinModuleName
	DpllPinPadding
	DpllPinClockID
	DpllPinBoardLabel
	DpllPinPanelLabel
	DpllPinPackageLabel
	DpllPinType
	DpllPinDirection
	DpllPinFrequency
	DpllPinFrequencySupported
	DpllPinFrequencyMin
	DpllPinFrequencyMax
	DpllPinPrio
	DpllPinState
	DpllPinCapabilities
	DpllPinParentDevice
	DpllPinParentPin
	DpllPinPhaseAdjustMin
	DpllPinPhaseAdjustMax
	DpllPinPhaseAdjust
	DpllPinPhaseOffset
	// DpllPinFractionalFrequencyOffset is the netlink attribute ID for the FFO
	// (Fractional Frequency Offset) of a pin in PPM (parts per million).
	// At the top-level pin scope this represents the RX vs TX symbol rate offset
	// on the media associated with the pin.
	// Inside the pin-parent-device nest it represents the frequency offset between
	// the pin and its parent DPLL device.
	// This is a lower-precision version of DpllPinFractionalFrequencyOffsetPPT.
	DpllPinFractionalFrequencyOffset
	DpllPinEsyncFrequency
	DpllPinEsyncFrequencySupported
	DpllPinEsyncPulse
	DpllPinReferenceSync
	DpllPinPhaseAdjustGran
	// DpllPinFractionalFrequencyOffsetPPT is the netlink attribute ID for the FFO
	// (Fractional Frequency Offset) of a pin in PPT (parts per trillion, 10^-12).
	// At the top-level pin scope this represents the RX vs TX symbol rate offset
	// on the media associated with the pin.
	// Inside the pin-parent-device nest it represents the frequency offset between
	// the pin and its parent DPLL device.
	// This is a higher-precision version of DpllPinFractionalFrequencyOffset.
	DpllPinFractionalFrequencyOffsetPPT
	// DpllPinMeasuredFrequency is the netlink attribute ID for the measured
	// frequency of an input pin in millihertz. Divide by
	// DpllPinMeasuredFrequencyDivider to obtain Hz with mHz fractional precision.
	DpllPinMeasuredFrequency
	// DpllPinOperstate is the netlink attribute ID for the operational state of a
	// pin with respect to its parent DPLL device (pin-operstate enum).
	DpllPinOperstate
)

DpllPinTypes defines the attribute-set for dpll_a_pin

View Source
const (
	DpllCmds = iota
	DpllCmdDeviceIDGet
	DpllCmdDeviceGet
	DpllCmdDeviceSet
	DpllCmdDeviceCreateNtf
	DpllCmdDeviceDeleteNtf
	DpllCmdDeviceChangeNtf
	DpllCmdPinIDGet
	DpllCmdPinGet
	DpllCmdPinSet
	DpllCmdPinCreateNtf
	DpllCmdPinDeleteNtf
	DpllCmdPinChangeNtf
)

DpllCmds defines DPLL subsystem commands encoding

View Source
const (
	DpllLockStatusAttribute = iota
	DpllLockStatusUnlocked
	DpllLockStatusLocked
	DpllLockStatusLockedHoldoverAcquired
	DpllLockStatusHoldover
)

DpllLockStatusAttribute defines DPLL lock status encoding

View Source
const (
	LockStatusErrorTypes = iota
	LockStatusErrorNone
	LockStatusErrorUndefined
	// LockStatusErrorMediaDown indicates dpll device lock status was changed because of associated
	// media got down.
	// This may happen for example if dpll device was previously
	// locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT.
	LockStatusErrorMediaDown
	// LockStatusFFOTooHigh indicates the FFO (Fractional Frequency Offset) between the RX and TX
	// symbol rate on the media got too high.
	// This may happen for example if dpll device was previously
	// locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT.
	LockStatusFFOTooHigh
)

LockStatusErrorTypes defines device lock error types

View Source
const (
	PhaseOffsetMonitorAttribute = iota
	PhaseOffsetMonitorEnabled
	PhaseOffsetMonitorDisabled
)

PhaseOffsetMonitor defines phase offset monitor enable / disable states.

View Source
const (
	ClockQualityLevel = iota
	ClockQualityLevelITUOpt1PRC
	ClockQualityLevelITUOpt1SSUA
	ClockQualityLevelITUOpt1SSUB
	ClockQualityLevelITUOpt1EEC1
	ClockQualityLevelITUOpt1PRTC
	ClockQualityLevelITUOpt1EPRTC
	ClockQualityLevelITUOpt1EEEC
	ClockQualityLevelItuOpt1EPRC
)

ClockQualityLevel defines possible clock quality levels when on holdover

View Source
const (
	DpllTypeAttribute = iota
	// DpllTypePPS indicates dpll produces Pulse-Per-Second signal
	DpllTypePPS
	// DpllTypeEEC indicates dpll drives the Ethernet Equipment Clock
	DpllTypeEEC
)

DpllTypeAttribute defines DPLL types

View Source
const (
	PinStateConnected    = 1
	PinStateDisconnected = 2
	PinStateSelectable   = 3
)

Defines possible pin states

View Source
const (
	PinTypeMUX   = 1
	PinTypeEXT   = 2
	PinTypeSYNCE = 3
	PinTypeINT   = 4
	PinTypeGNSS  = 5
)

Defines possible pin types

View Source
const (
	PinDirectionInput  = 1
	PinDirectionOutput = 2
)

Defines pin directions

View Source
const (
	PinCapNone  = 0
	PinCapDir   = (1 << 0)
	PinCapPrio  = (1 << 1)
	PinCapState = (1 << 2)
)

Defines pin capabilities

View Source
const DpllMCGRPMonitor = "monitor"

DpllMCGRPMonitor defines DPLL subsystem multicast group name

View Source
const DpllPhaseOffsetDivider = 1000

DpllPhaseOffsetDivider phase offset divider allows userspace to calculate a value of measured signal phase difference between a pin and dpll device as a fractional value with three digit decimal precision. Value of (DPLL_A_PHASE_OFFSET / DPLL_PHASE_OFFSET_DIVIDER) is an integer part of a measured phase offset value. Value of (DPLL_A_PHASE_OFFSET % DPLL_PHASE_OFFSET_DIVIDER) is a fractional part of a measured phase offset value.

View Source
const DpllPinMeasuredFrequencyDivider = 1000

DpllPinMeasuredFrequencyDivider allows userspace to calculate a value of measured input frequency as a fractional value with three digit decimal precision (millihertz). Value of (DPLL_A_PIN_MEASURED_FREQUENCY / DpllPinMeasuredFrequencyDivider) is an integer part of a measured frequency value. Value of (DPLL_A_PIN_MEASURED_FREQUENCY % DpllPinMeasuredFrequencyDivider) is a fractional part of a measured frequency value.

View Source
const DpllTemperatureDivider = 1000

DpllTemperatureDivider allows userspace to calculate the temperature as float with three digit decimal precision. Value of (DPLL_A_TEMP / DPLL_TEMP_DIVIDER) is integer part of temperature value. Value of (DPLL_A_TEMP % DPLL_TEMP_DIVIDER) is fractional part of temperature value.

Variables

This section is empty.

Functions

func EncodePinControl

func EncodePinControl(req PinParentDeviceCtl) ([]byte, error)

func GetClockQualityLevel

func GetClockQualityLevel(cq uint32) string

GetClockQualityLevel returns clock quality level as a string

func GetClockQualityLevels

func GetClockQualityLevels(cqs []uint32) string

GetClockQualityLevels returns clock quality levels as a string

func GetDpllStatusHR

func GetDpllStatusHR(reply *DoDeviceGetReply, timestamp time.Time) ([]byte, error)

GetDpllStatusHR returns human-readable DPLL status

func GetDpllType

func GetDpllType(tp uint32) string

GetDpllType returns DPLL type as a string

func GetFrequencyMonitor

func GetFrequencyMonitor(s uint32) string

GetFrequencyMonitor returns the frequency-monitor feature state as a human-readable string. Uses the feature-state enum (same as phase-offset-monitor): "enabled", "disabled", or "unknown".

func GetLockStatus

func GetLockStatus(ls uint32) string

GetLockStatus returns DPLL lock status as a string

func GetLockStatusError

func GetLockStatusError(le uint32) string

GetLockStatusError returns lock status error as a string

func GetMode

func GetMode(md uint32) string

GetMode returns DPLL mode as a string

func GetPhaseOffsetMonitor

func GetPhaseOffsetMonitor(po uint32) string

GetPhaseOffsetMonitor returns phase offset monitor as a string

func GetPinCapabilities

func GetPinCapabilities(c uint32) string

GetPinCapabilities returns DPLL pin capabilities as a csv

func GetPinDirection

func GetPinDirection(d uint32) string

GetPinDirection returns DPLL pin direction as a string

func GetPinInfoHR

func GetPinInfoHR(reply *PinInfo, timestamp time.Time) ([]byte, error)

GetPinInfoHR returns human-readable pin status

func GetPinOperstate

func GetPinOperstate(s uint32) string

GetPinOperstate returns the pin operational state as a human-readable string. Returns "active", "standby", "no-signal", "qual-failed", or "" for unknown values.

func GetPinState

func GetPinState(s uint32) string

GetPinState returns DPLL pin state as a string

func GetPinType

func GetPinType(tp uint32) string

GetPinType returns DPLL pin type as a string

func LogPinConfirmation

func LogPinConfirmation(pin *PinInfo)

LogPinConfirmation logs the current configuration of a single pin via LogPins. Unlike LogPinTable, this applies no filtering by direction, clock ID, device, or lock state — it's meant to show the full post-write state of exactly the pin that was just set (including output pins, which LogPinTable always skips), immediately after a pin-set command, for confirmation purposes.

func LogPinTable

func LogPinTable(reason string, clockID uint64, deviceID uint32, lockStatus uint32)

LogPinTable logs a compact table of the input pins relevant to the DPLL device (deviceID) on the given clockID that just reported a lock-state change (reason is a free-form description used in the log line, e.g. "eth0 eec->LOCKED").

This is a best-effort diagnostic: the actual netlink dial/dump happens in a background goroutine so callers on latency-sensitive paths (e.g. nlUpdateState, processing notifications inline) are never blocked or stalled by it.

func LogPins

func LogPins(title string, pins []*PinInfo)

LogPins logs the given pins as a compact table, one row per parent device of each pin. Unlike LogPinTable, this applies no filtering by direction, clock ID, device, or lock state — every parent device of every pin passed in is shown, including output pins.

This is the shared rendering primitive behind LogPinTable and LogPinConfirmation, exported so other packages that already hold a []*PinInfo (their own DumpPinGet result, a single pin from DoPinGet, or a test fixture) can log a consistent table without duplicating table-building code or going through LogPinTable's dial/dump/notification-filtering path.

func ParsePinDirection

func ParsePinDirection(d string) uint32

ParsePinDirection parses a human-readable pin direction into its numeric code. Supported: input, output.

func ParsePinState

func ParsePinState(s string) uint32

ParsePinState parses a human-readable pin state into its numeric code. Supported: connected, disconnected, selectable.

func ParsePinType

func ParsePinType(tp string) uint32

ParsePinType parses a human-readable pin type into its numeric code. Supported: mux, ext, synce-eth-port, int-oscillator, gnss.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

A Conn is a connection to netlink family "dpll".

func Dial

func Dial(cfg *netlink.Config) (*Conn, error)

Dial opens a Conn for netlink family "dpll". Any options are passed directly to the underlying netlink package.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the Conn's underlying netlink connection.

func (*Conn) DoDeviceGet

func (c *Conn) DoDeviceGet(req DoDeviceGetRequest) (*DoDeviceGetReply, error)

DoDeviceGet wraps the "device-get" operation: Get list of DPLL devices (dump) or attributes of a single dpll device

func (*Conn) DoDeviceIDGet

func (c *Conn) DoDeviceIDGet(req DoDeviceIDGetRequest) (*DoDeviceIDGetReply, error)

DoDeviceIDGet wraps the "device-id-get" operation: Get id of dpll device that matches given attributes

func (*Conn) DoPinGet

func (c *Conn) DoPinGet(req DoPinGetRequest) (*PinInfo, error)

DoPinGet wraps the "pin-get" operation:

func (*Conn) DumpDeviceGet

func (c *Conn) DumpDeviceGet() ([]*DoDeviceGetReply, error)

func (*Conn) DumpPinGet

func (c *Conn) DumpPinGet() ([]*PinInfo, error)

func (*Conn) GetGenetlinkConn

func (c *Conn) GetGenetlinkConn() *genetlink.Conn

GetGenetlinkConn exposes genetlink connection

func (*Conn) GetGenetlinkFamily

func (c *Conn) GetGenetlinkFamily() genetlink.Family

GetGenetlinkFamily exposes genetlink family

func (*Conn) GetMcastGroupID

func (c *Conn) GetMcastGroupID(mcGroup string) (id uint32, found bool)

GetMcastGroupID finds the requested multicast group in the family and returns its ID

func (*Conn) PinPhaseAdjust

func (c *Conn) PinPhaseAdjust(req PinPhaseAdjustRequest) error

PinPhaseAdjust wraps the "pin-set" operation: Set PhaseAdjust of a target pin

func (*Conn) SendCommand

func (c *Conn) SendCommand(command uint8, data []byte) error

SendCommand sends DPLL commands that don't require waiting for a reply

type DoDeviceGetReply

type DoDeviceGetReply struct {
	ID                       uint32
	ModuleName               string
	Mode                     uint32
	ModeSupported            []uint32
	LockStatus               uint32
	Temp                     int32
	ClockID                  uint64
	Type                     uint32
	LockStatusError          uint32
	ClockQualityLevel        []uint32
	PhaseOffsetMonitor       uint32
	PhaseOffsetAverageFactor uint32
	FrequencyMonitor         uint32
}

DoDeviceGetReply is used with the DoDeviceGet method.

func ParseDeviceReplies

func ParseDeviceReplies(msgs []genetlink.Message) ([]*DoDeviceGetReply, error)

type DoDeviceGetRequest

type DoDeviceGetRequest struct {
	ID         uint32
	ModuleName string
}

DoDeviceGetRequest is used with the DoDeviceGet method.

type DoDeviceIDGetReply

type DoDeviceIDGetReply struct {
	ID uint32
}

DoDeviceIDGetReply is used with the DoDeviceIDGet method.

type DoDeviceIDGetRequest

type DoDeviceIDGetRequest struct {
	// TODO: field "ModuleName", type "string"
	ClockID uint64
	Type    uint8
}

DoDeviceIDGetRequest is used with the DoDeviceIDGet method.

type DoPinGetRequest

type DoPinGetRequest struct {
	ID uint32
}

DoPinGetRequest is used with the DoPinGet method.

type DpllStatusHR

type DpllStatusHR struct {
	Timestamp                time.Time `json:"timestamp"`
	ID                       uint32    `json:"id"`
	ModuleName               string    `json:"moduleName"`
	Mode                     string    `json:"mode"`
	ModeSupported            string    `json:"modeSupported"`
	LockStatus               string    `json:"lockStatus"`
	ClockID                  string    `json:"clockId"`
	Type                     string    `json:"type"`
	Temp                     float64   `json:"temp,omitempty"`
	LockStatusError          string    `json:"lockStatusError,omitempty"`
	ClockQualityLevel        string    `json:"clockQualityLevel,omitempty"`
	PhaseOffsetMonitor       string    `json:"phaseOffsetMonitor,omitempty"`
	PhaseOffsetAverageFactor uint32    `json:"phaseOffsetAverageFactor,omitempty"`
	FrequencyMonitor         string    `json:"frequencyMonitor,omitempty"`
}

DpllStatusHR represents human-readable DPLL status

type FrequencyRange

type FrequencyRange struct {
	FrequencyMin uint64 `json:"frequencyMin"`
	FrequencyMax uint64 `json:"frequencyMax"`
}

FrequencyRange contains nested netlink attributes.

type PinControl

type PinControl struct {
	PinParentID uint32
	Direction   *uint32
	Prio        *uint32
	State       *uint32
}

func (PinControl) String

func (p PinControl) String() string

String returns a concise debug representation aligned with PinParentDeviceHR field semantics (direction/state as names when known).

type PinInfo

type PinInfo struct {
	ID                           uint32
	ParentID                     uint32
	ModuleName                   string
	ClockID                      uint64
	BoardLabel                   string
	PanelLabel                   string
	PackageLabel                 string
	Type                         uint32
	Direction                    uint32
	Frequency                    uint64
	FrequencySupported           []FrequencyRange
	FrequencyMin                 uint64
	FrequencyMax                 uint64
	Prio                         uint32
	State                        uint32
	Capabilities                 uint32
	ParentDevice                 []PinParentDevice
	ParentPin                    []PinParentPin
	PhaseAdjustMin               int32
	PhaseAdjustMax               int32
	PhaseAdjust                  int32
	PhaseOffset                  int64
	FractionalFrequencyOffset    int
	FractionalFrequencyOffsetPPT int64
	EsyncFrequency               int64
	EsyncFrequencySupported      []FrequencyRange
	EsyncPulse                   uint32
	ReferenceSync                []ReferenceSync
	PhaseAdjustGran              uint32
	MeasuredFrequency            uint64
	Operstate                    uint32
}

PinInfo is used with the DoPinSet /DoPinGet / DumpPinGet / monitor methods.

func ParsePinReplies

func ParsePinReplies(msgs []genetlink.Message) ([]*PinInfo, error)

type PinInfoHR

type PinInfoHR struct {
	Timestamp                    time.Time           `json:"timestamp"`
	ID                           uint32              `json:"id"`
	ModuleName                   string              `json:"moduleName,omitempty"`
	ClockID                      string              `json:"clockId"`
	BoardLabel                   string              `json:"boardLabel,omitempty"`
	PanelLabel                   string              `json:"panelLabel,omitempty"`
	PackageLabel                 string              `json:"packageLabel,omitempty"`
	Type                         string              `json:"type,omitempty"`
	Frequency                    uint64              `json:"frequency,omitempty"`
	FrequencySupported           []FrequencyRange    `json:"frequencySupported,omitempty"`
	Capabilities                 string              `json:"capabilities,omitempty"`
	ParentDevice                 []PinParentDeviceHR `json:"pinParentDevice,omitempty"`
	ParentPin                    []PinParentPinHR    `json:"pinParentPin,omitempty"`
	PhaseAdjustMin               int32               `json:"phaseAdjustMin,omitempty"`
	PhaseAdjustMax               int32               `json:"phaseAdjustMax,omitempty"`
	PhaseAdjust                  int32               `json:"phaseAdjust"`
	FractionalFrequencyOffset    int                 `json:"fractionalFrequencyOffset,omitempty"`
	EsyncFrequency               int64               `json:"esyncFrequency,omitempty"`
	EsyncFrequencySupported      []FrequencyRange    `json:"esyncFrequencySupported,omitempty"`
	EsyncPulse                   int64               `json:"esyncPulse,omitempty"`
	ReferenceSync                []ReferenceSync     `json:"referenceSync,omitempty"`
	PhaseAdjustGran              uint32              `json:"phaseAdjustGran,omitempty"`
	FractionalFrequencyOffsetPPT int64               `json:"fractionalFrequencyOffsetPPT,omitempty"`
	MeasuredFrequencyHz          float64             `json:"measuredFrequencyHz,omitempty"`
	Operstate                    string              `json:"operstate,omitempty"`
}

PinInfoHR is used with the DoPinGet method.

type PinParentDevice

type PinParentDevice struct {
	ParentID                     uint32
	Direction                    uint32
	Prio                         *uint32
	State                        uint32
	PhaseOffset                  int64
	Operstate                    uint32
	FractionalFrequencyOffset    int
	FractionalFrequencyOffsetPPT int64
}

PinParentDevice contains nested netlink attributes.

type PinParentDeviceCtl

type PinParentDeviceCtl struct {
	ID             uint32
	Frequency      *uint64
	PhaseAdjust    *int32
	EsyncFrequency *uint64
	PinParentCtl   []PinControl
}

func (PinParentDeviceCtl) String

func (p PinParentDeviceCtl) String() string

String returns a concise debug representation of the pin parent device control request.

type PinParentDeviceHR

type PinParentDeviceHR struct {
	ParentID                     uint32  `json:"parentID"`
	Direction                    string  `json:"direction"`
	Prio                         *uint32 `json:"prio,omitempty"`
	State                        string  `json:"state"`
	PhaseOffsetPs                float64 `json:"phaseOffsetPs"`
	Operstate                    string  `json:"operstate,omitempty"`
	FractionalFrequencyOffset    int     `json:"fractionalFrequencyOffset,omitempty"`
	FractionalFrequencyOffsetPPT int64   `json:"fractionalFrequencyOffsetPPT,omitempty"`
}

PinParentDeviceHR contains nested netlink attributes.

type PinParentPin

type PinParentPin struct {
	ParentID uint32
	State    uint32
}

PinParentPin contains nested netlink attributes.

type PinParentPinHR

type PinParentPinHR struct {
	ParentID uint32 `json:"parentID"`
	State    string `json:"parentState"`
}

PinParentPin contains nested netlink attributes.

type PinPhaseAdjustRequest

type PinPhaseAdjustRequest struct {
	ID          uint32
	PhaseAdjust int32
}

PinPhaseAdjustRequest is used with PinPhaseAdjust method.

type ReferenceSync

type ReferenceSync struct {
	ID    uint32 `json:"id"`
	State uint32 `json:"state"`
}

ReferenceSync represents a reference-sync pin pair.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址