eal

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: 13 Imported by: 2

Documentation

Overview

Package eal contains bindings of DPDK Environment Abstraction Layer.

Index

Constants

View Source
const MaxLCoreID = C.RTE_MAX_LCORE

MaxLCoreID is the maximum LCore ID.

Variables

View Source
var (
	// MainLCore is the main lcore.
	MainLCore LCore
	// Workers are worker lcores.
	Workers []LCore
	// Sockets are NUMA sockets of worker lcores.
	Sockets []NumaSocket

	// MainThread is a PollThread running on the initial lcore.
	MainThread PollThread
	// MainReadSide is an RCU read-side object of the MainThread.
	MainReadSide *urcu.ReadSide
)

EAL variables, available after ealinit.Init().

View Source
var GqlWithNumaSocket = &graphql.Field{
	Type:        graphql.Int,
	Name:        "numaSocket",
	Description: "NUMA socket.",
	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		socket := p.Source.(WithNumaSocket).NumaSocket()
		return gqlserver.Optional(socket.ID(), !socket.IsAny()), nil
	},
}

GqlWithNumaSocket is a GraphQL field for source object that implements WithNumaSocket.

Functions

func AllocObjectID

func AllocObjectID(dbgtype string) string

AllocObjectID allocates an identifier/name for DPDK objects.

func CallMain

func CallMain(f interface{}) interface{}

CallMain executes a function on the main thread and waits for its completion. f must be a function with zero parameters and zero or one return values. Returns f's return value, or nil if f does not have a return value.

func Free

func Free(ptr interface{})

Free deallocates memory from Zmalloc.

func FromTscDuration

func FromTscDuration(d int64) time.Duration

FromTscDuration converts TSC duration to time.Duration.

func GetNanosInTscUnit

func GetNanosInTscUnit() float64

GetNanosInTscUnit returns number of nanoseconds in a TSC time unit.

func GetTscUnit

func GetTscUnit() time.Duration

GetTscUnit returns TSC time unit as time.Duration.

func PostMain

func PostMain(fn cptr.Function)

PostMain asynchronously posts a function to be executed on the main thread.

func ToTscDuration

func ToTscDuration(d time.Duration) int64

ToTscDuration converts time.Duration to TSC duration.

func Zmalloc

func Zmalloc(dbgtype string, size interface{}, socket NumaSocket) unsafe.Pointer

Zmalloc allocates zero'ed memory on specified NumaSocket. Panics if out of memory.

func ZmallocAligned

func ZmallocAligned(dbgtype string, size interface{}, align int, socket NumaSocket) unsafe.Pointer

ZmallocAligned allocates zero'ed memory on specified NumaSocket. Panics if out of memory. size can be either uintptr or a signed integer type. align specifies alignment requirement in cachelines (must be power of 2), or 0 to indicate no requirement.

Types

type Errno

type Errno syscall.Errno

Errno represents a DPDK error.

func GetErrno

func GetErrno() Errno

GetErrno returns the current DPDK error.

func (Errno) Error

func (e Errno) Error() string

type LCore

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

LCore represents a logical core. Zero LCore is invalid.

func CurrentLCore

func CurrentLCore() LCore

CurrentLCore returns the current lcore.

func LCoreFromID

func LCoreFromID(id int) (lc LCore)

LCoreFromID converts lcore ID to LCore.

func (LCore) ID

func (lc LCore) ID() int

ID returns lcore ID.

func (LCore) IsBusy

func (lc LCore) IsBusy() bool

IsBusy returns true if this lcore is running a function.

func (LCore) MarshalJSON

func (lc LCore) MarshalJSON() ([]byte, error)

MarshalJSON encodes lcore as number. Invalid lcore is encoded as null.

func (LCore) NumaSocket

func (lc LCore) NumaSocket() (socket NumaSocket)

NumaSocket returns the NUMA socket where this lcore is located.

func (LCore) RemoteLaunch

func (lc LCore) RemoteLaunch(fn cptr.Function)

RemoteLaunch asynchronously launches a function on this lcore. Errors are fatal.

func (LCore) String

func (lc LCore) String() string

func (LCore) Valid

func (lc LCore) Valid() bool

Valid returns true if this is a valid lcore (not zero value).

func (LCore) Wait

func (lc LCore) Wait() (exitCode int)

Wait blocks until this lcore finishes running, and returns lcore function's return value. If this lcore is not running, returns 0 immediately.

type NumaSocket

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

NumaSocket represents a NUMA socket. Zero value is SOCKET_ID_ANY.

func NumaSocketFromID

func NumaSocketFromID(id int) (socket NumaSocket)

NumaSocketFromID converts socket ID to NumaSocket.

func NumaSocketsOf

func NumaSocketsOf(list interface{}) (result []NumaSocket)

NumaSocketsOf collects associated/preferred NUMA sockets of a list of objects. list must be a slice of objects that implement WithNumaSocket; panics otherwise.

func (NumaSocket) ID

func (socket NumaSocket) ID() int

ID returns NUMA socket ID.

func (NumaSocket) IsAny

func (socket NumaSocket) IsAny() bool

IsAny returns true if this represents SOCKET_ID_ANY.

func (NumaSocket) MarshalJSON

func (socket NumaSocket) MarshalJSON() ([]byte, error)

MarshalJSON encodes NUMA socket as number. Any is encoded as null.

func (NumaSocket) Match

func (socket NumaSocket) Match(other NumaSocket) bool

Match returns true if either NumaSocket is SOCKET_ID_ANY, or both are the same NumaSocket.

func (NumaSocket) NumaSocket

func (socket NumaSocket) NumaSocket() NumaSocket

NumaSocket implements WithNumaSocket.

func (NumaSocket) String

func (socket NumaSocket) String() string

type PollThread

type PollThread interface {
	Post(fn cptr.Function)
}

PollThread represents a thread that can accept and execute posted functions.

type TscTime

type TscTime uint64

TscTime represents a time point on TSC clock.

func TscNow

func TscNow() TscTime

TscNow returns current TscTime.

func (TscTime) Add

func (t TscTime) Add(d time.Duration) TscTime

Add returns t+d.

func (TscTime) Sub

func (t TscTime) Sub(t0 TscTime) time.Duration

Sub returns t-t0.

func (TscTime) ToTime

func (t TscTime) ToTime() time.Time

ToTime converts to time.Time.

type VDev

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

VDev represents a DPDK virtual device.

func NewVDev

func NewVDev(name, args string, socket NumaSocket) (vdev *VDev, e error)

NewVDev creates a virtual device.

func (*VDev) Close

func (vdev *VDev) Close() error

Close destroys the virtual device.

func (*VDev) Name

func (vdev *VDev) Name() string

Name returns the device name.

func (*VDev) NumaSocket

func (vdev *VDev) NumaSocket() NumaSocket

NumaSocket returns the NUMA socket of this device, if known.

type WithNumaSocket

type WithNumaSocket interface {
	NumaSocket() NumaSocket
}

WithNumaSocket interface is implemented by types that have an associated or preferred NUMA socket.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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