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 ¶
- Constants
- Variables
- func DerivePreflightSafety(report PreflightReport) (bool, []string)
- func ErrnoName(errno int) string
- func ErrnoText(errno int) string
- func FailedRTRLogLine(line string) bool
- func IsIPv4MappedGID(gid GID) bool
- func IsZeroGID(gid GID) bool
- func PreflightGIDScanLimit(tableLen int32, requested int) int
- func RequireRTRAttemptAllowed(allow bool) error
- func RouteGIDScanLimit(tableLen int32) int
- type GID
- type GIDInfo
- type PreflightDevice
- type PreflightReport
- type RouteGID
Examples ¶
Constants ¶
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 )
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 ¶
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 FailedRTRLogLine ¶
FailedRTRLogLine reports whether line contains Apple's INIT-to-RTR failure marker. Apple logs have used both ASCII "->" and Unicode "→".
func IsIPv4MappedGID ¶
IsIPv4MappedGID reports whether gid has the IPv4-mapped IPv6 prefix.
func PreflightGIDScanLimit ¶
PreflightGIDScanLimit returns the bounded diagnostic GID scan length.
func RequireRTRAttemptAllowed ¶
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 ¶
RouteGIDScanLimit returns the bounded automatic GID scan length.
Types ¶
type PreflightDevice ¶
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 ¶
RouteGID is a nonzero GID candidate returned by ibv_query_gid.
func SelectRouteGID ¶
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