rdma

package
v0.6.10 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package rdma provides operational helpers for Apple's generated RDMA bindings.

The package keeps policy that is not part of the C verbs ABI out of github.com/tmc/apple/rdma. It does not open devices, transition queue pairs, or post work requests; callers use it to classify errors, select route GIDs, and decide whether a read-only preflight permits one bounded RTR attempt.

Index

Examples

Constants

View Source
const (
	// PortActive is the ibv_port_state value for PORT_ACTIVE.
	PortActive int32 = 4

	// LinkLayerThunderbolt is Apple's ibv_port_attr link_layer value for
	// Thunderbolt RDMA.
	LinkLayerThunderbolt uint8 = 100

	// MaxRouteGIDScan bounds automatic route-GID discovery. Apple Thunderbolt
	// devices can report large gid_tbl_len values while only exposing a small
	// useful prefix.
	MaxRouteGIDScan = 8
)
View Source
const (
	ReasonNoSafeRouteGID     = "active Thunderbolt RDMA device has no safe route GID"
	ReasonRouteGIDIndexZero  = "active Thunderbolt RDMA route GID resolved to index 0"
	ReasonNoActiveTBDevice   = "no PORT_ACTIVE Thunderbolt RDMA device found"
	ReasonNoPeerInterface    = "no AppleThunderboltRDMAPeerInterface entries found"
	ReasonNoXDomainService   = "no IOThunderboltXDomainService entries found"
	ReasonNoRecentLog        = "no recent AppleThunderboltRDMA log lines captured"
	ReasonRecentRTRFailure   = "recent AppleThunderboltRDMA log contains Failed INIT->RTR"
	ReasonReadOnlyPreflight  = "read-only preflight passed; safe_to_attempt_rtr is necessary, not sufficient"
	IORegistryPeerInterface  = "AppleThunderboltRDMAPeerInterface"
	IORegistryXDomainService = "IOThunderboltXDomainService"

	RTRAttemptWarning = "" /* 192-byte string literal not displayed */
)

Variables

View Source
var (
	ErrRTRUnsafe = errors.New("rdma rtr unsafe")
)

Functions

func DerivePreflightSafety

func DerivePreflightSafety(report PreflightReport) (bool, []string)

DerivePreflightSafety returns whether report permits one bounded RTR attempt.

A true result is necessary, not sufficient. It is not a production or performance proof.

Example
package main

import (
	"fmt"

	xrdma "github.com/tmc/apple/x/rdma"
)

func main() {
	routeIndex := 1
	ok, reasons := xrdma.DerivePreflightSafety(xrdma.PreflightReport{
		Devices: []xrdma.PreflightDevice{{
			Name:          "rdma_en1",
			State:         xrdma.PortActive,
			LinkLayer:     xrdma.LinkLayerThunderbolt,
			RouteGIDIndex: &routeIndex,
		}},
		IORegistry: map[string]int{
			xrdma.IORegistryPeerInterface:  1,
			xrdma.IORegistryXDomainService: 1,
		},
		RecentLog: []string{"AppleThunderboltRDMA context allocation/query/free"},
	})

	fmt.Println(ok)
	fmt.Println(reasons[0])
}
Output:
true
read-only preflight passed; safe_to_attempt_rtr is necessary, not sufficient

func ErrnoName

func ErrnoName(errno int) string

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

func ErrnoText

func ErrnoText(errno int) string

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

func FailedRTRLogLine

func FailedRTRLogLine(line string) bool

FailedRTRLogLine reports whether line contains Apple's INIT-to-RTR failure marker. Apple logs have used both ASCII "->" and Unicode "→".

func IsIPv4MappedGID

func IsIPv4MappedGID(gid GID) bool

IsIPv4MappedGID reports whether gid has the IPv4-mapped IPv6 prefix.

func IsZeroGID

func IsZeroGID(gid GID) bool

IsZeroGID reports whether gid is all zeros.

func PreflightGIDScanLimit

func PreflightGIDScanLimit(tableLen int32, requested int) int

PreflightGIDScanLimit returns the bounded diagnostic GID scan length.

func RequireRTRAttemptAllowed

func RequireRTRAttemptAllowed(allow bool) error

RequireRTRAttemptAllowed returns ErrRTRUnsafe unless allow is true.

Example
package main

import (
	"errors"
	"fmt"

	xrdma "github.com/tmc/apple/x/rdma"
)

func main() {
	err := xrdma.RequireRTRAttemptAllowed(false)

	fmt.Println(errors.Is(err, xrdma.ErrRTRUnsafe))
	fmt.Println(err)
}
Output:
true
rdma-pingpong drives QP INIT->RTR, which can wedge Apple Thunderbolt RDMA ports; run rdmainfo preflight, run rdma-probe, and read the README first, then pass -allow-rtr for one bounded attempt

func RouteGIDScanLimit

func RouteGIDScanLimit(tableLen int32) int

RouteGIDScanLimit returns the bounded automatic GID scan length.

Types

type GID

type GID = bindings.IbvGID

GID is an RDMA global identifier.

type GIDInfo

type GIDInfo struct {
	Index      int
	Raw        string
	IPv4Mapped bool
}

GIDInfo is the JSON-friendly form used by diagnostics.

func SelectRouteGIDInfo

func SelectRouteGIDInfo(gids []GIDInfo, linkLayer uint8) (GIDInfo, bool)

SelectRouteGIDInfo applies the automatic route-GID policy to diagnostic records.

type PreflightDevice

type PreflightDevice struct {
	Name          string
	State         int32
	LinkLayer     uint8
	RouteGIDIndex *int
}

PreflightDevice is the read-only state for one RDMA device.

type PreflightReport

type PreflightReport struct {
	Devices    []PreflightDevice
	IORegistry map[string]int
	RecentLog  []string
}

PreflightReport is the read-only evidence needed to decide whether an RDMA RTR attempt is even eligible to run.

type RouteGID

type RouteGID struct {
	Index int
	GID   GID
}

RouteGID is a nonzero GID candidate returned by ibv_query_gid.

func SelectRouteGID

func SelectRouteGID(gids []RouteGID, preferred int, linkLayer uint8) (RouteGID, bool)

SelectRouteGID selects a route GID for QP RTR setup.

If preferred is non-negative, it is treated as an explicit diagnostic override and must match a nonzero candidate. Automatic selection rejects Thunderbolt index 0, prefers IPv4-mapped GIDs, then accepts index 1. Other link layers may fall back to the first nonzero candidate.

Example
package main

import (
	"fmt"

	xrdma "github.com/tmc/apple/x/rdma"
)

func main() {
	gid0 := xrdma.GID{0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
	gid1 := xrdma.GID{0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}

	route, ok := xrdma.SelectRouteGID([]xrdma.RouteGID{
		{Index: 0, GID: gid0},
		{Index: 1, GID: gid1},
	}, -1, xrdma.LinkLayerThunderbolt)

	fmt.Println(ok, route.Index)
}
Output:
true 1

Jump to

Keyboard shortcuts

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