Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateDeviceName(name string) error
- 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) DeleteDevice(name string) error
- func (m *Agent) DeleteFunction(name string) error
- func (m *Agent) DeleteModuleConfig(moduleType, configName string) error
- func (m *Agent) DeleteObject(objectType, objectName 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) UpdateObjects(objects []ObjectConfig) error
- func (m *Agent) UpdatePipeline(pipelineConfig PipelineConfig) error
- type AgentInfo
- type AgentInstanceInfo
- type AgentMemoryNode
- type AttachConfig
- type Attachment
- 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) CurrentTime() (uint64, bool)
- func (m *DPConfig) Device(deviceType, name string) (DeviceInfo, bool)
- 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) ModuleObjectLinkCounters(deviceName string, pipelineName string, functionName string, chainName string, ...) ([]CounterInfo, error)
- 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 ObjectConfig
- 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
- func (m *SharedMemory) ExtendAgent(instanceIdx uint32, name string, size datasize.ByteSize) (datasize.ByteSize, error)
- type ShmDeviceConfig
- type WorkerCounter
- type WorkerRxMempool
Constants ¶
const ( // ErrNotFound: the entity the operation names does not exist. ErrNotFound = cerrors.NotFound // ErrFailedPrecondition: the system is not in the state the operation // needs, such as a live configuration naming an entity that does not // exist. ErrFailedPrecondition = cerrors.FailedPrecondition // ErrBusy: the entity is still referenced, so the operation was refused. ErrBusy = cerrors.Busy // ErrInvalidArgument: the request is wrong regardless of the system // state. ErrInvalidArgument = cerrors.InvalidArgument // ErrResourceExhausted: the pool the operation draws from has no room // left for the request. ErrResourceExhausted = cerrors.ResourceExhausted )
Kinds a failed agent mutation reports, matched through errors.Is.
The C layer tags the cause, the caller maps it to a status code: the same kind means different things to different operations.
const CounterNameLen = C.COUNTER_NAME_LEN
CounterNameLen is the size of the C counter name buffer, including its terminating NUL.
const CounterTagKeyLen = C.COUNTER_TAG_KEY_LEN
CounterTagKeyLen is the size of the C counter-tag key buffer, including its terminating NUL.
const CounterTagValueLen = C.COUNTER_TAG_VALUE_LEN
CounterTagValueLen is the size of the C counter-tag value buffer, including its terminating NUL.
const MaxAgentNameLen = C.AGENT_NAME_LEN
MaxAgentNameLen is the size of the C-side agent name buffer, including the terminating NUL.
const MaxDeviceNameLen = C.CP_DEVICE_NAME_LEN
MaxDeviceNameLen is the size of the C-side device name buffer, including the terminating NUL.
The largest usable name is one byte shorter than this bound.
const MaxModuleNameLen = C.CP_MODULE_NAME_LEN
MaxModuleNameLen is the size of the C-side module config name buffer, including the terminating NUL.
const MaxObjectNameLen = C.CP_OBJECT_NAME_LEN
MaxObjectNameLen is the size of the C-side object name buffer, including the terminating NUL.
The largest usable name is one byte shorter than this bound.
const MaxPipelineNameLen = C.CP_PIPELINE_NAME_LEN
MaxPipelineNameLen is the size of the C-side pipeline name buffer, including the terminating NUL.
Variables ¶
var ErrAgentNotFound = errors.New("agent is not attached")
ErrAgentNotFound reports that no agent is attached under the requested name.
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 ValidateDeviceName ¶ added in v0.1.0
ValidateDeviceName rejects a name the C-side fixed-size device name buffer cannot round-trip: one with a NUL byte, or one that does not fit.
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) DeleteDevice ¶ added in v0.1.0
func (*Agent) DeleteFunction ¶
func (*Agent) DeleteModuleConfig ¶
func (*Agent) DeleteObject ¶ added in v0.1.0
DeleteObject removes the named shared object.
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) UpdateObjects ¶ added in v0.1.0
func (m *Agent) UpdateObjects(objects []ObjectConfig) error
UpdateObjects upserts the given objects into the active configuration generation.
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 AttachConfig ¶ added in v0.1.0
type AttachConfig struct {
// InstanceID specifies which dataplane instance the agent serves.
//
// Required: a listed module or device must set it explicitly, even
// to 0.
InstanceID xcfg.Required[uint32] `yaml:"instance_id"`
// MemoryPath is the path to the shared-memory file that is used to
// communicate with the dataplane.
MemoryPath xcfg.NonEmptyString `yaml:"memory_path"`
// MemoryRequirements is the size of the agent's arena in shared
// memory.
MemoryRequirements xcfg.NonZero[datasize.ByteSize] `yaml:"memory_requirements"`
}
AttachConfig names the dataplane instance an agent serves and the shared memory it attaches to.
A module or device control plane embeds it inline in its own config, so the keys sit at the top level of that config's document.
func DefaultAttachConfig ¶ added in v0.1.0
func DefaultAttachConfig(memory datasize.ByteSize) AttachConfig
DefaultAttachConfig returns the shared-memory defaults with the given arena size and no instance, which every listed agent must set itself.
type Attachment ¶ added in v0.1.0
type Attachment struct {
Agent *Agent
// contains filtered or unexported fields
}
Attachment is an agent attached to a dataplane instance together with the shared-memory mapping it lives in.
func Attach ¶ added in v0.1.0
func Attach(cfg AttachConfig, name string, log *zap.Logger) (*Attachment, error)
Attach maps the shared memory the config names and attaches the named agent to its dataplane instance.
A failed agent attach unmaps the memory again, so an error leaves nothing behind for the caller to release.
func (*Attachment) Close ¶ added in v0.1.0
func (m *Attachment) Close() error
Close releases the agent and unmaps the shared memory.
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) CurrentTime ¶ added in v0.1.0
func (*DPConfig) Device ¶ added in v0.1.0
func (m *DPConfig) Device(deviceType, name string) (DeviceInfo, bool)
Device returns the device of the given type and name from the dataplane registry, or false when none matches.
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) ModuleObjectLinkCounters ¶ added in v0.1.0
func (m *DPConfig) ModuleObjectLinkCounters( deviceName string, pipelineName string, functionName string, chainName string, moduleType string, moduleName string, objectType string, objectName string, counterQuery []string, ) ([]CounterInfo, error)
ModuleObjectLinkCounters returns the counters an object's link counter registry spawns for one module link, e.g. the route module's per-nexthop counters, optionally filtered by name.
If counterQuery is nil or empty, returns all of the link's counters.
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.
func (*ModuleConfig) Free ¶ added in v0.1.0
func (m *ModuleConfig) Free( free func(ptr unsafe.Pointer) (rc int, cErr unsafe.Pointer, errno error), ) error
Free destroys the module config through the typed free the module supplies and forgets the pointer once it is gone.
The typed free succeeds only once no live generation references the config. A refused attempt reports ErrStillReferenced, releases the error chain it allocated and leaves the handle usable, so the owner can retry once the generations holding it drain. Repeated calls after a success are no-ops reporting nil. The handle to free is the binding's own, not a copy handed out for publishing, which would keep the original live after the object is gone.
type ModuleReference ¶
type ObjectConfig ¶ added in v0.1.0
type ObjectConfig struct {
// contains filtered or unexported fields
}
ObjectConfig is a Go wrapper around a C cp_object pointer, representing a shared object's configuration, such as a route module's FIB.
Each object owner wraps it in its own typed handle, using unsafe.Pointer as a bridge between CGo contexts of different packages.
func NewObjectConfig ¶ added in v0.1.0
func NewObjectConfig(ptr unsafe.Pointer) ObjectConfig
NewObjectConfig wraps a raw C pointer into an ObjectConfig.
The pointer must originate from an object-specific C constructor that returns a valid cp_object pointer. The caller is responsible for ensuring the pointer's validity and lifetime.
func (ObjectConfig) AsRawPtr ¶ added in v0.1.0
func (m ObjectConfig) AsRawPtr() unsafe.Pointer
AsRawPtr returns the underlying C pointer as unsafe.Pointer for passing across CGo package boundaries.
func (*ObjectConfig) Free ¶ added in v0.1.0
func (m *ObjectConfig) Free( free func(ptr unsafe.Pointer) (rc int, cErr unsafe.Pointer, errno error), ) error
Free destroys the object config through the typed free the object supplies and forgets the pointer once it is gone.
The refusal contract is the one of a module config's free.
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.
The first attachment installs a process-wide SIGBUS handler. A bus error attempts a nonblocking diagnostic to pipe/socket stderr and exits with status 135 without cleanup. Full streams and other stderr destinations are skipped; the supervisor must restart the process to attach to the new arena.
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.
func (*SharedMemory) ExtendAgent ¶ added in v0.1.0
func (m *SharedMemory) ExtendAgent( instanceIdx uint32, name string, size datasize.ByteSize, ) (datasize.ByteSize, error)
ExtendAgent grows the shared memory of the agent attached under the given name and reports the size it holds afterwards.
The size is a lower bound, because the allocator rounds it up to its own granularity. Finding the agent and growing it happen under one hold of the configuration lock, so a re-attach of the same name cannot retire the agent midway. Reports ErrAgentNotFound when no agent goes by that name.
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.
func (*ShmDeviceConfig) Free ¶ added in v0.1.0
func (m *ShmDeviceConfig) Free( free func(ptr unsafe.Pointer) (rc int, cErr unsafe.Pointer, errno error), ) error
Free destroys the device config through the typed free the device supplies and forgets the pointer once it is gone.
The refusal contract is the one of a module config's free.
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
RxMempool *WorkerRxMempool
}
type WorkerRxMempool ¶ added in v0.1.0
WorkerRxMempool is the occupancy of one worker's RX packet pool, in mempool objects. In-use objects are the difference Capacity minus Available, which counts mbufs held by NIC descriptors and in flight.