private bool CheckSMBDNegotiate(out RdmaAdapterInfo rdmaAdapterInfo) { try { using (var client = new SMBDClient(DetectionInfo.ConnectionTimeout)) { var config = DetectionInfo.SMBDClientCapability; client.ConnectOverRDMA(DetectionInfo.DriverRdmaNICIPAddress, DetectionInfo.SUTRdmaNICIPAddress, DetectionInfo.SMBDPort, config.MaxReceiveSize, out rdmaAdapterInfo); client.SMBDNegotiate( config.CreditsRequested, config.ReceiveCreditMax, config.PreferredSendSize, config.MaxReceiveSize, config.MaxFragmentedSize ); return(true); } } catch (Exception ex) { DetectorUtil.WriteLog(String.Format("CheckSMBDNegotiate threw exception: {0}", ex)); rdmaAdapterInfo = null; return(false); } }
public bool CheckSMBDCapability(out RdmaAdapterInfo rdmaAdapterInfo, out bool rdmaChannelV1Supported, out bool rdmaChannelV1InvalidateSupported) { rdmaAdapterInfo = null; rdmaChannelV1Supported = false; rdmaChannelV1InvalidateSupported = false; if (DetectionInfo.SUTRdmaNICIPAddress == null || DetectionInfo.DriverRdmaNICIPAddress == null) { DetectorUtil.WriteLog("Check the supported SMBD capabilities of SUT skipped since not available.", true, LogStyle.StepSkipped); return(false); } DetectorUtil.WriteLog("Check the supported SMBD capabilities of SUT..."); bool result = CheckSMBDNegotiate(out rdmaAdapterInfo); if (result) { if (CheckSMBDReadWriteRDMAV1()) { result = true; rdmaChannelV1Supported = true; if (CheckSMBDReadWriteRDMAV1Invalidate()) { rdmaChannelV1InvalidateSupported = true; } } } if (result) { DetectorUtil.WriteLog("Finished", false, LogStyle.StepPassed); return(true); } else { DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); return(false); } }
public void ConnectOverRDMA(string localIpAddress, string remoteIpAddress, int port, uint maxReceiveSize, out RdmaAdapterInfo adapterInfo) { NtStatus status; RdmaProviderInfo[] providers; status = (NtStatus)RdmaProvider.LoadRdmaProviders(out providers); if (status != NtStatus.STATUS_SUCCESS) { throw new InvalidOperationException("Failed to load RDMA providers!"); } RdmaAdapter adapter = null; foreach (var provider in providers) { if (provider.Provider == null) { continue; } RdmaAdapter outputAdapter; status = (NtStatus)provider.Provider.OpenAdapter(localIpAddress, (short)AddressFamily.InterNetwork, out outputAdapter); if (status == NtStatus.STATUS_SUCCESS) { adapter = outputAdapter; break; } } if (adapter == null) { throw new InvalidOperationException("Failed to find the specified RDMA adapter!"); } status = (NtStatus)adapter.Query(out adapterInfo); if (status != (int)NtStatus.STATUS_SUCCESS) { throw new InvalidOperationException("Failed to query RDMA provider info!"); } status = smbdClient.ConnectToServerOverRdma( localIpAddress, remoteIpAddress, port, AddressFamily.InterNetwork, adapterInfo.MaxInboundRequests, adapterInfo.MaxOutboundRequests, adapterInfo.MaxInboundReadLimit, maxReceiveSize ); if (status != NtStatus.STATUS_SUCCESS) { throw new InvalidOperationException("ConnectToServerOverRdma failed!"); } decoder.TransportType = Smb2TransportType.Rdma; }