pktmbuf

package
v0.0.0-...-b000f17 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: NIST-PD-fallback Imports: 15 Imported by: 2

Documentation

Overview

Package pktmbuf contains bindings of DPDK mbuf library.

Index

Constants

View Source
const DefaultHeadroom = C.RTE_PKTMBUF_HEADROOM

DefaultHeadroom is the default headroom of a mbuf.

Variables

View Source
var (
	GqlConfigType   *graphql.Object
	GqlPoolType     *graphql.Object
	GqlTemplateType *graphql.Object
)

GraphQL types.

Functions

This section is empty.

Types

type MbufAccessor

type MbufAccessor C.struct_rte_mbuf

MbufAccessor allows accessing mbuf union fields as pointers.

func MbufAccessorFromPtr

func MbufAccessorFromPtr[T any](ptr *T) *MbufAccessor

MbufAccessorFromPtr converts *C.struct_rte_mbuf pointer to Packet.

func (*MbufAccessor) BufLen

func (m *MbufAccessor) BufLen() *uint16

func (*MbufAccessor) DataLen

func (m *MbufAccessor) DataLen() *uint16

func (*MbufAccessor) DataOff

func (m *MbufAccessor) DataOff() *uint16

func (*MbufAccessor) NbSegs

func (m *MbufAccessor) NbSegs() *uint16

func (*MbufAccessor) PacketType

func (m *MbufAccessor) PacketType() *uint32

func (*MbufAccessor) PktLen

func (m *MbufAccessor) PktLen() *uint32

func (*MbufAccessor) Port

func (m *MbufAccessor) Port() *uint16

type Packet

type Packet C.struct_rte_mbuf

Packet represents a packet in mbuf.

func PacketFromPtr

func PacketFromPtr(ptr unsafe.Pointer) *Packet

PacketFromPtr converts *C.struct_rte_mbuf pointer to Packet.

func (*Packet) Append

func (pkt *Packet) Append(input []byte) error

Append appends to the packet in tailroom of the last segment.

func (*Packet) Bytes

func (pkt *Packet) Bytes() []byte

Bytes returns a []byte that contains a copy of the data in this packet.

func (*Packet) Chain

func (pkt *Packet) Chain(tail *Packet) error

Chain combines two packets. tail will be freed when pkt is freed.

func (*Packet) Close

func (pkt *Packet) Close() error

Close releases the mbuf to mempool.

func (*Packet) Headroom

func (pkt *Packet) Headroom() int

Headroom returns headroom of the first segment.

func (*Packet) Len

func (pkt *Packet) Len() int

Len returns packet length in octets.

func (*Packet) Port

func (pkt *Packet) Port() uint16

Port returns ingress network interface.

func (*Packet) Prepend

func (pkt *Packet) Prepend(input []byte) error

Prepend prepends to the packet in headroom of the first segment.

func (*Packet) Ptr

func (pkt *Packet) Ptr() unsafe.Pointer

Ptr returns *C.struct_rte_mbuf pointer.

func (*Packet) ReadFrom

func (pkt *Packet) ReadFrom(r io.Reader) (n int64, e error)

ReadFrom reads once from the reader into the dataroom of this packet. It can only be used on an empty packet.

func (*Packet) SegmentBytes

func (pkt *Packet) SegmentBytes() (list [][]byte)

SegmentBytes returns the data in each segment. Each []byte aliases the mbuf.

func (*Packet) SetHeadroom

func (pkt *Packet) SetHeadroom(headroom int) error

SetHeadroom changes headroom of the first segment. It can only be used on an empty packet.

func (*Packet) SetPort

func (pkt *Packet) SetPort(port uint16)

SetPort sets ingress network interface.

func (*Packet) SetTimestamp

func (pkt *Packet) SetTimestamp(t eal.TscTime)

SetTimestamp sets receive timestamp.

func (*Packet) SetType32

func (pkt *Packet) SetType32(packetType uint32)

SetType32 sets 32-bit packet type.

func (*Packet) Tailroom

func (pkt *Packet) Tailroom() int

Tailroom returns tailroom of the last segment.

func (*Packet) Timestamp

func (pkt *Packet) Timestamp() eal.TscTime

Timestamp returns receive timestamp.

func (*Packet) Type32

func (pkt *Packet) Type32() uint32

Type32 returns 32-bit packet type.

type Pool

type Pool struct {
	mempool.Mempool
}

Pool represents a DPDK memory pool for packet buffers.

func NewPool

func NewPool(cfg PoolConfig, socket eal.NumaSocket) (mp *Pool, e error)

NewPool creates a Pool.

func PoolFromPtr

func PoolFromPtr(ptr unsafe.Pointer) *Pool

PoolFromPtr converts *C.struct_rte_mempool pointer to Pool.

func (*Pool) Alloc

func (mp *Pool) Alloc(count int) (vec Vector, e error)

Alloc allocates a vector of mbufs.

func (*Pool) Dataroom

func (mp *Pool) Dataroom() int

Dataroom returns dataroom setting.

func (*Pool) MustAlloc

func (mp *Pool) MustAlloc(count int) Vector

MustAlloc allocates a vector of mbufs, and panics upon error

type PoolConfig

type PoolConfig struct {
	Capacity int `json:"capacity"`
	PrivSize int `json:"privSize"`
	Dataroom int `json:"dataroom"`
}

PoolConfig contains configuration for NewPool.

type PoolInfo

type PoolInfo struct {
	*Pool
	// contains filtered or unexported fields
}

PoolInfo augments *Pool with NUMA socket information.

func (PoolInfo) NumaSocket

func (pool PoolInfo) NumaSocket() eal.NumaSocket

NumaSocket returns NUMA socket on which the Pool was created.

type Template

type Template interface {
	// ID returns template identifier.
	ID() string

	// Config returns current configuration.
	Config() PoolConfig

	// Update changes mempool configuration.
	// PrivSize can only be increased.
	// Dataroom can be updated only if original dataroom is non-zero.
	// Returns self.
	Update(update PoolConfig) Template

	// Pools returns a list of created Pools.
	Pools() []PoolInfo

	// Get retrieves or creates a Pool on the given NUMA socket.
	// Errors are fatal.
	Get(socket eal.NumaSocket) *Pool
}

Template represents a template to create mempools.

var (
	// Direct is a mempool template for direct mbufs.
	Direct Template

	// Indirect is a mempool template for indirect mbufs.
	Indirect Template
)

Predefined mempool templates.

func FindTemplate

func FindTemplate(id string) Template

FindTemplate locates template by ID.

func RegisterTemplate

func RegisterTemplate(id string, cfg PoolConfig) Template

RegisterTemplate adds a mempool template.

type TemplateUpdates

type TemplateUpdates map[string]PoolConfig

TemplateUpdates contains updates to several mempool templates.

func (TemplateUpdates) Apply

func (updates TemplateUpdates) Apply()

Apply applies the updates.

type Vector

type Vector []*Packet

Vector is a vector of packet buffers.

func VectorFromPtr

func VectorFromPtr(ptr unsafe.Pointer, count int) Vector

VectorFromPtr constructs Vector from **C.struct_rte_mbuf and count.

func (Vector) Close

func (vec Vector) Close() error

Close releases the mbufs.

func (*Vector) Take

func (vec *Vector) Take() (pkt *Packet)

Take returns the first mbuf and removes it from the vector. Panics if the vector is empty.

Directories

Path Synopsis
Package mbuftestenv contains helper functions to construct mbufs in test code.
Package mbuftestenv contains helper functions to construct mbufs in test code.

Jump to

Keyboard shortcuts

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