Files
versitygw/rdma/rdma_stub.go
T
niksis02 ee25c95948 fix: port the cuObjServer wrapper to libcuobjserver 2.0.0
NVIDIA's rolling cuda-rhel9 repository bumped libcuobjserver from `1.2.0` to `2.0.0` and `build/vgwrdma-builder/Dockerfile` installs it unpinned, so `make vgwrdma-docker` broke: `setTelemFlags` gained a second mask and `initRDMAConfigParams` vanished along with the `RDMAConnection` base class that 2.0.0 deletes entirely. Rather than pin the package, this ports the C wrapper and the Go `rdma` package to the new API.

Telemetry now calls `setTelemFlags(flags, 0)`, where 0 reproduces the old behaviour. `Server.InitRDMAConfig` and its C entry point are removed, which drops a method from the exported API of `github.com/versity/versitygw/rdma`; it had no callers, and 2.0.0 only accepts tunables through the four-argument constructor that `NewServer` already uses. The `dlsym` lookups for `startRDMASession` and `closeRDMASession` go too, as dead code: 1.2.0 never exported those symbols either, so the fallback paths were always what ran. `HandleGet` and `HandlePut` now wrap the library's negative return in a `syscall.Errno` so 2.0.0's new `-EPROTO` is legible, and the wrapper compile rule gains `-std=c++17`. No defaults change.

`make vgwrdma-docker` passes and the binary links `libcuobjserver.so.2`, so it requires a 2.x install at runtime. `cuobjtest-gpu` and `cuobjtest-host` are unaffected. The RDMA data path itself is not verified here; that needs Mellanox hardware with DC transport.
2026-09-10 21:15:01 +04:00

98 lines
3.4 KiB
Go

// Copyright 2026 Versity Software
// This file is licensed under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//go:build !(linux && amd64 && cgo)
// Package rdma provides Go bindings to libcuobjserver.
// This file is a stub for platforms without RDMA support.
package rdma
import (
"errors"
"unsafe"
)
var errNotSupported = errors.New("rdma: not supported on this platform")
// Buffer wraps an RDMA-registered memory region (stub — always zero-valued).
type Buffer struct {
hostPtr unsafe.Pointer
size int
}
// HostPtr returns the underlying host memory pointer.
func (b *Buffer) HostPtr() unsafe.Pointer { return b.hostPtr }
// Size returns the buffer size in bytes.
func (b *Buffer) Size() int { return b.size }
// Slice returns the buffer contents as a Go byte slice.
func (b *Buffer) Slice() []byte { return []byte{} }
// Server wraps a cuObjServer instance (stub — always returns errNotSupported).
type Server struct{}
// ConfigureTelemetry is a no-op on platforms without RDMA support.
func ConfigureTelemetry(debug bool) {}
// DebugTelemetryEnabled always reports false on stub platforms.
func DebugTelemetryEnabled() bool { return false }
// NewServer always returns errNotSupported on this platform.
func NewServer(ip string, port uint16, tunables *RDMATunables) (*Server, error) {
return nil, errNotSupported
}
// StartSession always returns errNotSupported on this platform.
func (s *Server) StartSession() error { return errNotSupported }
// IsConnected always returns false on this platform.
func (s *Server) IsConnected() bool { return false }
// AllocHostBuffer always returns errNotSupported on this platform.
func (s *Server) AllocHostBuffer(size int) (unsafe.Pointer, error) { return nil, errNotSupported }
// FreeHostBuffer is a no-op on this platform.
func (s *Server) FreeHostBuffer(ptr unsafe.Pointer) {}
// RegisterBuffer always returns errNotSupported on this platform.
func (s *Server) RegisterBuffer(ptr unsafe.Pointer, size int) (*Buffer, error) {
return nil, errNotSupported
}
// DeregisterBuffer is a no-op on this platform.
func (s *Server) DeregisterBuffer(buf *Buffer) {}
// AllocateChannel always returns errNotSupported on this platform.
func (s *Server) AllocateChannel() (uint16, error) { return 0, errNotSupported }
// FreeChannel is a no-op on this platform.
func (s *Server) FreeChannel(id uint16) {}
// HandleGet always returns errNotSupported on this platform.
func (s *Server) HandleGet(key string, buf *Buffer, remoteStart uint64, size int64, rdmaDescr string, channel uint16) (int64, error) {
return 0, errNotSupported
}
// HandlePut always returns errNotSupported on this platform.
func (s *Server) HandlePut(key string, buf *Buffer, remoteStart uint64, size int64, rdmaDescr string, channel uint16) (int64, error) {
return 0, errNotSupported
}
// CloseSession is a no-op on this platform.
func (s *Server) CloseSession() {}
// Close is a no-op on this platform.
func (s *Server) Close() {}