-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-rdma.ps1
345 lines (310 loc) · 10.8 KB
/
test-rdma.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True, Position=1, HelpMessage="Interface index of the adapter for which RDMA config is to be verified")]
[string] $IfIndex,
[Parameter(Mandatory=$True, Position=2, HelpMessage="True if underlying fabric type is RoCE. False for iWarp or IB")]
[bool] $IsRoCE,
[Parameter(Mandatory=$True, Position=3, HelpMessage="IP address of the remote RDMA adapter")]
[string] $RemoteIpAddress,
[Parameter(Mandatory=$False, Position=4, HelpMessage="Full path to the folder containing diskspd.exe")]
[string] $PathToDiskspd,
[Parameter(Mandatory=$False, Position=5, HelpMessage="Output level [none|verbose|debug]")]
[string] $OutputLevel,
[Parameter(Mandatory=$False, Position=6, HelpMessage="Interface ID of VF driver in Guest OS (mandatory for Guest RDMA tests only)")]
[string] $VfIndex)
if ($OutputLevel -eq "none")
{
$OutputLevel = 0
}
elseif ($OutputLevel -eq "debug" )
{
$OutputLevel = 2
}
else
{
$OutputLevel = 1 # verbose
}
if ($RemoteIpAddress -ne $null)
{
if (($PathToDiskspd -eq $null) -Or ($PathToDiskspd -eq ''))
{
$PathToDiskspd = "C:\Windows\System32"
}
$FullPathToDiskspd = $PathToDiskspd + "\diskspd.exe"
if ((Test-Path $FullPathToDiskspd) -eq $false)
{
Write-Host "ERROR: Diskspd.exe not found at" $FullPathToDiskspd ". Please download diskspd.exe and place it in the specified location. Exiting." -ForegroundColor Red
return
}
elseif ($OutputLevel -gt 0)
{
Write-Host "VERBOSE: Diskspd.exe found at" $FullPathToDiskspd
}
}
$rdmaAdapter = Get-NetAdapter -IfIndex $IfIndex
if ($outputLevel -eq 2)
{
Write-Host "DEBUG: Name is " $rdmaAdapter.Name
Write-Host "DEBUG: IfDesc is " $rdmaAdapter.InterfaceDescription
}
if ($rdmaAdapter -eq $null)
{
Write-Host "ERROR: The adapter with interface index $IfIndex not found" -ForegroundColor Red
return
}
$rdmaAdapterName = $rdmaAdapter.Name
if ($rdmaAdapter.InterfaceDescription -Match "Hyper-V Virtual Ethernet Adapter")
{
$rdmaAdapterType = "vNIC"
}
elseif ($rdmaAdapter.InterfaceDescription -Match "Microsoft Hyper-V Network Adapter")
{
$rdmaAdapterType = "vmNIC"
if( $VfIndex -eq "" )
{
Write-Host "ERROR: VF adapter Interface Index missing" -ForegroundColor Red
return
}
$VFAdapter = Get-NetAdapter -IfIndex $VfIndex
if ($outputLevel -eq 2)
{
Write-Host "DEBUG: VF Name is " $VFAdapter.Name
Write-Host "DEBUG: IfDesc of VF is " $VFAdapter.InterfaceDescription
}
$VFrdmaCapabilities = Get-NetAdapterRdma -InterfaceDescription $VFAdapter.InterfaceDescription
}
else
{
$rdmaAdapterType = "pNIC"
}
if ($outputLevel -gt 0)
{
Write-Host "VERBOSE: The adapter " $rdmaAdapterName " is a " $rdmaAdapterType
}
$rdmaCapabilities = Get-NetAdapterRdma -InterfaceDescription $rdmaAdapter.InterfaceDescription
if ($rdmaCapabilities -eq $null -or $rdmaCapabilities.Enabled -eq $false)
{
Write-Host "ERROR: The adapter " $rdmaAdapterName " is not enabled for RDMA" -ForegroundColor Red
return
}
if ($rdmaAdapterType -eq "vmNIC" -and ( $VFrdmaCapabilities -eq $null -or $VFrdmaCapabilities.Enabled -eq $false ))
{
Write-Host "ERROR: The VF adapter " $VFAdapter.Name " is not enabled for RDMA" -ForegroundColor Red
return
}
if ($rdmaCapabilities.MaxQueuePairCount -eq 0)
{
Write-Host "ERROR: RDMA capabilities for adapter $rdmaAdapterName are not valid : MaxQueuePairCount is 0" -ForegroundColor Red
return
}
if ($rdmaCapabilities.MaxCompletionQueueCount -eq 0)
{
Write-Host "ERROR: RDMA capabilities for adapter $rdmaAdapterName are not valid : MaxCompletionQueueCount is 0" -ForegroundColor Red
return
}
$smbClientNetworkInterfaces = Get-SmbClientNetworkInterface
if ($smbClientNetworkInterfaces -eq $null)
{
Write-Host "ERROR: No network interfaces detected by SMB (Get-SmbClientNetworkInterface)" -ForegroundColor Red
return
}
$rdmaAdapterSmbClientNetworkInterface = $null
foreach ($smbClientNetworkInterface in $smbClientNetworkInterfaces)
{
if ($smbClientNetworkInterface.InterfaceIndex -eq $IfIndex)
{
$rdmaAdapterSmbClientNetworkInterface = $smbClientNetworkInterface
}
}
if ($rdmaAdapterSmbClientNetworkInterface -eq $null)
{
Write-Host "ERROR: No network interfaces found by SMB for adapter $rdmaAdapterName (Get-SmbClientNetworkInterface)" -ForegroundColor Red
return
}
if ($rdmaAdapterSmbClientNetworkInterface.RdmaCapable -eq $false)
{
Write-Host "ERROR: SMB did not detect adapter $rdmaAdapterName as RDMA capable. Make sure the adapter is bound to TCP/IP and not to other protocol like vmSwitch." -ForegroundColor Red
return
}
$rdmaAdapters = $rdmaAdapter
if ($RdmaAdapterType -eq "vNIC")
{
if ($OutputLevel -gt 0)
{
Write-Host "VERBOSE: Retrieving vSwitch bound to the virtual adapter"
}
$virtualAdapter = Get-VMNetworkAdapter -ManagementOS | where DeviceId -eq $rdmaAdapter.DeviceID
$switchName = $virtualAdapter.switchName
if ($OutputLevel -gt 0)
{
Write-Host "VERBOSE: Found vSwitch: $switchName"
}
$vSwitch = Get-VMSwitch -Name $switchName
$rdmaAdapters = Get-NetAdapter -InterfaceDescription $vSwitch.NetAdapterInterfaceDescriptions
if ($OutputLevel -gt 0)
{
$vSwitchAdapterMessage = "VERBOSE: Found the following physical adapter(s) bound to vSwitch: "
$index = 1
foreach ($qosAdapter in $rdmaAdapters)
{
$qosAdapterName = $qosAdapter.Name
$vSwitchAdapterMessage = $vSwitchAdapterMessage + [string]$qosAdapterName
if ($index -lt $rdmaAdapters.Length)
{
$vSwitchAdapterMessage = $vSwitchAdapterMessage + ", "
}
$index = $index + 1
}
Write-Host $vSwitchAdapterMessage
}
}
if ($IsRoCE -eq $true -and $RdmaAdapterType -ne "vmNIC")
{
Write-Host "VERBOSE: Underlying adapter is RoCE. Checking if QoS/DCB/PFC is configured on each physical adapter(s)"
foreach ($qosAdapter in $rdmaAdapters)
{
$qosAdapterName = $qosAdapter.Name
$qos = Get-NetAdapterQos -Name $qosAdapterName
if ($qos.Enabled -eq $false)
{
Write-Host "ERROR: QoS is not enabled for adapter $qosAdapterName" -ForegroundColor Red
return
}
if ($qos.OperationalFlowControl -eq "All Priorities Disabled")
{
Write-Host "ERROR: Flow control is not enabled for adapter $qosAdapterName" -ForegroundColor Red
return
}
}
if ($OutputLevel -gt 0)
{
Write-Host "VERBOSE: QoS/DCB/PFC configuration is correct."
}
}
if ($RdmaAdapterType -eq "vmNIC")
{
Write-Host "CAUTION: Guest Virtual NIC being tested, Guest can't check host adapter settings." -ForegroundColor Yellow
}
elseif ($OutputLevel -gt 0)
{
Write-Host "VERBOSE: RDMA configuration is correct."
}
if ($RemoteIpAddress -ne '')
{
if ($OutputLevel -eq 2)
{
Write-Host "DEBUG: Checking if remote IP address, $RemoteIpAddress, is reachable."
}
$canPing = Test-Connection $RemoteIpAddress -Quiet
if ($canPing -eq $false)
{
Write-Host "ERROR: Cannot reach remote IP $RemoteIpAddress" -ForegroundColor Red
return
}
elseif ($OutputLevel -gt 0)
{
Write-Host "VERBOSE: Remote IP $RemoteIpAddress is reachable."
}
}
else
{
Write-Host "ERROR: Remote IP address was not provided."
}
if ($OutputLevel -gt 0)
{
Write-Host "VERBOSE: Disabling RDMA on adapters that are not part of this test. RDMA will be enabled on them later."
}
$adapters = Get-NetAdapterRdma
$InstanceIds = $rdmaAdapters.InstanceID;
$adaptersToEnableRdma = @()
foreach ($adapter in $adapters)
{
if ($adapter.Enabled -eq $true)
{
if (($adapter.InstanceID -notin $InstanceIds) -and
($adapter.InstanceID -ne $rdmaAdapter.InstanceID) -and
($adapter.InstanceID -ne $VFAdapter.InstanceID))
{
$adaptersToEnableRdma += $adapter
Disable-NetAdapterRdma -Name $adapter.Name
if ($OutputLevel -eq 2)
{
Write-Host "DEBUG: RDMA disabled on Adapter " $adapter.Name
}
}
elseif ($OutputLevel -eq 2)
{
Write-Host "DEBUG: RDMA not disabled on Adapter " $adapter.Name
}
}
}
if ($OutputLevel -ne 0)
{
Write-Host "VERBOSE: Testing RDMA traffic. Traffic will be sent in a background job. Job details:"
}
# PseudoRandomize the target file name so two copies of this script can execute at the same time against the same destination
$TargetFileName = "\\$RemoteIpAddress\C$\testfile$IfIndex.dat"
if ($OutputLevel -eq 2)
{
Write-Host "DEBUG: TargetFileName is $TargetFileName"
}
$ScriptBlock = {
param($RemoteIpAddress, $PathToDiskspd, $TargetFileName)
cd $PathToDiskspd
.\diskspd.exe -b4K -c10G -t4 -o16 -d100000 -L -Sr -d30 $TargetFileName
}
$thisJob = Start-Job $ScriptBlock -ArgumentList $RemoteIpAddress,$PathToDiskspd,$TargetFileName
$RdmaTrafficDetected = $false
# Check Perfmon counters while the job is running
While ((Get-Job -id $($thisJob).Id).state -eq "Running")
{
#Counter paths updated to reflech changes in server 2025
$written = Get-Counter -Counter "\SMB Direct\Bytes RDMA Written/sec" -ErrorAction Ignore
$sent = Get-Counter -Counter "\SMB Direct\Bytes Sent/sec" -ErrorAction Ignore
{
$RdmaWriteBytesPerSecond = [uint64]($written.Readings.split(":")[1])
if ($RdmaWriteBytesPerSecond -gt 0)
{
$RdmaTrafficDetected = $true
}
if ($OutputLevel -gt 0)
{
Write-Host "VERBOSE:" $RdmaWriteBytesPerSecond "RDMA bytes written per second"
}
}
if ($sent -ne $null)
{
$RdmaWriteBytesPerSecond = [uint64]($sent.Readings.split(":")[1])
if ($RdmaWriteBytesPerSecond -gt 0)
{
$RdmaTrafficDetected = $true
}
if ($OutputLevel -gt 0)
{
Write-Host "VERBOSE:" $RdmaWriteBytesPerSecond "RDMA bytes sent per second"
}
}
}
del $TargetFileName
if ($OutputLevel -gt 0)
{
Write-Host "VERBOSE: Enabling RDMA on adapters that are not part of this test. RDMA was disabled on them prior to sending RDMA traffic."
}
foreach ($adapter in $adaptersToEnableRdma)
{
Enable-NetAdapterRdma -Name $adapter.Name
if ($OutputLevel -eq 2)
{
Write-Host "DEBUG: RDMA enabled on Adapter " $adapter.Name
}
}
if ($RdmaTrafficDetected)
{
Write-Host "SUCCESS: RDMA traffic test SUCCESSFUL: RDMA traffic was sent to" $RemoteIpAddress -ForegroundColor Green
}
else
{
Write-Host "ERROR: RDMA traffic test FAILED: Please check " -ForegroundColor Yellow
Write-Host "ERROR: a) physical switch port configuration for Priorty Flow Control." -ForegroundColor Yellow
Write-Host "ERROR: b) job owner has write permission at " $RemoteIpAddress "\C$" -ForegroundColor Yellow
}