Module: Ignis::Collective::NetworkDirect::Bindings

Extended by:
FFI::Library
Defined in:
lib/nvruby/collective/net/nd_bindings.rb

Overview

Windows NetworkDirect SPI v2 FFI Bindings

NetworkDirect is Windows-native RDMA API supporting:

  • InfiniBand

  • RoCE (RDMA over Converged Ethernet)

  • iWARP

Requires: Mellanox ConnectX NICs with WinOF-2 drivers

Key interfaces (COM-based):

  • IND2Provider: Service provider, opens adapters

  • IND2Adapter: Hardware adapter, creates queues

  • IND2CompletionQueue: RDMA completion notifications

  • IND2QueuePair: Send/Receive queue pair for I/O

  • IND2MemoryRegion: Registered RDMA memory

  • IND2Connector: Connection establishment

Defined Under Namespace

Classes: ND2AdapterInfo, ND2Result, ND2Sge

Constant Summary collapse

ND_SUCCESS =

NetworkDirect status codes

0
ND_TIMEOUT =
0x80070102
ND_PENDING =
0x80000005
ND_BUFFER_OVERFLOW =
0x8007006F
ND_DEVICE_NOT_READY =
0x80070015
ND_NO_MEMORY =
0x8007000E
ND_CONNECTION_REFUSED =
0x8007107D
ND_CONNECTION_ABORTED =
0x80070453
ND_CONNECTION_INVALID =
0x800710CD
ND_NOT_SUPPORTED =
0x80070032
ND_QP_TYPE_SEND_RECV =

Queue pair types

0
ND_QP_TYPE_RDMA =
1
ND_CQ_SUCCESS =

Work completion status

0
ND_CQ_FLUSHED =
1
ND_CQ_LOCAL_ERROR =
2
ND_CQ_TRANSPORT_ERROR =
3
ND_CQ_RNR_ERROR =
4

Class Method Summary collapse

Class Method Details

.attach_nd_functions!Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/nvruby/collective/net/nd_bindings.rb', line 116

def self.attach_nd_functions!
  # Provider enumeration
  attach_function :NdOpenAdapter, [
    :pointer,   # const ND2_ADAPTER_ADDRESS* pAddress
    :uint32,    # DWORD cbAddressLength
    :pointer    # IND2Adapter** ppAdapter (output)
  ], :int32

  # Query adapters
  attach_function :NdQueryAddressList, [
    :uint32,    # DWORD Flags
    :pointer,   # ND2_ADAPTER_ADDRESS* pAddressList
    :pointer    # DWORD* pcbAddressList (in/out)
  ], :int32

  # Provider initialization
  attach_function :NdStartup, [:uint16], :int32   # Version
  attach_function :NdCleanup, [], :int32
end

.available?Boolean

Returns:

  • (Boolean)


107
108
109
110
# File 'lib/nvruby/collective/net/nd_bindings.rb', line 107

def self.available?
  ensure_loaded!
  @loaded
end

.check_status!(status, context = "NetworkDirect operation") ⇒ Object

Check status and raise on error

Raises:



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/nvruby/collective/net/nd_bindings.rb', line 137

def self.check_status!(status, context = "NetworkDirect operation")
  return if status == ND_SUCCESS

  error_name = case status
               when ND_TIMEOUT then "ND_TIMEOUT"
               when ND_PENDING then "ND_PENDING"
               when ND_NO_MEMORY then "ND_NO_MEMORY"
               when ND_DEVICE_NOT_READY then "ND_DEVICE_NOT_READY"
               when ND_CONNECTION_REFUSED then "ND_CONNECTION_REFUSED"
               when ND_CONNECTION_ABORTED then "ND_CONNECTION_ABORTED"
               when ND_NOT_SUPPORTED then "ND_NOT_SUPPORTED"
               else "UNKNOWN_ERROR"
               end

  raise RDMAError.new("#{context}: #{error_name} (0x#{status.to_s(16)})", code: status)
end

.ensure_loaded!Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/nvruby/collective/net/nd_bindings.rb', line 86

def self.ensure_loaded!
  return if @loaded

  begin
    # NetworkDirect provider DLL (from Mellanox WinOF-2 or similar)
    # Standard locations for RDMA providers
    ffi_lib [
      "nd",
      "NetworkDirect",
      "mlx5nd",  # Mellanox ConnectX-5+
      "mlx4nd"   # Older Mellanox
    ]
    attach_nd_functions!
    @loaded = true
  rescue FFI::NotFoundError => e
    # Not an error if hardware not present
    @loaded = false
    @load_error = e.message
  end
end

.load_errorObject



112
113
114
# File 'lib/nvruby/collective/net/nd_bindings.rb', line 112

def self.load_error
  @load_error
end