Documentation
¶
Index ¶
- Variables
- func ValidateQuery(query []string) error
- func ValidateTag(tag CounterTag) error
- type Agent
- func (m *Agent) AsRawPtr() unsafe.Pointer
- func (m *Agent) BlockAllocatorFreeSize() uint64
- func (m *Agent) CleanUp() error
- func (m *Agent) Close() error
- func (m *Agent) DPConfig() *DPConfig
- func (m *Agent) DeleteFunction(name string) error
- func (m *Agent) DeleteModuleConfig(moduleType, configName string) error
- func (m *Agent) DeletePipeline(name string) error
- func (m *Agent) Extend(size datasize.ByteSize) error
- func (m *Agent) MemoryLimit() datasize.ByteSize
- func (m *Agent) UpdateDevices(devices []ShmDeviceConfig) error
- func (m *Agent) UpdateFunction(functionConfig FunctionConfig) error
- func (m *Agent) UpdateModules(modules []ModuleConfig) error
- func (m *Agent) UpdatePipeline(pipelineConfig PipelineConfig) error
- type AgentInfo
- type AgentInstanceInfo
- type AgentMemoryNode
- type CPConfig
- type Chain
- type ChainConfig
- type ChainModule
- type ChainModuleConfig
- type CounterGroup
- type CounterInfo
- type CounterSet
- type CounterTag
- type DPConfig
- func (m *DPConfig) Agents() []AgentInfo
- func (m *DPConfig) AllModulePositions(moduleType string) iter.Seq[ModuleReference]
- func (m *DPConfig) CPConfigs() []CPConfig
- func (m *DPConfig) ChainCounters(deviceName string, pipelineName string, functionName string, chainName string) []CounterInfo
- func (m *DPConfig) CountersByTags(tags []CounterTag, query []string) ([]CounterGroup, error)
- func (m *DPConfig) DeviceCounters(deviceName string) []CounterInfo
- func (m *DPConfig) Devices() []DeviceInfo
- func (m *DPConfig) FunctionCounters(deviceName string, pipelineName string, functionName string) []CounterInfo
- func (m *DPConfig) Functions() []Function
- func (m *DPConfig) ModuleCounters(deviceName string, pipelineName string, functionName string, chainName string, ...) []CounterInfo
- func (m *DPConfig) ModuleRuntimeCounters(deviceName string, pipelineName string, functionName string, chainName string, ...) ([]CounterInfo, error)
- func (m *DPConfig) Modules() []DPModule
- func (m *DPConfig) NumaIdx() uint32
- func (m *DPConfig) ObjectCounters(objectType string, objectName string) []CounterInfo
- func (m *DPConfig) PipelineCounters(deviceName string, pipelineName string) []CounterInfo
- func (m *DPConfig) Pipelines() []Pipeline
- func (m *DPConfig) PortCounters() ([]PortGroup, error)
- func (m *DPConfig) RawWorkerCounters() []CounterInfo
- func (m *DPConfig) WorkerCount() uint32
- func (m *DPConfig) WorkerCounters() ([]WorkerCounter, error)
- type DPModule
- type DeviceConfig
- type DeviceInfo
- type DevicePipeline
- type DevicePipelineConfig
- type DevicePipelineInfo
- type Function
- type FunctionChainConfig
- type FunctionConfig
- type MaybeCounter
- type ModuleConfig
- type ModuleReference
- type Pipeline
- type PipelineConfig
- type PortCounter
- type PortGroup
- type SharedMemory
- func (m *SharedMemory) AgentAttach(name string, instanceIdx uint32, size datasize.ByteSize) (*Agent, error)
- func (m *SharedMemory) AsRawPtr() unsafe.Pointer
- func (m *SharedMemory) DPConfig(instanceIdx uint32) *DPConfig
- func (m *SharedMemory) DataplaneReady(instanceIdx uint32) bool
- func (m *SharedMemory) Detach() error
- type ShmDeviceConfig
- type WorkerCounter
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidQuery = errors.New("invalid counter query")
ErrInvalidQuery reports a counter query the matcher refused to compile.
var ErrInvalidTag = errors.New("invalid counter tag")
ErrInvalidTag reports a counter tag the fixed-size C counter_tag fields cannot carry.
var ErrStillReferenced = errors.New("object still referenced by a live configuration generation")
ErrStillReferenced is reported by a handle Free when a live configuration generation still references the object: the object is intact, the free was refused, and the owner — the module, device or object control plane that knows the type — must remember the handle and free it again once the generations holding it drain.
Functions ¶
func ValidateQuery ¶
ValidateQuery rejects a query a C string cannot carry, such as one with a NUL.
func ValidateTag ¶
func ValidateTag(tag CounterTag) error
ValidateTag rejects a tag the fixed-size C counter_tag fields cannot carry: one with a NUL byte, or a key or value that does not fit.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func (*Agent) BlockAllocatorFreeSize ¶
BlockAllocatorFreeSize returns the total free memory in the agent's block allocator.
func (*Agent) DeleteFunction ¶
func (*Agent) DeleteModuleConfig ¶
func (*Agent) DeletePipeline ¶
func (*Agent) Extend ¶
Extend grows the agent's shared memory by the given size.
An agent that draws memory straight from the controlplane pool cannot be grown.
func (*Agent) MemoryLimit ¶
MemoryLimit reports the shared memory currently reserved for the agent.
func (*Agent) UpdateDevices ¶
func (m *Agent) UpdateDevices(devices []ShmDeviceConfig) error
UpdateDevices attaches the given pipelines to the given device IDs.
func (*Agent) UpdateFunction ¶
func (m *Agent) UpdateFunction(functionConfig FunctionConfig) error
func (*Agent) UpdateModules ¶
func (m *Agent) UpdateModules(modules []ModuleConfig) error
func (*Agent) UpdatePipeline ¶
func (m *Agent) UpdatePipeline(pipelineConfig PipelineConfig) error
type AgentInfo ¶
type AgentInfo struct {
Name string
Instances []AgentInstanceInfo
}
AgentInfo represents information about a control plane agent.
type AgentInstanceInfo ¶
type AgentInstanceInfo struct {
PID uint32
MemoryLimit uint64
FreeBytes uint64
Gen uint64
// MemoryTree is a flat depth-first snapshot of the agent's
// memory-context tree.
//
// Index 0 is the root; each later node references its parent via
// ParentIdx. Best-effort: a concurrent update may make a node appear or
// vanish between traversal passes.
MemoryTree []AgentMemoryNode
}
AgentInstanceInfo contains details about a specific agent instance.
type AgentMemoryNode ¶
type AgentMemoryNode struct {
Name string
ParentIdx uint32
BAllocCount uint64
BFreeCount uint64
BAllocSize uint64
BFreeSize uint64
}
AgentMemoryNode is one entry in a flat depth-first snapshot of an agent's memory-context tree.
Copied from shared memory by the C info API; the caller never accesses shared memory directly through this type.
type Chain ¶
type Chain struct {
Name string
Weight uint64
Modules []ChainModule
}
type ChainConfig ¶
type ChainConfig struct {
Name string
Modules []ChainModuleConfig
}
type ChainModule ¶
type ChainModuleConfig ¶
type CounterGroup ¶
type CounterGroup struct {
Tags []CounterTag
Counters []CounterInfo
}
CounterGroup is a set of counters that share the same tag set.
func MergeWorkerCounterGroups ¶
func MergeWorkerCounterGroups( workerCount int, perWorker [][]CounterGroup, ) []CounterGroup
MergeWorkerCounterGroups combines per-worker counter groups into one slice spanning every worker.
A counter is identified by its group's tag set and its name. The first worker carrying it defines its position and its size, every other carrier's snapshot lands in that worker's instance slot, and workers without the counter contribute zero values in theirs. Sizes come from the module's registry and are expected to agree across workers; on disagreement the first worker's size stays and the disagreeing worker's instance remains zero.
type CounterInfo ¶
type CounterInfo struct {
Name string
// Values is indexed by instance, then by value index within that instance.
Values [][]uint64
}
CounterInfo is a snapshot of one dataplane counter sharded across equally sized instances.
func (CounterInfo) InstanceValues ¶
func (m CounterInfo) InstanceValues(instance int) []uint64
InstanceValues returns every value of one instance.
func (CounterInfo) Instances ¶
func (m CounterInfo) Instances() int
Instances returns the number of instances this counter is sharded across.
func (CounterInfo) Size ¶
func (m CounterInfo) Size() int
Size returns the number of values each instance holds.
type CounterSet ¶
type CounterSet struct {
// contains filtered or unexported fields
}
CounterSet indexes one batch of counters by name, all sharing the same instance count.
func NewCounterSet ¶
func NewCounterSet(counters []CounterInfo) (*CounterSet, error)
NewCounterSet fails when the counters carry duplicate names or disagree on their instance count.
func (*CounterSet) Err ¶
func (m *CounterSet) Err() error
Err reports every counter that could not be resolved, or nil when all of them resolved.
func (*CounterSet) Instances ¶
func (m *CounterSet) Instances() int
Instances returns the instance count shared by every counter, or zero when the set is empty.
func (*CounterSet) Lookup ¶
func (m *CounterSet) Lookup(name string, size int) MaybeCounter
Lookup names a counter and its required size; zero leaves the size unchecked.
type CounterTag ¶
CounterTag is a (key, value) predicate against a counter's tag set. Value semantics follow the C API: an empty string requires the tag to be absent, "*" requires the tag to be present with any value, and any other string requires an exact match.
type DPConfig ¶
type DPConfig struct {
// contains filtered or unexported fields
}
DPConfig represents a handle to dataplane configuration.
func NewDPConfigFromRaw ¶
func (*DPConfig) AllModulePositions ¶
func (m *DPConfig) AllModulePositions(moduleType string) iter.Seq[ModuleReference]
func (*DPConfig) ChainCounters ¶
func (m *DPConfig) ChainCounters( deviceName string, pipelineName string, functionName string, chainName string, ) []CounterInfo
ChainCounters returns the chain's counters, or nil when the read fails.
func (*DPConfig) CountersByTags ¶
func (m *DPConfig) CountersByTags( tags []CounterTag, query []string, ) ([]CounterGroup, error)
CountersByTags returns counters matching every predicate in tags and at least one pattern in query. A nil or empty tags slice imposes no per-tag constraint. A nil or empty query matches any counter name.
Every worker's counter storage registry is matched independently and the sets are merged: a counter is identified by its group's tag set and its name, and a worker that does not carry it contributes zero values for its instance. Every returned counter therefore spans exactly one value set per dataplane worker.
func (*DPConfig) DeviceCounters ¶
func (m *DPConfig) DeviceCounters(deviceName string) []CounterInfo
DeviceCounters returns the device's counters, or nil when the read fails.
func (*DPConfig) Devices ¶
func (m *DPConfig) Devices() []DeviceInfo
Devices returns all device information from the dataplane.
func (*DPConfig) FunctionCounters ¶
func (m *DPConfig) FunctionCounters( deviceName string, pipelineName string, functionName string, ) []CounterInfo
FunctionCounters returns the function's counters, or nil when the read fails.
func (*DPConfig) ModuleCounters ¶
func (m *DPConfig) ModuleCounters( deviceName string, pipelineName string, functionName string, chainName string, moduleType string, moduleName string, counterQuery []string, ) []CounterInfo
ModuleCounters returns the module's predefined counters, optionally filtered by name, or nil when the read fails.
If counterQuery is nil or empty, returns all counters, a refused one none. The module's per-rule counters live on runtime-kind storages; read them through ModuleRuntimeCounters.
func (*DPConfig) ModuleRuntimeCounters ¶
func (m *DPConfig) ModuleRuntimeCounters( deviceName string, pipelineName string, functionName string, chainName string, moduleType string, moduleName string, counterQuery []string, ) ([]CounterInfo, error)
ModuleRuntimeCounters returns the module's runtime counters — those expanded from its named counter registries (per-route, per-rule, etc.) — optionally filtered by name.
If counterQuery is nil or empty, returns all runtime counters.
func (*DPConfig) ObjectCounters ¶
func (m *DPConfig) ObjectCounters( objectType string, objectName string, ) []CounterInfo
ObjectCounters returns the counters of an object identified by its type and name, or nil when the read fails.
func (*DPConfig) PipelineCounters ¶
func (m *DPConfig) PipelineCounters( deviceName string, pipelineName string, ) []CounterInfo
PipelineCounters returns the pipeline's counters, or nil when the read fails.
func (*DPConfig) PortCounters ¶
func (*DPConfig) RawWorkerCounters ¶
func (m *DPConfig) RawWorkerCounters() []CounterInfo
RawWorkerCounters returns the worker counters, or nil when they cannot be read.
The C API snapshots one worker at a time, so every worker is read separately and the per-worker snapshots are merged into one list spanning every worker: worker i's values land in instance slot i of each counter.
func (*DPConfig) WorkerCount ¶
func (*DPConfig) WorkerCounters ¶
func (m *DPConfig) WorkerCounters() ([]WorkerCounter, error)
type DPModule ¶
type DPModule struct {
// contains filtered or unexported fields
}
DPModule represents a dataplane module in the YANET configuration.
type DeviceConfig ¶
type DeviceConfig struct {
Name string
Input []DevicePipelineConfig
Output []DevicePipelineConfig
}
type DeviceInfo ¶
type DeviceInfo struct {
Type string
Name string
Index uint32
InputPipelines []DevicePipelineInfo
OutputPipelines []DevicePipelineInfo
}
DeviceInfo represents information about a device.
type DevicePipeline ¶
type DevicePipelineConfig ¶
type DevicePipelineInfo ¶
DevicePipelineInfo represents information about a pipeline in a device.
type FunctionChainConfig ¶
type FunctionChainConfig struct {
Chain ChainConfig
Weight uint64
}
type FunctionConfig ¶
type FunctionConfig struct {
Name string
Chains []FunctionChainConfig
}
type MaybeCounter ¶
type MaybeCounter struct {
// contains filtered or unexported fields
}
MaybeCounter is a lookup that materializes once the caller chooses how absence is reported.
func (MaybeCounter) Require ¶
func (m MaybeCounter) Require() CounterInfo
Require returns zero for an absent counter and records the miss.
type ModuleConfig ¶
type ModuleConfig struct {
// contains filtered or unexported fields
}
ModuleConfig is a Go wrapper around a C cp_module pointer, representing a module's shared memory configuration.
Each module package creates its own typed wrapper embedding ModuleConfig, using unsafe.Pointer as a bridge between CGo contexts of different packages.
func NewModuleConfig ¶
func NewModuleConfig(ptr unsafe.Pointer) ModuleConfig
NewModuleConfig wraps a raw C pointer into a ModuleConfig.
The pointer must originate from a module-specific C constructor that returns a valid cp_module pointer. The caller is responsible for ensuring the pointer's validity and lifetime.
func (ModuleConfig) AsRawPtr ¶
func (m ModuleConfig) AsRawPtr() unsafe.Pointer
AsRawPtr returns the underlying C pointer as unsafe.Pointer for passing across CGo package boundaries.
type ModuleReference ¶
type Pipeline ¶
type Pipeline struct {
// Name is the name of the pipeline.
Name string
// Functions is the list of functions in the pipeline
Functions []string
}
Pipeline represents a dataplane packet processing pipeline configuration.
type PortCounter ¶
type PortGroup ¶
type PortGroup struct {
PortID uint16
PortName string
Counters []PortCounter
}
type SharedMemory ¶
type SharedMemory struct {
// contains filtered or unexported fields
}
SharedMemory represents a handle to YANET shared memory segment.
func AttachSharedMemory ¶
func AttachSharedMemory(path string) (*SharedMemory, error)
AttachSharedMemory attaches to YANET shared memory segment.
func NewSharedMemoryFromRaw ¶
func NewSharedMemoryFromRaw(ptr unsafe.Pointer) *SharedMemory
NewSharedMemoryFromRaw wraps an opaque C shared-memory handle.
The pointer is the process-local handle the C API hands out, not the segment itself; it must only be used through the C API.
func (*SharedMemory) AgentAttach ¶
func (m *SharedMemory) AgentAttach( name string, instanceIdx uint32, size datasize.ByteSize, ) (*Agent, error)
AgentAttach attaches a module agent to shared memory on the dataplane instance.
func (*SharedMemory) AsRawPtr ¶
func (m *SharedMemory) AsRawPtr() unsafe.Pointer
AsRawPtr returns the opaque C shared-memory handle.
The pointer is the process-local handle, not the segment itself; it must only be used through the C API.
func (*SharedMemory) DPConfig ¶
func (m *SharedMemory) DPConfig(instanceIdx uint32) *DPConfig
DPConfig gets configuration of the dataplane instance from shared memory.
func (*SharedMemory) DataplaneReady ¶
func (m *SharedMemory) DataplaneReady(instanceIdx uint32) bool
DataplaneReady reports whether the dataplane instance has finished initializing its shared memory.
func (*SharedMemory) Detach ¶
func (m *SharedMemory) Detach() error
Detach detaches from YANET shared memory segment.
Every agent attached to the segment must be closed before detaching, because the mapping is unmapped and a later agent operation would fault. The mapping length travels inside the handle, so detaching works at any point after a successful attach, including before the dataplane has written the segment header. The handle is consumed whatever the outcome, so a second call is a no-op.
type ShmDeviceConfig ¶
type ShmDeviceConfig struct {
// contains filtered or unexported fields
}
ShmDeviceConfig is a Go wrapper around a C cp_device pointer, representing a device's shared memory configuration.
Device packages (plain, vlan) create their own typed wrappers embedding ShmDeviceConfig.
func NewShmDeviceConfig ¶
func NewShmDeviceConfig(ptr unsafe.Pointer) ShmDeviceConfig
NewShmDeviceConfig wraps a raw C pointer into a ShmDeviceConfig.
The pointer must originate from a device-specific C constructor (e.g. cp_device_plain_new). The caller is responsible for ensuring the pointer's validity and lifetime.
func (ShmDeviceConfig) AsRawPtr ¶
func (m ShmDeviceConfig) AsRawPtr() unsafe.Pointer
AsRawPtr returns the underlying C pointer as unsafe.Pointer for passing across CGo package boundaries.
type WorkerCounter ¶
type WorkerCounter struct {
WorkerIdx uint32
CoreID uint32
DeviceID uint32
QueueID uint32
MaxBurstSize uint32
RxBursts []uint64
Iterations uint64
RxPackets uint64
RxBytes uint64
TxPackets uint64
TxBytes uint64
RemoteRxPackets uint64
RemoteTxPackets uint64
LocalTxDrops uint64
RemoteTxDrops uint64
Disposed uint64
}