Documentation ¶
Overview ¶
Package queue provides the implementation of transmit and receive queues based on shared memory ring buffers.
Index ¶
- Constants
- func EncodeRxCompletion(b []byte, size, reserved uint32)
- func EncodeRxCompletionBuffer(b []byte, i int, rxb RxBuffer)
- func EncodeTxCompletion(b []byte, id uint64)
- func RxCompletionSize(count int) uint64
- type Rx
- func (r *Rx) Bytes() (tx, rx []byte)
- func (r *Rx) Dequeue(bufs []RxBuffer) ([]RxBuffer, uint32)
- func (r *Rx) DisableNotification()
- func (r *Rx) EnableNotification()
- func (r *Rx) Init(tx, rx []byte, sharedEventFDState *atomicbitops.Uint32)
- func (r *Rx) PostBuffers(buffers []RxBuffer) bool
- func (r *Rx) PostedBuffersLimit() uint64
- type RxBuffer
- type Tx
- type TxBuffer
- type TxPacketInfo
Constants ¶
const ( // The following are the allowed states of the shared data area. // EventFDUinitialized is the value stored at the start of the shared data // region when it hasn't been initialized. EventFDUninitialized = 0 // EventFDDisabled is the value stored at the start of the shared data region // when notifications using eventFD has been disabled. EventFDDisabled = 1 // EventFDEnabled is the value stored at the start of the shared data region // when eventFD should be notified as the peer might be blocked waiting on // notifications. EventFDEnabled = 2 )
Variables ¶
This section is empty.
Functions ¶
func EncodeRxCompletion ¶
EncodeRxCompletion encodes an rx completion header.
func EncodeRxCompletionBuffer ¶
EncodeRxCompletionBuffer encodes the i-th rx completion buffer header.
func EncodeTxCompletion ¶
EncodeTxCompletion encodes a tx completion header.
func RxCompletionSize ¶
RxCompletionSize returns the number of bytes needed to encode an rx completion containing "count" buffers.
Types ¶
type Rx ¶
type Rx struct {
// contains filtered or unexported fields
}
Rx is a receive queue. It is implemented with one tx and one rx pipe: the tx pipe is used to "post" buffers, while the rx pipe is used to receive packets whose contents have been written to previously posted buffers.
This struct is thread-compatible.
func (*Rx) Dequeue ¶
Dequeue receives buffers that have been previously posted by PostBuffers() and that have been filled by the peer and posted back.
This is similar to append() in that new buffers are appended to "bufs", with reallocation only if "bufs" doesn't have enough capacity.
func (*Rx) DisableNotification ¶
func (r *Rx) DisableNotification()
DisableNotification updates the shared state such that the peer will not notify the eventfd.
func (*Rx) EnableNotification ¶
func (r *Rx) EnableNotification()
EnableNotification updates the shared state such that the peer will notify the eventfd when there are packets to be dequeued.
func (*Rx) Init ¶
func (r *Rx) Init(tx, rx []byte, sharedEventFDState *atomicbitops.Uint32)
Init initializes the receive queue with the given pipes, and shared state pointer -- the latter is used to enable/disable eventfd notifications.
func (*Rx) PostBuffers ¶
PostBuffers makes the given buffers available for receiving data from the peer. Once they are posted, the peer is free to write to them and will eventually post them back for consumption.
func (*Rx) PostedBuffersLimit ¶
PostedBuffersLimit returns the maximum number of buffers that can be posted before the tx queue fills up.
type RxBuffer ¶
RxBuffer is the descriptor of a receive buffer.
func DecodeRxBufferHeader ¶
DecodeRxBufferHeader decodes the header of a buffer posted on an rx queue.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is a transmit queue. It is implemented with one tx and one rx pipe: the tx pipe is used to request the transmission of packets, while the rx pipe is used to receive which transmissions have completed.
This struct is thread-compatible.
func (*Tx) CompletedPacket ¶
CompletedPacket returns the id of the last completed transmission. The returned id, if any, refers to a value passed on a previous call to Enqueue().
func (*Tx) Enqueue ¶
Enqueue queues the given linked list of buffers for transmission as one packet. While it is queued, the caller must not modify them.
func (*Tx) Init ¶
func (t *Tx) Init(tx, rx []byte, sharedEventFDState *atomicbitops.Uint32)
Init initializes the transmit queue with the given pipes.
func (*Tx) NotificationsEnabled ¶
NotificationsEnabled returns true if eventFD should be used to notify the peer of events (eg. packet transmit etc).
type TxBuffer ¶
TxBuffer is the descriptor of a transmit buffer.
func DecodeTxBufferHeader ¶
DecodeTxBufferHeader decodes the header of the i-th buffer of a packet sent over a tx queue.
type TxPacketInfo ¶
TxPacketInfo holds information about a packet sent on a tx queue.
func DecodeTxPacketHeader ¶
func DecodeTxPacketHeader(b []byte) TxPacketInfo
DecodeTxPacketHeader decodes the header of a packet sent over a tx queue.