pktmbuf

package
v0.0.0-...-c2e30b8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: NIST-PD-fallback Imports: 12 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 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) DataPtr

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

DataPtr returns void* pointer to data in first segment.

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) SegmentLengths

func (pkt *Packet) SegmentLengths() (list []int)

SegmentLengths returns lengths of segments in this packet.

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) 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.

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 (Vector) Close

func (vec Vector) Close() error

Close releases the mbufs.

func (Vector) Ptr

func (vec Vector) Ptr() unsafe.Pointer

Ptr returns **C.struct_rte_mbuf pointer.

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