ethdev

package
v0.0.0-...-1e60831 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: NIST-PD-fallback Imports: 24 Imported by: 0

Documentation

Overview

Package ethdev contains bindings of DPDK Ethernet device.

Index

Constants

View Source
const (
	DriverAfPacket = "net_af_packet"
	DriverXDP      = "net_af_xdp"
	DriverMemif    = "net_memif"
	DriverRing     = "net_ring"
)

Driver names.

View Source
const MaxEthDevs = C.RTE_MAX_ETHPORTS

MaxEthDevs is maximum number of EthDevs.

Variables

View Source
var (
	GqlEthDevType *gqlserver.NodeType[EthDev]
)

GraphQL types.

Functions

func OnClose

func OnClose(dev EthDev, cb func()) (cancel func())

OnClose registers a callback when a port is stopped and closed. Returns a function that cancels the callback registration.

Types

type BurstModeInfo

type BurstModeInfo struct {
	Flags uint64 `json:"flags"`
	Info  string `json:"info"`
}

BurstModeInfo describes queue burst mode.

type Config

type Config struct {
	RxQueues []RxQueueConfig
	TxQueues []TxQueueConfig
	MTU      int            // if non-zero, change MTU
	Promisc  bool           // promiscuous mode
	Conf     unsafe.Pointer // pointer to rte_eth_conf, nil means default
}

Config contains EthDev configuration.

func (*Config) AddRxQueues

func (cfg *Config) AddRxQueues(count int, qcfg RxQueueConfig)

AddRxQueues adds RxQueueConfig for several queues

func (*Config) AddTxQueues

func (cfg *Config) AddTxQueues(count int, qcfg TxQueueConfig)

AddTxQueues adds TxQueueConfig for several queues

type DevInfo

type DevInfo struct {
	DevInfoC
}

DevInfo provides contextual information of an Ethernet port.

func (DevInfo) Driver

func (info DevInfo) Driver() string

Driver returns DPDK net driver name.

func (DevInfo) HasTxChecksumOffload

func (info DevInfo) HasTxChecksumOffload() bool

HasTxChecksumOffload determines whether device can compute IPv4 and UDP checksum upon transmission.

func (DevInfo) HasTxMultiSegOffload

func (info DevInfo) HasTxMultiSegOffload() bool

HasTxMultiSegOffload determines whether device can transmit multi-segment packets.

func (DevInfo) IsVDev

func (info DevInfo) IsVDev() bool

IsVDev determines whether the driver is a virtual device.

func (DevInfo) MarshalJSON

func (info DevInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

type EthDev

type EthDev interface {
	eal.WithNumaSocket
	fmt.Stringer
	io.Closer

	// ID returns DPDK ethdev ID.
	ID() int
	// ZapField returns a zap.Field for logging.
	ZapField(key string) zap.Field
	// Name returns port name.
	Name() string

	// DevInfo returns information about the hardware device.
	DevInfo() DevInfo
	// HardwareAddr returns the device MAC address.
	HardwareAddr() net.HardwareAddr
	// MTU returns MTU of this EthDev.
	MTU() int
	// IsDown determines whether this device is down.
	IsDown() bool

	// Start configures and starts this device.
	Start(cfg Config) error

	// RxQueues returns RX queues of a running port.
	RxQueues() []RxQueue
	// TxQueues returns TX queues of a running port.
	TxQueues() []TxQueue

	// Stats retrieves hardware statistics.
	Stats() Stats
	// ResetStats clears hardware statistics.
	ResetStats() error
}

EthDev represents an Ethernet adapter.

func FromHardwareAddr

func FromHardwareAddr(a net.HardwareAddr) EthDev

FromHardwareAddr returns the first EthDev with specified MAC address.

func FromID

func FromID(id int) EthDev

FromID converts port ID to EthDev.

func FromName

func FromName(name string) EthDev

FromName retrieves Ethernet adapter by name.

func FromPCI

func FromPCI(addr pciaddr.PCIAddress) EthDev

FromPCI finds an EthDev from PCI address.

func List

func List() (list []EthDev)

List returns a list of Ethernet adapters.

func NewMemif

func NewMemif(loc memiftransport.Locator) (EthDev, error)

NewMemif creates a net_memif device.

func NewVDev

func NewVDev(name string, args map[string]any, socket eal.NumaSocket) (EthDev, error)

NewVDev creates a virtual Ethernet device. The VDev will be destroyed when the EthDev is stopped and detached.

func ProbePCI

func ProbePCI(addr pciaddr.PCIAddress, args map[string]any) (EthDev, error)

ProbePCI requests to probe a PCI Ethernet adapter.

type RxQueue

type RxQueue struct {
	Port  uint16
	Queue uint16
}

RxQueue represents an RX queue.

func (RxQueue) Info

func (q RxQueue) Info() (info RxqInfo)

Info returns information about the RX queue.

func (RxQueue) RxBurst

func (q RxQueue) RxBurst(vec pktmbuf.Vector) int

RxBurst receives a burst of input packets. Returns the number of packets received and written into vec.

type RxQueueConfig

type RxQueueConfig struct {
	Capacity int            // ring capacity
	Socket   eal.NumaSocket // where to allocate the ring
	RxPool   *pktmbuf.Pool  // where to store packets
	Conf     unsafe.Pointer // pointer to rte_eth_rxconf
}

RxQueueConfig contains EthDev RX queue configuration.

type RxqInfo

type RxqInfo struct {
	RxqInfoC
	// contains filtered or unexported fields
}

RxqInfo provides contextual information of an RX queue.

func (RxqInfo) BurstMode

func (info RxqInfo) BurstMode() BurstModeInfo

BurstMode retrieves queue burst mode.

func (RxqInfo) MarshalJSON

func (info RxqInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

type Stats

type Stats struct {
	StatsBasic
	// contains filtered or unexported fields
}

Stats contains statistics for an Ethernet port.

func (Stats) MarshalJSON

func (stats Stats) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (Stats) String

func (stats Stats) String() string

func (Stats) X

func (stats Stats) X() (m map[string]any)

X retrieves extended statistics.

type TxQueue

type TxQueue struct {
	Port  uint16
	Queue uint16
}

TxQueue represents a TX queue.

func (TxQueue) Info

func (q TxQueue) Info() (info TxqInfo)

Info returns information about the TX queue.

func (TxQueue) TxBurst

func (q TxQueue) TxBurst(vec pktmbuf.Vector) int

TxBurst transmits a burst of output packets. Returns the number of packets enqueued.

type TxQueueConfig

type TxQueueConfig struct {
	Capacity int            // ring capacity
	Socket   eal.NumaSocket // where to allocate the ring
	Conf     unsafe.Pointer // pointer to rte_eth_txconf
}

TxQueueConfig contains EthDev TX queue configuration.

type TxqInfo

type TxqInfo struct {
	TxqInfoC
	// contains filtered or unexported fields
}

TxqInfo provides contextual information of a TX queue.

func (TxqInfo) BurstMode

func (info TxqInfo) BurstMode() BurstModeInfo

BurstMode retrieves queue burst mode.

func (TxqInfo) MarshalJSON

func (info TxqInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

Directories

Path Synopsis
Package ethnetif manages DPDK Ethernet devices associated with kernel network interfaces.
Package ethnetif manages DPDK Ethernet devices associated with kernel network interfaces.
Package ethringdev contains bindings of DPDK net_eth_ring driver.
Package ethringdev contains bindings of DPDK net_eth_ring driver.

Jump to

Keyboard shortcuts

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