Index: makefile
===================================================================
--- makefile	(revision 0)
+++ makefile	(revision 0)
@@ -0,0 +1,7 @@
+#
+# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
+# file to this component.  This file merely indirects to the real make file
+# that is shared by all the driver components of the Windows NT DDK
+#
+
+!INCLUDE ..\..\..\inc\openib.def
Index: makefile.inc
===================================================================
--- makefile.inc	(revision 0)
+++ makefile.inc	(revision 0)
@@ -0,0 +1,7 @@
+_LNG=$(LANGUAGE)
+_INX=.
+STAMP=stampinf -f $@ -a $(_BUILDARCH) -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR)
+
+$(OBJ_PATH)\$(O)\$(INF_NAME).inf: $(_INX)\$(INF_NAME).inx 
+    copy $(_INX)\$(@B).inx $@
+    $(STAMP)
Index: SOURCES
===================================================================
--- SOURCES	(revision 1006)
+++ SOURCES	(working copy)
@@ -1,36 +1,19 @@
 TARGETNAME=winverbs
 TARGETPATH=..\..\..\bin\kernel\obj$(BUILD_ALT_DIR)
-TARGETTYPE=DRIVER_LIBRARY
+TARGETTYPE=DRIVER
 
-!if $(FREEBUILD)
-ENABLE_EVENT_TRACING=1
-!else
-#ENABLE_EVENT_TRACING=1
-!endif
+KMDF_VERSION_MAJOR=1
+INF_NAME=winverbs
+NTTARGETFILES=$(OBJ_PATH)\$(O)\$(INF_NAME).inf
+MISCFILES=$(NTTARGETFILES)
+TARGETLIBS=$(TARGETLIBS) $(DDK_LIB_PATH)\wdmsec.lib
 
-DLLDEF=wv_exports.def
+SOURCES = \
+	winverbs.rc		\
+	wv_driver.c		\
+	wv_provider.c
 
-SOURCES= winverbs.rc	\
-	 wv_provider.c
+INCLUDES = ..;..\..\..\inc;..\..\..\inc\kernel;..\..\..\inc\user;
 
-INCLUDES=..;..\..\..\inc;..\..\..\inc\kernel;
-
-C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS \
-	-DEXPORT_WV_SYMBOLS
-
-!if !defined(DDK_TARGET_OS) || "$(DDK_TARGET_OS)"=="Win2K"
-#
-# The driver is built in the Win2K build environment
-# - use the library version of safe strings 
-#
-TARGETLIBS= $(TARGETLIBS) $(DDK_LIB_PATH)\ntstrsafe.lib
-!endif
-
-!IFDEF ENABLE_EVENT_TRACING
-
-C_DEFINES = $(C_DEFINES) -DEVENT_TRACING
-
-RUN_WPP = $(SOURCES) -km -ext: .cpp .h
-!ENDIF
-
-MSC_WARNING_LEVEL= /W4
+C_DEFINES = $(C_DEFINES) -DIOCTL_INTERFACE=1
+MSC_WARNING_LEVEL = /W4 /wd4244 /wd4201
Index: winverbs.inx
===================================================================
--- winverbs.inx	(revision 0)
+++ winverbs.inx	(revision 0)
@@ -0,0 +1,109 @@
+;
+; 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 AWV
+; 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.
+;
+
+[Version]
+Signature = "$WINDOWS NT$"
+Class = InfiniBandHca
+ClassGUID = {58517E00-D3CF-40c9-A679-CEE5752F4491}
+Provider = %OFA%
+DriverVer = 03/07/2008
+CatalogFile = winverbs.cat
+
+[SourceDisksNames]
+1 = %DiskId%
+
+[SourceDisksFiles]
+winverbs.sys = 1
+
+[ClassInstall32]
+AddReg = ClassAddReg
+
+[ClassAddReg]
+HKR,,,0,%ClassName%
+HKR,,Icon,,-5
+
+[DestinationDirs]
+DefaultDestDir = 12
+
+[Manufacturer]
+%OFA% = WvModel, NT$ARCH$
+
+[WvModel.NT$ARCH$]
+%WinVerbs.DeviceDesc% = WvDevice, root\WinVerbs
+
+[WvDevice.NT]
+CopyFiles = WvDDInst
+CopyFile = WvDLLInst
+
+[WvDDInst]
+winverbs.sys
+
+[WvDLLInst]
+winverbs.dll
+winverbsd.dll
+
+[WvDevice.NT.Services]
+AddService = WinVerbs, 2, WvServiceInst;
+
+[WvServiceInst]
+DisplayName = %WinVerbs.ServiceDesc%
+ServiceType = 1
+StartType = 3
+ErrorControl = 1
+ServiceBinary  = %12%\winverbs.sys
+LoadOrderGroup = Extended Base
+
+[WvDevice.NT.CoInstallers]
+AddReg = WvDeviceCoInstAddReg
+CopyFiles = WvDeviceCoInstCopyFiles
+
+[DestinationDirs]
+WvDeviceCoInstCopyFiles = 11
+
+[WvDeviceCoInstAddReg]
+HKR,,CoInstallers32,0x00010000, "WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll, WdfCoInstaller"
+
+[WvDeviceCoInstCopyFiles]
+WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll
+
+[SourceDisksFiles]
+WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1
+
+[WvDevice.NT.Wdf]
+KmdfService = WinVerbs, WvWdfSect
+
+[WvWdfSect]
+KmdfLibraryVersion = $KMDFVERSION$
+
+[Strings]
+OFA = "OpenFabrics"
+DiskId = "OpenFabrics WinVerbs Installation Disk"
+WinVerbs.DeviceDesc = "WinVerbs Driver"
+WinVerbs.ServiceDesc = "WinVerbs Service"
+ClassName = "WinVerbs Device"
Index: winverbs.rc
===================================================================
--- winverbs.rc	(revision 1006)
+++ winverbs.rc	(working copy)
@@ -27,11 +27,10 @@
  * SOFTWARE.
  */
 
-
 #include <oib_ver.h>
 
-#define VER_FILETYPE			VFT_DRV
-#define VER_FILESUBTYPE			VFT2_UNKNOWN
+#define VER_FILETYPE				VFT_DRV
+#define VER_FILESUBTYPE				VFT2_DRV_SYSTEM
 
 #ifdef _DEBUG_
 #define VER_FILEDESCRIPTION_STR		"Kernel WinVerbs (Debug)"
Index: wv_cq.h
===================================================================
--- wv_cq.h	(revision 0)
+++ wv_cq.h	(revision 0)
@@ -0,0 +1,50 @@
+/*
+ * 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 AWV
+ * 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 _WV_CQ_H_
+#define _WV_CQ_H_
+
+#include <wdm.h>
+#include <iba\ib_types.h>
+#include <iba\ib_ci.h>
+#include "wv_device.h"
+
+typedef struct _WV_COMPLETION_QUEUE
+{
+	WV_DEVICE			*pDevice;
+	ci_interface_t		*pVerbs;
+	ib_cq_handle_t		hVerbsCq;
+	UINT64				Id;
+	LONG				nRef;
+
+}	WV_COMPLETION_QUEUE;
+
+#endif //_WV_CQ_H_
Index: wv_device.h
===================================================================
--- wv_device.h	(revision 0)
+++ wv_device.h	(revision 0)
@@ -0,0 +1,53 @@
+/*
+ * 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 AWV
+ * 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 _WV_DEVICE_H_
+#define _WV_DEVICE_H_
+
+#include <ntddk.h>
+#include <wdm.h>
+#include <iba\ib_types.h>
+#include <iba\ib_ci.h>
+#include "wv_provider.h"
+
+typedef struct _WV_DEVICE
+{
+	WV_PROVIDER			*pProvider;
+	LIST_ENTRY			Entry;
+	ci_interface_t		Verbs;
+	ib_ca_handle_t		hVerbsDevice;
+	SIZE_T				Id;
+	UINT64				Guid;
+	LONG				nRef;
+
+}	WV_DEVICE;
+
+#endif // __WV_DEVICE_H_
Index: wv_driver.c
===================================================================
--- wv_driver.c	(revision 0)
+++ wv_driver.c	(revision 0)
@@ -0,0 +1,285 @@
+/*
+ * 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 AWV
+ * 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.
+ */
+
+#include <ntddk.h>
+#include <wdf.h>
+#include <wdmsec.h>
+#include <winerror.h>
+#include <initguid.h>
+
+#include "wv_driver.h"
+#include "wv_ioctl.h"
+#include "wv_provider.h"
+#include "wv_device.h"
+#include "wv_pd.h"
+#include "wv_cq.h"
+#include "wv_srq.h"
+#include "wv_qp.h"
+#include "wv_listen.h"
+#include "wv_ep.h"
+
+WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(WV_RDMA_DEVICE, WvGetRdmaDevice)
+WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(WV_PROVIDER, WvGetProvider)
+
+static WDFDEVICE	ControlDevice;
+KGUARDED_MUTEX		DevLock;
+LIST_ENTRY			DevList;
+
+static EVT_WDF_DRIVER_DEVICE_ADD			WvDeviceAdd;
+static EVT_WDF_OBJECT_CONTEXT_CLEANUP		WvDeviceCleanup;
+static EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL	WvIoDeviceControl;
+static EVT_WDF_DEVICE_FILE_CREATE			WvFileCreate;
+static EVT_WDF_FILE_CLEANUP					WvFileCleanup;
+static EVT_WDF_FILE_CLOSE					WvFileClose;
+
+static VOID WvIoDeviceControl(WDFQUEUE Queue, WDFREQUEST Request,
+							  size_t OutLen, size_t InLen, ULONG IoControlCode)
+{
+	WDFFILEOBJECT	file;
+	WV_PROVIDER		*prov;
+	UNREFERENCED_PARAMETER(OutLen);
+	UNREFERENCED_PARAMETER(InLen);
+	UNREFERENCED_PARAMETER(Queue);
+
+	file = WdfRequestGetFileObject(Request);
+	prov = WvGetProvider(file);
+
+	switch (IoControlCode) {
+	case WV_IOCTL_GUID_QUERY:
+		WvGuidQuery(Request);
+		break;
+	//case WV_IOCTL_LIBRARY_QUERY:WvLibraryQuery;break;
+	//case WV_IOCTL_DEVICE_OPEN:WvDeviceOpen;break;
+	//case WV_IOCTL_DEVICE_CLOSE:WvDeviceClose;break;
+	//case WV_IOCTL_DEVICE_QUERY:WvDevideQuery;break;
+	//case WV_IOCTL_DEVICE_PORT_QUERY:WvDevicePortQuery;break;
+	//case WV_IOCTL_DEVICE_GID_QUERY:WvDeviceGidQuery;break;
+	//case WV_IOCTL_DEVICE_PKEY_QUERY:WvDevicePkeyQuery;break;
+	//case WV_IOCTL_DEVICE_NOTIFY:WvDeviceNotify;break;
+	//case WV_IOCTL_DEVICE_CANCEL:WvDeviceCancel;break;
+	//case WV_IOCTL_PD_ALLOCATE:WvPdAllocate;break;
+	//case WV_IOCTL_PD_DEALLOCATE:WvPdDeallocate;break;
+	//case WV_IOCTL_MEMORY_REGISTER:WvMemoryRegister;break;
+	//case WV_IOCTL_MEMORY_DEREGISTER:WvmemoryDeregister;break;
+	//case WV_IOCTL_MW_ALLOCATE:WvMwAllocate;break;
+	//case WV_IOCTL_MW_DEALLOCATE:WvMwDeallocate;break;
+	//case WV_IOCTL_AH_CREATE:WvAhCreate;break;
+	//case WV_IOCTL_AH_DESTROY:WvAhDestroy;break;
+	//case WV_IOCTL_CQ_CREATE:WvCqCreate;break;
+	//case WV_IOCTL_CQ_DESTROY:WvCqDestroy;break;
+	//case WV_IOCTL_CQ_RESIZE:WvCqResize;break;
+	//case WV_IOCTL_CQ_NOTIFY:WvCqNotify;break;
+	//case WV_IOCTL_CQ_BATCH_NOTIFY:WvCqBatchNotify;break;
+	//case WV_IOCTL_CQ_CANCEL:WvCqCancel;break;
+	//case WV_IOCTL_SRQ_CREATE :WvSrqCreate;break;
+	//case WV_IOCTL_SRQ_DESTROY:WvSrqDestroy;break;
+	//case WV_IOCTL_SRQ_QUERY:WvSrqQuery;break;
+	//case WV_IOCTL_SRQ_MODIFY:WvSrqModify;break;
+	//case WV_IOCTL_SRQ_NOTIFY:WvSrqNotify;break;
+	//case WV_IOCTL_SRQ_CANCEL:WvSrqCancel;break;
+	//case WV_IOCTL_QP_CREATE:WvQpCreate;break;
+	//case WV_IOCTL_QP_DESTROY:WvQpDestroy;break;
+	//case WV_IOCTL_QP_QUERY:WvQpQuery;break;
+	//case WV_IOCTL_QP_MODIFY:WvQpModify;break;
+	//case WV_IOCTL_QP_ATTACH:WvQpAttach;break;
+	//case WV_IOCTL_QP_DETACH:WvQpDetach;break;
+	//case WV_IOCTL_QP_CANCEL:WvQpCancel;break;
+	//case WV_IOCTL_ADDRESS_QUERY:WvAddressQuery;break;
+	//case WV_IOCTL_EP_CREATE:WvEpCreate;break;
+	//case WV_IOCTL_EP_DESTROY:WvEpDestroy;break;
+	//case WV_IOCTL_EP_BIND:WvEpBind;break;
+	//case WV_IOCTL_EP_REJECT:WvEpReject;break;
+	//case WV_IOCTL_EP_CONNECT:WvEpConnect;break;
+	//case WV_IOCTL_EP_ACCEPT:WvEpAccept;break;
+	//case WV_IOCTL_EP_DISCONNECT:WvEpDisconnect;break;
+	//case WV_IOCTL_EP_DISCONNECT_NOTIFY:WvEpDisconnectNotify;break;
+	//case WV_IOCTL_EP_QUERY:WvEpQuery;break;
+	//case WV_IOCTL_EP_LOOKUP:WvEpLookup;break;
+	//case WV_IOCTL_EP_MULTICAST_JOIN:WvEpMulticastJoin;break;
+	//case WV_IOCTL_EP_MULTICAST_LEAVE:WvEpMulticastLeave;break;
+	//case WV_IOCTL_EP_CANCEL:WvEpCancel;break;
+	//case WV_IOCTL_LISTEN:WvListen;break;
+	//case WV_IOCTL_LISTEN_DESTROY:WvListenDestroy;break;
+	//case WV_IOCTL_LISTEN_GET_REQUEST:WvListenGetRequest;break;
+	//case WV_IOCTL_LISTEN_CANCEL:WvListenCancel;break;
+	default:
+		WdfRequestComplete(Request, E_NOINTERFACE);
+		break;
+	}
+}
+
+static VOID WvFileCreate(WDFDEVICE Device, WDFREQUEST Request,
+						 WDFFILEOBJECT FileObject)
+{
+	WV_PROVIDER	*prov;
+
+	UNREFERENCED_PARAMETER(Device);
+
+	prov = WvGetProvider(FileObject);
+	WvProviderInit(prov);
+	WdfRequestComplete(Request, STATUS_SUCCESS);
+}
+
+static VOID WvFileCleanup(WDFFILEOBJECT FileObject)
+{
+	UNREFERENCED_PARAMETER(FileObject);
+}
+
+static VOID WvFileClose(WDFFILEOBJECT FileObject)
+{
+	WV_PROVIDER *prov;
+
+	prov = WvGetProvider(FileObject);
+	WvProviderDestroy(prov);
+}
+
+static VOID WvCreateControlDevice(WDFDRIVER Driver)
+{
+	PWDFDEVICE_INIT			pinit;
+	WDF_FILEOBJECT_CONFIG	fileconfig;
+	WDF_OBJECT_ATTRIBUTES	attr;
+	WDF_IO_QUEUE_CONFIG		ioconfig;
+	NTSTATUS				status;
+	WDFQUEUE				queue;
+	DECLARE_CONST_UNICODE_STRING(name, L"\\Device\\WinVerbs");
+	DECLARE_CONST_UNICODE_STRING(symlink, L"\\DosDevices\\WinVerbs");
+
+	pinit = WdfControlDeviceInitAllocate(Driver,
+										 &SDDL_DEVOBJ_SYS_ALL_ADM_RWX_WORLD_RW_RES_R);
+	if (pinit == NULL) {
+			return;
+	}
+
+	WdfDeviceInitSetExclusive(pinit, FALSE);
+	status = WdfDeviceInitAssignName(pinit, &name);
+	if (!NT_SUCCESS(status)) {
+		goto err1;
+	}
+
+	WDF_FILEOBJECT_CONFIG_INIT(&fileconfig, WvFileCreate, WvFileClose,
+							   WvFileCleanup);
+	WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attr, WV_PROVIDER);
+	WdfDeviceInitSetFileObjectConfig(pinit, &fileconfig, &attr);
+
+	WDF_OBJECT_ATTRIBUTES_INIT(&attr);
+	status = WdfDeviceCreate(&pinit, &attr, &ControlDevice);
+	if (!NT_SUCCESS(status)) {
+		goto err1;
+	}
+
+	status = WdfDeviceCreateSymbolicLink(ControlDevice, &symlink);
+	if (!NT_SUCCESS(status)) {
+		goto err2;
+	}
+
+	WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioconfig, WdfIoQueueDispatchParallel);
+	ioconfig.EvtIoDeviceControl = WvIoDeviceControl;
+	status = WdfIoQueueCreate(ControlDevice, &ioconfig,
+							  WDF_NO_OBJECT_ATTRIBUTES, &queue);
+	if (!NT_SUCCESS(status)) {
+		goto err2;
+	}
+
+	WdfControlFinishInitializing(ControlDevice);
+	return;
+
+err2:
+	WdfObjectDelete(ControlDevice);
+err1:
+	WdfDeviceInitFree(pinit);
+}
+
+static NTSTATUS WvDeviceAdd(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit)
+{
+	WDF_OBJECT_ATTRIBUTES	attr;
+	WDFDEVICE				dev;
+	NTSTATUS				status;
+	WV_RDMA_DEVICE			*pdev;
+	BOOLEAN					create;
+
+	WdfFdoInitSetFilter(DeviceInit);
+
+	WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attr, WV_RDMA_DEVICE);
+	attr.EvtCleanupCallback = WvDeviceCleanup;
+	status = WdfDeviceCreate(&DeviceInit, &attr, &dev);
+	if (!NT_SUCCESS(status)) {
+		return status;
+	}
+
+	pdev = WvGetRdmaDevice(dev);
+	pdev->Guid = 0x1234567890ABCDEF;
+
+	KeAcquireGuardedMutex(&DevLock);
+	create = IsListEmpty(&DevList);
+	InsertHeadList(&DevList, &pdev->Entry);
+	KeReleaseGuardedMutex(&DevLock);
+
+	if (create) {
+		WvCreateControlDevice(Driver);
+	}
+
+	return status;
+}
+
+static VOID WvDeviceCleanup(WDFDEVICE Device)
+{
+	WV_RDMA_DEVICE			*pdev;
+	BOOLEAN					destroy;
+	WDFDEVICE				ctrldev;
+
+	pdev = WvGetRdmaDevice(Device);
+	KeAcquireGuardedMutex(&DevLock);
+	RemoveEntryList(&pdev->Entry);
+	destroy = IsListEmpty(&DevList);
+	ctrldev = ControlDevice;
+	KeReleaseGuardedMutex(&DevLock);
+
+	if (destroy) {
+		WdfObjectDelete(ctrldev);
+	}
+}
+
+NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
+{
+	WDF_DRIVER_CONFIG		config;
+	NTSTATUS				status;
+	WDFDRIVER				driv;
+
+	InitializeListHead(&DevList);
+	KeInitializeGuardedMutex(&DevLock);
+
+	WDF_DRIVER_CONFIG_INIT(&config, WvDeviceAdd);
+	status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES,
+							 &config, &driv);
+	if (!NT_SUCCESS(status)) {
+		return status;
+	}
+
+	return STATUS_SUCCESS;
+}
Index: wv_driver.h
===================================================================
--- wv_driver.h	(revision 0)
+++ wv_driver.h	(revision 0)
@@ -0,0 +1,52 @@
+/*
+ * 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 AWV
+ * 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 _WV_DRIVER_H_
+#define _WV_DRIVER_H_
+
+#include <ntddk.h>
+#include <wdm.h>
+#include <iba\ib_types.h>
+#include <iba\ib_ci.h>
+
+typedef struct _WV_RDMA_DEVICE
+{
+	UINT64			Guid;
+	LIST_ENTRY		Entry;
+	ci_interface_t	Verbs;
+	ib_ca_handle_t	hVerbsDevice;
+
+}	WV_RDMA_DEVICE;
+
+extern KGUARDED_MUTEX	DevLock;
+extern LIST_ENTRY		DevList;
+
+#endif // _WV_DRIVER_H_
Index: wv_ep.h
===================================================================
--- wv_ep.h	(revision 0)
+++ wv_ep.h	(revision 0)
@@ -0,0 +1,56 @@
+/*
+ * 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 AWV
+ * 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 _WV_EP_H_
+#define _WV_EP_H_
+
+#include <wdm.h>
+#include <iba\ib_types.h>
+#include <iba\ib_ci.h>
+#include "wv_provider.h"
+
+typedef struct _WV_CONNECT_ENDPOINT
+{
+	WV_PROVIDER		*pProvider;
+	UINT64			Id;
+	LONG			nRef;
+
+}	WV_CONNECT_ENDPOINT;
+
+typedef struct _WV_DATAGRAM_ENDPOINT
+{
+	WV_PROVIDER		*pProvider;
+	UINT64			Id;
+	LONG			m_nRef;
+
+}	WV_DATAGRAM_ENDPOINT;
+
+#endif // _WV_EP_H_
Index: wv_exports.def
===================================================================
--- wv_exports.def	(revision 1006)
+++ wv_exports.def	(working copy)
@@ -1,7 +0,0 @@
-LIBRARY	winverbs.sys
-
-EXPORTS
-; DllInitialize and DllUnload must be exported for the OS reference counting to
-; work, and must be private for the compiler to accept them.
-DllInitialize private
-DllUnload private
Index: wv_listen.h
===================================================================
--- wv_listen.h	(revision 0)
+++ wv_listen.h	(revision 0)
@@ -0,0 +1,48 @@
+/*
+ * 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 AWV
+ * 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 _WV_LISTEN_H_
+#define _WV_LISTEN_H_
+
+#include <wdm.h>
+#include <iba\ib_types.h>
+#include <iba\ib_ci.h>
+#include "wv_provider.h"
+
+typedef struct _WV_LISTEN
+{
+	WV_PROVIDER		*pProvider;
+	UINT64			Id;
+	LONG			nRef;
+
+}	WV_LISTEN;
+
+#endif // _WV_LISTEN_H_
Index: wv_pd.h
===================================================================
--- wv_pd.h	(revision 0)
+++ wv_pd.h	(revision 0)
@@ -0,0 +1,79 @@
+/*
+ * 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 AWV
+ * 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 _WV_PD_H_
+#define _WV_PD_H_
+
+#include <wdm.h>
+#include <iba\ib_types.h>
+#include <iba\ib_ci.h>
+#include "wv_device.h"
+
+typedef struct _WV_PROTECTION_DOMAIN
+{
+	WV_DEVICE				*pDevice;
+	ci_interface_t			*pVerbs;
+	ib_pd_handle_t			hVerbsPd;
+	UINT64					Id;
+	volatile LONG			m_nRef;
+
+}	WV_PROTECTION_DOMAIN;
+
+
+typedef struct _WV_MEMORY_WINDOW
+{
+	WV_PROTECTION_DOMAIN	*pPd;
+	ci_interface_t			*pVerbs;
+	ib_mw_handle_t			hVerbsMw;
+	UINT64					Id;
+	UINT32					Rkey;
+	volatile LONG			nRef;
+
+}	WV_MEMORY_WINDOW;
+
+
+typedef struct _WV_ADDRESS_HANDLE
+{
+	WV_PROTECTION_DOMAIN	*pPd;
+	ci_interface_t			*pVerbs;
+	ib_av_handle_t			hVerbsAh;
+	UINT64					Id;
+	volatile LONG			m_nRef;
+
+}	WV_ADDRESS_HANDLE;
+
+//void WvVerbsConvertAv(ib_av_attr_t *pVerbsAv, WV_ADDRESS_VECTOR *pAv,
+//					  UINT8 PathMtu, UINT8 LocalAckTimeout,
+//					  UINT8 SequenceErrorRetryCount, UINT8 RnrRetryCount);
+//void WvIoConvertAv(WV_IO_AV *pIoAv, WV_ADDRESS_VECTOR *pAv);
+//void WvAvConvertIo(WV_ADDRESS_VECTOR *pAv, WV_IO_AV *pIoAv);
+
+#endif // _WV_PD_H_
Index: wv_provider.c
===================================================================
--- wv_provider.c	(revision 0)
+++ wv_provider.c	(revision 0)
@@ -0,0 +1,88 @@
+/*
+ * 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 AWV
+ * 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.
+ */
+
+#include <winerror.h>
+
+#include <rdma\wvstatus.h>
+#include "wv_driver.h"
+#include "wv_ioctl.h"
+#include "wv_provider.h"
+#include "wv_device.h"
+
+void WvGuidQuery(WDFREQUEST Request)
+{
+	WV_IO_GUID_LIST	*pioGuids;
+	size_t			len = 0;
+	WV_RDMA_DEVICE	*pdev;
+	ULONG			count, i;
+	LIST_ENTRY		*pentry;
+	NTSTATUS		status;
+
+	status = WdfRequestRetrieveOutputBuffer(Request, sizeof(WV_IO_GUID_LIST),
+											&pioGuids, &len);
+	if (!NT_SUCCESS(status)) {
+		goto out;
+	}
+
+	count = (len - sizeof(UINT64)) / sizeof(UINT64);
+	i = 0;
+	len = sizeof(UINT64);
+	KeAcquireGuardedMutex(&DevLock);
+	for (pentry = DevList.Flink; pentry != &DevList; pentry = pentry->Flink) {
+		pdev = CONTAINING_RECORD(pentry, WV_RDMA_DEVICE, Entry);
+		if (i < count) {
+			pioGuids->Guid[i] = pdev->Guid;
+			len += sizeof(UINT64);
+		}
+		i++;
+	}
+	pioGuids->Count = i;
+	KeReleaseGuardedMutex(&DevLock);
+
+out:
+	WdfRequestCompleteWithInformation(Request, status, len);
+}
+
+void WvProviderInit(WV_PROVIDER *pProvider)
+{
+	InitializeListHead(&pProvider->DevList);
+	KeInitializeGuardedMutex(&pProvider->Lock);
+}
+
+void WvProviderDestroy(WV_PROVIDER *pProvider)
+{
+	LIST_ENTRY *entry;
+	WV_DEVICE *dev;
+
+	while (!IsListEmpty(&pProvider->DevList)) {
+		entry = RemoveHeadList(&pProvider->DevList);
+		dev = CONTAINING_RECORD(entry, WV_DEVICE, Entry);
+		//WvDeviceDestroy(dev);
+	}
+}
Index: wv_provider.h
===================================================================
--- wv_provider.h	(revision 0)
+++ wv_provider.h	(revision 0)
@@ -0,0 +1,51 @@
+/*
+ * 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 AWV
+ * 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 _WV_PROVIDER_H_
+#define _WV_PROVIDER_H_
+
+#include <ntddk.h>
+#include <wdf.h>
+#include <wdm.h>
+
+typedef struct _WV_PROVIDER
+{
+	KGUARDED_MUTEX	Lock;
+	LIST_ENTRY		DevList;
+
+}	WV_PROVIDER;
+
+void WvProviderInit(WV_PROVIDER *pProvider);
+void WvProviderDestroy(WV_PROVIDER *pProvider);
+
+void WvGuidQuery(WDFREQUEST Request);
+
+#endif // _WV_PROVIDER_H_
Index: wv_qp.h
===================================================================
--- wv_qp.h	(revision 0)
+++ wv_qp.h	(revision 0)
@@ -0,0 +1,55 @@
+/*
+ * 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 AWV
+ * 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 _WV_QP_H_
+#define _WV_QP_H_
+
+#include <wdm.h>
+#include <iba\ib_types.h>
+#include <iba\ib_ci.h>
+#include "wv_pd.h"
+#include "wv_cq.h"
+#include "wv_srq.h"
+
+typedef struct _WV_QUEUE_PAIR
+{
+	WV_PROTECTION_DOMAIN	*pPd;
+	WV_COMPLETION_QUEUE		*pSendCq;
+	WV_COMPLETION_QUEUE		*pReceiveCq;
+	WV_SHARED_RECEIVE_QUEUE	*pSrq;
+	ci_interface_t			*pVerbs;
+	ib_qp_handle_t			m_hVerbsQp;
+	UINT64					m_Id;
+	LONG					nRef;
+
+}	WV_QUEUE_PAIR;
+
+#endif // _WV_QP_H_
Index: wv_srq.h
===================================================================
--- wv_srq.h	(revision 0)
+++ wv_srq.h	(revision 0)
@@ -0,0 +1,50 @@
+/*
+ * 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 AWV
+ * 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 _WV_SRQ_H_
+#define _WV_SRQ_H_
+
+#include <wdm.h>
+#include <iba\ib_types.h>
+#include <iba\ib_ci.h>
+#include "wv_pd.h"
+
+typedef struct _WV_SHARED_RECEIVE_QUEUE
+{
+	WV_PROTECTION_DOMAIN	*pPd;
+	ci_interface_t			*pVerbs;
+	ib_srq_handle_t			hVerbsSrq;
+	UINT64					Id;
+	LONG					nRef;
+
+}	WV_SHARED_RECEIVE_QUEUE;
+
+#endif // _WV_SRQ_H_
