[ofw] [PATCH 4/7] winverbs: add connection support to kernel driver

Sean Hefty sean.hefty at intel.com
Fri Jan 16 14:30:54 PST 2009


Add support for connection establishment over IB through the winverbs kernel
driver.  This depends on exporting the IB CM interface.  Connections follow
the RDMA CM model.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/SOURCES branches\winverbs/core/winverbs/kernel/SOURCES
--- trunk/core/winverbs/kernel/SOURCES	2008-08-26 08:56:24.578125000 -0700
+++ branches\winverbs/core/winverbs/kernel/SOURCES	2008-11-19 08:56:55.685145100 -0800
@@ -19,7 +19,8 @@ SOURCES = \
 	wv_cq.c			\
 	wv_pd.c			\
 	wv_srq.c		\
-	wv_qp.c
+	wv_qp.c			\
+	wv_ep.c
 
 INCLUDES = ..;..\..\..\inc;..\..\..\inc\kernel;..\..\..\inc\user;..\..\..\etc\kernel;
 
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/winverbs.inx
branches\winverbs/core/winverbs/kernel/winverbs.inx
--- trunk/core/winverbs/kernel/winverbs.inx	2008-08-26 08:56:24.609375000 -0700
+++ branches\winverbs/core/winverbs/kernel/winverbs.inx	2008-12-03 12:23:52.016428900 -0800
@@ -29,7 +29,7 @@
 
 [Version]
 Signature = "$WINDOWS NT$"
-Class=InfiniBandController
+Class = InfiniBandController
 ClassGUID = {58517E00-D3CF-40c9-A679-CEE5752F4491}
 Provider = %OFA%
 DriverVer = 05/20/2008
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/wv_cq.c branches\winverbs/core/winverbs/kernel/wv_cq.c
--- trunk/core/winverbs/kernel/wv_cq.c	2008-06-05 18:24:59.049262600 -0700
+++ branches\winverbs/core/winverbs/kernel/wv_cq.c	2008-11-24 23:25:20.265625000 -0800
@@ -67,33 +67,18 @@ void WvCqRelease(WV_COMPLETION_QUEUE *pC
 	WvCqPut(pCq);
 }
 
-static void WvCqCompleteRequests(WDFQUEUE Queue, NTSTATUS ReqStatus)
-{
-	WDFREQUEST	request;
-	NTSTATUS	status;
-
-	WdfObjectAcquireLock(Queue);
-	status = WdfIoQueueRetrieveNextRequest(Queue, &request);
-
-	while (NT_SUCCESS(status)) {
-		WdfRequestComplete(request, ReqStatus);
-		status = WdfIoQueueRetrieveNextRequest(Queue, &request);
-	}
-	WdfObjectReleaseLock(Queue);
-}
-
 static void WvCqEventHandler(ib_event_rec_t *pEvent)
 {
 	WV_COMPLETION_QUEUE	*cq = pEvent->context;
-	WvCqCompleteRequests(cq->Queue, STATUS_UNEXPECTED_IO_ERROR);
-	WvCqCompleteRequests(cq->ErrorQueue, STATUS_UNEXPECTED_IO_ERROR);
+	WvFlushQueue(cq->Queue, STATUS_UNEXPECTED_IO_ERROR);
+	WvFlushQueue(cq->ErrorQueue, STATUS_UNEXPECTED_IO_ERROR);
 }
 
 static void WvCqHandler(void *Context)
 {
 	WV_COMPLETION_QUEUE	*cq = Context;
 
-	WvCqCompleteRequests(cq->Queue, STATUS_SUCCESS);
+	WvFlushQueue(cq->Queue, STATUS_SUCCESS);
 }
 
 static NTSTATUS WvCqAlloc(WV_DEVICE *pDevice, UINT32 *pSize,
@@ -341,8 +326,8 @@ void WvCqCancel(WV_PROVIDER *pProvider, 
 		goto out;
 	}
 
-	WvCqCompleteRequests(cq->Queue, STATUS_CANCELLED);
-	WvCqCompleteRequests(cq->ErrorQueue, STATUS_CANCELLED);
+	WvFlushQueue(cq->Queue, STATUS_CANCELLED);
+	WvFlushQueue(cq->ErrorQueue, STATUS_CANCELLED);
 	WvCqRelease(cq);
 
 out:
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/wv_driver.c
branches\winverbs/core/winverbs/kernel/wv_driver.c
--- trunk/core/winverbs/kernel/wv_driver.c	2008-07-17 16:45:10.015625000 -0700
+++ branches\winverbs/core/winverbs/kernel/wv_driver.c	2009-01-12 00:33:58.359375000 -0800
@@ -54,6 +54,9 @@ WDFDEVICE				ControlDevice;
 static LIST_ENTRY		DevList;
 static LIST_ENTRY		ProvList;
 static KGUARDED_MUTEX	Lock;
+ULONG					RandomSeed;
+
+INFINIBAND_INTERFACE_CM	IbCmInterface;
 
 static EVT_WDF_DRIVER_DEVICE_ADD			WvRdmaDeviceAdd;
 static EVT_WDF_OBJECT_CONTEXT_CLEANUP		WvRdmaDeviceCleanup;
@@ -88,6 +91,44 @@ void WvRdmaDevicePut(WV_RDMA_DEVICE *pDe
 	}
 }
 
+
+void WvCompleteRequests(WDFQUEUE Queue, NTSTATUS ReqStatus)
+{
+	WDFREQUEST	request;
+	NTSTATUS	status;
+
+	status = WdfIoQueueRetrieveNextRequest(Queue, &request);
+
+	while (NT_SUCCESS(status)) {
+		WdfRequestComplete(request, ReqStatus);
+		status = WdfIoQueueRetrieveNextRequest(Queue, &request);
+	}
+}
+
+void WvFlushQueue(WDFQUEUE Queue, NTSTATUS ReqStatus)
+{
+	WdfObjectAcquireLock(Queue);
+	WvCompleteRequests(Queue, ReqStatus);
+	WdfObjectReleaseLock(Queue);
+}
+
+void WvCompleteRequestsWithInformation(WDFQUEUE Queue, NTSTATUS ReqStatus)
+{
+	WDFREQUEST	request;
+	NTSTATUS	status;
+	UINT8		*out;
+	size_t		outlen;
+
+	status = WdfIoQueueRetrieveNextRequest(Queue, &request);
+
+	while (NT_SUCCESS(status)) {
+		outlen = 0;
+		WdfRequestRetrieveOutputBuffer(request, 0, &out, &outlen);
+		WdfRequestCompleteWithInformation(request, ReqStatus, outlen);
+		status = WdfIoQueueRetrieveNextRequest(Queue, &request);
+	}
+}
+
 static void WvGuidQuery(WDFREQUEST Request)
 {
 	WV_IO_GUID_LIST	*list;
@@ -281,77 +322,53 @@ static VOID WvIoDeviceControl(WDFQUEUE Q
 	case WV_IOCTL_QP_CANCEL:
 		WvQpCancel(prov, Request);
 		break;
-	case WV_IOCTL_ADDRESS_QUERY:
-		//WvAddressQuery(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
-		break;
 	case WV_IOCTL_EP_CREATE:
-		//WvEpCreate(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpCreate(prov, Request);
 		break;
 	case WV_IOCTL_EP_DESTROY:
-		//WvEpDestroy(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpDestroy(prov, Request);
+		break;
+	case WV_IOCTL_EP_MODIFY:
+		WvEpModify(prov, Request);
 		break;
 	case WV_IOCTL_EP_BIND:
-		//WvEpBind(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpBind(prov, Request);
 		break;
 	case WV_IOCTL_EP_REJECT:
-		//WvEpReject(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpReject(prov, Request);
 		break;
 	case WV_IOCTL_EP_CONNECT:
-		//WvEpConnect(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpConnect(prov, Request);
 		break;
 	case WV_IOCTL_EP_ACCEPT:
-		//WvEpAccept(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpAccept(prov, Request);
 		break;
 	case WV_IOCTL_EP_DISCONNECT:
-		//WvEpDisconnect(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpDisconnect(prov, Request);
 		break;
 	case WV_IOCTL_EP_DISCONNECT_NOTIFY:
-		//WvEpDisconnectNotify(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpDisconnectNotify(prov, Request);
 		break;
 	case WV_IOCTL_EP_QUERY:
-		//WvEpQuery(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpQuery(prov, Request);
 		break;
 	case WV_IOCTL_EP_LOOKUP:
-		//WvEpLookup(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpLookup(prov, Request);
 		break;
 	case WV_IOCTL_EP_MULTICAST_JOIN:
-		//WvEpMulticastJoin(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpMulticastJoin(prov, Request);
 		break;
 	case WV_IOCTL_EP_MULTICAST_LEAVE:
-		//WvEpMulticastLeave(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpMulticastLeave(prov, Request);
 		break;
 	case WV_IOCTL_EP_CANCEL:
-		//WvEpCancel(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+		WvEpCancel(prov, Request);
+		break;
+	case WV_IOCTL_EP_LISTEN:
+		WvEpListen(prov, Request);
 		break;
-	case WV_IOCTL_LISTEN:
-		//WvListen(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
-		break;
-	case WV_IOCTL_LISTEN_DESTROY:
-		//WvListenDestroy(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
-		break;
-	case WV_IOCTL_LISTEN_GET_REQUEST:
-		//WvListenGetRequest(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
-		break;
-	case WV_IOCTL_LISTEN_CANCEL:
-		//WvListenCancel(prov, Request);
-		WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);
+	case WV_IOCTL_EP_GET_REQUEST:
+		WvEpGetRequest(prov, Request);
 		break;
 	default:
 		WdfRequestComplete(Request, STATUS_PROCEDURE_NOT_FOUND);
@@ -363,9 +380,8 @@ static VOID WvFileCreate(WDFDEVICE Devic
 						 WDFFILEOBJECT FileObject)
 {
 	WV_PROVIDER	*prov = WvProviderGetContext(FileObject);
-	UNREFERENCED_PARAMETER(Device);
 
-	WvProviderInit(prov);
+	WvProviderInit(Device, prov);
 	KeAcquireGuardedMutex(&Lock);
 	InsertHeadList(&ProvList, &prov->Entry);
 	KeReleaseGuardedMutex(&Lock);
@@ -471,9 +487,13 @@ static NTSTATUS WvPowerD0Entry(WDFDEVICE
 
 	if (create) {
 		WvCreateControlDevice(WdfGetDriver());
+		status = WdfFdoQueryForInterface(Device, &GUID_INFINIBAND_INTERFACE_CM,
+										 (PINTERFACE) &IbCmInterface,
+										 sizeof(IbCmInterface),
+										 IbaCmVersion(1, 0), NULL);
 	}
 
-	return STATUS_SUCCESS;
+	return status;
 }
 
 static NTSTATUS WvRdmaDeviceAdd(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit)
@@ -535,8 +555,13 @@ static VOID WvRdmaDeviceCleanup(WDFDEVIC
 		KeWaitForSingleObject(&pdev->Event, Executive, KernelMode, FALSE, NULL);
 	}
 
-	pdev->Interface.InterfaceHeader.
-		InterfaceDereference(pdev->Interface.InterfaceHeader.Context);
+	if (IbCmInterface.CM.create_id != NULL) {
+		IbCmInterface.InterfaceHeader.InterfaceDereference(IbCmInterface.
+
InterfaceHeader.Context);
+	}
+
+	pdev->Interface.InterfaceHeader.InterfaceDereference(pdev->Interface.
+
InterfaceHeader.Context);
 
 	if (destroy) {
 		WdfObjectDelete(ctrldev);
@@ -552,6 +577,7 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT Driv
 	InitializeListHead(&DevList);
 	InitializeListHead(&ProvList);
 	KeInitializeGuardedMutex(&Lock);
+	RandomSeed = (ULONG) (ULONG_PTR) DriverObject;
 
 	WDF_DRIVER_CONFIG_INIT(&config, WvRdmaDeviceAdd);
 	status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES,
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/wv_driver.h
branches\winverbs/core/winverbs/kernel/wv_driver.h
--- trunk/core/winverbs/kernel/wv_driver.h	2008-08-04 09:55:51.419762000 -0700
+++ branches\winverbs/core/winverbs/kernel/wv_driver.h	2009-01-12 00:34:09.390625000 -0800
@@ -38,17 +38,20 @@
 
 #include <iba\ib_types.h>
 #include <iba\ib_ci.h>
+#include <iba\ib_cm_ifc.h>
 #include <rdma\verbs.h>
 #include "wv_ioctl.h"
 
 #if WINVER <= _WIN32_WINNT_WINXP
-#define KGUARDED_MUTEX FAST_MUTEX
+#define KGUARDED_MUTEX			 FAST_MUTEX
 #define KeInitializeGuardedMutex ExInitializeFastMutex
-#define KeAcquireGuardedMutex ExAcquireFastMutex
-#define KeReleaseGuardedMutex ExReleaseFastMutex
+#define KeAcquireGuardedMutex	 ExAcquireFastMutex
+#define KeReleaseGuardedMutex	 ExReleaseFastMutex
 #endif
 
-extern WDFDEVICE			ControlDevice;
+extern WDFDEVICE				ControlDevice;
+extern INFINIBAND_INTERFACE_CM	IbCmInterface;
+extern ULONG					RandomSeed;
 
 typedef struct _WV_RDMA_DEVICE
 {
@@ -74,4 +77,8 @@ static inline void WvInitVerbsData(ci_um
 	pVerbsData->status = 0;
 }
 
+void WvCompleteRequests(WDFQUEUE Queue, NTSTATUS ReqStatus);
+void WvFlushQueue(WDFQUEUE Queue, NTSTATUS ReqStatus);
+void WvCompleteRequestsWithInformation(WDFQUEUE Queue, NTSTATUS ReqStatus);
+
 #endif // _WV_DRIVER_H_
Only in branches\winverbs/core/winverbs/kernel: wv_ep.c
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/wv_ep.h branches\winverbs/core/winverbs/kernel/wv_ep.h
--- trunk/core/winverbs/kernel/wv_ep.h	2008-03-31 11:29:41.159672000 -0700
+++ branches\winverbs/core/winverbs/kernel/wv_ep.h	2009-01-07 15:56:19.211637200 -0800
@@ -32,25 +32,68 @@
 #ifndef _WV_EP_H_
 #define _WV_EP_H_
 
+#include <ntddk.h>
 #include <wdm.h>
+
 #include <iba\ib_types.h>
 #include <iba\ib_ci.h>
 #include "wv_provider.h"
+#include "wv_ioctl.h"
 
-typedef struct _WV_CONNECT_ENDPOINT
+typedef enum _WV_ENDPOINT_STATE
 {
-	WV_PROVIDER		*pProvider;
-	UINT64			Id;
-	LONG			nRef;
+	WvEpIdle,
+	WvEpAddressBound,
+	WvEpListening,
+	WvEpQueued,
+	WvEpRouteResolved,
+	WvEpPassiveConnect,
+	WvEpActiveConnect,
+	WvEpConnected,
+	WvEpActiveDisconnect,
+	WvEpPassiveDisconnect,
+	WvEpDisconnected
 
-}	WV_CONNECT_ENDPOINT;
+}	WV_ENDPOINT_STATE;
 
-typedef struct _WV_DATAGRAM_ENDPOINT
+typedef struct _WV_ENDPOINT
 {
-	WV_PROVIDER		*pProvider;
-	UINT64			Id;
-	LONG			m_nRef;
-
-}	WV_DATAGRAM_ENDPOINT;
+	WV_PROVIDER			*pProvider;
+	LIST_ENTRY			Entry;
+	WV_ENDPOINT_STATE	State;
+
+	iba_cm_id			*pIbCmId;
+	WV_IO_EP_ATTRIBUTES	Attributes;
+	ib_path_rec_t		Route;
+
+	UINT16				EpType;
+	KEVENT				Event;
+	LONG				Ref;
+	WDFQUEUE			Queue;
+
+}	WV_ENDPOINT;
+
+void WvEpCreate(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpDestroy(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpFree(WV_ENDPOINT *pEndpoint);
+void WvEpCancelListen(WV_ENDPOINT *pEndpoint);
+
+void WvEpQuery(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpModify(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpBind(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpCancel(WV_PROVIDER *pProvider, WDFREQUEST Request);
+
+void WvEpConnect(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpAccept(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpReject(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpDisconnect(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpDisconnectNotify(WV_PROVIDER *pProvider, WDFREQUEST Request);
+
+void WvEpListen(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpGetRequest(WV_PROVIDER *pProvider, WDFREQUEST Request);
+
+void WvEpLookup(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpMulticastJoin(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvEpMulticastLeave(WV_PROVIDER *pProvider, WDFREQUEST Request);
 
 #endif // _WV_EP_H_
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/wv_provider.c
branches\winverbs/core/winverbs/kernel/wv_provider.c
--- trunk/core/winverbs/kernel/wv_provider.c	2008-05-01 00:06:15.472250000 -0700
+++ branches\winverbs/core/winverbs/kernel/wv_provider.c	2009-01-05 17:54:44.895851600 -0800
@@ -38,6 +38,7 @@
 #include "wv_srq.h"
 #include "wv_cq.h"
 #include "wv_qp.h"
+#include "wv_ep.h"
 
 void WvProviderGet(WV_PROVIDER *pProvider)
 {
@@ -51,7 +52,7 @@ void WvProviderPut(WV_PROVIDER *pProvide
 	}
 }
 
-void WvProviderInit(WV_PROVIDER *pProvider)
+void WvProviderInit(WDFDEVICE Device, WV_PROVIDER *pProvider)
 {
 	IndexListInit(&pProvider->DevIndex);
 	IndexListInit(&pProvider->CqIndex);
@@ -60,6 +61,7 @@ void WvProviderInit(WV_PROVIDER *pProvid
 	IndexListInit(&pProvider->QpIndex);
 	IndexListInit(&pProvider->MwIndex);
 	IndexListInit(&pProvider->AhIndex);
+	IndexListInit(&pProvider->EpIndex);
 
 	KeInitializeGuardedMutex(&pProvider->Lock);
 	pProvider->Ref = 1;
@@ -81,7 +83,19 @@ void WvProviderCleanup(WV_PROVIDER *pPro
 	WV_QUEUE_PAIR			*qp;
 	WV_MEMORY_WINDOW		*mw;
 	WV_ADDRESS_HANDLE		*ah;
+	WV_ENDPOINT				*ep;
+	SIZE_T					i;
 
+	IndexListForEach(&pProvider->EpIndex, i) {
+		ep = (WV_ENDPOINT *) IndexListAt(&pProvider->EpIndex, i);
+		if (ep->State == WvEpListening) {
+			WvEpCancelListen(ep);
+		}
+	}
+	while ((ep = IndexListRemoveHead(&pProvider->EpIndex)) != NULL) {
+		RemoveEntryList(&ep->Entry);
+		WvEpFree(ep);
+	}
 	while ((ah = IndexListRemoveHead(&pProvider->AhIndex)) != NULL) {
 		RemoveEntryList(&ah->Entry);
 		WvAhFree(ah);
@@ -114,6 +128,7 @@ void WvProviderCleanup(WV_PROVIDER *pPro
 		KeWaitForSingleObject(&pProvider->Event, Executive, KernelMode, FALSE, NULL);
 	}
 
+	IndexListDestroy(&pProvider->EpIndex);
 	IndexListDestroy(&pProvider->AhIndex);
 	IndexListDestroy(&pProvider->MwIndex);
 	IndexListDestroy(&pProvider->QpIndex);
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/wv_provider.h
branches\winverbs/core/winverbs/kernel/wv_provider.h
--- trunk/core/winverbs/kernel/wv_provider.h	2008-04-25 10:50:14.008012400 -0700
+++ branches\winverbs/core/winverbs/kernel/wv_provider.h	2008-12-19 16:53:01.397692300 -0800
@@ -53,6 +53,7 @@ typedef struct _WV_PROVIDER
 	INDEX_LIST		QpIndex;
 	INDEX_LIST		MwIndex;
 	INDEX_LIST		AhIndex;
+	INDEX_LIST		EpIndex;
 
 	KGUARDED_MUTEX	Lock;
 	LONG			Ref;
@@ -67,7 +68,7 @@ typedef struct _WV_PROVIDER
 
 void WvProviderGet(WV_PROVIDER *pProvider);
 void WvProviderPut(WV_PROVIDER *pProvider);
-void WvProviderInit(WV_PROVIDER *pProvider);
+void WvProviderInit(WDFDEVICE Device, WV_PROVIDER *pProvider);
 void WvProviderCleanup(WV_PROVIDER *pProvider);
 
 void WvProviderRemoveHandler(WV_PROVIDER *pProvider, WV_RDMA_DEVICE *pDevice);
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/wv_qp.c branches\winverbs/core/winverbs/kernel/wv_qp.c
--- trunk/core/winverbs/kernel/wv_qp.c	2008-07-17 16:47:45.421875000 -0700
+++ branches\winverbs/core/winverbs/kernel/wv_qp.c	2009-01-14 12:39:00.299387600 -0800
@@ -458,6 +458,7 @@ void WvQpCreate(WV_PROVIDER *pProvider, 
 		goto err3;
 	}
 
+	qp->Qpn = ib_attr.num;
 	KeAcquireGuardedMutex(&pProvider->Lock);
 	outattr->Id.Id = IndexListInsertHead(&pProvider->QpIndex, qp);
 	if (outattr->Id.Id == 0) {
@@ -572,6 +573,7 @@ void WvQpQuery(WV_PROVIDER *pProvider, W
 		goto complete;
 	}
 
+	RtlZeroMemory(&attr, sizeof attr);
 	qp->pVerbs->query_qp(qp->hVerbsQp, &attr, NULL);
 	WvQpRelease(qp);
 
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/wv_qp.h branches\winverbs/core/winverbs/kernel/wv_qp.h
--- trunk/core/winverbs/kernel/wv_qp.h	2008-05-01 11:40:35.327097500 -0700
+++ branches\winverbs/core/winverbs/kernel/wv_qp.h	2008-11-19 17:04:09.069421500 -0800
@@ -51,6 +51,7 @@ typedef struct _WV_QUEUE_PAIR
 	WV_SHARED_RECEIVE_QUEUE	*pSrq;
 	ci_interface_t			*pVerbs;
 	ib_qp_handle_t			hVerbsQp;
+	UINT32					Qpn;
 	LIST_ENTRY				Entry;
 	LIST_ENTRY				McList;
 
@@ -64,6 +65,9 @@ void WvQpDestroy(WV_PROVIDER *pProvider,
 void WvQpFree(WV_QUEUE_PAIR *pQp);
 void WvQpRemoveHandler(WV_QUEUE_PAIR *pQp);
 
+WV_QUEUE_PAIR *WvQpAcquire(WV_PROVIDER *pProvider, UINT64 Id);
+void WvQpRelease(WV_QUEUE_PAIR *pQp);
+
 void WvQpModify(WV_PROVIDER *pProvider, WDFREQUEST Request);
 void WvQpQuery(WV_PROVIDER *pProvider, WDFREQUEST Request);
 void WvQpAttach(WV_PROVIDER *pProvider, WDFREQUEST Request);
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/kernel/wv_srq.c
branches\winverbs/core/winverbs/kernel/wv_srq.c
--- trunk/core/winverbs/kernel/wv_srq.c	2008-06-10 00:50:47.781375000 -0700
+++ branches\winverbs/core/winverbs/kernel/wv_srq.c	2008-11-24 23:25:23.171875000 -0800
@@ -75,32 +75,19 @@ static void WvVerbsConvertSrq(ib_srq_att
 	pVerbsAttr->srq_limit = pAttr->SrqLimit;
 }
 
-static void WvSrqCompleteRequests(WV_SHARED_RECEIVE_QUEUE *pSrq, NTSTATUS ReqStatus)
-{
-	WDFREQUEST	request;
-	NTSTATUS	status;
-
-	WdfObjectAcquireLock(pSrq->Queue);
-	status = WdfIoQueueRetrieveNextRequest(pSrq->Queue, &request);
-
-	while (NT_SUCCESS(status)) {
-		WdfRequestComplete(request, ReqStatus);
-		status = WdfIoQueueRetrieveNextRequest(pSrq->Queue, &request);
-	}
-	WdfObjectReleaseLock(pSrq->Queue);
-}
-
 static void WvSrqEventHandler(ib_event_rec_t *pEvent)
 {
+	WV_SHARED_RECEIVE_QUEUE *srq = pEvent->context;
+
 	switch (pEvent->type) {
 	case IB_AE_SRQ_LIMIT_REACHED:
-		WvSrqCompleteRequests(pEvent->context, STATUS_ALERTED);
+		WvFlushQueue(srq->Queue, STATUS_ALERTED);
 		break;
 	case IB_AE_SRQ_QP_LAST_WQE_REACHED:
-		WvSrqCompleteRequests(pEvent->context, STATUS_NOTIFY_CLEANUP);
+		WvFlushQueue(srq->Queue, STATUS_NOTIFY_CLEANUP);
 		break;
 	default:
-		WvSrqCompleteRequests(pEvent->context, STATUS_UNEXPECTED_IO_ERROR);
+		WvFlushQueue(srq->Queue, STATUS_UNEXPECTED_IO_ERROR);
 		break;
 	}
 }
@@ -383,7 +370,7 @@ void WvSrqCancel(WV_PROVIDER *pProvider,
 		goto out;
 	}
 
-	WvSrqCompleteRequests(srq, STATUS_CANCELLED);
+	WvFlushQueue(srq->Queue, STATUS_CANCELLED);
 	WvSrqRelease(srq);
 
 out:
diff -up -r -X trunk\docs\dontdiff.txt -I '\$Id:' trunk/core/winverbs/wv_ioctl.h branches\winverbs/core/winverbs/wv_ioctl.h
--- trunk/core/winverbs/wv_ioctl.h	2008-07-17 16:43:44.468750000 -0700
+++ branches\winverbs/core/winverbs/wv_ioctl.h	2009-01-07 14:32:56.497700600 -0800
@@ -81,9 +81,9 @@ enum {
 	WV_IO_FUNCTION_QP_ATTACH,
 	WV_IO_FUNCTION_QP_DETACH,
 	WV_IO_FUNCTION_QP_CANCEL,
-	WV_IO_FUNCTION_ADDRESS_QUERY,
 	WV_IO_FUNCTION_EP_CREATE,
 	WV_IO_FUNCTION_EP_DESTROY,
+	WV_IO_FUNCTION_EP_MODIFY,
 	WV_IO_FUNCTION_EP_BIND,
 	WV_IO_FUNCTION_EP_REJECT,
 	WV_IO_FUNCTION_EP_CONNECT,
@@ -95,10 +95,8 @@ enum {
 	WV_IO_FUNCTION_EP_MULTICAST_JOIN,
 	WV_IO_FUNCTION_EP_MULTICAST_LEAVE,
 	WV_IO_FUNCTION_EP_CANCEL,
-	WV_IO_FUNCTION_LISTEN,
-	WV_IO_FUNCTION_LISTEN_DESTROY,
-	WV_IO_FUNCTION_LISTEN_GET_REQUEST,
-	WV_IO_FUNCTION_LISTEN_CANCEL,
+	WV_IO_FUNCTION_EP_LISTEN,
+	WV_IO_FUNCTION_EP_GET_REQUEST,
 	WV_IO_FUNCTION_MAX
 };
 
@@ -230,7 +228,7 @@ enum {
 #define WV_IOCTL_QP_QUERY				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_QP_QUERY)
 
-// WV_IO_QP_ATTRIBUTES / none
+// WV_IO_QP_ATTRIBUTES / verbs specific
 #define WV_IOCTL_QP_MODIFY				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_QP_MODIFY)
 
@@ -246,43 +244,69 @@ enum {
 #define WV_IOCTL_QP_CANCEL				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_QP_CANCEL)
 
-// TODO
-#define WV_IOCTL_ADDRESS_QUERY			WV_IOCTL(WV_IO_FUNCTION_BASE + \
-												 WV_IO_FUNCTION_ADDRESS_QUERY)
+// UINT64 EpType / UINT64 Id
 #define WV_IOCTL_EP_CREATE				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_CREATE)
+
+// UINT64 Id / none
 #define WV_IOCTL_EP_DESTROY				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_DESTROY)
+
+// WV_IO_ID + UINT8[] / none
+#define WV_IOCTL_EP_MODIFY				WV_IOCTL(WV_IO_FUNCTION_BASE + \
+												 WV_IO_FUNCTION_EP_MODIFY)
+
+// WV_IO_EP_BIND / WV_IO_EP_BIND
 #define WV_IOCTL_EP_BIND				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_BIND)
+
+// WV_IO_ID + UINT8[] / none
 #define WV_IOCTL_EP_REJECT				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_REJECT)
+
+// WV_IO_EP_CONNECT / none
 #define WV_IOCTL_EP_CONNECT				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_CONNECT)
+
+// WV_IO_EP_ACCEPT / verbs specific
 #define WV_IOCTL_EP_ACCEPT				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_ACCEPT)
+
+// UINT64 Id / none
 #define WV_IOCTL_EP_DISCONNECT			WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_DISCONNECT)
+
+// UINT64 Id / none
 #define WV_IOCTL_EP_DISCONNECT_NOTIFY	WV_IOCTL(WV_IO_FUNCTION_BASE + \
 
WV_IO_FUNCTION_EP_DISCONNECT_NOTIFY)
+
+// UINT64 Id / WV_IO_EP_ATTRIBUTES
 #define WV_IOCTL_EP_QUERY				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_QUERY)
+
+// TODO
 #define WV_IOCTL_EP_LOOKUP				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_LOOKUP)
+
+// TODO
 #define WV_IOCTL_EP_MULTICAST_JOIN		WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_MULTICAST_JOIN)
+
+// TODO
 #define WV_IOCTL_EP_MULTICAST_LEAVE		WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_MULTICAST_LEAVE)
+
+// UINT64 Id / none
 #define WV_IOCTL_EP_CANCEL				WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_EP_CANCEL)
-#define WV_IOCTL_LISTEN					WV_IOCTL(WV_IO_FUNCTION_BASE + \
-												 WV_IO_FUNCTION_LISTEN)
-#define WV_IOCTL_LISTEN_DESTROY			WV_IOCTL(WV_IO_FUNCTION_BASE + \
-												 WV_IO_FUNCTION_LISTEN_DESTROY)
-#define WV_IOCTL_LISTEN_GET_REQUEST		WV_IOCTL(WV_IO_FUNCTION_BASE + \
-												 WV_IO_FUNCTION_LISTEN_GET_REQUEST)
-#define WV_IOCTL_LISTEN_CANCEL			WV_IOCTL(WV_IO_FUNCTION_BASE + \
-												 WV_IO_FUNCTION_LISTEN_CANCEL)
+
+// WV_IO_EP_LISTEN / none
+#define WV_IOCTL_EP_LISTEN				WV_IOCTL(WV_IO_FUNCTION_BASE + \
+												 WV_IO_FUNCTION_EP_LISTEN)
+
+// WV_IO_EP_GET_REQUEST / none
+#define WV_IOCTL_EP_GET_REQUEST			WV_IOCTL(WV_IO_FUNCTION_BASE + \
+												 WV_IO_FUNCTION_EP_GET_REQUEST)
 
 #define WV_IOCTL_MIN					WV_IO_FUNCTION_BASE + WV_IO_FUNCTION_MIN
 #define WV_IOCTL_MAX					WV_IO_FUNCTION_BASE + WV_IO_FUNCTION_MAX
@@ -592,20 +616,125 @@ typedef struct _WV_IO_QP_MULTICAST
 
 }	WV_IO_QP_MULTICAST;
 
-// TODO:
-//WV_IO_ADDRESS_QUERY
-//WV_IO_EP_CREATE
-//WV_IO_EP_BIND
-//WV_IO_EP_REJECT
-//WV_IO_EP_CONNECT
-//WV_IO_EP_ACCEPT
-//WV_IO_EP_DISCONNECT
-//WV_IO_EP_DISCONNECT_NOTIFY
-//WV_IO_EP_QUERY
-//WV_IO_EP_LOOKUP
-//WV_IO_EP_MULTICAST_JOIN
-//WV_IO_EP_MULTICAST_LEAVE
-//WV_IO_LISTEN
-//WV_IO_LISTEN_GET_REQUEST
+// Windows kernel does not define sockaddr* pre-Vista
+typedef struct _WV_IO_SOCKADDR
+{
+	UINT16			SaFamily;
+	UINT8			SaData[14];
+
+}	WV_IO_SOCKADDR;
+
+typedef struct _WV_IO_SOCKADDR_IN
+{
+	UINT16			SinFamily;
+	UINT16			SinPort;
+	UINT32			SinAddr;
+	UINT8			SinZero[8];
+
+}	WV_IO_SOCKADDR_IN;
+
+typedef struct _WV_IO_SOCKADDR_IN6
+{
+	UINT16			Sin6Family;
+	UINT16			Sin6Port;
+	UINT32			Sin6FlowInfo;
+	UINT8			Sin6Addr[16];
+	UINT32			Sin6ScopeId;
+
+}	WV_IO_SOCKADDR_IN6;
+
+typedef struct _WV_IO_SOCKADDR_DATA
+{
+	union
+	{
+		WV_IO_SOCKADDR		Sa;
+		WV_IO_SOCKADDR_IN	In;
+		WV_IO_SOCKADDR_IN6	In6;
+
+	}	SockAddr;
+
+	UINT32					Reserved;
+
+}	WV_IO_SOCKADDR_DATA;
+
+typedef struct _WV_IO_DEVICE_ADDRESS
+{
+	NET64			DeviceGuid;
+	NET16			Pkey;
+	UINT8			PortNumber;
+	UINT8			Reserved[5];
+
+}	WV_IO_DEVICE_ADDRESS;
+
+typedef struct _WV_IO_EP_BIND
+{
+	UINT64					Id;
+	WV_IO_SOCKADDR_DATA		Address;
+	WV_IO_DEVICE_ADDRESS	Device;
+
+}	WV_IO_EP_BIND;
+
+#define WV_IO_EP_OPTION_ROUTE		0x00000001
+
+#define WV_IO_EP_TYPE_CONNECT		0x0106
+#define WV_IO_EP_TYPE_DATAGRAM		0x0111
+
+typedef struct _WV_IO_EP_LISTEN
+{
+	UINT64			Id;
+	UINT64			Backlog;
+
+}	WV_IO_EP_LISTEN;
+
+typedef struct _WV_IO_EP_GET_REQUEST
+{
+	UINT64			Id;
+	UINT64			EpId;
+
+}	WV_IO_EP_GET_REQUEST;
+
+typedef struct _WV_IO_CONNECT_PARAM
+{
+	UINT64			ResponderResources;
+	UINT64			InitiatorDepth;
+	UINT8			RetryCount;
+	UINT8			RnrRetryCount;
+	UINT8			DataLength;
+	UINT8			Reserved[5];
+	UINT8			Data[56];
+
+}	WV_IO_CONNECT_PARAM;
+
+typedef struct _WV_IO_EP_CONNECT
+{
+	UINT64					Id;
+	UINT64					QpId;
+	WV_IO_SOCKADDR_DATA		PeerAddress;
+	WV_IO_CONNECT_PARAM		Param;
+
+}	WV_IO_EP_CONNECT;
+
+typedef struct _WV_IO_EP_ACCEPT
+{
+	UINT64					Id;
+	UINT64					QpId;
+	WV_IO_CONNECT_PARAM		Param;
+
+}	WV_IO_EP_ACCEPT;
+
+typedef struct _WV_IO_EP_ATTRIBUTES
+{
+	WV_IO_SOCKADDR_DATA		LocalAddress;
+	WV_IO_SOCKADDR_DATA		PeerAddress;
+	WV_IO_DEVICE_ADDRESS	Device;
+
+	union {
+		WV_IO_CONNECT_PARAM	Connect;
+		UINT64				Backlog;
+
+	}	Param;
+
+
+}	WV_IO_EP_ATTRIBUTES;
 
 #endif // _WV_IOCTL_H_
diff -up -N trunk\inc\kernel\iba/ib_rdma_cm.h branches\winverbs\inc\kernel\iba/ib_rdma_cm.h
--- trunk\inc\kernel\iba/ib_rdma_cm.h	1969-12-31 16:00:00.000000000 -0800
+++ branches\winverbs\inc\kernel\iba/ib_rdma_cm.h	2008-11-19 18:22:52.995500000 -0800
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2008 Intel Corporation.  All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#pragma once
+
+#ifndef _IB_RDMA_CM_H_
+#define _IB_RDMA_CM_H_
+
+#include <ntddk.h>
+
+#define IB_CMA_VERSION 0x00
+
+#define IB_CMA_SERVICE_ID       0x0000000001000000
+#define IB_CMA_SERVICE_ID_MASK  0xFFFFFFFFFF000000
+#define IB_CMA_CM_RESPONSE_TIMEOUT				20
+#define IB_CMA_MAX_CM_RETRIES					15
+
+typedef union _IB_CMA_IP_ADDRESS
+{
+	UINT8				Ip6Address[16];
+	struct {
+		UINT32			Pad[3];
+		UINT32			Address;
+
+	}	Ip4;
+
+}	IB_CMA_IP_ADDRESS;
+
+typedef struct _IB_CMA_HEADER
+{
+	UINT8				CmaVersion;
+	UINT8				IpVersion;		// IP Version: 7:4
+	UINT16				Port;
+	IB_CMA_IP_ADDRESS	SrcAddress;
+	IB_CMA_IP_ADDRESS	DstAddress;
+
+}	IB_CMA_HEADER;
+
+#endif // _IB_RDMA_CM_H_





More information about the ofw mailing list