sharedmem

package
v0.0.0-...-ba09d25 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Overview

Package sharedmem provides the implemention of data-link layer endpoints backed by shared memory.

Shared memory endpoints can be used in the networking stack by calling New() to create a new endpoint, and then passing it as an argument to Stack.CreateNIC().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts Options) (stack.LinkEndpoint, error)

New creates a new shared-memory-based endpoint. Buffers will be broken up into buffers of "bufferSize" bytes.

func NewServerEndpoint

func NewServerEndpoint(opts Options) (stack.LinkEndpoint, error)

NewServerEndpoint creates a new shared-memory-based endpoint. Buffers will be broken up into buffers of "bufferSize" bytes.

Types

type Options

type Options struct {
	// MTU is the mtu to use for this endpoint.
	MTU uint32

	// BufferSize is the size of each scatter/gather buffer that will hold packet
	// data.
	//
	// NOTE: This directly determines number of packets that can be held in
	// the ring buffer at any time. This does not have to be sized to the MTU as
	// the shared memory queue design allows usage of more than one buffer to be
	// used to make up a given packet.
	BufferSize uint32

	// LinkAddress is the link address for this endpoint (required).
	LinkAddress tcpip.LinkAddress

	// TX is the transmit queue configuration for this shared memory endpoint.
	TX QueueConfig

	// RX is the receive queue configuration for this shared memory endpoint.
	RX QueueConfig

	// PeerFD is the fd for the connected peer which can be used to detect
	// peer disconnects.
	PeerFD int

	// OnClosed is a function that is called when the endpoint is being closed
	// (probably due to peer going away)
	OnClosed func(err tcpip.Error)

	// TXChecksumOffload if true, indicates that this endpoints capability
	// set should include CapabilityTXChecksumOffload.
	TXChecksumOffload bool

	// RXChecksumOffload if true, indicates that this endpoints capability
	// set should include CapabilityRXChecksumOffload.
	RXChecksumOffload bool

	// VirtioNetHeaderRequired if true, indicates that all outbound packets should have
	// a virtio header and inbound packets should have a virtio header as well.
	VirtioNetHeaderRequired bool
}

Options specify the details about the sharedmem endpoint to be created.

type QueueConfig

type QueueConfig struct {
	// DataFD is a file descriptor for the file that contains the data to
	// be transmitted via this queue. Descriptors contain offsets within
	// this file.
	DataFD int

	// EventFD is a file descriptor for the event that is signaled when
	// data is becomes available in this queue.
	EventFD eventfd.Eventfd

	// TxPipeFD is a file descriptor for the tx pipe associated with the
	// queue.
	TxPipeFD int

	// RxPipeFD is a file descriptor for the rx pipe associated with the
	// queue.
	RxPipeFD int

	// SharedDataFD is a file descriptor for the file that contains shared
	// state between the two ends of the queue. This data specifies, for
	// example, whether EventFD signaling is enabled or disabled.
	SharedDataFD int
}

QueueConfig holds all the file descriptors needed to describe a tx or rx queue over shared memory. It is used when creating new shared memory endpoints to describe tx and rx queues.

func QueueConfigFromFDs

func QueueConfigFromFDs(fds []int) (QueueConfig, error)

QueueConfigFromFDs constructs a QueueConfig out of a slice of ints where each entry represents an file descriptor. The order of FDs in the slice must be in the order specified below for the config to be valid. QueueConfig.FDs() should be used when the config needs to be serialized or sent as part of a control message to ensure the correct order.

func (*QueueConfig) FDs

func (q *QueueConfig) FDs() []int

FDs returns the FD's in the QueueConfig as a slice of ints. This must be used in conjunction with QueueConfigFromFDs to ensure the order of FDs matches when reconstructing the config when serialized or sent as part of control messages.

type QueuePair

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

A QueuePair represents a pair of TX/RX queues.

func NewQueuePair

func NewQueuePair() (*QueuePair, error)

NewQueuePair creates a shared memory QueuePair.

func (*QueuePair) Close

func (q *QueuePair) Close()

Close closes underlying tx/rx queue fds.

func (*QueuePair) RXQueueConfig

func (q *QueuePair) RXQueueConfig() QueueConfig

RXQueueConfig returns the QueueConfig for the transmit queue.

func (*QueuePair) TXQueueConfig

func (q *QueuePair) TXQueueConfig() QueueConfig

TXQueueConfig returns the QueueConfig for the receive queue.

Directories

Path Synopsis
Package pipe implements a shared memory ring buffer on which a single reader and a single writer can operate (read/write) concurrently.
Package pipe implements a shared memory ring buffer on which a single reader and a single writer can operate (read/write) concurrently.
Package queue provides the implementation of transmit and receive queues based on shared memory ring buffers.
Package queue provides the implementation of transmit and receive queues based on shared memory ring buffers.

Jump to

Keyboard shortcuts

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