pipeline

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package pipeline wraps RTE Pipeline.

This tool is part of the DPDK Packet Framework tool suite and provides a standard methodology (logically similar to OpenFlow) for rapid development of complex packet processing pipelines out of ports, tables and actions.

Basic operation. A pipeline is constructed by connecting its input ports to its output ports through a chain of lookup tables. As result of lookup operation into the current table, one of the table entries (or the default table entry, in case of lookup miss) is identified to provide the actions to be executed on the current packet and the associated action meta-data. The behavior of user actions is defined through the configurable table action handler, while the reserved actions define the next hop for the current packet (either another table, an output port or packet drop) and are handled transparently by the framework.

Initialization and run-time flows. Once all the pipeline elements (input ports, tables, output ports) have been created, input ports connected to tables, table action handlers configured, tables populated with the initial set of entries (actions and action meta-data) and input ports enabled, the pipeline runs automatically, pushing packets from input ports to tables and output ports. At each table, the identified user actions are being executed, resulting in action meta-data (stored in the table entry) and packet meta-data (stored with the packet descriptor) being updated. The pipeline tables can have further updates and input ports can be disabled or enabled later on as required.

Multi-core scaling. Typically, each CPU core will run its own pipeline instance. Complex application-level pipelines can be implemented by interconnecting multiple CPU core-level pipelines in tree-like topologies, as the same port devices (e.g. SW rings) can serve as output ports for the pipeline running on CPU core A, as well as input ports for the pipeline running on CPU core B. This approach enables the application development using the pipeline (CPU cores connected serially), cluster/run-to-completion (CPU cores connected in parallel) or mixed (pipeline of CPU core clusters) programming models.

Thread safety. It is possible to have multiple pipelines running on the same CPU core, but it is not allowed (for thread safety reasons) to have multiple CPU cores running the same pipeline instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action uint32

Action specifies what to do with packets on table output.

const (
	// Drop packet.
	ActionDrop Action = C.RTE_PIPELINE_ACTION_DROP

	// Send to port specified in TableEntry.
	ActionPort Action = C.RTE_PIPELINE_ACTION_PORT

	// Send to port specified in packet metadata.
	ActionPortMeta Action = C.RTE_PIPELINE_ACTION_PORT_META

	// Send to table specified in TableEntry.
	ActionTable Action = C.RTE_PIPELINE_ACTION_TABLE
)

Reserved actions.

type Controller added in v0.0.10

type Controller interface {
	// Transformer is implemented to reflect the configuration into C
	// memory.
	common.Transformer

	// Ops returns the C implementation of hooks for controlling
	// pipeline execution.
	Ops() *Ops
}

Controller controls execution of pipeline loop.

type Ops added in v0.0.10

type Ops struct {
	Ctrl OpsCtrlF
}

Ops is the control operations of a pipeline tight loop.

type OpsCtrlF added in v0.0.10

type OpsCtrlF C.pipeline_op_ctrl

OpsCtrlF returns 0 if the pipeline continues, >0 if the pipeline should be stopped and <0 in case of error.

The implementation should satisfy the signature:

int (*pipeline_op_ctrl)(void *params, struct rte_pipeline *p);

type Params

type Params struct {
	// Name of the pipeline.
	Name string

	// SocketID for memory allocation.
	SocketID int

	// Offset within packet meta-data to port_id to be used by action
	// "Send packet to output port read from packet meta-data". Has to
	// be 4-byte aligned.
	OffsetPortID uint32
}

Params configures the pipeline.

func (*Params) Transform

func (p *Params) Transform(alloc common.Allocator) (unsafe.Pointer, func(unsafe.Pointer))

Transform implements common.Transformer interface.

type Pipeline

type Pipeline C.struct_rte_pipeline

Pipeline object.

func Create

func Create(p *Params) *Pipeline

Create pipeline with specified configuration.

Returns nil in case of an error.

func (*Pipeline) Check

func (pl *Pipeline) Check() error

Check the consistency of the pipeline.

func (*Pipeline) ConnectToTable

func (pl *Pipeline) ConnectToTable(port PortIn, table Table) error

ConnectToTable connects specified portID to created tableID.

func (*Pipeline) Disable

func (pl *Pipeline) Disable(port PortIn) error

Disable input port in the pipeline.

func (*Pipeline) Enable

func (pl *Pipeline) Enable(port PortIn) error

Enable input port in the pipeline.

func (*Pipeline) Flush

func (pl *Pipeline) Flush() error

Flush the pipeline.

func (*Pipeline) Free

func (pl *Pipeline) Free() error

Free destroys the pipeline.

func (*Pipeline) PortInCreate

func (pl *Pipeline) PortInCreate(p *PortInParams) (id PortIn, err error)

PortInCreate creates new input port in the pipeline with specified configuration. Returns id of the created port or an error.

func (*Pipeline) PortInStatsRead

func (pl *Pipeline) PortInStatsRead(port PortIn, s *PortInStats, clear bool) error

PortInStatsRead reads stats on input port registered in the pipeline.

If clear s true then clear stats after reading.

func (*Pipeline) PortOutCreate

func (pl *Pipeline) PortOutCreate(p *PortOutParams) (id PortOut, err error)

PortOutCreate creates new output port in the pipeline with specified configuration. Returns id of the created port or an error.

func (*Pipeline) PortOutStatsRead

func (pl *Pipeline) PortOutStatsRead(port PortOut, s *PortOutStats, clear bool) error

PortOutStatsRead reads stats on output port registered in the pipeline.

If clear s true then clear stats after reading.

func (*Pipeline) Run

func (pl *Pipeline) Run() int

Run the pipeline.

func (*Pipeline) RunLoop

func (pl *Pipeline) RunLoop(flush uint32, c Controller) error

RunLoop runs pipeline continuously, flushing it every 'flush' iterations. RunLoop returns if value referenced by 'stop' is set to non-zero value.

flush must be power of 2.

func (*Pipeline) TableCreate

func (pl *Pipeline) TableCreate(p *TableParams) (id Table, err error)

TableCreate creates new table in the pipeline.

func (*Pipeline) TableDefaultEntryAdd

func (pl *Pipeline) TableDefaultEntryAdd(table Table, entry *TableEntry) (*TableEntry, error)

TableDefaultEntryAdd adds default entry to table in the pipeline. Returns pointer to actual TableEntry instance in the pipeline's table.

func (*Pipeline) TableDefaultEntryDelete

func (pl *Pipeline) TableDefaultEntryDelete(table Table, entry *TableEntry) error

TableDefaultEntryDelete deletes default entry from table in the pipeline. entry then is filled with removed entry.

func (*Pipeline) TableEntryAdd

func (pl *Pipeline) TableEntryAdd(table Table, pkey unsafe.Pointer, entry *TableEntry, ptrEntry **TableEntry) (bool, error)

TableEntryAdd adds key/entry into table. On successful invocation, ptrEntry points to found entry. Returns true of entry was present in the map prior to invocation.

pkey is table-specific pointer to a struct containing a key. Please refer to table's API for key specification.

func (*Pipeline) TableEntryDelete

func (pl *Pipeline) TableEntryDelete(table Table, pkey unsafe.Pointer, entry *TableEntry) (bool, error)

TableEntryDelete removes key from table. entry is filled with removed entry.

pkey is table-specific pointer to a struct containing a key. Please refer to table's API for key specification.

func (*Pipeline) TableStatsRead

func (pl *Pipeline) TableStatsRead(table Table, s *TableStats, clear bool) error

TableStatsRead reads stats on table registered in the pipeline.

If clear s true then clear stats after reading.

type PortIn

type PortIn C.uint32_t

PortIn represents an input port created in a pipeline.

type PortInAction

PortInAction is the pipeline input port action handler.

The action handler can decide to drop packets by resetting the associated packet bit in the pkts_mask parameter. In this case, the action handler is required not to free the packet buffer, which will be freed eventually by the pipeline.

type PortInParams

type PortInParams struct {
	// Port configuration. See port package.
	Params port.InParams

	// Input port action. Implemented in C.
	Action PortInAction
	// Input port action argument.
	ActionArg unsafe.Pointer

	// Amount of packet burst.
	BurstSize int
}

PortInParams configures input port creation for pipeline.

type PortInStats

type PortInStats struct {
	port.InStats

	// Number of packets dropped by action handler.
	PacketsDroppedByAH uint64
}

PortInStats is the pipeline input port stats.

type PortOut

type PortOut C.uint32_t

PortOut represents an output port created in a pipeline.

type PortOutAction

PortOutAction is the pipeline output port action handler.

The action handler can decide to drop packets by resetting the associated packet bit in the pkts_mask parameter. In this case, the action handler is required not to free the packet buffer, which will be freed eventually by the pipeline.

type PortOutParams

type PortOutParams struct {
	// Port configuration. See port package.
	Params port.OutParams

	// Output port action. Implemented in C.
	Action PortOutAction
	// Output port action argument.
	ActionArg unsafe.Pointer
}

PortOutParams configures output port creation for pipeline.

type PortOutStats

type PortOutStats struct {
	port.OutStats

	// Number of packets dropped by action handler.
	PacketsDroppedByAH uint64
}

PortOutStats is the pipeline output port stats.

type SimpleController added in v0.0.10

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

SimpleController implements Controller for pipeline control.

It allocates a single byte which serves as a stop flag for pipeline loop. Empty SimpleController is not usable, please use NewSimpleController to create SimpleController instance.

func NewSimpleController added in v0.0.10

func NewSimpleController() *SimpleController

NewSimpleController allocates new SimpleController.

func (*SimpleController) Ops added in v0.0.10

func (c *SimpleController) Ops() *Ops

Ops implements Controller interface.

func (*SimpleController) Stop added in v0.0.10

func (c *SimpleController) Stop()

Stop stops the execution of a pipeline that watches this controller. It may be used by multiple pipelines.

func (*SimpleController) Transform added in v0.0.10

func (c *SimpleController) Transform(alloc common.Allocator) (unsafe.Pointer, func(unsafe.Pointer))

Transform implements common.Transformer interface.

type Table

type Table C.uint32_t

Table represents created table in a pipeline.

type TableActionHitFunc

type TableActionHitFunc C.rte_pipeline_table_action_handler_hit

TableActionHitFunc is executed on the hit in table.

type TableActionMissFunc

type TableActionMissFunc C.rte_pipeline_table_action_handler_miss

TableActionMissFunc is executed on the miss in table.

type TableEntry

TableEntry specifies the entry in table.

func NewTableEntry

func NewTableEntry(actionDataSize uintptr) *TableEntry

NewTableEntry creates new table entry template allocated in Go. Use actionDataSize as specified during table creation.

func (*TableEntry) GetAction

func (entry *TableEntry) GetAction() (code Action)

GetAction returns configured action in the entry.

func (*TableEntry) GetActionData

func (entry *TableEntry) GetActionData() unsafe.Pointer

GetActionData returns pointer to action user data.

func (*TableEntry) GetPortID

func (entry *TableEntry) GetPortID() (port PortOut)

GetPortID returns configured output port ID (meta-data for "Send packet to output port" action).

func (*TableEntry) GetTableID

func (entry *TableEntry) GetTableID() Table

GetTableID returns configured table in the entry for "Send packet to table" action.

func (*TableEntry) SetAction

func (entry *TableEntry) SetAction(code Action)

SetAction sets configured action in the entry.

func (*TableEntry) SetPortID

func (entry *TableEntry) SetPortID(port PortOut)

SetPortID sets configured output port ID (meta-data for "Send packet to output port" action).

func (*TableEntry) SetTableID

func (entry *TableEntry) SetTableID(table Table)

SetTableID sets configured table in the entry for "Send packet to table" action.

type TableParams

type TableParams struct {
	Params table.Params

	// OnHit and OnMiss action handlers must be implemented in C.
	OnHit  TableActionHitFunc
	OnMiss TableActionMissFunc

	// Argument for OnHit/OnMiss action handlers.
	ActionArg unsafe.Pointer

	// ActionDataSize specifies size of action data in an entry.
	ActionDataSize uintptr
}

TableParams configures table creation in the pipeline.

type TableStats

type TableStats struct {
	table.Stats

	PacketsDroppedByHitAH  uint64
	PacketsDroppedByMissAH uint64
	PacketsDroppedByHit    uint64
	PacketsDroppedByMiss   uint64
}

TableStats is the pipeline table stats.

Jump to

Keyboard shortcuts

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