]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
winverbs/nd: ND 2.0 provider template
authorSean Hefty <sean.hefty@intel.com>
Thu, 27 May 2010 16:44:51 +0000 (16:44 +0000)
committerSean Hefty <sean.hefty@intel.com>
Thu, 27 May 2010 16:44:51 +0000 (16:44 +0000)
Initial port ND 1.0 provider to 2.0 APIs.  Only those functions which easily ported from 1.0 to 2.0 were implemented.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1@2814 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

28 files changed:
trunk/ulp/netdirect2/dirs [new file with mode: 0644]
trunk/ulp/netdirect2/user/SOURCES [new file with mode: 0644]
trunk/ulp/netdirect2/user/makefile [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_adapter.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_adapter.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_base.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_base.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_connect.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_connect.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_cq.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_cq.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_ep.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_ep.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_export.def [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_exports.src [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_listen.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_listen.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_main.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_main.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_mw.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_mw.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_provider.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_provider.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_qp.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_qp.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_srq.cpp [new file with mode: 0644]
trunk/ulp/netdirect2/user/nd_srq.h [new file with mode: 0644]
trunk/ulp/netdirect2/user/netdirect.rc [new file with mode: 0644]

diff --git a/trunk/ulp/netdirect2/dirs b/trunk/ulp/netdirect2/dirs
new file mode 100644 (file)
index 0000000..0e61a79
--- /dev/null
@@ -0,0 +1 @@
+DIRS = user\r
diff --git a/trunk/ulp/netdirect2/user/SOURCES b/trunk/ulp/netdirect2/user/SOURCES
new file mode 100644 (file)
index 0000000..dc490f0
--- /dev/null
@@ -0,0 +1,45 @@
+!if $(FREEBUILD)\r
+TARGETNAME = wvnd2prov\r
+!else\r
+TARGETNAME = wvnd2provd\r
+!endif\r
+\r
+TARGETPATH = ..\..\..\bin\user\obj$(BUILD_ALT_DIR)\r
+TARGETTYPE = DYNLINK\r
+\r
+!if $(_NT_TOOLS_VERSION) == 0x700\r
+DLLDEF = $O\nd_export.def\r
+!else\r
+DLLDEF = $(OBJ_PATH)\$O\nd_export.def\r
+!endif\r
+\r
+DLLENTRY = DllMain\r
+USE_MSVCRT = 1\r
+\r
+SOURCES =                      \\r
+       nd_main.cpp             \\r
+       nd_base.cpp             \\r
+       nd_provider.cpp \\r
+       nd_adapter.cpp  \\r
+       nd_listen.cpp   \\r
+       nd_connect.cpp  \\r
+       nd_qp.cpp               \\r
+       nd_ep.cpp               \\r
+       nd_mw.cpp               \\r
+       nd_cq.cpp               \\r
+       nd_srq.cpp\r
+\r
+INCLUDES = ..\..\..\inc;..\..\..\inc\user;\\r
+                  ..\..\..\inc\user\linux;$(ND2_SDK_PATH)\include;\r
+\r
+TARGETLIBS =                                           \\r
+       $(SDK_LIB_PATH)\kernel32.lib    \\r
+       $(SDK_LIB_PATH)\uuid.lib                \\r
+       $(SDK_LIB_PATH)\ws2_32.lib              \\r
+       $(SDK_LIB_PATH)\iphlpapi.lib    \\r
+       $(TARGETPATH)\*\ibat.lib                \\r
+!if $(FREEBUILD)\r
+       $(TARGETPATH)\*\winverbs.lib\r
+!else\r
+       $(TARGETPATH)\*\winverbsd.lib\r
+!endif\r
diff --git a/trunk/ulp/netdirect2/user/makefile b/trunk/ulp/netdirect2/user/makefile
new file mode 100644 (file)
index 0000000..c43884f
--- /dev/null
@@ -0,0 +1,14 @@
+#\r
+# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source\r
+# file to this component.  This file merely indirects to the real make file\r
+# that is shared by all the driver components of the OpenIB Windows project.\r
+#\r
+\r
+!IFNDEF ND_SDK_PATH\r
+!MESSAGE Skipping wvndprov.dll build: ND_SD_PATH not set.\r
+DDK_BLOCK_ON_X86   = 1\r
+DDK_BLOCK_ON_AMD64 = 1\r
+DDK_BLOCK_ON_IA64  = 1\r
+!ENDIF\r
+\r
+!INCLUDE ..\..\..\inc\openib.def\r
diff --git a/trunk/ulp/netdirect2/user/nd_adapter.cpp b/trunk/ulp/netdirect2/user/nd_adapter.cpp
new file mode 100644 (file)
index 0000000..475c1e6
--- /dev/null
@@ -0,0 +1,246 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include "nd_adapter.h"\r
+#include "nd_cq.h"\r
+#include "nd_listen.h"\r
+#include "nd_connect.h"\r
+#include "nd_mw.h"\r
+#include "nd_qp.h"\r
+#include "nd_srq.h"\r
+#include "nd_ep.h"\r
+\r
+CNDAdapter::CNDAdapter(CNDProvider *pProvider)\r
+{\r
+       pProvider->AddRef();\r
+       m_pProvider = pProvider;\r
+       m_pWvDevice = NULL;\r
+       m_pWvPd = NULL;\r
+       m_MaxInlineSend = 0;\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+Init(UINT64 adapterId)\r
+{\r
+       HRESULT hr;\r
+       TCHAR val[16];\r
+       DWORD ret;\r
+\r
+       m_DeviceGuid = adapterId;\r
+       hr = m_pProvider->m_pWvProvider->OpenDevice(m_DeviceGuid, &m_pWvDevice);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       hr = m_pWvDevice->AllocateProtectionDomain(&m_pWvPd);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       ret = GetEnvironmentVariable("IBNDPROV_MAX_INLINE_SIZE", val, 16);\r
+       m_MaxInlineSend = (ret > 0 && ret <= 16) ? (SIZE_T) strtoul(val, NULL, 16) : 160;\r
+       return ND_SUCCESS;\r
+}\r
+\r
+CNDAdapter::~CNDAdapter(void)\r
+{\r
+       if (m_pWvPd != NULL) {\r
+               m_pWvPd->Release();\r
+       }\r
+       if (m_pWvDevice != NULL) {\r
+               m_pWvDevice->Release();\r
+       }\r
+       m_pProvider->Release();\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_INDAdapter) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDAdapter::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDAdapter::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+STDMETHODIMP_(HANDLE) CNDAdapter::\r
+GetFileHandle(void)\r
+{\r
+       return m_pProvider->m_pWvProvider->GetFileHandle();\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+Query(ND_ADAPTER_INFO* pInfo, SIZE_T* pcbInfo)\r
+{\r
+       WV_DEVICE_ATTRIBUTES attr;\r
+       HRESULT hr;\r
+\r
+       if (pInfo != NULL && pInfo->InfoVersion != 1) {\r
+               return ND_NOT_SUPPORTED;\r
+       }\r
+\r
+       if (*pcbInfo < sizeof(ND_ADAPTER_INFO)) {\r
+               hr = ND_BUFFER_OVERFLOW;\r
+               goto out;\r
+       }\r
+\r
+       hr = m_pWvDevice->Query(&attr);\r
+       if (FAILED(hr)) {\r
+               goto out;\r
+       }\r
+\r
+       pInfo->VendorId                                 = (UINT16) attr.VendorId;\r
+       pInfo->DeviceId                                 = (UINT16) attr.VendorPartId;\r
+       pInfo->AdapterId                                = m_DeviceGuid;\r
+       pInfo->MaxRegistrationSize              = attr.MaxMrSize;\r
+       pInfo->MaxWindowSize                    = attr.MaxMrSize;\r
+    pInfo->MaxReceiveSGE                       = (DWORD) attr.MaxSge;\r
+    pInfo->MaxInitiatorSGE                     = (DWORD) attr.MaxSge;\r
+    pInfo->MaxReadSGE                          = (DWORD) attr.MaxSge;\r
+    pInfo->MaxTransferLength           = 1 << 31;\r
+       pInfo->MaxInboundReadLimit              = (DWORD) attr.MaxQpResponderResources;\r
+       pInfo->MaxOutboundReadLimit             = (DWORD) attr.MaxQpInitiatorDepth;\r
+    pInfo->MaxRQDepth                          = (DWORD) attr.MaxQpWr;\r
+    pInfo->MaxIQDepth                          = (DWORD) attr.MaxQpWr;\r
+    pInfo->MaxSRQDepth                         = (DWORD) attr.MaxSrqWr;\r
+    pInfo->MaxCQDepth                          = (DWORD) attr.MaxCqEntries;\r
+    pInfo->InlineRequestThreshold      = m_MaxInlineSend;\r
+    pInfo->LargeRequestThreshold       = 0;\r
+       pInfo->MaxCallerData                    = ND_PRIVATE_DATA_SIZE;\r
+       pInfo->MaxCalleeData                    = ND_PRIVATE_DATA_SIZE;\r
+    pInfo->InlineDataFactor                    = 0;\r
+    pInfo->InlineDataAdjustment                = -((LONG) attr.MaxInlineSend);\r
+    pInfo->InOrderDMA                          = TRUE;\r
+    pInfo->SupportsCQResize                    = TRUE;\r
+    pInfo->SupportsLoopbackConnections = TRUE;\r
+\r
+out:\r
+       *pcbInfo = sizeof(ND_ADAPTER_INFO);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+QueryAddressList(SOCKET_ADDRESS_LIST* pAddressList, SIZE_T* pcbAddressList)\r
+{\r
+       return m_pProvider->QueryAdapterAddressList(pAddressList, pcbAddressList, m_DeviceGuid);\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+CreateCompletionQueue(DWORD queueDepth, GROUP_AFFINITY* pAffinity,\r
+                                         INDCompletionQueue** ppCompletionQueue)\r
+{\r
+       return CNDCompletionQueue::CreateInstance(this, queueDepth, ppCompletionQueue);\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+CreateMemoryRegion(INDMemoryRegion** ppMemoryRegion)\r
+{\r
+       return CNDMemoryRegion::CreateInstance(this, ppMemoryRegion);\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+CreateMemoryWindow(INDMemoryWindow** ppMemoryWindow)\r
+{\r
+       return CNDMemoryWindow::CreateInstance(this, ppMemoryWindow);\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+CreateSharedReceiveQueue(DWORD queueDepth, DWORD maxSGE,\r
+                                                DWORD notifyThreshold, GROUP_AFFINITY* pAffinity,\r
+                                                INDSharedReceiveQueue** ppSharedReceiveQueue)\r
+{\r
+       return CNDSharedReceiveQueue::CreateInstance(this, queueDepth, maxSGE,\r
+                                                                                                notifyThreshold, pAffinity,\r
+                                                                                                ppSharedReceiveQueue);\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+CreateQueuePair(INDCompletionQueue* pReceiveCompletionQueue,\r
+                               INDCompletionQueue* pInitiatorCompletionQueue, VOID* context,\r
+                               DWORD receiveQueueDepth, DWORD initiatorQueueDepth,\r
+                               DWORD maxReceiveRequestSGE, DWORD maxInitiatorRequestSGE,\r
+                               INDQueuePair** ppQueuePair)\r
+{\r
+       CNDCompletionQueue *rcq = (CNDCompletionQueue *) pReceiveCompletionQueue;\r
+       CNDCompletionQueue *icq = (CNDCompletionQueue *) pInitiatorCompletionQueue;\r
+\r
+       return CNDQueuePair::CreateInstance(this, rcq, icq, NULL,\r
+                                                                               context, receiveQueueDepth, initiatorQueueDepth,\r
+                                                                               maxReceiveRequestSGE, maxInitiatorRequestSGE,\r
+                                                                               ppQueuePair);\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+CreateQueuePairWithSRQ(INDCompletionQueue* pReceiveCompletionQueue,\r
+                                          INDCompletionQueue* pInitiatorCompletionQueue,\r
+                                          INDSharedReceiveQueue* pSharedReceiveQueue, VOID* context,\r
+                                          DWORD initiatorQueueDepth, DWORD maxInitiatorRequestSGE,\r
+                                          INDQueuePair** ppQueuePair)\r
+{\r
+       CNDCompletionQueue *rcq = (CNDCompletionQueue *) pReceiveCompletionQueue;\r
+       CNDCompletionQueue *icq = (CNDCompletionQueue *) pInitiatorCompletionQueue;\r
+       CNDSharedReceiveQueue *srq = (CNDSharedReceiveQueue *) pSharedReceiveQueue;\r
+\r
+       return CNDQueuePair::CreateInstance(this, rcq, icq, srq,\r
+                                                                               context, 0, initiatorQueueDepth, 0,\r
+                                                                               maxInitiatorRequestSGE, ppQueuePair);\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+CreateSharedEndpoint(INDSharedEndpoint** ppSharedEndpoint)\r
+{\r
+       return CNDSharedEndpoint::CreateInstance(this, ppSharedEndpoint);\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+CreateConnector(INDConnector** ppConnector)\r
+{\r
+       return CNDConnector::CreateInstance(this, ppConnector);\r
+}\r
+\r
+STDMETHODIMP CNDAdapter::\r
+CreateListen(INDListen** ppListen)\r
+{\r
+       return CNDListen::CreateInstance(this, ppListen);\r
+}\r
diff --git a/trunk/ulp/netdirect2/user/nd_adapter.h b/trunk/ulp/netdirect2/user/nd_adapter.h
new file mode 100644 (file)
index 0000000..9821570
--- /dev/null
@@ -0,0 +1,114 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_ADAPTER_H_\r
+#define _ND_ADAPTER_H_\r
+\r
+#include <ndspi.h>\r
+#include "nd_base.h"\r
+#include "nd_provider.h"\r
+\r
+\r
+class CNDAdapter : public INDAdapter, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // INDAdapter methods\r
+       STDMETHODIMP_(HANDLE) GetFileHandle();\r
+       STDMETHODIMP Query(ND_ADAPTER_INFO* pInfo, SIZE_T* pcbInfo);\r
+       STDMETHODIMP QueryAddressList(SOCKET_ADDRESS_LIST* pAddressList, SIZE_T* pcbAddressList);\r
+       STDMETHODIMP CreateCompletionQueue(DWORD queueDepth, GROUP_AFFINITY* pAffinity,\r
+                                                                          INDCompletionQueue** ppCompletionQueue);\r
+       STDMETHODIMP CreateMemoryRegion(INDMemoryRegion** ppMemoryRegion);\r
+       STDMETHODIMP CreateMemoryWindow(INDMemoryWindow** ppMemoryWindow);\r
+       STDMETHODIMP CreateSharedReceiveQueue(DWORD queueDepth, DWORD maxSGE,\r
+                                                                                 DWORD notifyThreshold, GROUP_AFFINITY* pAffinity,\r
+                                                                                 INDSharedReceiveQueue** ppSharedReceiveQueue);\r
+       STDMETHODIMP CreateQueuePair(INDCompletionQueue* pReceiveCompletionQueue,\r
+                                                                INDCompletionQueue* pInitiatorCompletionQueue, VOID* context,\r
+                                                                DWORD receiveQueueDepth, DWORD initiatorQueueDepth,\r
+                                                                DWORD maxReceiveRequestSGE, DWORD maxInitiatorRequestSGE,\r
+                                                                INDQueuePair** ppQueuePair);\r
+       STDMETHODIMP CreateQueuePairWithSRQ(INDCompletionQueue* pReceiveCompletionQueue,\r
+                                                                               INDCompletionQueue* pInitiatorCompletionQueue,\r
+                                                                               INDSharedReceiveQueue* pSharedReceiveQueue, VOID* context,\r
+                                                                               DWORD initiatorQueueDepth, DWORD maxInitiatorRequestSGE,\r
+                                                                               INDQueuePair** ppQueuePair);\r
+       STDMETHODIMP CreateSharedEndpoint(INDSharedEndpoint** ppSharedEndpoint);\r
+       STDMETHODIMP CreateConnector(INDConnector** ppConnector);\r
+       STDMETHODIMP CreateListen(INDListen** ppListen);\r
+\r
+       CNDAdapter(CNDProvider *pProvider);\r
+       ~CNDAdapter();\r
+       void Delete() {delete this;}\r
+       static STDMETHODIMP\r
+       CreateInstance(CNDProvider *pProvider, UINT64 adapterId, INDAdapter** ppAdapter)\r
+       {\r
+               HRESULT hr;\r
+               CNDAdapter *adapter;\r
+\r
+               adapter = new CNDAdapter(pProvider);\r
+               if (adapter == NULL) {\r
+                       hr = ND_NO_MEMORY;\r
+                       goto err1;\r
+               }\r
+\r
+               hr = adapter->Init(adapterId);\r
+               if (FAILED(hr)) {\r
+                       goto err2;\r
+               }\r
+\r
+               *ppAdapter = adapter;\r
+               return ND_SUCCESS;\r
+\r
+       err2:\r
+               adapter->Release();\r
+       err1:\r
+               *ppAdapter = NULL;\r
+               return hr;\r
+       }\r
+\r
+       CNDProvider                     *m_pProvider;\r
+       IWVDevice                       *m_pWvDevice;\r
+       IWVProtectionDomain     *m_pWvPd;\r
+       DWORD                           m_MaxInlineSend;\r
+\r
+protected:\r
+       UINT64                          m_DeviceGuid;\r
+\r
+       STDMETHODIMP            Init(UINT64 adapterId);\r
+};\r
+\r
+#endif // _ND_ADAPTER_H_\r
diff --git a/trunk/ulp/netdirect2/user/nd_base.cpp b/trunk/ulp/netdirect2/user/nd_base.cpp
new file mode 100644 (file)
index 0000000..933b229
--- /dev/null
@@ -0,0 +1,64 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include "nd_base.h"\r
+#include <ndstatus.h>\r
+\r
+CNDBase::CNDBase()\r
+{\r
+       m_nRef = 1;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDBase::\r
+AddRef(void)\r
+{\r
+       return InterlockedIncrement(&m_nRef);\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDBase::\r
+Release(void)\r
+{\r
+       ULONG ref;\r
+\r
+       ref = (ULONG) InterlockedDecrement(&m_nRef);\r
+       if (ref == 0) {\r
+               Delete();\r
+       }\r
+       return ref;\r
+}\r
+\r
+HRESULT NDConvertWVStatus(HRESULT hr)\r
+{\r
+       switch (hr) {\r
+       case WV_IO_PENDING:\r
+               return ND_PENDING;\r
+       default:\r
+               return hr;\r
+       }\r
+}\r
diff --git a/trunk/ulp/netdirect2/user/nd_base.h b/trunk/ulp/netdirect2/user/nd_base.h
new file mode 100644 (file)
index 0000000..d11b1a0
--- /dev/null
@@ -0,0 +1,66 @@
+/*\r
+ * Copyright (c) 2009 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_BASE_H_\r
+#define _ND_BASE_H_\r
+\r
+#include <windows.h>\r
+#include <rdma\winverbs.h>\r
+#include <stdio.h>\r
+\r
+class CNDBase\r
+{\r
+public:\r
+       CNDBase();\r
+       ~CNDBase() {};\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       virtual void Delete() {};\r
+\r
+       volatile LONG                   m_nRef;\r
+\r
+protected:\r
+};\r
+\r
+__inline void* __cdecl operator new(size_t size)\r
+{\r
+       return HeapAlloc(GetProcessHeap(), 0, size);\r
+}\r
+\r
+__inline void __cdecl operator delete(void *pObj)\r
+{\r
+       HeapFree(GetProcessHeap(), 0, pObj);\r
+}\r
+\r
+HRESULT NDConvertWVStatus(HRESULT hr);\r
+\r
+#endif // _ND_BASE_H_\r
diff --git a/trunk/ulp/netdirect2/user/nd_connect.cpp b/trunk/ulp/netdirect2/user/nd_connect.cpp
new file mode 100644 (file)
index 0000000..579fd11
--- /dev/null
@@ -0,0 +1,332 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include "nd_connect.h"\r
+#include "nd_ep.h"\r
+#include "nd_qp.h"\r
+#include <iba/ibat.h>\r
+\r
+\r
+CNDConnector::CNDConnector(CNDAdapter *pAdapter)\r
+{\r
+       pAdapter->AddRef();\r
+       m_pAdapter = pAdapter;\r
+       m_pWvConnEp = NULL;\r
+       m_Connects = 0;\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+Init(void)\r
+{\r
+       IWVConnectEndpoint *ep;\r
+       HRESULT hr;\r
+\r
+       hr = m_pAdapter->m_pProvider->m_pWvProvider->CreateConnectEndpoint(&ep);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       if (m_pWvConnEp != NULL) {\r
+               m_pWvConnEp->Release();\r
+       }\r
+\r
+       m_pWvConnEp = ep;\r
+       return ND_SUCCESS;\r
+}\r
+\r
+CNDConnector::~CNDConnector()\r
+{\r
+       if (m_pWvConnEp != NULL) {\r
+               m_pWvConnEp->Release();\r
+       }\r
+       m_pAdapter->Release();\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_INDConnector) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDConnector::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDConnector::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+CancelOverlappedRequests(void)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->CancelOverlappedRequests();\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+GetOverlappedResult(OVERLAPPED *pOverlapped, BOOL bWait)\r
+{\r
+       DWORD bytes;\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->GetOverlappedResult(pOverlapped, &bytes, bWait);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+ConnectQp(INDQueuePair* pQueuePair, BOOL SharedAddress,\r
+                 const struct sockaddr* pSrcAddress, SIZE_T cbSrcAddress,\r
+                 const struct sockaddr* pDestAddress, SIZE_T cbDestAddress,\r
+                 DWORD inboundReadLimit, DWORD outboundReadLimit,\r
+                 const VOID* pPrivateData, DWORD cbPrivateData, OVERLAPPED* pOverlapped)\r
+{\r
+       CNDQueuePair *qp = (CNDQueuePair *) pQueuePair;\r
+       WV_CONNECT_PARAM attr;\r
+       IBAT_PATH_BLOB path;\r
+       HRESULT hr;\r
+\r
+       if (m_Connects++ > 0) {\r
+               hr = Init();\r
+               if (FAILED(hr)) {\r
+                       goto out;\r
+               }\r
+       }\r
+\r
+       hr = IBAT::ResolvePath(pSrcAddress, pDestAddress, &path, INFINITE);\r
+       if (FAILED(hr)) {\r
+               goto out;\r
+       }\r
+\r
+       if (SharedAddress) {\r
+               //hr = m_pWvConnEp->BindAddress((SOCKADDR *) pSrcAddress);\r
+               if (FAILED(hr)) {\r
+                       goto out;\r
+               }\r
+       } else {\r
+               hr = m_pWvConnEp->BindAddress((SOCKADDR *) pSrcAddress);\r
+               if (FAILED(hr)) {\r
+                       goto out;\r
+               }\r
+       }\r
+\r
+       hr = m_pWvConnEp->Modify(WV_EP_OPTION_ROUTE, &path, sizeof path);\r
+       if (FAILED(hr)) {\r
+               goto out;\r
+       }\r
+\r
+       RtlZeroMemory(&attr, sizeof attr);\r
+       if ((attr.DataLength = cbPrivateData)) {\r
+               RtlCopyMemory(attr.Data, pPrivateData, cbPrivateData);\r
+       }\r
+       attr.ResponderResources = inboundReadLimit;\r
+       attr.InitiatorDepth = outboundReadLimit;\r
+       attr.RetryCount = 7;\r
+\r
+       hr = m_pWvConnEp->Connect(qp->m_pWvQp, pDestAddress, &attr, pOverlapped);\r
+out:\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+Connect(INDQueuePair* pQueuePair,\r
+               const struct sockaddr* pSrcAddress, SIZE_T cbSrcAddress,\r
+               const struct sockaddr* pDestAddress, SIZE_T cbDestAddress,\r
+               DWORD inboundReadLimit, DWORD outboundReadLimit,\r
+               const VOID* pPrivateData, DWORD cbPrivateData, OVERLAPPED* pOverlapped)\r
+{\r
+       return ConnectQp(pQueuePair, FALSE, pSrcAddress, cbSrcAddress,\r
+                                        pDestAddress, cbDestAddress, inboundReadLimit,\r
+                                        outboundReadLimit, pPrivateData, cbPrivateData, pOverlapped);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+ConnectSharedEndpoint(INDQueuePair* pQueuePair, INDSharedEndpoint* pSharedEndpoint,\r
+                                         const struct sockaddr* pDestAddress, SIZE_T cbDestAddress,\r
+                                         DWORD inboundReadLimit, DWORD outboundReadLimit,\r
+                                         const VOID* pPrivateData, DWORD cbPrivateData,\r
+                                         OVERLAPPED* pOverlapped)\r
+{\r
+       CNDSharedEndpoint *sep = (CNDSharedEndpoint *) pSharedEndpoint;\r
+\r
+       return ConnectQp(pQueuePair, TRUE, (SOCKADDR *) &sep->m_Address, sep->m_AddressSize,\r
+                                        pDestAddress, cbDestAddress, inboundReadLimit,\r
+                                        outboundReadLimit, pPrivateData, cbPrivateData, pOverlapped);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+CompleteConnect(OVERLAPPED* pOverlapped)\r
+{\r
+       WV_CONNECT_PARAM attr;\r
+       HRESULT hr;\r
+\r
+       RtlZeroMemory(&attr, sizeof attr);\r
+       hr = m_pWvConnEp->Accept(NULL, &attr, pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+Accept(INDQueuePair* pQueuePair, DWORD inboundReadLimit, DWORD outboundReadLimit,\r
+          const VOID* pPrivateData, DWORD cbPrivateData, OVERLAPPED* pOverlapped)\r
+{\r
+       CNDQueuePair *qp = (CNDQueuePair *) pQueuePair;\r
+       WV_CONNECT_PARAM attr;\r
+       HRESULT hr;\r
+\r
+       RtlZeroMemory(&attr, sizeof attr);\r
+       if ((attr.DataLength = cbPrivateData)) {\r
+               RtlCopyMemory(attr.Data, pPrivateData, cbPrivateData);\r
+       }\r
+       attr.ResponderResources = inboundReadLimit;\r
+       attr.InitiatorDepth = outboundReadLimit;\r
+\r
+       hr = m_pWvConnEp->Accept(qp->m_pWvQp, &attr, pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+Reject(const void* pPrivateData, DWORD cbPrivateData)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->Reject(pPrivateData, cbPrivateData);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+GetConnectionData(DWORD* pInboundReadLimit, DWORD* pOutboundReadLimit,\r
+                                 void* pPrivateData, DWORD* pcbPrivateData)\r
+{\r
+       WV_CONNECT_ATTRIBUTES attr;\r
+       HRESULT hr;\r
+       \r
+       hr = m_pWvConnEp->Query(&attr);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       if (pInboundReadLimit) {\r
+               *pInboundReadLimit = (DWORD) attr.Param.ResponderResources;\r
+       }\r
+       if (pOutboundReadLimit) {\r
+               *pOutboundReadLimit = (DWORD) attr.Param.InitiatorDepth;\r
+       }\r
+       if (pcbPrivateData) {\r
+               if (*pcbPrivateData < ND_PRIVATE_DATA_SIZE) {\r
+                       hr = ND_BUFFER_OVERFLOW;\r
+               }\r
+\r
+               RtlCopyMemory(pPrivateData, attr.Param.Data,\r
+                                         min(*pcbPrivateData, ND_PRIVATE_DATA_SIZE));\r
+               *pcbPrivateData = ND_PRIVATE_DATA_SIZE;\r
+       }\r
+\r
+       return hr;\r
+}\r
+\r
+SIZE_T GetAddressSize(WV_SOCKADDR *addr)\r
+{\r
+       return (addr->Sa.sa_family == AF_INET) ? sizeof(addr->Sin) : sizeof(addr->Sin6);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+GetLocalAddress(struct sockaddr* pAddress, SIZE_T* pcbAddress)\r
+{\r
+       WV_CONNECT_ATTRIBUTES attr;\r
+       HRESULT hr;\r
+       SIZE_T size;\r
+       \r
+       hr = m_pWvConnEp->Query(&attr);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       size = GetAddressSize(&attr.LocalAddress);\r
+       if (*pcbAddress >= size) {\r
+               RtlCopyMemory(pAddress, &attr.LocalAddress, size);\r
+       } else {\r
+               hr = ND_BUFFER_OVERFLOW;\r
+       }\r
+\r
+       *pcbAddress = size;\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+GetPeerAddress(struct sockaddr* pAddress, SIZE_T* pcbAddress)\r
+{\r
+       WV_CONNECT_ATTRIBUTES attr;\r
+       HRESULT hr;\r
+       SIZE_T size;\r
+       \r
+       hr = m_pWvConnEp->Query(&attr);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       size = GetAddressSize(&attr.PeerAddress);\r
+       if (*pcbAddress >= size) {\r
+               RtlCopyMemory(pAddress, &attr.PeerAddress, size);\r
+       } else {\r
+               hr = ND_BUFFER_OVERFLOW;\r
+       }\r
+\r
+       *pcbAddress = size;\r
+       return hr;\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+NotifyDisconnect(OVERLAPPED* pOverlapped)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->NotifyDisconnect(pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDConnector::\r
+Disconnect(OVERLAPPED* pOverlapped)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->Disconnect(pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
+}\r
diff --git a/trunk/ulp/netdirect2/user/nd_connect.h b/trunk/ulp/netdirect2/user/nd_connect.h
new file mode 100644 (file)
index 0000000..dd1e142
--- /dev/null
@@ -0,0 +1,124 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_CONNECTOR_H_\r
+#define _ND_CONNECTOR_H_\r
+\r
+#include <initguid.h>\r
+#include <ndspi.h>\r
+#include "nd_base.h"\r
+#include "nd_adapter.h"\r
+\r
+\r
+#define ND_PRIVATE_DATA_SIZE   56\r
+\r
+\r
+class CNDConnector : public INDConnector, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // INDOverlapped methods\r
+       STDMETHODIMP CancelOverlappedRequests();\r
+       STDMETHODIMP GetOverlappedResult(OVERLAPPED *pOverlapped, BOOL bWait);\r
+\r
+       // INDConnector methods\r
+       STDMETHODIMP Connect(INDQueuePair* pQueuePair,\r
+                                                const struct sockaddr* pSrcAddress, SIZE_T cbSrcAddress,\r
+                                                const struct sockaddr* pDestAddress, SIZE_T cbDestAddress,\r
+                                                DWORD inboundReadLimit, DWORD outboundReadLimit,\r
+                                                const VOID* pPrivateData, DWORD cbPrivateData, OVERLAPPED* pOverlapped);\r
+       STDMETHODIMP ConnectSharedEndpoint(INDQueuePair* pQueuePair, INDSharedEndpoint* pSharedEndpoint,\r
+                                                                          const struct sockaddr* pDestAddress, SIZE_T cbDestAddress,\r
+                                                                          DWORD inboundReadLimit, DWORD outboundReadLimit,\r
+                                                                          const VOID* pPrivateData, DWORD cbPrivateData,\r
+                                                                          OVERLAPPED* pOverlapped);\r
+       STDMETHODIMP CompleteConnect(OVERLAPPED* pOverlapped);\r
+       STDMETHODIMP Accept(INDQueuePair* pQueuePair, DWORD inboundReadLimit, DWORD outboundReadLimit,\r
+                                               const VOID* pPrivateData, DWORD cbPrivateData, OVERLAPPED* pOverlapped);\r
+       STDMETHODIMP Reject(const VOID* pPrivateData, DWORD cbPrivateData);\r
+       STDMETHODIMP GetConnectionData(DWORD* pInboundReadLimit, DWORD* pOutboundReadLimit,\r
+                                                                  VOID* pPrivateData, DWORD* pcbPrivateData);\r
+       STDMETHODIMP GetLocalAddress(struct sockaddr* pAddress, SIZE_T* pcbAddress);\r
+       STDMETHODIMP GetPeerAddress(struct sockaddr* pAddress, SIZE_T* pcbAddress);\r
+       STDMETHODIMP NotifyDisconnect(OVERLAPPED* pOverlapped);\r
+       STDMETHODIMP Disconnect(OVERLAPPED* pOverlapped);\r
+\r
+       CNDConnector(CNDAdapter *pAdapter);\r
+       ~CNDConnector();\r
+       void Delete() {delete this;}\r
+       static STDMETHODIMP\r
+       CreateInstance(CNDAdapter *pAdapter, INDConnector** ppConnector)\r
+       {\r
+               HRESULT hr;\r
+               CNDConnector *conn;\r
+\r
+               conn = new CNDConnector(pAdapter);\r
+               if (conn == NULL) {\r
+                       hr = ND_NO_MEMORY;\r
+                       goto err1;\r
+               }\r
+\r
+               hr = conn->Init();\r
+               if (FAILED(hr)) {\r
+                       goto err2;\r
+               }\r
+\r
+               *ppConnector = conn;\r
+               return ND_SUCCESS;\r
+\r
+       err2:\r
+               conn->Release();\r
+       err1:\r
+               *ppConnector = NULL;\r
+               return hr;\r
+       }\r
+\r
+       IWVConnectEndpoint      *m_pWvConnEp;\r
+       CNDAdapter                      *m_pAdapter;\r
+\r
+protected:\r
+       STDMETHODIMP            Init();\r
+       STDMETHODIMP            ConnectQp(INDQueuePair* pQueuePair, BOOL SharedAddress,\r
+                                                                 const struct sockaddr* pSrcAddress, SIZE_T cbSrcAddress,\r
+                                                                 const struct sockaddr* pDestAddress, SIZE_T cbDestAddress,\r
+                                                                 DWORD inboundReadLimit, DWORD outboundReadLimit,\r
+                                                                 const VOID* pPrivateData, DWORD cbPrivateData,\r
+                                                                 OVERLAPPED* pOverlapped);\r
+       int                                     m_Connects;\r
+};\r
+\r
+SIZE_T GetAddressSize(WV_SOCKADDR *addr);\r
+\r
+#endif // _ND_CONNECTOR_H_\r
diff --git a/trunk/ulp/netdirect2/user/nd_cq.cpp b/trunk/ulp/netdirect2/user/nd_cq.cpp
new file mode 100644 (file)
index 0000000..9f8fdb6
--- /dev/null
@@ -0,0 +1,169 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include "nd_cq.h"\r
+\r
+CNDCompletionQueue::CNDCompletionQueue(CNDAdapter *pAdapter)\r
+{\r
+       pAdapter->AddRef();\r
+       m_pAdapter = pAdapter;\r
+       m_pWvCq = NULL;\r
+}\r
+\r
+STDMETHODIMP CNDCompletionQueue::\r
+Init(DWORD queueDepth)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pAdapter->m_pWvDevice->CreateCompletionQueue((SIZE_T *) &queueDepth, &m_pWvCq);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+CNDCompletionQueue::~CNDCompletionQueue()\r
+{\r
+       if (m_pWvCq != NULL) {\r
+               m_pWvCq->Release();\r
+       }\r
+       m_pAdapter->Release();\r
+}\r
+\r
+STDMETHODIMP CNDCompletionQueue::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_INDCompletionQueue) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDCompletionQueue::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDCompletionQueue::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+STDMETHODIMP CNDCompletionQueue::\r
+CancelOverlappedRequests(void)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvCq->CancelOverlappedRequests();\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDCompletionQueue::\r
+GetOverlappedResult(OVERLAPPED *pOverlapped, BOOL bWait)\r
+{\r
+       DWORD bytes;\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvCq->GetOverlappedResult(pOverlapped, &bytes, bWait);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDCompletionQueue::\r
+Resize(DWORD queueDepth)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvCq->Resize((SIZE_T *) &queueDepth);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDCompletionQueue::\r
+Notify(DWORD type, OVERLAPPED* pOverlapped)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvCq->Notify((WV_CQ_NOTIFY_TYPE) type, pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP_(HRESULT) CNDCompletionQueue::\r
+ConvertStatus(WV_WC_STATUS Status)\r
+{\r
+       switch (Status) {\r
+       case WvWcSuccess:\r
+               return ND_SUCCESS;\r
+       case WvWcFlushed:\r
+               return ND_CANCELED;\r
+       case WvWcLocalLengthError:\r
+               return ND_LOCAL_LENGTH;\r
+       case WvWcRnrRetryError:\r
+       case WvWcTimeoutRetryError:\r
+               return ND_TIMEOUT;\r
+       case WvWcLocalAccessError:\r
+       case WvWcLocalOpError:\r
+       case WvWcLocalProtectionError:\r
+       case WvWcMwBindError:\r
+               return ND_ACCESS_VIOLATION;\r
+       case WvWcRemoteAccessError:\r
+       case WvWcRemoteOpError:\r
+       case WvWcRemoteInvalidRequest:\r
+       case WvWcBadResponse:\r
+               return ND_REMOTE_ERROR;\r
+       default:\r
+               return ND_INTERNAL_ERROR;\r
+       }\r
+}\r
+\r
+STDMETHODIMP_(DWORD) CNDCompletionQueue::\r
+GetResults(ND_RESULT results[], DWORD nResults)\r
+{\r
+       WV_COMPLETION   wc[8];\r
+       DWORD                   cnt, total, i;\r
+\r
+       for (total = 0; nResults; nResults -= cnt) {\r
+               cnt = min(8, nResults);\r
+               cnt = (DWORD) m_pWvCq->Poll(wc, cnt);\r
+               if (cnt == 0) {\r
+                       break;\r
+               }\r
+\r
+               for (i = 0; i < cnt; i++) {\r
+                       results[total].Status = ConvertStatus(wc[i].Status);\r
+                       if (wc[i].Opcode & WvReceive) {\r
+                               results[total].BytesTransferred = wc[i].Length;\r
+                       }\r
+                       results[total].QueuePairContext = wc[i].QpContext;\r
+                       results[total].RequestContext = (VOID *) (ULONG_PTR) wc[i].WrId;\r
+               }\r
+       }\r
+       return total;\r
+}\r
diff --git a/trunk/ulp/netdirect2/user/nd_cq.h b/trunk/ulp/netdirect2/user/nd_cq.h
new file mode 100644 (file)
index 0000000..1f6af0e
--- /dev/null
@@ -0,0 +1,95 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_CQ_H_\r
+#define _ND_CQ_H_\r
+\r
+#include <initguid.h>\r
+#include <ndspi.h>\r
+#include "nd_base.h"\r
+#include "nd_adapter.h"\r
+\r
+class CNDCompletionQueue : public INDCompletionQueue, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // INDOverlapped methods\r
+       STDMETHODIMP CancelOverlappedRequests();\r
+       STDMETHODIMP GetOverlappedResult(OVERLAPPED *pOverlapped, BOOL bWait);\r
+\r
+       // INDCompletionQueue methods\r
+       STDMETHODIMP Resize(DWORD queueDepth);\r
+       STDMETHODIMP Notify(DWORD type, OVERLAPPED* pOverlapped);\r
+       STDMETHODIMP_(DWORD) GetResults(ND_RESULT results[], DWORD nResults);\r
+\r
+       CNDCompletionQueue(CNDAdapter *pAdapter);\r
+       ~CNDCompletionQueue();\r
+       void Delete() {delete this;}\r
+       static STDMETHODIMP\r
+       CreateInstance(CNDAdapter *pAdapter, DWORD queueDepth, INDCompletionQueue** ppCq)\r
+       {\r
+               HRESULT hr;\r
+               CNDCompletionQueue *cq;\r
+\r
+               cq = new CNDCompletionQueue(pAdapter);\r
+               if (cq == NULL) {\r
+                       hr = ND_NO_MEMORY;\r
+                       goto err1;\r
+               }\r
+\r
+               hr = cq->Init(queueDepth);\r
+               if (FAILED(hr)) {\r
+                       goto err2;\r
+               }\r
+\r
+               *ppCq = cq;\r
+               return ND_SUCCESS;\r
+\r
+       err2:\r
+               cq->Release();\r
+       err1:\r
+               *ppCq = NULL;\r
+               return hr;\r
+       }\r
+\r
+       IWVCompletionQueue      *m_pWvCq;\r
+\r
+protected:\r
+       CNDAdapter                      *m_pAdapter;\r
+       STDMETHODIMP            Init(DWORD queueDepth);\r
+       STDMETHODIMP_(HRESULT) ConvertStatus(WV_WC_STATUS Status);\r
+};\r
+\r
+#endif // _ND_CQ_H_\r
diff --git a/trunk/ulp/netdirect2/user/nd_ep.cpp b/trunk/ulp/netdirect2/user/nd_ep.cpp
new file mode 100644 (file)
index 0000000..3f73e16
--- /dev/null
@@ -0,0 +1,92 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include "nd_ep.h"\r
+#include "nd_adapter.h"\r
+#include <netinet/in.h>\r
+\r
+\r
+CNDSharedEndpoint::CNDSharedEndpoint(CNDAdapter *pAdapter)\r
+{\r
+       pAdapter->AddRef();\r
+       m_pAdapter = pAdapter;\r
+}\r
+\r
+CNDSharedEndpoint::~CNDSharedEndpoint()\r
+{\r
+       m_pAdapter->Release();\r
+}\r
+\r
+STDMETHODIMP CNDSharedEndpoint::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_INDSharedEndpoint) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDSharedEndpoint::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDSharedEndpoint::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+STDMETHODIMP CNDSharedEndpoint::\r
+Bind(const struct sockaddr* pAddress, SIZE_T cbAddress)\r
+{\r
+       //???\r
+       return ND_NOT_SUPPORTED;\r
+}\r
+\r
+STDMETHODIMP CNDSharedEndpoint::\r
+GetLocalAddress(struct sockaddr* pAddress, SIZE_T* pcbAddress)\r
+{\r
+       HRESULT hr;\r
+       \r
+       if (*pcbAddress >= m_AddressSize) {\r
+               RtlCopyMemory(pAddress, &m_Address, m_AddressSize);\r
+               hr = ND_SUCCESS;\r
+       } else {\r
+               hr = ND_BUFFER_OVERFLOW;\r
+       }\r
+\r
+       *pcbAddress = m_AddressSize;\r
+       return NDConvertWVStatus(hr);\r
+}\r
diff --git a/trunk/ulp/netdirect2/user/nd_ep.h b/trunk/ulp/netdirect2/user/nd_ep.h
new file mode 100644 (file)
index 0000000..e33df94
--- /dev/null
@@ -0,0 +1,81 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_ENDPOINT_H_\r
+#define _ND_ENDPOINT_H_\r
+\r
+#include <initguid.h>\r
+#include <ndspi.h>\r
+#include "nd_base.h"\r
+#include "nd_adapter.h"\r
+\r
+\r
+class CNDSharedEndpoint : public INDSharedEndpoint, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // INDEndpoint methods\r
+       STDMETHODIMP Bind(const struct sockaddr* pAddress, SIZE_T cbAddress);\r
+       STDMETHODIMP GetLocalAddress(struct sockaddr* pAddress, SIZE_T* pcbAddress);\r
+       \r
+       CNDSharedEndpoint(CNDAdapter *pAdapter);\r
+       ~CNDSharedEndpoint();\r
+       void Delete() {delete this;}\r
+       static STDMETHODIMP\r
+       CreateInstance(CNDAdapter *pAdapter, INDSharedEndpoint** ppSharedEndpoint)\r
+       {\r
+               HRESULT hr;\r
+               CNDSharedEndpoint *ep;\r
+\r
+               ep = new CNDSharedEndpoint(pAdapter);\r
+               if (ep == NULL) {\r
+                       hr = ND_NO_MEMORY;\r
+                       goto err;\r
+               }\r
+\r
+               *ppSharedEndpoint = ep;\r
+               return ND_SUCCESS;\r
+\r
+       err:\r
+               *ppSharedEndpoint = NULL;\r
+               return hr;\r
+       }\r
+\r
+       SOCKADDR_STORAGE        m_Address;\r
+       SIZE_T                          m_AddressSize;\r
+       CNDAdapter                      *m_pAdapter;\r
+};\r
+\r
+#endif // _ND_ENDPOINT_H_\r
diff --git a/trunk/ulp/netdirect2/user/nd_export.def b/trunk/ulp/netdirect2/user/nd_export.def
new file mode 100644 (file)
index 0000000..f02ae6f
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+ * Copyright (c) 2009 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#if _DEBUG_\r
+LIBRARY        WVNDPROVD.DLL\r
+#else\r
+LIBRARY        WVNDPROV.DLL\r
+#endif\r
+\r
+EXPORTS\r
+       DllCanUnloadNow         PRIVATE\r
+       DllGetClassObject       PRIVATE\r
+       WSPStartup\r
diff --git a/trunk/ulp/netdirect2/user/nd_exports.src b/trunk/ulp/netdirect2/user/nd_exports.src
new file mode 100644 (file)
index 0000000..042f3cd
--- /dev/null
@@ -0,0 +1,12 @@
+#if DBG\r
+LIBRARY wvndprov.dll\r
+#else\r
+LIBRARY wvndprov.dll\r
+#endif\r
+\r
+#ifndef _WIN64\r
+EXPORTS\r
+       DllCanUnloadNow         PRIVATE\r
+       DllGetClassObject       PRIVATE\r
+       WSPStartup\r
+#endif\r
diff --git a/trunk/ulp/netdirect2/user/nd_listen.cpp b/trunk/ulp/netdirect2/user/nd_listen.cpp
new file mode 100644 (file)
index 0000000..80d1725
--- /dev/null
@@ -0,0 +1,154 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include "nd_listen.h"\r
+#include "nd_adapter.h"\r
+#include "nd_connect.h"\r
+\r
+\r
+CNDListen::CNDListen(CNDAdapter *pAdapter)\r
+{\r
+       pAdapter->AddRef();\r
+       m_pAdapter = pAdapter;\r
+       m_pWvConnEp = NULL;\r
+}\r
+\r
+CNDListen::~CNDListen()\r
+{\r
+       if (m_pWvConnEp != NULL) {\r
+               m_pWvConnEp->Release();\r
+       }\r
+       m_pAdapter->Release();\r
+}\r
+\r
+STDMETHODIMP CNDListen::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_INDListen) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDListen::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDListen::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+STDMETHODIMP CNDListen::\r
+CancelOverlappedRequests(void)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->CancelOverlappedRequests();\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDListen::\r
+GetOverlappedResult(OVERLAPPED *pOverlapped, BOOL bWait)\r
+{\r
+       DWORD bytes;\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->GetOverlappedResult(pOverlapped, &bytes, bWait);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDListen::\r
+Listen(const struct sockaddr* pAddress, SIZE_T cbAddress, SIZE_T backlog)\r
+{\r
+       WV_SOCKADDR addr;\r
+       HRESULT hr;\r
+\r
+       hr = m_pAdapter->m_pProvider->m_pWvProvider->CreateConnectEndpoint(&m_pWvConnEp);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       hr = m_pWvConnEp->BindAddress((SOCKADDR *) pAddress);\r
+       if (FAILED(hr)) {\r
+               goto err;\r
+       }\r
+\r
+       hr = m_pWvConnEp->Listen(backlog);\r
+       if (FAILED(hr)) {\r
+               goto err;\r
+       }\r
+\r
+       return ND_SUCCESS;\r
+\r
+err:\r
+       m_pWvConnEp->Release();\r
+       m_pWvConnEp = NULL;\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDListen::\r
+GetLocalAddress(struct sockaddr* pAddress, SIZE_T* pcbAddress)\r
+{\r
+       WV_CONNECT_ATTRIBUTES attr;\r
+       HRESULT hr;\r
+       SIZE_T size;\r
+\r
+       hr = m_pWvConnEp->Query(&attr);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       size = GetAddressSize(&attr.LocalAddress);\r
+       if (*pcbAddress >= size) {\r
+               RtlCopyMemory(pAddress, &attr.LocalAddress.Sa, size);\r
+       } else {\r
+               hr = ND_BUFFER_OVERFLOW;\r
+       }\r
+\r
+       *pcbAddress = size;\r
+       return hr;\r
+}\r
+\r
+STDMETHODIMP CNDListen::\r
+GetConnectionRequest(INDConnector* pConnector, OVERLAPPED* pOverlapped)\r
+{\r
+       CNDConnector *conn = (CNDConnector *) pConnector;\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->GetRequest(conn->m_pWvConnEp, pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
+}\r
diff --git a/trunk/ulp/netdirect2/user/nd_listen.h b/trunk/ulp/netdirect2/user/nd_listen.h
new file mode 100644 (file)
index 0000000..d077a3e
--- /dev/null
@@ -0,0 +1,87 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_LISTEN_H_\r
+#define _ND_LISTEN_H_\r
+\r
+#include <initguid.h>\r
+#include <ndspi.h>\r
+#include "nd_base.h"\r
+#include "nd_adapter.h"\r
+\r
+class CNDListen : public INDListen, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // INDOverlapped methods\r
+       STDMETHODIMP CancelOverlappedRequests();\r
+       STDMETHODIMP GetOverlappedResult(OVERLAPPED *pOverlapped, BOOL bWait);\r
+\r
+       // INDListen methods\r
+       STDMETHODIMP Listen(const struct sockaddr* pAddress, SIZE_T cbAddress, SIZE_T backlog);\r
+       STDMETHODIMP GetLocalAddress(struct sockaddr* pAddress, SIZE_T* pcbAddress);\r
+       STDMETHODIMP GetConnectionRequest(INDConnector* pConnector, OVERLAPPED* pOverlapped);\r
+\r
+       CNDListen(CNDAdapter *pAdapter);\r
+       ~CNDListen();\r
+       void Delete() {delete this;}\r
+       static STDMETHODIMP\r
+       CreateInstance(CNDAdapter *pAdapter, INDListen** ppListen)\r
+       {\r
+               HRESULT hr;\r
+               CNDListen *listener;\r
+\r
+               listener = new CNDListen(pAdapter);\r
+               if (listener == NULL) {\r
+                       hr = ND_NO_MEMORY;\r
+                       goto err1;\r
+               }\r
+\r
+               *ppListen = listener;\r
+               return ND_SUCCESS;\r
+\r
+       err1:\r
+               *ppListen = NULL;\r
+               return hr;\r
+       }\r
+\r
+protected:\r
+       CNDAdapter                      *m_pAdapter;\r
+       IWVConnectEndpoint      *m_pWvConnEp;\r
+\r
+       STDMETHODIMP            Init();\r
+};\r
+\r
+#endif // _ND_LISTEN_H_\r
diff --git a/trunk/ulp/netdirect2/user/nd_main.cpp b/trunk/ulp/netdirect2/user/nd_main.cpp
new file mode 100644 (file)
index 0000000..a27764d
--- /dev/null
@@ -0,0 +1,88 @@
+/*\r
+ * Copyright (c) 2009 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include <windows.h>\r
+#include <ws2spi.h>\r
+#include <stdio.h>\r
+#include "nd_provider.h"\r
+\r
+\r
+extern "C" {\r
+\r
+extern BOOL APIENTRY\r
+_DllMainCRTStartupForGS(HINSTANCE h_module, DWORD ul_reason_for_call,\r
+                                               LPVOID lp_reserved);\r
+\r
+\r
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)\r
+{\r
+       switch (dwReason) {\r
+       case DLL_PROCESS_ATTACH:\r
+       case DLL_PROCESS_DETACH:\r
+               return _DllMainCRTStartupForGS(hInstance, dwReason, lpReserved);\r
+       default:\r
+               return TRUE;\r
+       }\r
+}\r
+\r
+STDAPI DllCanUnloadNow(void)\r
+{\r
+       return S_OK;\r
+}\r
+\r
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv)\r
+{\r
+       UNREFERENCED_PARAMETER(rclsid);\r
+\r
+       if (riid != IID_IClassFactory) {\r
+               *ppv = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppv = new CNDClassFactory();\r
+       if (*ppv == NULL) {\r
+               return E_OUTOFMEMORY;\r
+       }\r
+\r
+       return S_OK;\r
+}\r
+\r
+int WSPStartup(WORD wVersionRequested, LPWSPDATA lpWSPData,\r
+                          LPWSAPROTOCOL_INFOW lpProtocolInfo,\r
+                          WSPUPCALLTABLE UpcallTable, LPWSPPROC_TABLE lpProcTable)\r
+{\r
+       UNREFERENCED_PARAMETER(wVersionRequested);\r
+       UNREFERENCED_PARAMETER(lpWSPData);\r
+       UNREFERENCED_PARAMETER(lpProtocolInfo);\r
+       UNREFERENCED_PARAMETER(UpcallTable);\r
+       UNREFERENCED_PARAMETER(lpProcTable);\r
+       return WSASYSNOTREADY;\r
+}\r
+\r
+} // extern "C"
\ No newline at end of file
diff --git a/trunk/ulp/netdirect2/user/nd_main.h b/trunk/ulp/netdirect2/user/nd_main.h
new file mode 100644 (file)
index 0000000..9a89272
--- /dev/null
@@ -0,0 +1,37 @@
+/*\r
+ * Copyright (c) 2009 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_MAIN_H_\r
+#define _ND_MAIN_H_\r
+\r
+#include <rdma\winverbs.h>\r
+\r
+#endif // _ND_MAIN_H_\r
diff --git a/trunk/ulp/netdirect2/user/nd_mw.cpp b/trunk/ulp/netdirect2/user/nd_mw.cpp
new file mode 100644 (file)
index 0000000..be5446d
--- /dev/null
@@ -0,0 +1,158 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include "nd_mw.h"\r
+\r
+\r
+CNDMemoryRegion::CNDMemoryRegion(CNDAdapter *pAdapter)\r
+{\r
+       pAdapter->AddRef();\r
+       m_pAdapter = pAdapter;\r
+       RtlZeroMemory(&m_Keys, sizeof(m_Keys));\r
+}\r
+\r
+CNDMemoryRegion::~CNDMemoryRegion()\r
+{\r
+       m_pAdapter->Release();\r
+}\r
+\r
+STDMETHODIMP CNDMemoryRegion::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_INDMemoryRegion) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDMemoryRegion::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDMemoryRegion::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+DWORD ConvertAccessFlags(DWORD Flags)\r
+{\r
+       DWORD opts = 0;\r
+\r
+       //other flags to convert???\r
+       if (!(Flags & ND_OP_FLAG_ALLOW_READ)) {\r
+               opts |= WV_ACCESS_REMOTE_READ;\r
+       }\r
+       if (Flags & ND_OP_FLAG_ALLOW_WRITE) {\r
+               opts |= WV_ACCESS_REMOTE_WRITE;\r
+       }\r
+       return opts;\r
+}\r
+\r
+STDMETHODIMP CNDMemoryRegion::\r
+Register(const VOID* pBuffer, SIZE_T cbBuffer, DWORD flags, OVERLAPPED* pOverlapped)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pAdapter->m_pWvPd->RegisterMemory(pBuffer, cbBuffer, ConvertAccessFlags(flags),\r
+                                                                                        pOverlapped, &m_Keys);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDMemoryRegion::\r
+Deregister(OVERLAPPED* pOverlapped)\r
+{\r
+       HRESULT hr;\r
+\r
+       //??? if the lkey is not unique, we need to change this\r
+       hr = m_pAdapter->m_pWvPd->DeregisterMemory(m_Keys.Lkey, pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP_(UINT32) CNDMemoryRegion::\r
+GetLocalToken()\r
+{\r
+       return m_Keys.Lkey;\r
+}\r
+\r
+STDMETHODIMP_(UINT32) CNDMemoryRegion::\r
+GetRemoteToken()\r
+{\r
+       return m_Keys.Rkey;\r
+}\r
+\r
+\r
+CNDMemoryWindow::CNDMemoryWindow(CNDAdapter *pAdapter)\r
+{\r
+       pAdapter->AddRef();\r
+       m_pAdapter = pAdapter;\r
+       m_pMr = NULL;\r
+}\r
+\r
+CNDMemoryWindow::~CNDMemoryWindow()\r
+{\r
+       m_pAdapter->Release();\r
+}\r
+\r
+STDMETHODIMP CNDMemoryWindow::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_INDMemoryWindow) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDMemoryWindow::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDMemoryWindow::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+STDMETHODIMP_(UINT32) CNDMemoryWindow::\r
+GetRemoteToken()\r
+{\r
+       return m_pMr->GetRemoteToken();\r
+}\r
diff --git a/trunk/ulp/netdirect2/user/nd_mw.h b/trunk/ulp/netdirect2/user/nd_mw.h
new file mode 100644 (file)
index 0000000..8409a0e
--- /dev/null
@@ -0,0 +1,127 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_MW_H_\r
+#define _ND_MW_H_\r
+\r
+#include <initguid.h>\r
+#include <ndspi.h>\r
+#include "nd_base.h"\r
+#include "nd_adapter.h"\r
+\r
+class CNDMemoryRegion : public INDMemoryRegion, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // INDMemoryRegion methods\r
+       STDMETHODIMP Register(const VOID* pBuffer, SIZE_T cbBuffer, DWORD flags,\r
+                                                 OVERLAPPED* pOverlapped);\r
+    STDMETHODIMP Deregister(OVERLAPPED* pOverlapped);\r
+       STDMETHODIMP_(UINT32) GetLocalToken();\r
+       STDMETHODIMP_(UINT32) GetRemoteToken();\r
+\r
+       CNDMemoryRegion(CNDAdapter *m_pAdapter);\r
+       ~CNDMemoryRegion();\r
+       void Delete() {delete this;}\r
+       static STDMETHODIMP\r
+       CreateInstance(CNDAdapter *pAdapter, INDMemoryRegion** ppMemoryRegion)\r
+       {\r
+               HRESULT hr;\r
+               CNDMemoryRegion *mr;\r
+\r
+               mr = new CNDMemoryRegion(pAdapter);\r
+               if (mr == NULL) {\r
+                       hr = ND_NO_MEMORY;\r
+                       goto err;\r
+               }\r
+\r
+               *ppMemoryRegion = mr;\r
+               return ND_SUCCESS;\r
+\r
+       err:\r
+               *ppMemoryRegion = NULL;\r
+               return hr;\r
+       }\r
+\r
+       WV_MEMORY_KEYS          m_Keys;\r
+\r
+protected:\r
+       CNDAdapter                      *m_pAdapter;\r
+};\r
+\r
+\r
+class CNDMemoryWindow : public INDMemoryWindow, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // INDMemoryWindow methods\r
+       STDMETHODIMP_(UINT32) GetRemoteToken();\r
+       \r
+       CNDMemoryWindow(CNDAdapter *m_pAdapter);\r
+       ~CNDMemoryWindow();\r
+       void Delete() {delete this;}\r
+       static STDMETHODIMP\r
+       CreateInstance(CNDAdapter *pAdapter, INDMemoryWindow** ppMemoryWindow)\r
+       {\r
+               HRESULT hr;\r
+               CNDMemoryWindow *mw;\r
+\r
+               mw = new CNDMemoryWindow(pAdapter);\r
+               if (mw == NULL) {\r
+                       hr = ND_NO_MEMORY;\r
+                       goto err;\r
+               }\r
+\r
+               *ppMemoryWindow = mw;\r
+               return ND_SUCCESS;\r
+\r
+       err:\r
+               *ppMemoryWindow = NULL;\r
+               return hr;\r
+       }\r
+\r
+       CNDMemoryRegion         *m_pMr;\r
+\r
+protected:\r
+       CNDAdapter                      *m_pAdapter;\r
+};\r
+\r
+DWORD ConvertAccessFlags(DWORD Flags);\r
+\r
+#endif // _ND_MW_H_\r
diff --git a/trunk/ulp/netdirect2/user/nd_provider.cpp b/trunk/ulp/netdirect2/user/nd_provider.cpp
new file mode 100644 (file)
index 0000000..92835fd
--- /dev/null
@@ -0,0 +1,211 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include "nd_provider.h"\r
+#include "nd_adapter.h"\r
+#include <ws2tcpip.h>\r
+\r
+CNDProvider::CNDProvider()\r
+{\r
+       WvGetObject(IID_IWVProvider, (LPVOID *) &m_pWvProvider);\r
+}\r
+\r
+CNDProvider::~CNDProvider()\r
+{\r
+       if (m_pWvProvider) {\r
+               m_pWvProvider->Release();\r
+       }\r
+}\r
+\r
+STDMETHODIMP CNDProvider::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_INDProvider) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDProvider::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDProvider::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+STDMETHODIMP CNDProvider::\r
+QueryAdapterAddressList(SOCKET_ADDRESS_LIST* pAddressList,\r
+                                               SIZE_T* pcbAddressList, UINT64 adapterId)\r
+{\r
+       WV_DEVICE_ADDRESS devaddr;\r
+       struct addrinfo *res, *ai;\r
+       HRESULT hr;\r
+       int cnt = 0;\r
+       size_t addrlen = 0, size;\r
+       UINT8 *offset;\r
+\r
+       if (m_pWvProvider == NULL) {\r
+               return ND_INSUFFICIENT_RESOURCES;\r
+       }\r
+\r
+       hr = getaddrinfo("..localmachine", NULL, NULL, &res);\r
+       if (hr) {\r
+               goto out;\r
+       }\r
+\r
+       for (ai = res; ai; ai = ai->ai_next) {\r
+               ai->ai_flags = m_pWvProvider->TranslateAddress(ai->ai_addr, &devaddr);\r
+               if (SUCCEEDED(ai->ai_flags) &&\r
+                       ((adapterId == 0) || (adapterId == devaddr.DeviceGuid))) {\r
+                       cnt++;\r
+                       addrlen += ai->ai_addrlen;\r
+               }\r
+       }\r
+\r
+       if (cnt == 0) {\r
+               *pcbAddressList = 0;\r
+               goto free;\r
+       }\r
+\r
+       size = sizeof(SOCKET_ADDRESS_LIST) + sizeof(SOCKET_ADDRESS) * (cnt - 1);\r
+       if (size + addrlen > *pcbAddressList) {\r
+               *pcbAddressList = size + addrlen;\r
+               hr = ND_BUFFER_OVERFLOW;\r
+               goto free;\r
+       }\r
+\r
+       pAddressList->iAddressCount = cnt;\r
+       offset = (UINT8 *) pAddressList + size;\r
+       for (cnt = 0, ai = res; ai; ai = ai->ai_next) {\r
+               if (SUCCEEDED(ai->ai_flags)) {\r
+                       pAddressList->Address[cnt].iSockaddrLength = ai->ai_addrlen;\r
+                       pAddressList->Address[cnt].lpSockaddr = (LPSOCKADDR) offset;\r
+                       RtlCopyMemory(offset, ai->ai_addr, ai->ai_addrlen);\r
+                       offset += ai->ai_addrlen;\r
+               }\r
+       }\r
+\r
+free:\r
+       freeaddrinfo(res);\r
+out:\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDProvider::\r
+QueryAddressList(SOCKET_ADDRESS_LIST* pAddressList, SIZE_T* pcbAddressList)\r
+{\r
+       return QueryAdapterAddressList(pAddressList, pcbAddressList, 0);\r
+}\r
+\r
+STDMETHODIMP CNDProvider::\r
+ResolveAddress(const struct sockaddr* pAddress, SIZE_T cbAddress, UINT64* pAdapterId)\r
+{\r
+       WV_DEVICE_ADDRESS devaddr;\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvProvider->TranslateAddress(pAddress, &devaddr);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       *pAdapterId = devaddr.DeviceGuid;\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP CNDProvider::\r
+OpenAdapter(UINT64 adapterId, INDAdapter** ppAdapter)\r
+{\r
+       return CNDAdapter::CreateInstance(this, adapterId, ppAdapter);\r
+}\r
+\r
+\r
+//-------------------------\r
+// CNDClassFactory routines\r
+//-------------------------\r
+\r
+STDMETHODIMP CNDClassFactory::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_IClassFactory) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDClassFactory::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDClassFactory::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+STDMETHODIMP CNDClassFactory::\r
+CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppObject)\r
+{\r
+       if (pUnkOuter != NULL) {\r
+               return CLASS_E_NOAGGREGATION;\r
+       }\r
+\r
+       if (riid != IID_INDProvider) {\r
+               *ppObject = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppObject = new CNDProvider();\r
+       if (*ppObject == NULL) {\r
+               return E_OUTOFMEMORY;\r
+       }\r
+\r
+       return S_OK;\r
+}\r
+\r
+STDMETHODIMP CNDClassFactory::\r
+LockServer(BOOL fLock)\r
+{\r
+       UNREFERENCED_PARAMETER(fLock);\r
+       return S_OK;\r
+}\r
diff --git a/trunk/ulp/netdirect2/user/nd_provider.h b/trunk/ulp/netdirect2/user/nd_provider.h
new file mode 100644 (file)
index 0000000..15a74f6
--- /dev/null
@@ -0,0 +1,81 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_PROVIDER_H_\r
+#define _ND_PROVIDER_H_\r
+\r
+#include <initguid.h>\r
+#include <ndspi.h>\r
+#include "nd_base.h"\r
+\r
+class CNDProvider : public INDProvider, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // INDProvider methods\r
+       STDMETHODIMP QueryAddressList(SOCKET_ADDRESS_LIST* pAddressList,\r
+                                                                 SIZE_T* pcbAddressList);\r
+       STDMETHODIMP ResolveAddress(const struct sockaddr* pAddress,\r
+                                                               SIZE_T cbAddress, UINT64* pAdapterId);\r
+       STDMETHODIMP OpenAdapter(UINT64 adapterId, INDAdapter** ppAdapter);\r
+\r
+       CNDProvider();\r
+       ~CNDProvider();\r
+       void Delete() {delete this;}\r
+\r
+       STDMETHODIMP QueryAdapterAddressList(SOCKET_ADDRESS_LIST* pAddressList,\r
+                                                                                SIZE_T* pcbAddressList, UINT64 adapterId);\r
+       IWVProvider *m_pWvProvider;\r
+};\r
+\r
+\r
+class CNDClassFactory : public IClassFactory, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // IClassFactory methods\r
+       STDMETHODIMP CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppObject);\r
+       STDMETHODIMP LockServer(BOOL fLock);\r
+\r
+       CNDClassFactory() {};\r
+       ~CNDClassFactory() {};\r
+       void Delete() {delete this;}\r
+};\r
+\r
+#endif // _ND_PROVIDER_H_
\ No newline at end of file
diff --git a/trunk/ulp/netdirect2/user/nd_qp.cpp b/trunk/ulp/netdirect2/user/nd_qp.cpp
new file mode 100644 (file)
index 0000000..6473540
--- /dev/null
@@ -0,0 +1,248 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include "nd_qp.h"\r
+#include "nd_adapter.h"\r
+#include "nd_connect.h"\r
+#include "nd_cq.h"\r
+#include "nd_mw.h"\r
+#include <netinet/in.h>\r
+\r
+\r
+CNDQueuePair::CNDQueuePair(CNDAdapter *pAdapter)\r
+{\r
+       pAdapter->AddRef();\r
+       m_pAdapter = pAdapter;\r
+       m_pWvQp = NULL;\r
+       m_pReceiveCq = NULL;\r
+       m_pSendCq = NULL;\r
+}\r
+\r
+STDMETHODIMP CNDQueuePair::\r
+Init(CNDCompletionQueue* pReceiveCompletionQueue,\r
+        CNDCompletionQueue* pInitiatorCompletionQueue,\r
+        CNDSharedReceiveQueue *pSharedReceiveQueue,\r
+        VOID* context, DWORD receiveQueueDepth, DWORD initiatorQueueDepth,\r
+        DWORD maxReceiveRequestSGE, DWORD maxInitiatorRequestSGE)\r
+{\r
+       WV_QP_CREATE create;\r
+       WV_QP_ATTRIBUTES attr;\r
+       //WV_DEVICE_ADDRESS *addr;\r
+       DWORD opts;\r
+       HRESULT hr;\r
+\r
+       RtlZeroMemory(&create, sizeof create);\r
+       m_pReceiveCq = pReceiveCompletionQueue;\r
+       m_pSendCq = pInitiatorCompletionQueue;\r
+       m_pReceiveCq->AddRef();\r
+       m_pSendCq->AddRef();\r
+       if ((m_pSrq = pSharedReceiveQueue)) {\r
+               m_pSrq->AddRef();\r
+               create.pSharedReceiveQueue = m_pSrq->m_pWvSrq;\r
+       }\r
+\r
+       create.pSendCq = m_pSendCq->m_pWvCq;\r
+       create.pReceiveCq = m_pReceiveCq->m_pWvCq;\r
+       create.Context = context;\r
+       create.SendDepth = initiatorQueueDepth;\r
+       create.SendSge = maxInitiatorRequestSGE;\r
+       create.ReceiveDepth = receiveQueueDepth;\r
+       create.ReceiveSge = maxReceiveRequestSGE;\r
+       //create.InitiatorDepth = ???;\r
+       //create.ResponderResources = ???;\r
+       create.MaxInlineSend = m_pAdapter->m_MaxInlineSend;\r
+       create.QpType = WvQpTypeRc;\r
+       \r
+       hr = m_pAdapter->m_pWvPd->CreateConnectQueuePair(&create, &m_pWvQp);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       opts = WV_QP_ATTR_STATE | WV_QP_ATTR_PORT_NUMBER | WV_QP_ATTR_PKEY_INDEX;\r
+       attr.QpState = WvQpStateInit;\r
+       //??? need pkey and port for adapter\r
+       //addr = &m_pAdapter->m_DevAddress;\r
+       //attr.AddressVector.PortNumber = addr->PortNumber;\r
+       //hr = m_pConnector->m_pAdapter->m_pWvDevice->FindPkey(addr->PortNumber, addr->Pkey,\r
+       //                                                                                                       &attr.PkeyIndex);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       hr = m_pWvQp->Modify(&attr, opts, NULL);\r
+       if (FAILED(hr)) {\r
+               return NDConvertWVStatus(hr);\r
+       }\r
+\r
+       return ND_SUCCESS;\r
+}\r
+\r
+CNDQueuePair::~CNDQueuePair()\r
+{\r
+       if (m_pWvQp != NULL) {\r
+               m_pWvQp->Release();\r
+       }\r
+       if (m_pReceiveCq != NULL) {\r
+               m_pReceiveCq->Release();\r
+       }\r
+       if (m_pSendCq != NULL) {\r
+               m_pSendCq->Release();\r
+       }\r
+       if (m_pSrq != NULL) {\r
+               m_pSrq->Release();\r
+       }\r
+       m_pAdapter->Release();\r
+}\r
+\r
+STDMETHODIMP CNDQueuePair::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_INDQueuePair) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDQueuePair::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDQueuePair::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+STDMETHODIMP CNDQueuePair::\r
+Flush(void)\r
+{\r
+       //??? Modify QP to error state\r
+       return ND_NOT_SUPPORTED;\r
+}\r
+\r
+STDMETHODIMP_(DWORD) CNDQueuePair::\r
+ConvertSendFlags(DWORD Flags)\r
+{\r
+       DWORD opts = 0;\r
+\r
+       if (!(Flags & ND_OP_FLAG_SILENT_SUCCESS)) {\r
+               opts |= WV_SEND_SIGNALED;\r
+       }\r
+       if (Flags & ND_OP_FLAG_READ_FENCE) {\r
+               opts |= WV_SEND_FENCE;\r
+       }\r
+       if (Flags & ND_OP_FLAG_SEND_AND_SOLICIT_EVENT) {\r
+               opts |= WV_SEND_SOLICITED;\r
+       }\r
+       if (Flags & ND_OP_FLAG_INLINE) {\r
+               opts |= WV_SEND_INLINE;\r
+       }\r
+       return opts;\r
+}\r
+\r
+STDMETHODIMP CNDQueuePair::\r
+Send(VOID* requestContext, const ND_SGE* pSGE, DWORD nSGE, DWORD flags)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvQp->Send((UINT64) (ULONG_PTR) requestContext, (WV_SGE *) pSGE, nSGE,\r
+                                          ConvertSendFlags(flags), 0);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDQueuePair::\r
+Receive(VOID* requestContext, const ND_SGE* pSGE, DWORD nSGE)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvQp->PostReceive((UINT64) (ULONG_PTR) requestContext, (WV_SGE *) pSGE, nSGE);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDQueuePair::\r
+Bind(VOID* requestContext, INDMemoryRegion* pMemoryRegion,\r
+        INDMemoryWindow* pMemoryWindow, const VOID* pBuffer, SIZE_T cbBuffer,\r
+        DWORD flags)\r
+{\r
+       CNDMemoryRegion *mr = (CNDMemoryRegion *) pMemoryRegion;\r
+       CNDMemoryWindow *mw = (CNDMemoryWindow *) pMemoryWindow;\r
+       HRESULT hr;\r
+\r
+       if (mw->m_pMr != NULL) {\r
+               mw->m_pMr->Release();\r
+       }\r
+       mw->m_pMr = mr;\r
+       mr->AddRef();\r
+       hr = m_pWvQp->Write((UINT64) (ULONG_PTR) requestContext, NULL, 0,\r
+                                               ConvertSendFlags(flags), 0, 0, 0);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDQueuePair::\r
+Invalidate(VOID* requestContext, INDMemoryWindow* pMemoryWindow, DWORD flags)\r
+{\r
+       CNDMemoryWindow *mw = (CNDMemoryWindow *) pMemoryWindow;\r
+       HRESULT hr;\r
+\r
+       mw->m_pMr->Release();\r
+       mw->m_pMr = NULL;\r
+       hr = m_pWvQp->Write((UINT64) (ULONG_PTR) requestContext, NULL, 0,\r
+                                               ConvertSendFlags(flags), 0, 0, 0);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDQueuePair::\r
+Read(VOID* requestContext, const ND_SGE* pSGE, DWORD nSGE,\r
+        UINT64 remoteAddress, UINT32 remoteToken, DWORD flags)\r
+{\r
+       DWORD opts;\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvQp->Read((UINT64) (ULONG_PTR) requestContext, (WV_SGE *) pSGE, nSGE,\r
+                                          ConvertSendFlags(flags), htonll(remoteAddress), remoteToken);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDQueuePair::\r
+Write(VOID* requestContext, const ND_SGE* pSGE, DWORD nSGE,\r
+         UINT64 remoteAddress, UINT32 remoteToken, DWORD flags)\r
+{\r
+       DWORD opts;\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvQp->Write((UINT64) (ULONG_PTR) requestContext, (WV_SGE *) pSGE, nSGE,\r
+                                           ConvertSendFlags(flags), 0, htonll(remoteAddress), remoteToken);\r
+       return NDConvertWVStatus(hr);\r
+}\r
diff --git a/trunk/ulp/netdirect2/user/nd_qp.h b/trunk/ulp/netdirect2/user/nd_qp.h
new file mode 100644 (file)
index 0000000..1d09ddc
--- /dev/null
@@ -0,0 +1,118 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_QUEUEPAIR_H_\r
+#define _ND_QUEUEPAIR_H_\r
+\r
+#include <initguid.h>\r
+#include <ndspi.h>\r
+#include "nd_base.h"\r
+#include "nd_cq.h"\r
+#include "nd_srq.h"\r
+#include "nd_adapter.h"\r
+\r
+\r
+class CNDQueuePair : public INDQueuePair, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // INDQueuePair methods\r
+       STDMETHODIMP Flush();\r
+       STDMETHODIMP Send(VOID* requestContext, const ND_SGE* pSGE, DWORD nSGE, DWORD flags);\r
+       STDMETHODIMP Receive(VOID* requestContext, const ND_SGE* pSGE, DWORD nSGE);\r
+       STDMETHODIMP Bind(VOID* requestContext, INDMemoryRegion* pMemoryRegion,\r
+                                         INDMemoryWindow* pMemoryWindow, const VOID* pBuffer, SIZE_T cbBuffer,\r
+                                         DWORD flags);\r
+       STDMETHODIMP Invalidate(VOID* requestContext, INDMemoryWindow* pMemoryWindow, DWORD flags);\r
+       STDMETHODIMP Read(VOID* requestContext, const ND_SGE* pSGE, DWORD nSGE,\r
+                                         UINT64 remoteAddress, UINT32 remoteToken, DWORD flags);\r
+       STDMETHODIMP Write(VOID* requestContext, const ND_SGE* pSGE, DWORD nSGE,\r
+                                          UINT64 remoteAddress, UINT32 remoteToken, DWORD flags);\r
+       \r
+       CNDQueuePair(CNDAdapter *pAdapter);\r
+       ~CNDQueuePair();\r
+       void Delete() {delete this;}\r
+       static STDMETHODIMP\r
+       CreateInstance(CNDAdapter *pAdapter,\r
+                                  CNDCompletionQueue* pReceiveCompletionQueue,\r
+                                  CNDCompletionQueue* pInitiatorCompletionQueue,\r
+                                  CNDSharedReceiveQueue *pSharedReceiveQueue,\r
+                                  VOID* context, DWORD receiveQueueDepth, DWORD initiatorQueueDepth,\r
+                                  DWORD maxReceiveRequestSGE, DWORD maxInitiatorRequestSGE,\r
+                                  INDQueuePair** ppQueuePair)\r
+       {\r
+               HRESULT hr;\r
+               CNDQueuePair *qp;\r
+\r
+               qp = new CNDQueuePair(pAdapter);\r
+               if (qp == NULL) {\r
+                       hr = ND_NO_MEMORY;\r
+                       goto err1;\r
+               }\r
+\r
+               hr = qp->Init(pReceiveCompletionQueue, pInitiatorCompletionQueue,\r
+                                         pSharedReceiveQueue, context, receiveQueueDepth,\r
+                                         initiatorQueueDepth, maxReceiveRequestSGE, maxInitiatorRequestSGE);\r
+               if (FAILED(hr)) {\r
+                       goto err2;\r
+               }\r
+\r
+               *ppQueuePair = qp;\r
+               return ND_SUCCESS;\r
+\r
+       err2:\r
+               qp->Release();\r
+       err1:\r
+               *ppQueuePair = NULL;\r
+               return hr;\r
+       }\r
+\r
+       IWVConnectQueuePair     *m_pWvQp;\r
+\r
+protected:\r
+       CNDAdapter                      *m_pAdapter;\r
+       CNDCompletionQueue      *m_pReceiveCq;\r
+       CNDCompletionQueue      *m_pSendCq;\r
+       CNDSharedReceiveQueue *m_pSrq;\r
+\r
+       STDMETHODIMP Init(CNDCompletionQueue* pReceiveCompletionQueue,\r
+                                         CNDCompletionQueue* pInitiatorCompletionQueue,\r
+                                         CNDSharedReceiveQueue *pSharedReceiveQueue,\r
+                                         VOID* context, DWORD receiveQueueDepth, DWORD initiatorQueueDepth,\r
+                                         DWORD maxReceiveRequestSGE, DWORD maxInitiatorRequestSGE);\r
+       STDMETHODIMP_(DWORD) ConvertSendFlags(DWORD Flags);\r
+};\r
+\r
+#endif // _ND_QUEUEPAIR_H_\r
diff --git a/trunk/ulp/netdirect2/user/nd_srq.cpp b/trunk/ulp/netdirect2/user/nd_srq.cpp
new file mode 100644 (file)
index 0000000..e472757
--- /dev/null
@@ -0,0 +1,128 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#include "nd_srq.h"\r
+\r
+\r
+CNDSharedReceiveQueue::CNDSharedReceiveQueue(CNDAdapter *pAdapter)\r
+{\r
+       pAdapter->AddRef();\r
+       m_pAdapter = pAdapter;\r
+       m_pWvSrq = NULL;\r
+}\r
+\r
+STDMETHODIMP CNDSharedReceiveQueue::\r
+Init(DWORD queueDepth, DWORD maxSGE, DWORD notifyThreshold, GROUP_AFFINITY* pAffinity)\r
+{\r
+       HRESULT hr;\r
+\r
+       //??? pAffinity ignored\r
+       hr = m_pAdapter->m_pWvPd->CreateSharedReceiveQueue(queueDepth, maxSGE,\r
+                                                                                                          notifyThreshold, &m_pWvSrq);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+CNDSharedReceiveQueue::~CNDSharedReceiveQueue()\r
+{\r
+       if (m_pWvSrq != NULL) {\r
+               m_pWvSrq->Release();\r
+       }\r
+       m_pAdapter->Release();\r
+}\r
+\r
+STDMETHODIMP CNDSharedReceiveQueue::\r
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)\r
+{\r
+       if (riid != IID_IUnknown && riid != IID_INDSharedReceiveQueue) {\r
+               *ppvObj = NULL;\r
+               return E_NOINTERFACE;\r
+       }\r
+\r
+       *ppvObj = this;\r
+       AddRef();\r
+       return ND_SUCCESS;\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDSharedReceiveQueue::\r
+AddRef(void)\r
+{\r
+       return CNDBase::AddRef();\r
+}\r
+\r
+STDMETHODIMP_(ULONG) CNDSharedReceiveQueue::\r
+Release(void)\r
+{\r
+       return CNDBase::Release();\r
+}\r
+\r
+STDMETHODIMP CNDSharedReceiveQueue::\r
+CancelOverlappedRequests(void)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvSrq->CancelOverlappedRequests();\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDSharedReceiveQueue::\r
+GetOverlappedResult(OVERLAPPED *pOverlapped, BOOL bWait)\r
+{\r
+       DWORD bytes;\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvSrq->GetOverlappedResult(pOverlapped, &bytes, bWait);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDSharedReceiveQueue::\r
+Modify(DWORD queueDepth, DWORD notifyThreshold)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvSrq->Modify(queueDepth, notifyThreshold);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDSharedReceiveQueue::\r
+Notify(OVERLAPPED* pOverlapped)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvSrq->Notify(pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
+}\r
+\r
+STDMETHODIMP CNDSharedReceiveQueue::\r
+Receive(VOID* requestContext, const ND_SGE* pSGE, DWORD nSGE)\r
+{\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvSrq->PostReceive((UINT64) (ULONG_PTR) requestContext, (WV_SGE *) pSGE, nSGE);\r
+       return NDConvertWVStatus(hr);\r
+}\r
diff --git a/trunk/ulp/netdirect2/user/nd_srq.h b/trunk/ulp/netdirect2/user/nd_srq.h
new file mode 100644 (file)
index 0000000..80f2c4b
--- /dev/null
@@ -0,0 +1,99 @@
+/*\r
+ * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+#pragma once\r
+\r
+#ifndef _ND_SRQ_H_\r
+#define _ND_SRQ_H_\r
+\r
+#include <initguid.h>\r
+#include <ndspi.h>\r
+#include "nd_base.h"\r
+#include "nd_adapter.h"\r
+\r
+\r
+class CNDSharedReceiveQueue : public INDSharedReceiveQueue, public CNDBase\r
+{\r
+public:\r
+       // IUnknown methods\r
+       STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);\r
+       STDMETHODIMP_(ULONG) AddRef();\r
+       STDMETHODIMP_(ULONG) Release();\r
+\r
+       // INDOverlapped methods\r
+       STDMETHODIMP CancelOverlappedRequests();\r
+       STDMETHODIMP GetOverlappedResult(OVERLAPPED *pOverlapped, BOOL bWait);\r
+\r
+       // INDSharedReceiveQueue methods\r
+       STDMETHODIMP Modify(DWORD queueDepth, DWORD notifyThreshold);\r
+       STDMETHODIMP Notify(OVERLAPPED* pOverlapped);\r
+       STDMETHODIMP Receive(VOID* requestContext, const ND_SGE* pSGE, DWORD nSGE);\r
+\r
+       CNDSharedReceiveQueue(CNDAdapter *pAdapter);\r
+       ~CNDSharedReceiveQueue();\r
+       void Delete() {delete this;}\r
+       static STDMETHODIMP\r
+       CreateInstance(CNDAdapter *pAdapter, DWORD queueDepth, DWORD maxSGE,\r
+                                  DWORD notifyThreshold, GROUP_AFFINITY* pAffinity,\r
+                                  INDSharedReceiveQueue** ppSharedReceiveQueue)\r
+       {\r
+               HRESULT hr;\r
+               CNDSharedReceiveQueue *srq;\r
+\r
+               srq = new CNDSharedReceiveQueue(pAdapter);\r
+               if (srq == NULL) {\r
+                       hr = ND_NO_MEMORY;\r
+                       goto err1;\r
+               }\r
+\r
+               hr = srq->Init(queueDepth, maxSGE, notifyThreshold, pAffinity);\r
+               if (FAILED(hr)) {\r
+                       goto err2;\r
+               }\r
+\r
+               *ppSharedReceiveQueue = srq;\r
+               return ND_SUCCESS;\r
+\r
+       err2:\r
+               srq->Release();\r
+       err1:\r
+               *ppSharedReceiveQueue = NULL;\r
+               return hr;\r
+       }\r
+\r
+       IWVSharedReceiveQueue   *m_pWvSrq;\r
+\r
+protected:\r
+       CNDAdapter                              *m_pAdapter;\r
+\r
+       STDMETHODIMP Init(DWORD queueDepth, DWORD maxSGE, DWORD notifyThreshold,\r
+                                         GROUP_AFFINITY* pAffinity);\r
+};\r
+\r
+#endif // _ND_SRQ_H_\r
diff --git a/trunk/ulp/netdirect2/user/netdirect.rc b/trunk/ulp/netdirect2/user/netdirect.rc
new file mode 100644 (file)
index 0000000..7ed0d78
--- /dev/null
@@ -0,0 +1,46 @@
+/*\r
+ * Copyright (c) 2008 Intel Corporation.  All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+\r
+#include <oib_ver.h>\r
+\r
+#define VER_FILETYPE                   VFT_DLL\r
+#define VER_FILESUBTYPE                        VFT2_UNKNOWN\r
+\r
+#ifdef _DEBUG_\r
+#define VER_FILEDESCRIPTION_STR                "OpenFabrics Winverbs Network Direct Provider (Debug)"\r
+#define VER_INTERNALNAME_STR           "wvndprovd.dll"\r
+#define VER_ORIGINALFILENAME_STR       "wvndprovd.dll"\r
+#else\r
+#define VER_FILEDESCRIPTION_STR                "OpenFabrics Winverbs Network Direct Provider"\r
+#define VER_INTERNALNAME_STR           "wvndprov.dll"\r
+#define VER_ORIGINALFILENAME_STR       "wvndprov.dll"\r
+#endif\r
+\r
+#include <common.ver>\r