Documentation ¶
Overview ¶
Package eal contains bindings of DPDK Environment Abstraction Layer.
Index ¶
- Constants
- Variables
- func AllocObjectID(dbgtype string) string
- func CallMain(f any) any
- func ClassifyByNumaSocket[T WithNumaSocket, S ~[]T](s S, r RewriteAnyNumaSocket) (m map[NumaSocket]S)
- func Free[T any](ptr *T)
- func FromTscDuration(d int64) time.Duration
- func InitTscUnit()
- func JoinDevArgs(m map[string]any) string
- func MakeErrno[I constraints.Signed](v I) error
- func PostMain(fn cptr.Function)
- func ProbePCI(addr pciaddr.PCIAddress, args map[string]any) error
- func ToTscDuration(d time.Duration) int64
- func UpdateLCoreSockets(lcoreSockets map[int]int, mainLCoreID int) (undo func())
- func Zmalloc[T any, S constraints.Integer](dbgtype string, size S, socket NumaSocket) *T
- func ZmallocAligned[T any, S constraints.Integer](dbgtype string, size S, align int, socket NumaSocket) *T
- type Errno
- type LCore
- func (lc LCore) ID() int
- func (lc LCore) IsBusy() bool
- func (lc LCore) MarshalJSON() ([]byte, error)
- func (lc LCore) NumaSocket() (socket NumaSocket)
- func (lc LCore) RemoteLaunch(fn cptr.Function)
- func (lc LCore) String() string
- func (lc LCore) Valid() bool
- func (lc LCore) Wait() (exitCode int)
- func (lc LCore) ZapField(key string) zap.Field
- type LCorePredicate
- type LCores
- type NumaSocket
- func (socket NumaSocket) ID() int
- func (socket NumaSocket) IsAny() bool
- func (socket NumaSocket) MarshalJSON() ([]byte, error)
- func (socket NumaSocket) Match(other NumaSocket) bool
- func (socket NumaSocket) NumaSocket() NumaSocket
- func (socket NumaSocket) String() string
- func (socket *NumaSocket) UnmarshalJSON(p []byte) error
- func (socket NumaSocket) ZapField(key string) zap.Field
- type PollThread
- type RewriteAnyNumaSocket
- type TscTime
- type VDev
- type WithNumaSocket
Constants ¶
const MaxLCoreID = C.RTE_MAX_LCORE
MaxLCoreID is the (exclusive) maximum LCore ID.
Variables ¶
var ( // MainLCore is the main lcore. MainLCore LCore // Workers are worker lcores. Workers LCores // 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().
var ( // TscHz is TSC time units in one second. TscHz uint64 // TscGHz is TSC time units in one nanosecond. TscGHz float64 // TscSeconds is seconds in one TSC time unit. TscSeconds float64 // TscNanos is nanoseconds in one TSC time unit. TscNanos float64 )
var GqlWithNumaSocket = &graphql.Field{ Type: graphql.Int, Name: "numaSocket", Description: "NUMA socket.", Resolve: func(p graphql.ResolveParams) (any, error) { socket := p.Source.(WithNumaSocket).NumaSocket() if socket.IsAny() { return nil, nil } return socket.ID(), nil }, }
GqlWithNumaSocket is a GraphQL field for source object that implements WithNumaSocket.
var Version string
Version is DPDK version. This is assigned during package ealinit initialization.
Functions ¶
func AllocObjectID ¶
AllocObjectID allocates an identifier/name for DPDK objects.
func CallMain ¶
CallMain runs 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 ClassifyByNumaSocket ¶
func ClassifyByNumaSocket[T WithNumaSocket, S ~[]T](s S, r RewriteAnyNumaSocket) (m map[NumaSocket]S)
ClassifyByNumaSocket classifies items by NUMA socket.
T: type that satisfies WithNumaSocket interface s: source []T
Returns map[eal.NumaSocket][]T
func FromTscDuration ¶
FromTscDuration converts TSC duration to time.Duration.
func InitTscUnit ¶
func InitTscUnit()
InitTscUnit saves TSC time unit. This is called by ealinit package.
func JoinDevArgs ¶
JoinDevArgs converts device argument key-value pairs to a string. nil values are skipped. As a special case, if the map has a "" key, its value would override all other arguments.
func MakeErrno ¶
func MakeErrno[I constraints.Signed](v I) error
MakeErrno creates Errno from non-zero number or returns nil for zero.
func ProbePCI ¶
func ProbePCI(addr pciaddr.PCIAddress, args map[string]any) error
ProbePCI requests to probe a PCI device.
func ToTscDuration ¶
ToTscDuration converts time.Duration to TSC duration.
func UpdateLCoreSockets ¶
UpdateLCoreSockets saves LCores and Sockets information. Returns an undo function that reverts the changes, useful for mocking in unit tests.
func Zmalloc ¶
func Zmalloc[T any, S constraints.Integer](dbgtype string, size S, socket NumaSocket) *T
Zmalloc allocates zero'ed memory on specified NumaSocket. Panics if out of memory.
func ZmallocAligned ¶
func ZmallocAligned[T any, S constraints.Integer](dbgtype string, size S, align int, socket NumaSocket) *T
ZmallocAligned allocates zero'ed memory on specified NumaSocket. Panics if out of memory. align specifies alignment requirement in cachelines (must be power of 2), or 0 to indicate no requirement.
Types ¶
type LCore ¶
type LCore struct {
// contains filtered or unexported fields
}
LCore represents a logical core. Zero LCore is invalid.
func (LCore) MarshalJSON ¶
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 ¶
RemoteLaunch asynchronously launches a function on this lcore. Errors are fatal.
type LCorePredicate ¶
LCorePredicate is a predicate function on LCore.
func LCoreOnNumaSocket ¶
func LCoreOnNumaSocket(socket NumaSocket) LCorePredicate
LCoreOnNumaSocket creates a predicate that accepts lcores on a particular NUMA socket. If socket==any, it accepts any NUMA socket.
func (LCorePredicate) Negate ¶
func (pred LCorePredicate) Negate() LCorePredicate
Negate returns the negated predicate.
type LCores ¶
type LCores []LCore
LCores is a slice of LCore.
func (LCores) ByNumaSocket ¶
func (lcores LCores) ByNumaSocket() map[NumaSocket]LCores
ByNumaSocket classifies lcores by NUMA socket.
func (LCores) Filter ¶
func (lcores LCores) Filter(pred ...LCorePredicate) (filtered LCores)
Filter returns lcores that satisfy zero or more predicates.
func (LCores) MarshalLogArray ¶
func (lcores LCores) MarshalLogArray(enc zapcore.ArrayEncoder) error
MarshalLogArray implements zapcore.ArrayMarshaler interface.
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 RandomSocket ¶
func RandomSocket() (socket NumaSocket)
RandomSocket returns a random NumaSocket that has at least one worker lcore.
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
func (*NumaSocket) UnmarshalJSON ¶
func (socket *NumaSocket) UnmarshalJSON(p []byte) error
UnmarshalJSON decodes NUMA socket as number. null is interpreted as Any.
type PollThread ¶
PollThread represents a thread that can accept and run posted functions.
type RewriteAnyNumaSocket ¶
type RewriteAnyNumaSocket int
RewriteAnyNumaSocket provides a function to change "any NUMA socket" to a concrete NUMA socket.
const ( // KeepAnyNumaSocket keeps "any NUMA socket" unchanged. KeepAnyNumaSocket RewriteAnyNumaSocket = -2 - iota // RewriteAnyNumaSocketFirst rewrites "any NUMA socket" to eal.Sockets[0]. RewriteAnyNumaSocketFirst // RewriteAnyNumaSocketRandom rewrites "any NUMA socket" to eal.RandomSocket(). RewriteAnyNumaSocketRandom )
func RewriteAnyNumaSocketTo ¶
func RewriteAnyNumaSocketTo(socket NumaSocket) (r RewriteAnyNumaSocket)
RewriteAnyNumaSocketTo rewrites "any NUMA socket" to the specified NUMA socket.
func (RewriteAnyNumaSocket) Rewrite ¶
func (r RewriteAnyNumaSocket) Rewrite(socket NumaSocket) NumaSocket
Rewrite rewrites the input if it is "any NUMA socket", otherwise keeps it unchanged.
type VDev ¶
type VDev struct {
// contains filtered or unexported fields
}
VDev represents a DPDK virtual device.
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.