memiftransport

package
v0.0.0-...-6c4fd92 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: NIST-PD-fallback Imports: 18 Imported by: 1

Documentation

Overview

Package memiftransport implements a transport over a shared memory packet interface (memif).

Index

Constants

View Source
const (
	MaxSocketNameSize = 108

	MinID = 0
	MaxID = math.MaxUint32

	MinDataroom     = 512
	MaxDataroom     = math.MaxUint16
	DefaultDataroom = 2048

	MinRingCapacity     = 1 << 1
	MaxRingCapacity     = 1 << 14
	DefaultRingCapacity = 1 << 10
)

Defaults and limits.

Variables

This section is empty.

Functions

func ExecBridgeHelper

func ExecBridgeHelper()

ExecBridgeHelper runs the bridge helper if os.Args requests it. In unit test binary, this should be invoked in TestMain() function.

func ForkBridgeHelper

func ForkBridgeHelper(locA, locB Locator, f func()) error

ForkBridgeHelper forks a bridge helper subprocess and invokes f() while it's running.

Types

type Bridge

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

Bridge bridges two memif interfaces. The memifs can operate in either server or client mode.

This is mainly useful for unit testing. It is impossible to run both memif peers in the same process, so the test program should run this bridge in a separate process.

func NewBridge

func NewBridge(locA, locB Locator) (bridge *Bridge, e error)

NewBridge creates a Bridge.

func (*Bridge) Close

func (bridge *Bridge) Close() error

Close stops the bridge.

type CoexistMap

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

CoexistMap determines whether two memif transports can coexist.

func NewCoexistMap

func NewCoexistMap() CoexistMap

NewCoexistMap creates an empty CoexistMap.

func (*CoexistMap) Add

func (c *CoexistMap) Add(loc Locator)

Add inserts a transport.

func (CoexistMap) Check

func (c CoexistMap) Check(loc Locator) error

Check determines whether creating a transport from given locator would conflict with existing transports. loc.ApplyDefaults() should have been called.

func (CoexistMap) Has

func (c CoexistMap) Has(socketName string) bool

Has determines whether there's an existing transport with the same socketName.

func (*CoexistMap) Remove

func (c *CoexistMap) Remove(loc Locator)

Remove deletes a transport.

type Locator

type Locator struct {
	// Role selects memif role.
	// Default is "client" in NDNgo library and "server" in NDN-DPDK service.
	Role Role `json:"role,omitempty"`

	// SocketName is the control socket filename.
	// It must be an absolute path, not longer than MaxSocketNameSize.
	SocketName string `json:"socketName"`

	// SocketOwner changes owner uid:gid of the socket file.
	// This is only applicable in NDN-DPDK service when creating the first memif in "server" role on a SocketName.
	SocketOwner *[2]int `json:"socketOwner,omitempty"`

	// ID is the interface identifier.
	// It must be between MinID and MaxID.
	ID int `json:"id"`

	// Dataroom is the buffer size of each packet.
	// Default is DefaultDataroom.
	// It is automatically clamped between MinDataroom and MaxDataroom.
	Dataroom int `json:"dataroom,omitempty"`

	// RingCapacity is the capacity of queue pair rings.
	// Default is DefaultRingCapacity.
	// It is automatically adjusted up to the next power of 2, and clamped between MinRingCapacity and MaxRingCapacity.
	RingCapacity int `json:"ringCapacity,omitempty"`
}

Locator identifies memif interface.

func (*Locator) ApplyDefaults

func (loc *Locator) ApplyDefaults(defaultRole Role)

ApplyDefaults sets empty values to defaults.

func (Locator) ReverseRole

func (loc Locator) ReverseRole() (reversed Locator)

ReverseRole returns a copy of Locator with server and client roles reversed.

func (*Locator) ToCreateFaceLocator

func (loc *Locator) ToCreateFaceLocator() (json.RawMessage, error)

ToCreateFaceLocator builds a JSON object suitable for NDN-DPDK face creation API.

func (*Locator) ToVDevArgs

func (loc *Locator) ToVDevArgs() (args map[string]any, e error)

ToVDevArgs builds arguments for DPDK virtual device, acceptable to eal.NewVDev() function.

func (Locator) Validate

func (loc Locator) Validate() error

Validate checks Locator fields.

type Role

type Role string

Role indicates memif role.

const (
	RoleServer Role = "server"
	RoleClient Role = "client"
)

Role constants.

type Transport

type Transport interface {
	l3.Transport

	Locator() Locator
}

Transport is an l3.Transport that communicates via libmemif.

func New

func New(loc Locator) (t Transport, e error)

New creates a Transport.

Jump to

Keyboard shortcuts

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