port

package
v0.1.1-r1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package port wraps RTE Port.

This tool is part of the DPDK Packet Framework tool suite and provides a standard interface to implement different types of packet ports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EthdevRx

type EthdevRx struct {
	// Configured Ethernet port and RX queue ID.
	PortID, QueueID uint16
}

EthdevRx is an input port built on top of pre-initialized NIC RX queue.

func (*EthdevRx) InOps

func (p *EthdevRx) InOps() *InOps

InOps implements InParams interface.

func (*EthdevRx) Transform

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

Transform implements common.Transformer interface.

type EthdevTx

type EthdevTx struct {
	// Configured Ethernet port and TX queue ID.
	PortID, QueueID uint16

	// Recommended burst size for NIC TX queue.
	TxBurstSize uint32

	// If NoDrop set writer makes Retries attempts to write packets to
	// NIC TX queue.
	NoDrop bool

	// If NoDrop set and Retries is 0, number of retries is unlimited.
	Retries uint32
}

EthdevTx is an output port built on top of pre-initialized NIC TX queue.

func (*EthdevTx) OutOps

func (p *EthdevTx) OutOps() *OutOps

OutOps implements OutParams interface.

func (*EthdevTx) Transform

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

Transform implements common.Transformer interface.

type FdRx

type FdRx struct {
	// Pre-initialized buffer pool.
	*mempool.Mempool

	// File descriptor.
	Fd uintptr

	// Maximum Transfer Unit (MTU)
	MTU uint32
}

FdRx input port built on top of valid non-blocking file descriptor.

func (*FdRx) InOps

func (rd *FdRx) InOps() *InOps

InOps implements InParams interface.

func (*FdRx) Transform

func (rd *FdRx) Transform(alloc common.Allocator) (unsafe.Pointer, func(unsafe.Pointer))

Transform implements common.Transformer interface.

type FdTx

type FdTx struct {
	// File descriptor.
	Fd uintptr

	// Recommended write burst size. The actual burst size can be
	// bigger or smaller than this value.
	//
	// Should be power of 2.
	BurstSize uint32

	// If NoDrop set writer makes Retries attempts to write packets to
	// ring.
	NoDrop bool

	// If NoDrop set and Retries is 0, number of retries is unlimited.
	Retries uint32
}

FdTx is an output port built on top of valid non-blocking file descriptor.

func (*FdTx) OutOps

func (wr *FdTx) OutOps() *OutOps

OutOps implements OutParams interface.

func (*FdTx) Transform

func (wr *FdTx) Transform(alloc common.Allocator) (unsafe.Pointer, func(unsafe.Pointer))

Transform implements common.Transformer interface.

type In

type In [0]byte

In is the instantiated input port.

func CreateIn

func CreateIn(socket int, params InParams) *In

CreateIn creates input port for specified socket and configuration.

It may return nil in case of an error.

func (*In) Free

func (port *In) Free(inOps *InOps) error

Free destroys created input port.

type InOps

InOps is the function table which implements input port.

type InParams

type InParams interface {
	// Returns allocated opaque structure along with its destructor.
	// Since InParams describes Go implementation of the port
	// configuration this member allocates its C counterpart as stated
	// in DPDK rte_port.
	common.Transformer

	// Returns pointer to associated rte_port_in_ops.
	InOps() *InOps
}

InParams describes the input port interface.

type InStats

type InStats struct {
	PacketsIn   uint64
	PacketsDrop uint64
}

InStats is an input port statistics.

type Out

type Out [0]byte

Out is the instantiated output port.

func CreateOut

func CreateOut(socket int, params OutParams) *Out

CreateOut creates output port for specified socket and configuration.

It may return nil in case of an error.

func (*Out) Free

func (port *Out) Free(outOps *OutOps) error

Free destroys created output port.

type OutOps

OutOps is the function table which implements output port.

type OutParams

type OutParams interface {
	// Returns allocated opaque structure argument along with its
	// destructor. It is used with ops function table.
	common.Transformer

	// Returns pointer to associated rte_port_out_ops.
	OutOps() *OutOps
}

OutParams describes configuration and behaviour of output port.

type OutStats

type OutStats struct {
	PacketsIn   uint64
	PacketsDrop uint64
}

OutStats is an output port statistics.

type RingRx

type RingRx struct {
	// Underlying ring
	*ring.Ring

	// Set if specified ring is multi consumer.
	Multi bool
}

RingRx is an input port built on top of pre-initialized RTE ring.

func (*RingRx) InOps

func (rd *RingRx) InOps() *InOps

InOps implements InParams interface.

func (*RingRx) Transform

func (rd *RingRx) Transform(alloc common.Allocator) (unsafe.Pointer, func(unsafe.Pointer))

Transform implements common.Transformer interface.

type RingTx

type RingTx struct {
	// Underlying ring
	*ring.Ring

	// Recommended burst size for ring operations.
	TxBurstSize uint32

	// Set if specified ring is multi producer.
	Multi bool

	// If NoDrop set writer makes Retries attempts to write packets to
	// ring.
	NoDrop bool

	// If NoDrop set and Retries is 0, number of retries is unlimited.
	Retries uint32
}

RingTx is an output port built on top of pre-initialized single producer ring.

func (*RingTx) OutOps

func (wr *RingTx) OutOps() *OutOps

OutOps implements OutParams interface.

func (*RingTx) Transform

func (wr *RingTx) Transform(alloc common.Allocator) (unsafe.Pointer, func(unsafe.Pointer))

Transform implements common.Transformer interface.

type Sink

type Sink struct {
	// The full path of the pcap file to write the packets to.
	Filename string

	// The maximum number of packets write to the pcap file. If this value is
	// 0, the "infinite" write will be carried out.
	MaxPackets uint32
}

Sink is an output port that drops all packets written to it.

func (*Sink) OutOps

func (wr *Sink) OutOps() *OutOps

OutOps implements OutParams interface.

func (*Sink) Transform

func (wr *Sink) Transform(alloc common.Allocator) (unsafe.Pointer, func(unsafe.Pointer))

Transform implements common.Transformer interface.

type Source

type Source struct {
	// Pre-initialized buffer pool.
	*mempool.Mempool

	// The full path of the pcap file to read packets from.
	Filename string

	// The number of bytes to be read from each packet in the pcap file. If
	// this value is 0, the whole packet is read; if it is bigger than packet
	// size, the generated packets will contain the whole packet.
	BytesPerPacket uint32
}

Source is an input port that can be used to generate packets.

func (*Source) InOps

func (rd *Source) InOps() *InOps

InOps implements InParams interface.

func (*Source) Transform

func (rd *Source) Transform(alloc common.Allocator) (unsafe.Pointer, func(unsafe.Pointer))

Transform implements common.Transformer interface.

Jump to

Keyboard shortcuts

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