ethport

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: 20 Imported by: 0

README

ndn-dpdk/iface/ethport

This package implements faces using DPDK ethdev as transport.

Face type represents an Ethernet-based face or a memif face. See package ethface and package memifface for more information.

Port type organizes faces on the same DPDK ethdev. It manages ethdev resources and prevents conflicts among the faces.

Receive Path

There are three receive path implementations. One of them is chosen during port creation; the choice cannot be changed afterwards.

RxFlow is a hardware-accelerated receive path. It uses one or more RX queues per face, and creates a flow via rte_flow API to steer incoming frames to those queues. The hardware performs header matching; there is minimal checking on software side.

RxTable is a software receive path. It continuously polls ethdev RX queue 0 for incoming frames. For each incoming frame, the software performs header matching (implemented in EthRxMatch struct), and then labels each matched frame with the face ID. If no match is found for an incoming frame, it is dropped.

RxMemif is a memif-specific receive path, where each port has only one face. It continuously polls ethdev RX queue 0 for incoming frames, and then labels each frame with the only face ID.

Send Path

EthFace_TxBurst function implements the send path. Currently, the send path only uses ethdev TX queue 0. It prepends Ethernet/UDP/VXLAN headers to each frame (implemented in EthTxHdr struct), and requires every outgoing packet to have sufficient headroom for the headers.

The send path is thread-safe only if the underlying DPDK PMD is thread safe, which generally is not the case. Therefore, iface.TxLoop calls EthFace_TxBurst from the same thread for all faces on the same port.

Documentation

Overview

Package ethport implements faces using DPDK Ethernet device as transport.

Index

Constants

View Source
const (
	DefaultRxQueueSize = 4096
	DefaultTxQueueSize = 4096
)

Limits and defaults.

View Source
const UDPPortVXLAN = C.RTE_VXLAN_DEFAULT_PORT

UDPPortVXLAN is the default UDP destination port for VXLAN.

Variables

View Source
var (
	GqlRxGroupInterface *gqlserver.Interface
	GqlRxgFlowType      *graphql.Object
	GqlRxgTableType     *graphql.Object
)

GraphQL types.

Functions

func CheckLocatorCoexist

func CheckLocatorCoexist(a, b Locator) error

CheckLocatorCoexist determines whether two locators can coexist on the same port.

func NewFace

func NewFace(port *Port, loc Locator) (iface.Face, error)

NewFace creates a face on the given port.

func RxTablePtrFromPort

func RxTablePtrFromPort(port *Port) unsafe.Pointer

RxTablePtrFromPort extracts *C.RxTable pointer from Port.

Types

type Config

type Config struct {
	// ethnetif.Config specifies how to find or create EthDev.
	ethnetif.Config
	// EthDev specifies EthDev. It overrides ethnetif.Config.
	EthDev ethdev.EthDev `json:"-"`
	// AutoClose indicates that EthDev should be closed when the last face is closed.
	AutoClose bool `json:"-"`

	RxQueueSize int `json:"rxQueueSize,omitempty" gqldesc:"Hardware RX queue capacity."`
	TxQueueSize int `json:"txQueueSize,omitempty" gqldesc:"Hardware TX queue capacity."`

	MTU int `json:"mtu,omitempty" gqldesc:"Change interface MTU (excluding Ethernet/VLAN headers)."`

	RxFlowQueues int `json:"rxFlowQueues,omitempty" gqldesc:"Enable RxFlow and set maximum queue count."`
}

Config contains Port creation arguments.

type Face

type Face struct {
	iface.Face
	// contains filtered or unexported fields
}

Face represents a face on Ethernet Port.

type FaceConfig

type FaceConfig struct {
	iface.Config

	// EthDev causes the face to be created on a specific Ethernet adapter.
	// This allows setting a local MAC address that differs from the physical MAC address.
	//
	// If omitted, local MAC address is used to find the Ethernet adapter.
	//
	// In either case, a Port must be created on the Ethernet adapter before creating faces.
	EthDev ethdev.EthDev `json:"-"`

	// Port is GraphQL ID of the EthDev.
	// This field has the same semantics as EthDev.
	// If both EthDev and Port are specified, EthDev takes priority.
	Port string `json:"port,omitempty"`

	// NRxQueues is the number of RX queues for this face.
	// It is meaningful only if the port is using RxFlow.
	// For most DPDK drivers, it is effective in improving performance on VXLAN face only.
	//
	// Default is 1.
	NRxQueues int `json:"nRxQueues,omitempty"`

	// DisableTxMultiSegOffload forces every packet to be copied into a linear buffer in software.
	DisableTxMultiSegOffload bool `json:"disableTxMultiSegOffload,omitempty"`

	// DisableTxChecksumOffload disables the usage of IPv4 and UDP checksum offloads.
	DisableTxChecksumOffload bool `json:"disableTxChecksumOffload,omitempty"`
	// contains filtered or unexported fields
}

FaceConfig contains additional face configuration. They appear as input-only fields of ethface.EtherLocator.

func (FaceConfig) EthFaceConfig

func (cfg FaceConfig) EthFaceConfig() FaceConfig

EthFaceConfig implements Locator interface.

func (FaceConfig) FindPort

func (cfg FaceConfig) FindPort(local net.HardwareAddr) (port *Port, e error)

FindPort finds an existing Port from cfg.EthDev, cfg.Port, or local MAC address.

func (*FaceConfig) HideFaceConfigFromJSON

func (cfg *FaceConfig) HideFaceConfigFromJSON()

HideFaceConfigFromJSON hides FaceConfig fields from JSON marshaling.

type Locator

type Locator interface {
	iface.Locator
	EthLocatorC() LocatorC
	EthFaceConfig() FaceConfig
}

Locator is an Ethernet-based face locator.

type LocatorConflictError

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

LocatorConflictError indicates that the locator of a new face conflicts with an existing face.

func (LocatorConflictError) Error

func (e LocatorConflictError) Error() string

type Port

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

Port organizes EthFaces on an EthDev.

func Find

func Find(dev ethdev.EthDev) *Port

Find finds Port by EthDev.

func New

func New(cfg Config) (port *Port, e error)

New opens a Port.

func (*Port) Close

func (port *Port) Close() error

Close closes the port.

func (*Port) EthDev

func (port *Port) EthDev() ethdev.EthDev

EthDev returns the Ethernet device.

func (*Port) Faces

func (port *Port) Faces() (list []iface.Face)

Faces returns a list of active faces.

type RxMatch

type RxMatch C.EthRxMatch

RxMatch contains prepared buffer to match incoming packets with a locator.

func NewRxMatch

func NewRxMatch(loc Locator) (match RxMatch)

NewRxMatch creates RxMatch from a locator.

func (RxMatch) HdrLen

func (match RxMatch) HdrLen() int

HdrLen returns header length.

func (RxMatch) Match

func (match RxMatch) Match(pkt *pktmbuf.Packet) bool

Match determines whether an incoming packet matches the locator.

type TxHdr

type TxHdr C.EthTxHdr

TxHdr contains prepare buffer to prepend headers to outgoing packets.

func NewTxHdr

func NewTxHdr(loc Locator, hasChecksumOffloads bool) (hdr TxHdr)

NewTxHdr creates TxHdr from a locator.

func (TxHdr) IPLen

func (hdr TxHdr) IPLen() int

IPLen returns the total length of IP, UDP, and VXLAN headers.

func (TxHdr) Prepend

func (hdr TxHdr) Prepend(pkt *pktmbuf.Packet, newBurst bool)

Prepend prepends headers to an outgoing packet.

newBurst: whether pkt is the first packet in a burst. It increments UDP source port in VXLAN
          headers. If NDN network layer packet is fragmented, only the first fragment might
          start a new burst, so that all fragments have the same UDP source port.

Jump to

Keyboard shortcuts

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