rdma

package
v0.6.16 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package rdma provides Go bindings for the rdma framework.

Code generated from Apple documentation. DO NOT EDIT.

Index

Constants

View Source
const (
	IBV_WC_LOC_PROT_ERR   = 4
	IBV_WC_LOC_ACCESS_ERR = 8
	IBV_WC_REM_ACCESS_ERR = 10
)

Work-completion statuses used to classify provider errors. These values are part of the verbs ABI; they do not imply that an unsupported verb is usable.

View Source
const (
	IBV_ACCESS_LOCAL_WRITE  = 1
	IBV_ACCESS_REMOTE_WRITE = 2
	IBV_ACCESS_REMOTE_READ  = 4

	IBV_QPT_UC = 3

	IBV_QPS_RESET = 0
	IBV_QPS_INIT  = 1
	IBV_QPS_RTR   = 2
	IBV_QPS_RTS   = 3
	IBV_QPS_ERR   = 6

	IBV_QP_STATE        = 1
	IBV_QP_ACCESS_FLAGS = 8
	IBV_QP_PKEY_INDEX   = 16
	IBV_QP_PORT         = 32
	IBV_QP_AV           = 128
	IBV_QP_PATH_MTU     = 256
	IBV_QP_RQ_PSN       = 4096
	IBV_QP_SQ_PSN       = 65536
	IBV_QP_DEST_QPN     = 1048576

	IBV_MTU_1024 = 3
	IBV_MTU_4096 = 5

	// enum ibv_port_state. A port carries traffic only in ACTIVE.
	IBV_PORT_NOP          = 0
	IBV_PORT_DOWN         = 1
	IBV_PORT_INIT         = 2
	IBV_PORT_ARMED        = 3
	IBV_PORT_ACTIVE       = 4
	IBV_PORT_ACTIVE_DEFER = 5

	// enum ibv_link_layer. Thunderbolt is an Apple addition and is why the
	// value is 100 rather than the next one in sequence.
	IBV_LINK_LAYER_UNSPECIFIED = 0
	IBV_LINK_LAYER_INFINIBAND  = 1
	IBV_LINK_LAYER_ETHERNET    = 2
	IBV_LINK_LAYER_THUNDERBOLT = 100

	IBV_WR_RDMA_WRITE = 0
	IBV_WR_SEND       = 2
	IBV_SEND_SIGNALED = 2

	IBV_WC_SUCCESS = 0
)
View Source
const IBV_QPT_RCExperimental = 2

IBV_QPT_RCExperimental is the Apple verbs ABI value for a reliable-connected queue pair. It is exported solely for the one-shot RC capability probe.

Its presence does not claim that Apple's Thunderbolt RDMA provider accepts RC queue pairs. Production code must not use it until a separately recorded provider observation establishes that capability.

Variables

View Source
var (
	// ErrNoDevice reports that no RDMA device matched the requested operation.
	ErrNoDevice = errors.New("rdma: no device")

	// ErrSymbolUnavailable reports that an RDMA provider symbol is unavailable.
	ErrSymbolUnavailable = errors.New("rdma: symbol unavailable")

	// ErrNilInput reports a nil handle or pointer passed before a provider call.
	ErrNilInput = errors.New("rdma: nil input")

	// ErrNilProviderResult reports a provider call that returned a nil handle.
	ErrNilProviderResult = errors.New("rdma: nil provider result")

	// ErrNegativeProviderReturn reports a provider call that returned a negative status.
	ErrNegativeProviderReturn = errors.New("rdma: negative provider return")

	// ErrProviderStatus reports a provider call that returned a non-zero status.
	ErrProviderStatus = errors.New("rdma: provider status")

	// ErrProviderTimeout reports a bounded provider subprocess that timed out.
	ErrProviderTimeout = errors.New("rdma: provider timeout")

	// ErrUnsupportedOperation reports an RDMA operation the provider does not support.
	ErrUnsupportedOperation = errors.New("rdma: unsupported operation")
)
View Source
var ErrRDMAReadUnavailable = fmt.Errorf("%w: RDMA READ is not exposed by this binding", ErrUnsupportedOperation)

ErrRDMAReadUnavailable reports that this binding does not expose RDMA READ. It does not make a claim about whether the provider accepts it.

Functions

func Available

func Available() bool

Available reports whether librdma and the generated probe symbols are available.

func ErrnoName added in v0.6.11

func ErrnoName(errno int) string

ErrnoName returns the symbolic name for common Apple RDMA errno values.

func ErrnoText added in v0.6.11

func ErrnoText(errno int) string

ErrnoText returns a compact name for common Apple RDMA errno values.

func IbvAckCqEvents added in v0.6.11

func IbvAckCqEvents(cq RDMACQ, nevents uint32) error

IbvAckCqEvents acknowledges completion events returned by IbvGetCqEvent.

func IbvCloseDevice added in v0.6.4

func IbvCloseDevice(context RDMAContext) (int, error)

IbvCloseDevice.

func IbvCompChannelFD added in v0.6.11

func IbvCompChannelFD(channel RDMACompChannel) int

IbvCompChannelFD returns the file descriptor stored in channel.

func IbvDeallocPd added in v0.6.4

func IbvDeallocPd(pd RDMAPD) (int, error)

IbvDeallocPd.

func IbvDeregMr added in v0.6.4

func IbvDeregMr(mr RDMAMR) (int, error)

IbvDeregMr.

func IbvDestroyCompChannel added in v0.6.11

func IbvDestroyCompChannel(channel RDMACompChannel) (int, error)

IbvDestroyCompChannel destroys a completion event channel.

func IbvDestroyCq added in v0.6.4

func IbvDestroyCq(cq RDMACQ) (int, error)

IbvDestroyCq.

func IbvDestroyQp added in v0.6.4

func IbvDestroyQp(qp RDMAQP) (int, error)

IbvDestroyQp.

func IbvFreeDeviceList added in v0.6.4

func IbvFreeDeviceList(list RDMADeviceList) error

IbvFreeDeviceList.

func IbvGetCqEvent added in v0.6.11

func IbvGetCqEvent(channel RDMACompChannel, cq *RDMACQ, cqContext *uintptr) (int, error)

IbvGetCqEvent reads the next completion event from channel.

func IbvGetDeviceName added in v0.6.4

func IbvGetDeviceName(device RDMADevice) (uintptr, error)

IbvGetDeviceName.

func IbvModifyQp added in v0.6.4

func IbvModifyQp(qp RDMAQP, attr uintptr, attr_mask int) (int, error)

IbvModifyQp.

func IbvModifyQpAttr added in v0.6.11

func IbvModifyQpAttr(qp RDMAQP, attr *IbvQPAttr, attrMask int) (int, error)

IbvModifyQpAttr calls ibv_modify_qp with a typed attr pointer.

func IbvModifyQpToErr added in v0.6.14

func IbvModifyQpToErr(qp RDMAQP) error

IbvModifyQpToErr moves a queue pair to the ERR state. Outstanding send and receive work requests are flushed to the completion queue with a non-success status, which lets the caller poll them out and reclaim the queue pair and its memory regions without racing in-flight transfers.

func IbvQueryDevice added in v0.6.4

func IbvQueryDevice(context RDMAContext, device_attr uintptr) (int, error)

IbvQueryDevice.

func IbvQueryDeviceBytes added in v0.6.11

func IbvQueryDeviceBytes(context RDMAContext, buf []byte) (int, error)

IbvQueryDeviceBytes calls ibv_query_device with a byte buffer.

func IbvQueryGid added in v0.6.4

func IbvQueryGid(context RDMAContext, port_num uint8, index int, gid uintptr) (int, error)

IbvQueryGid.

func IbvQueryGidInto added in v0.6.11

func IbvQueryGidInto(context RDMAContext, portNum uint8, index int, gid *IbvGID) (int, error)

IbvQueryGidInto calls ibv_query_gid with a typed GID pointer.

func IbvQueryPort added in v0.6.4

func IbvQueryPort(context RDMAContext, port_num uint8, port_attr uintptr) (int, error)

IbvQueryPort.

func IbvQueryPortAttr added in v0.6.11

func IbvQueryPortAttr(context RDMAContext, portNum uint8, attr *IbvPortAttr) (int, error)

IbvQueryPortAttr calls ibv_query_port with a typed port-attr pointer.

func IbvReqNotifyCq added in v0.6.11

func IbvReqNotifyCq(cq RDMACQ, solicitedOnly int) (int, error)

IbvReqNotifyCq requests a completion notification for cq.

func Ibv_mr_lkey

func Ibv_mr_lkey(mr RDMAMR) uint32

func Ibv_mr_rkey

func Ibv_mr_rkey(mr RDMAMR) uint32

func Ibv_poll_cq

func Ibv_poll_cq(cq RDMACQ, numEntries int, wc *IbvWC) (int, error)

Ibv_poll_cq calls the SDK inline ibv_poll_cq wrapper through ibv_context_ops.

func Ibv_post_recv

func Ibv_post_recv(qp RDMAQP, wr *IbvRecvWR, badWR **IbvRecvWR) (int, error)

Ibv_post_recv calls the SDK inline ibv_post_recv wrapper through ibv_context_ops.

func Ibv_post_send

func Ibv_post_send(qp RDMAQP, wr *IbvSendWR, badWR **IbvSendWR) (int, error)

Ibv_post_send calls the SDK inline ibv_post_send wrapper through ibv_context_ops.

func Ibv_qp_num

func Ibv_qp_num(qp RDMAQP) uint32

func IsUnsupportedErrno added in v0.6.16

func IsUnsupportedErrno(errno int) bool

IsUnsupportedErrno reports whether errno is Apple's ENOTSUP or its UNIX03 EOPNOTSUPP value. Darwin strerror(102) is "Operation not supported on socket".

func NewModifyQPError added in v0.6.11

func NewModifyQPError(qp RDMAQP, attr *IbvQPAttr, attrMask int, rc int, err error) error

NewModifyQPError formats a failed ibv_modify_qp operation.

func QPAttrMaskNames added in v0.6.11

func QPAttrMaskNames(mask int) []string

func QPStateName added in v0.6.11

func QPStateName(state int32) string

Types

type Capabilities added in v0.6.16

type Capabilities struct {
	QueuePairUC Capability
	SendRecv    Capability
	QueuePairRC Capability
	RDMARead    Capability
	RDMAWrite   Capability
	RemoteKey   Capability
}

Capabilities describes the evidence currently available for Apple's Thunderbolt RDMA provider. It does not infer unsupported features from the absence of binding constants.

func AppleThunderboltCapabilities added in v0.6.16

func AppleThunderboltCapabilities() Capabilities

AppleThunderboltCapabilities reports the current evidence for Apple's Thunderbolt RDMA provider features.

UC queue pairs and SEND/RECV are confirmed by the working collective path. On 2026-07-17, a guarded RC create on rdma_en3 returned a nil QP with EOPNOTSUPP (errno 102), so RC is rejected for that device, configuration, and run. A guarded memory registration on the same device requested remote read/write and returned rkey 0x0. That is an observed key value, not an attempted or rejected one-sided operation. READ and WRITE remain unknown.

type Capability added in v0.6.16

type Capability string

Capability describes the evidence level for one Apple Thunderbolt RDMA feature.

const (
	// CapabilityUnknown reports that this binding has no primary provider
	// observation for the feature.
	CapabilityUnknown Capability = "unknown"

	// CapabilityConfirmed reports an observed working provider path.
	CapabilityConfirmed Capability = "confirmed"

	// CapabilityRejected reports an observed provider rejection for the
	// documented device, configuration, and run.
	CapabilityRejected Capability = "rejected"

	// CapabilityObservedZero reports an observed zero value where a nonzero
	// capability value would be required by the documented path.
	CapabilityObservedZero Capability = "observed_zero"
)

type CompletionStatusClass added in v0.6.16

type CompletionStatusClass string

CompletionStatusClass describes the result class of a work completion.

const (
	CompletionSuccess    CompletionStatusClass = "success"
	CompletionProtection CompletionStatusClass = "protection error"
	CompletionFailure    CompletionStatusClass = "failure"
)

func ClassifyCompletionStatus added in v0.6.16

func ClassifyCompletionStatus(status int32) CompletionStatusClass

ClassifyCompletionStatus classifies status without collapsing protection errors into a generic provider failure.

type Device

type Device struct {
	Handle RDMADevice
	Name   string
	// contains filtered or unexported fields
}

Device describes an RDMA device returned by Devices.

func Devices

func Devices() ([]Device, error)

Devices returns the RDMA devices currently reported by librdma.

It only calls exported lifecycle/probe symbols. It does not enable RDMA and may return an empty slice on systems where RDMA over Thunderbolt is disabled.

func (Device) Open added in v0.6.11

func (d Device) Open() (RDMAContext, error)

Open opens d with ibv_open_device and keeps the owning list alive for the duration of the provider call.

type DeviceList added in v0.6.11

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

DeviceList owns an ibv_get_device_list result.

Device handles returned by DeviceList.Devices remain valid until Close is called. Open devices before closing the list.

func OpenDeviceList added in v0.6.11

func OpenDeviceList() (*DeviceList, error)

OpenDeviceList returns the RDMA device list currently reported by librdma.

func (*DeviceList) Close added in v0.6.11

func (l *DeviceList) Close() error

Close releases the underlying device list. It is safe to call Close more than once.

func (*DeviceList) Devices added in v0.6.11

func (l *DeviceList) Devices() []Device

Devices returns a copy of the devices in the list.

type FailureClass added in v0.6.11

type FailureClass string

FailureClass identifies the provider-boundary failure class.

const (
	FailureNoDevice               FailureClass = "no_device"
	FailureSymbolUnavailable      FailureClass = "symbol_unavailable"
	FailureNilInput               FailureClass = "nil_input"
	FailureNilProviderResult      FailureClass = "nil_provider_result"
	FailureNegativeProviderReturn FailureClass = "negative_provider_return"
	FailureProviderStatus         FailureClass = "provider_status"
	FailureProviderTimeout        FailureClass = "provider_timeout"
	FailureUnsupportedOperation   FailureClass = "unsupported_operation"
)

type IbvAHAttr

type IbvAHAttr struct {
	GRH         IbvGlobalRoute
	DLID        uint16
	SL          uint8
	SrcPathBits uint8
	StaticRate  uint8
	IsGlobal    uint8
	PortNum     uint8
	// contains filtered or unexported fields
}

IbvAHAttr matches struct ibv_ah_attr.

type IbvCQPoller

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

func NewIbvCQPoller

func NewIbvCQPoller(cq RDMACQ) (IbvCQPoller, error)

func (IbvCQPoller) Poll

func (p IbvCQPoller) Poll(numEntries int, wc *IbvWC) int

Poll polls the completion queue. It reports -1 without calling the provider when the poller is the zero value, which happens when NewIbvCQPoller returned an error the caller ignored, or when the work-completion pointer is nil.

The pointer checks are not defensive style: the provider dereferences what it is given, so a nil here faults inside C, where the SIGSEGV arrives during cgo execution and no Go recover can reach it.

type IbvGID

type IbvGID [16]byte

IbvGID is the raw 16-byte representation of union ibv_gid.

type IbvGlobalRoute

type IbvGlobalRoute struct {
	DGID         IbvGID
	FlowLabel    uint32
	SGIDIndex    uint8
	HopLimit     uint8
	TrafficClass uint8
	// contains filtered or unexported fields
}

IbvGlobalRoute matches struct ibv_global_route.

type IbvPortAttr

type IbvPortAttr struct {
	State         int32
	MaxMTU        int32
	ActiveMTU     int32
	GIDTblLen     uint32
	PortCapFlags  uint32
	MaxMsgSz      uint32
	BadPKeyCntr   uint32
	QKeyViolCntr  uint32
	PKeyTblLen    uint16
	LID           uint16
	SMLID         uint16
	LMC           uint8
	MaxVLNum      uint8
	SMSL          uint8
	SubnetTimeout uint8
	InitTypeReply uint8
	ActiveWidth   uint8
	ActiveSpeed   uint8
	PhysState     uint8
	LinkLayer     uint8
	Flags         uint8
	PortCapFlags2 uint16
}

IbvPortAttr matches struct ibv_port_attr.

Every field is named. The struct has no interior padding: it is 52 bytes of 4-byte-aligned members, so anonymous filler would only hide fields callers need. State and LinkLayer in particular decide whether a port carries traffic and how a route GID must be selected, and a binding that cannot express those checks fails silently rather than loudly.

type IbvQPAttr

type IbvQPAttr struct {
	QPState          int32
	CurQPState       int32
	PathMTU          int32
	PathMigState     int32
	QKey             uint32
	RQPSN            uint32
	SQPSN            uint32
	DestQPNum        uint32
	QPAccessFlags    int32
	Cap              IbvQPCap
	AHAttr           IbvAHAttr
	AltAHAttr        IbvAHAttr
	PKeyIndex        uint16
	AltPKeyIndex     uint16
	EnSQDAsyncNotify uint8
	SQDraining       uint8
	MaxRDAtomic      uint8
	MaxDestRDAtomic  uint8
	MinRNRTimer      uint8
	PortNum          uint8
	Timeout          uint8
	RetryCnt         uint8
	RNRetry          uint8
	AltPortNum       uint8
	AltTimeout       uint8
	// contains filtered or unexported fields
}

IbvQPAttr matches the fields commonly used with ibv_modify_qp.

type IbvQPCap

type IbvQPCap struct {
	MaxSendWR     uint32
	MaxRecvWR     uint32
	MaxSendSGE    uint32
	MaxRecvSGE    uint32
	MaxInlineData uint32
}

IbvQPCap matches struct ibv_qp_cap.

type IbvQPInitAttr

type IbvQPInitAttr struct {
	QPContext uintptr
	SendCQ    RDMACQ
	RecvCQ    RDMACQ
	SRQ       uintptr
	Cap       IbvQPCap
	QPType    int32
	SQSigAll  int32
}

IbvQPInitAttr matches struct ibv_qp_init_attr.

type IbvQPPoster

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

func NewIbvQPPoster

func NewIbvQPPoster(qp RDMAQP) (IbvQPPoster, error)

func (IbvQPPoster) PostRecv

func (p IbvQPPoster) PostRecv(wr *IbvRecvWR, badWR **IbvRecvWR) int

PostRecv posts a receive work request. It reports -1 without calling the provider when the poster is the zero value, or when either work-request pointer is nil, as in PostSend.

func (IbvQPPoster) PostSend

func (p IbvQPPoster) PostSend(wr *IbvSendWR, badWR **IbvSendWR) int

PostSend posts a send work request. It reports -1 without calling the provider when the poster is the zero value, or when either work-request pointer is nil.

badWR is checked along with the rest. The provider writes the offending work request through it on the failure path, so it is dereferenced exactly when a post has already gone wrong; a nil there would turn a recoverable failure into a killed process.

type IbvRecvWR

type IbvRecvWR struct {
	WRID   uint64
	Next   *IbvRecvWR
	SGList *IbvSGE
	NumSGE int32
	// contains filtered or unexported fields
}

IbvRecvWR matches struct ibv_recv_wr.

type IbvSGE

type IbvSGE struct {
	Addr   uint64
	Length uint32
	LKey   uint32
}

IbvSGE matches struct ibv_sge.

type IbvSendWR

type IbvSendWR struct {
	WRID      uint64
	Next      *IbvSendWR
	SGList    *IbvSGE
	NumSGE    int32
	Opcode    int32
	SendFlags int32
	ImmData   uint32
	WR        [32]byte
	QPType    [8]byte
	BindMW    [48]byte
}

IbvSendWR matches struct ibv_send_wr for send operations.

type IbvWC

type IbvWC struct {
	WRID         uint64
	Status       int32
	Opcode       int32
	VendorErr    uint32
	ByteLen      uint32
	ImmData      uint32
	QPNum        uint32
	SrcQP        uint32
	WCFlags      int32
	PKeyIndex    uint16
	SLID         uint16
	SL           uint8
	DLIDPathBits uint8
	PortNum      uint8
	// contains filtered or unexported fields
}

IbvWC matches struct ibv_wc.

type ModifyQPError added in v0.6.11

type ModifyQPError struct {
	Transition string
	Device     string
	QPN        uint32
	Mask       int
	Attr       IbvQPAttr
	Return     int
	Cause      error
}

ModifyQPError describes a failed ibv_modify_qp transition.

func (*ModifyQPError) Error added in v0.6.11

func (e *ModifyQPError) Error() string

func (*ModifyQPError) Unwrap added in v0.6.11

func (e *ModifyQPError) Unwrap() error

type ProviderError added in v0.6.11

type ProviderError struct {
	Operation   string
	Device      string
	Context     RDMAContext
	ContextOpen bool
	Failure     FailureClass
	Input       string
	Result      string
	Return      int64
	ReturnSet   bool
	Errno       int
	ErrnoSet    bool
	Cause       error
}

ProviderError describes an RDMA provider-boundary failure.

Operation is the ibverbs operation. Device is set when the package can tie a context back to a named RDMA device. ContextOpen reports whether the failure happened after an RDMA context had been opened.

func (*ProviderError) Error added in v0.6.11

func (e *ProviderError) Error() string

func (*ProviderError) Is added in v0.6.11

func (e *ProviderError) Is(target error) bool

func (*ProviderError) Unwrap added in v0.6.11

func (e *ProviderError) Unwrap() error

type RDMACQ

type RDMACQ = uintptr

func IbvCreateCq added in v0.6.4

func IbvCreateCq(context RDMAContext, cqe int, cq_context uintptr, channel uintptr, comp_vector int) (RDMACQ, error)

IbvCreateCq.

type RDMACompChannel added in v0.6.11

type RDMACompChannel = uintptr

RDMACompChannel is an ibv_comp_channel handle.

func IbvCQChannel added in v0.6.11

func IbvCQChannel(cq RDMACQ) RDMACompChannel

IbvCQChannel returns the completion channel associated with cq, if any.

func IbvCreateCompChannel added in v0.6.11

func IbvCreateCompChannel(context RDMAContext) (RDMACompChannel, error)

IbvCreateCompChannel creates a completion event channel for context.

type RDMAContext

type RDMAContext = uintptr

func IbvOpenDevice added in v0.6.4

func IbvOpenDevice(device RDMADevice) (RDMAContext, error)

IbvOpenDevice.

type RDMADevice

type RDMADevice = uintptr

type RDMADeviceList

type RDMADeviceList = uintptr

func IbvGetDeviceList added in v0.6.4

func IbvGetDeviceList(num_devices uintptr) (RDMADeviceList, error)

IbvGetDeviceList.

type RDMAMR

type RDMAMR = uintptr

func IbvRegMr added in v0.6.4

func IbvRegMr(pd RDMAPD, addr uintptr, length uintptr, access int) (RDMAMR, error)

IbvRegMr.

type RDMAPD

type RDMAPD = uintptr

func IbvAllocPd added in v0.6.4

func IbvAllocPd(context RDMAContext) (RDMAPD, error)

IbvAllocPd.

type RDMAQP

type RDMAQP = uintptr

func IbvCreateQp added in v0.6.4

func IbvCreateQp(pd RDMAPD, qp_init_attr uintptr) (RDMAQP, error)

IbvCreateQp.

func IbvCreateQpAttr added in v0.6.11

func IbvCreateQpAttr(pd RDMAPD, attr *IbvQPInitAttr) (RDMAQP, error)

IbvCreateQpAttr calls ibv_create_qp with a typed init-attr pointer.

Jump to

Keyboard shortcuts

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