netdirect/winverbs: fixes to run nd sample tests
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sat, 1 Aug 2009 01:02:29 +0000 (01:02 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sat, 1 Aug 2009 01:02:29 +0000 (01:02 +0000)
Now that the WV ND provider can be installed, the ND sample tests can be run.  This provides various fixes to get at least a couple of the sample tests running.

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

13 files changed:
ulp/netdirect/user/SOURCES
ulp/netdirect/user/nd_adapter.cpp
ulp/netdirect/user/nd_base.cpp
ulp/netdirect/user/nd_base.h
ulp/netdirect/user/nd_connect.cpp
ulp/netdirect/user/nd_cq.cpp
ulp/netdirect/user/nd_ep.cpp
ulp/netdirect/user/nd_ep.h
ulp/netdirect/user/nd_export.def
ulp/netdirect/user/nd_listen.cpp
ulp/netdirect/user/nd_main.cpp
ulp/netdirect/user/nd_mw.cpp
ulp/netdirect/user/nd_provider.cpp

index f926731..ef6f2a1 100644 (file)
@@ -35,6 +35,7 @@ TARGETLIBS =                                          \
        $(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
index fc9f45d..107a44e 100644 (file)
@@ -53,22 +53,22 @@ Init(const struct sockaddr *pAddress, SIZE_T AddressLength)
 \r
        hr = WvGetObject(IID_IWVProvider, (LPVOID *) &m_pWvProvider);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
        hr = m_pWvProvider->TranslateAddress(pAddress, &m_DevAddress);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
        hr = m_pWvProvider->OpenDevice(m_DevAddress.DeviceGuid, &m_pWvDevice);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
        hr = m_pWvDevice->AllocateProtectionDomain(&m_pWvPd);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
        RtlCopyMemory(&m_Address, pAddress, AddressLength);\r
@@ -155,7 +155,7 @@ GetOverlappedResult(OVERLAPPED *pOverlapped,
                LeaveCriticalSection(&m_Lock);\r
        }\r
 \r
-       return hr;\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP_(HANDLE) CNDAdapter::\r
@@ -204,7 +204,7 @@ Query(DWORD VersionRequested, ND_ADAPTER_INFO* pInfo, SIZE_T* pBufferSize)
 \r
 out:\r
        *pBufferSize = sizeof(ND_ADAPTER_INFO);\r
-       return hr;\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDAdapter::\r
@@ -247,13 +247,13 @@ RegisterMemory(const void* pBuffer, SIZE_T BufferSize,
        flags = WV_ACCESS_REMOTE_READ | WV_ACCESS_REMOTE_WRITE |\r
                        WV_ACCESS_REMOTE_ATOMIC | WV_ACCESS_LOCAL_WRITE | WV_ACCESS_MW_BIND;\r
        hr = m_pWvPd->RegisterMemory(pBuffer, BufferSize, flags, pOverlapped, &mr->Keys);\r
-       if (FAILED(hr)) {\r
-               CleanupMr(mr);\r
-       } else {\r
+       if (SUCCEEDED(hr) || hr == WV_IO_PENDING) {\r
                *phMr = (ND_MR_HANDLE) mr;\r
+       } else {\r
+               CleanupMr(mr);\r
        }\r
 \r
-       return hr;\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDAdapter::\r
@@ -267,7 +267,7 @@ DeregisterMemory(ND_MR_HANDLE hMr, OVERLAPPED* pOverlapped)
        if (SUCCEEDED(hr) || hr == WV_IO_PENDING) {\r
                CleanupMr(mr);\r
        }\r
-       return hr;\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 void CNDAdapter::\r
index 6390f60..e51bc59 100644 (file)
@@ -28,6 +28,7 @@
  */\r
 \r
 #include "nd_base.h"\r
+#include <ndstatus.h>\r
 \r
 CNDBase::CNDBase()\r
 {\r
@@ -51,3 +52,15 @@ Release(void)
        }\r
        return ref;\r
 }\r
+\r
+HRESULT NDConvertWVStatus(HRESULT hr)\r
+{\r
+       switch (hr) {\r
+       case WV_IO_PENDING:\r
+               return ND_PENDING;\r
+       case WV_IO_TIMEOUT:\r
+               return ND_TIMEOUT;\r
+       default:\r
+               return hr;\r
+       }\r
+}\r
index da84e6a..d11b1a0 100644 (file)
@@ -34,6 +34,7 @@
 \r
 #include <windows.h>\r
 #include <rdma\winverbs.h>\r
+#include <stdio.h>\r
 \r
 class CNDBase\r
 {\r
@@ -60,4 +61,6 @@ __inline void __cdecl operator delete(void *pObj)
        HeapFree(GetProcessHeap(), 0, pObj);\r
 }\r
 \r
+HRESULT NDConvertWVStatus(HRESULT hr);\r
+\r
 #endif // _ND_BASE_H_\r
index 22d12e4..aa46ada 100644 (file)
@@ -29,6 +29,7 @@
 \r
 #include "nd_connect.h"\r
 #include "nd_ep.h"\r
+#include <iba/ibat.h>\r
 \r
 \r
 CNDConnector::CNDConnector(CNDAdapter *pAdapter)\r
@@ -41,7 +42,10 @@ CNDConnector::CNDConnector(CNDAdapter *pAdapter)
 STDMETHODIMP CNDConnector::\r
 Init(void)\r
 {\r
-       return m_pAdapter->m_pWvProvider->CreateConnectEndpoint(&m_pWvConnEp);\r
+       HRESULT hr;\r
+\r
+       hr = m_pAdapter->m_pWvProvider->CreateConnectEndpoint(&m_pWvConnEp);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 CNDConnector::~CNDConnector()\r
@@ -80,16 +84,22 @@ Release(void)
 STDMETHODIMP CNDConnector::\r
 CancelOverlappedRequests(void)\r
 {\r
-       return m_pWvConnEp->CancelOverlappedRequests();\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->CancelOverlappedRequests();\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDConnector::\r
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        SIZE_T *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return m_pWvConnEp->GetOverlappedResult(pOverlapped,\r
-                                                                                       (DWORD *) pNumberOfBytesTransferred,\r
-                                                                                       bWait);\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->GetOverlappedResult(pOverlapped,\r
+                                                                                 (DWORD *) pNumberOfBytesTransferred,\r
+                                                                                 bWait);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDConnector::\r
@@ -116,16 +126,32 @@ Connect(INDEndpoint* pEndpoint,
                const void* pPrivateData, SIZE_T PrivateDataLength,\r
                OVERLAPPED* pOverlapped)\r
 {\r
-       CNDEndpoint                     *ep = (CNDEndpoint *) pEndpoint;\r
-       WV_SOCKADDR                     addr;\r
-       WV_CONNECT_PARAM        attr;\r
+       CNDEndpoint *ep = (CNDEndpoint *) pEndpoint;\r
+       WV_SOCKADDR addr;\r
+       WV_CONNECT_PARAM attr;\r
+       IBAT_PATH_BLOB path;\r
+       HRESULT hr;\r
 \r
-       RtlCopyMemory(&addr, pAddress, AddressLength);\r
+       RtlCopyMemory(&addr, &m_pAdapter->m_Address, AddressLength);\r
        if (addr.Sa.sa_family == AF_INET) {\r
                addr.Sin.sin_port = LocalPort;\r
        } else {\r
                addr.Sin6.sin6_port = LocalPort;\r
        }\r
+       hr = m_pWvConnEp->BindAddress(&addr.Sa);\r
+       if (FAILED(hr)) {\r
+               goto out;\r
+       }\r
+\r
+       hr = IBAT::Resolve(&addr.Sa, pAddress, &path);\r
+       if (FAILED(hr)) {\r
+               goto out;\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 = PrivateDataLength)) {\r
@@ -135,16 +161,20 @@ Connect(INDEndpoint* pEndpoint,
        attr.InitiatorDepth = ep->m_InitiatorDepth;\r
        attr.RetryCount = 7;\r
 \r
-       return m_pWvConnEp->Connect(ep->m_pWvQp, &addr.Sa, &attr, pOverlapped);\r
+       hr = m_pWvConnEp->Connect(ep->m_pWvQp, pAddress, &attr, pOverlapped);\r
+out:\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDConnector::\r
 CompleteConnect(OVERLAPPED* pOverlapped)\r
 {\r
-       WV_CONNECT_PARAM        attr;\r
+       WV_CONNECT_PARAM attr;\r
+       HRESULT hr;\r
 \r
        RtlZeroMemory(&attr, sizeof attr);\r
-       return m_pWvConnEp->Accept(NULL, &attr, pOverlapped);\r
+       hr = m_pWvConnEp->Accept(NULL, &attr, pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDConnector::\r
@@ -152,8 +182,9 @@ Accept(INDEndpoint* pEndpoint,
           const void* pPrivateData, SIZE_T PrivateDataLength,\r
           OVERLAPPED* pOverlapped)\r
 {\r
-       CNDEndpoint                     *ep = (CNDEndpoint *) pEndpoint;\r
-       WV_CONNECT_PARAM        attr;\r
+       CNDEndpoint *ep = (CNDEndpoint *) pEndpoint;\r
+       WV_CONNECT_PARAM attr;\r
+       HRESULT hr;\r
 \r
        RtlZeroMemory(&attr, sizeof attr);\r
        if ((attr.DataLength = PrivateDataLength)) {\r
@@ -162,13 +193,17 @@ Accept(INDEndpoint* pEndpoint,
        attr.ResponderResources = ep->m_ResponderResources;\r
        attr.InitiatorDepth = ep->m_InitiatorDepth;\r
 \r
-       return m_pWvConnEp->Accept(ep->m_pWvQp, &attr, pOverlapped);\r
+       hr = m_pWvConnEp->Accept(ep->m_pWvQp, &attr, pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDConnector::\r
 Reject(const void* pPrivateData, SIZE_T PrivateDataLength)\r
 {\r
-       return m_pWvConnEp->Reject(pPrivateData, PrivateDataLength);\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->Reject(pPrivateData, PrivateDataLength);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDConnector::\r
@@ -178,23 +213,28 @@ GetConnectionData(SIZE_T* pInboundReadLimit, SIZE_T* pOutboundReadLimit,
        WV_CONNECT_ATTRIBUTES attr;\r
        HRESULT hr;\r
        \r
-       if (pPrivateDataLength && *pPrivateDataLength < ND_PRIVATE_DATA_SIZE) {\r
-               *pPrivateDataLength = ND_PRIVATE_DATA_SIZE;\r
-               return ND_BUFFER_OVERFLOW;\r
-       }\r
-\r
        hr = m_pWvConnEp->Query(&attr);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
-       *pInboundReadLimit = attr.Param.ResponderResources;\r
-       *pOutboundReadLimit = attr.Param.InitiatorDepth;\r
+       if (pInboundReadLimit) {\r
+               *pInboundReadLimit = attr.Param.ResponderResources;\r
+       }\r
+       if (pOutboundReadLimit) {\r
+               *pOutboundReadLimit = attr.Param.InitiatorDepth;\r
+       }\r
        if (pPrivateDataLength) {\r
-               RtlCopyMemory(pPrivateData, attr.Param.Data, ND_PRIVATE_DATA_SIZE);\r
+               if (*pPrivateDataLength < ND_PRIVATE_DATA_SIZE) {\r
+                       hr = ND_BUFFER_OVERFLOW;\r
+               }\r
+\r
+               RtlCopyMemory(pPrivateData, attr.Param.Data,\r
+                                         min(*pPrivateDataLength, ND_PRIVATE_DATA_SIZE));\r
                *pPrivateDataLength = ND_PRIVATE_DATA_SIZE;\r
        }\r
-       return ND_SUCCESS;\r
+\r
+       return hr;\r
 }\r
 \r
 static SIZE_T GetAddressSize(WV_SOCKADDR *addr)\r
@@ -210,7 +250,7 @@ GetLocalAddress(struct sockaddr* pAddress, SIZE_T* pAddressLength)
        \r
        hr = m_pWvConnEp->Query(&attr);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
        if (*pAddressLength < GetAddressSize(&attr.LocalAddress)) {\r
@@ -221,7 +261,7 @@ GetLocalAddress(struct sockaddr* pAddress, SIZE_T* pAddressLength)
        RtlCopyMemory(pAddress, &attr.LocalAddress, GetAddressSize(&attr.LocalAddress));\r
 out:\r
        *pAddressLength = GetAddressSize(&attr.LocalAddress);\r
-       return hr;\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDConnector::\r
@@ -232,7 +272,7 @@ GetPeerAddress(struct sockaddr* pAddress, SIZE_T* pAddressLength)
        \r
        hr = m_pWvConnEp->Query(&attr);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
        if (*pAddressLength < GetAddressSize(&attr.PeerAddress)) {\r
@@ -243,17 +283,23 @@ GetPeerAddress(struct sockaddr* pAddress, SIZE_T* pAddressLength)
        RtlCopyMemory(pAddress, &attr.PeerAddress, GetAddressSize(&attr.PeerAddress));\r
 out:\r
        *pAddressLength = GetAddressSize(&attr.PeerAddress);\r
-       return hr;\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDConnector::\r
 NotifyDisconnect(OVERLAPPED* pOverlapped)\r
 {\r
-       return m_pWvConnEp->NotifyDisconnect(pOverlapped);\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
-       return m_pWvConnEp->Disconnect(pOverlapped);\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->Disconnect(pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
 }\r
index 0324ed1..28aabe5 100644 (file)
@@ -39,7 +39,10 @@ CNDCompletionQueue::CNDCompletionQueue(CNDAdapter *pAdapter)
 STDMETHODIMP CNDCompletionQueue::\r
 Init(SIZE_T nEntries)\r
 {\r
-       return m_pAdapter->m_pWvDevice->CreateCompletionQueue(&nEntries, &m_pWvCq);\r
+       HRESULT hr;\r
+\r
+       hr = m_pAdapter->m_pWvDevice->CreateCompletionQueue(&nEntries, &m_pWvCq);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 CNDCompletionQueue::~CNDCompletionQueue()\r
@@ -78,27 +81,39 @@ Release(void)
 STDMETHODIMP CNDCompletionQueue::\r
 CancelOverlappedRequests(void)\r
 {\r
-       return m_pWvCq->CancelOverlappedRequests();\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvCq->CancelOverlappedRequests();\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDCompletionQueue::\r
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        SIZE_T *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return m_pWvCq->GetOverlappedResult(pOverlapped,\r
-                                                                               (DWORD *) pNumberOfBytesTransferred, bWait);\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvCq->GetOverlappedResult(pOverlapped,\r
+                                                                         (DWORD *) pNumberOfBytesTransferred, bWait);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDCompletionQueue::\r
 Resize(SIZE_T nEntries)\r
 {\r
-       return m_pWvCq->Resize(&nEntries);\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvCq->Resize(&nEntries);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDCompletionQueue::\r
 Notify(DWORD Type, OVERLAPPED* pOverlapped)\r
 {\r
-       return m_pWvCq->Notify((WV_CQ_NOTIFY_TYPE) Type, pOverlapped);\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvCq->Notify((WV_CQ_NOTIFY_TYPE) Type, pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP_(SIZE_T) CNDCompletionQueue::\r
@@ -116,8 +131,10 @@ GetResults(ND_RESULT* pResults[], SIZE_T nResults)
 \r
                for (i = 0; i < cnt; i++) {\r
                        pResults[total] = (ND_RESULT *) comp[i].WrId;\r
-                       pResults[total]->Status = comp[i].Status;\r
-                       pResults[total++]->BytesTransferred = comp[i].Length;\r
+                       if (comp[i].Opcode & WvReceive) {\r
+                               pResults[total]->BytesTransferred = comp[i].Length;\r
+                       }\r
+                       pResults[total++]->Status = comp[i].Status;\r
                }\r
        }\r
        return total;\r
index 07383f2..7b04fbe 100644 (file)
@@ -57,6 +57,8 @@ Init(CNDCompletionQueue* pInboundCq, CNDCompletionQueue* pOutboundCq,
        DWORD opts;\r
        HRESULT hr;\r
 \r
+       m_pInboundCq = pInboundCq;\r
+       m_pOutboundCq = pOutboundCq;\r
        m_pInboundCq->AddRef();\r
        m_pOutboundCq->AddRef();\r
        m_InitiatorDepth = OutboundReadLimit;\r
@@ -76,7 +78,7 @@ Init(CNDCompletionQueue* pInboundCq, CNDCompletionQueue* pOutboundCq,
        \r
        hr = m_pConnector->m_pAdapter->m_pWvPd->CreateConnectQueuePair(&create, &m_pWvQp);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
        opts = WV_QP_ATTR_STATE | WV_QP_ATTR_PORT_NUMBER | WV_QP_ATTR_PKEY_INDEX;\r
@@ -86,15 +88,17 @@ Init(CNDCompletionQueue* pInboundCq, CNDCompletionQueue* pOutboundCq,
        hr = m_pConnector->m_pAdapter->m_pWvDevice->FindPkey(addr->PortNumber, addr->Pkey,\r
                                                                                                                 &attr.PkeyIndex);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
        hr = m_pWvQp->Modify(&attr, opts, NULL);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
-       *pMaxInlineData = 0;\r
+       if (pMaxInlineData) {\r
+               *pMaxInlineData = 0;\r
+       }\r
        return ND_SUCCESS;\r
 }\r
 \r
@@ -155,16 +159,18 @@ SubmitRequestBatch(void)
        // no-op\r
 }\r
 \r
-STDMETHODIMP_(void) CNDEndpoint::\r
+STDMETHODIMP_(SIZE_T) CNDEndpoint::\r
 ConvertSgl(const ND_SGE* pSgl, SIZE_T nSge, WV_SGE* pWvSgl)\r
 {\r
-       SIZE_T i;\r
+       SIZE_T i, len = 0;\r
 \r
        for (i = 0; i < nSge; i++) {\r
                pWvSgl[i].pAddress = pSgl[i].pAddr;\r
                pWvSgl[i].Length = (UINT32) pSgl[i].Length;\r
+               len += pWvSgl[i].Length;\r
                pWvSgl[i].Lkey = pSgl[i].hMr ? ((ND_MR *) pSgl[i].hMr)->Keys.Lkey : 0;\r
        }\r
+       return len;\r
 }\r
 \r
 STDMETHODIMP_(DWORD) CNDEndpoint::\r
@@ -203,26 +209,33 @@ Send(ND_RESULT* pResult, const ND_SGE* pSgl, SIZE_T nSge, DWORD Flags)
 {\r
        WV_SGE sgl[ND_MAX_SGE];\r
        DWORD opts;\r
+       HRESULT hr;\r
 \r
-       ConvertSgl(pSgl, nSge, sgl);\r
-       opts = ConvertSendFlags(Flags) | (pSgl[0].hMr ? 0 : WV_SEND_INLINE);\r
-       return m_pWvQp->Send((UINT64) pResult, sgl, nSge, opts, 0);\r
+       pResult->BytesTransferred = ConvertSgl(pSgl, nSge, sgl);\r
+       opts = ConvertSendFlags(Flags) | (pSgl && pSgl[0].hMr ? 0 : WV_SEND_INLINE);\r
+       hr = m_pWvQp->Send((UINT64) pResult, sgl, nSge, opts, 0);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDEndpoint::\r
 SendAndInvalidate(ND_RESULT* pResult, const ND_SGE* pSgl, SIZE_T nSge,\r
                                  const ND_MW_DESCRIPTOR* pRemoteMwDescriptor, DWORD Flags)\r
 {\r
-       return Send(pResult, pSgl, nSge, Flags);\r
+       HRESULT hr;\r
+       \r
+       hr = Send(pResult, pSgl, nSge, Flags);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDEndpoint::\r
 Receive(ND_RESULT* pResult, const ND_SGE* pSgl, SIZE_T nSge)\r
 {\r
        WV_SGE sgl[ND_MAX_SGE];\r
+       HRESULT hr;\r
 \r
        ConvertSgl(pSgl, nSge, sgl);\r
-       return m_pWvQp->PostReceive((UINT64) pResult, sgl, nSge);\r
+       hr = m_pWvQp->PostReceive((UINT64) pResult, sgl, nSge);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDEndpoint::\r
@@ -232,25 +245,27 @@ Bind(ND_RESULT* pResult, ND_MR_HANDLE hMr, INDMemoryWindow* pMw,
 {\r
        CNDMemoryWindow *mw = (CNDMemoryWindow *) pMw;\r
        ND_MR *mr = (ND_MR *) hMr;\r
-       WV_SGE sge;\r
+       HRESULT hr;\r
 \r
+       pResult->BytesTransferred = 0;\r
        pMwDescriptor->Base = htonll((UINT64) (ULONG_PTR) pBuffer);\r
        pMwDescriptor->Length = htonll(BufferSize);\r
        pMwDescriptor->Token = mr->Keys.Rkey;\r
 \r
-       RtlZeroMemory(&sge, sizeof sge);\r
-       return m_pWvQp->Write((UINT64) pResult, &sge, 1, ConvertSendFlags(Flags),\r
-                                                 0, NULL, 0);\r
+       hr = m_pWvQp->Write((UINT64) pResult, NULL, 0, ConvertSendFlags(Flags),\r
+                                               0, 0, 0);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDEndpoint::\r
 Invalidate(ND_RESULT* pResult, INDMemoryWindow* pMw, DWORD Flags)\r
 {\r
-       WV_SGE sge;\r
+       HRESULT hr;\r
 \r
-       RtlZeroMemory(&sge, sizeof sge);\r
-       return m_pWvQp->Write((UINT64) pResult, &sge, 1, ConvertSendFlags(Flags),\r
-                                                 0, NULL, 0);\r
+       pResult->BytesTransferred = 0;\r
+       hr = m_pWvQp->Write((UINT64) pResult, NULL, 0, ConvertSendFlags(Flags),\r
+                                               0, 0, 0);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDEndpoint::\r
@@ -259,12 +274,14 @@ Read(ND_RESULT* pResult, const ND_SGE* pSgl, SIZE_T nSge,
 {\r
        WV_SGE sgl[ND_MAX_SGE];\r
        DWORD opts;\r
+       HRESULT hr;\r
 \r
-       ConvertSgl(pSgl, nSge, sgl);\r
+       pResult->BytesTransferred = ConvertSgl(pSgl, nSge, sgl);\r
        opts = ConvertSendFlags(Flags) | (pSgl[0].hMr ? 0 : WV_SEND_INLINE);\r
-       return m_pWvQp->Read((UINT64) pResult, sgl, nSge, opts,\r
-                                                pRemoteMwDescriptor->Base + htonll(Offset),\r
-                                                pRemoteMwDescriptor->Token);\r
+       hr = m_pWvQp->Read((UINT64) pResult, sgl, nSge, opts,\r
+                                          pRemoteMwDescriptor->Base + htonll(Offset),\r
+                                          pRemoteMwDescriptor->Token);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDEndpoint::\r
@@ -273,10 +290,12 @@ Write(ND_RESULT* pResult, const ND_SGE* pSgl, SIZE_T nSge,
 {\r
        WV_SGE sgl[ND_MAX_SGE];\r
        DWORD opts;\r
+       HRESULT hr;\r
 \r
-       ConvertSgl(pSgl, nSge, sgl);\r
-       opts = ConvertSendFlags(Flags) | (pSgl[0].hMr ? 0 : WV_SEND_INLINE);\r
-       return m_pWvQp->Write((UINT64) pResult, sgl, nSge, opts, 0,\r
-                                                 pRemoteMwDescriptor->Base + htonll(Offset),\r
-                                                 pRemoteMwDescriptor->Token);\r
+       pResult->BytesTransferred = ConvertSgl(pSgl, nSge, sgl);\r
+       opts = ConvertSendFlags(Flags) | (pSgl && pSgl[0].hMr ? 0 : WV_SEND_INLINE);\r
+       hr = m_pWvQp->Write((UINT64) pResult, sgl, nSge, opts, 0,\r
+                                               pRemoteMwDescriptor->Base + htonll(Offset),\r
+                                               pRemoteMwDescriptor->Token);\r
+       return NDConvertWVStatus(hr);\r
 }\r
index 8e60d00..a49c43e 100644 (file)
@@ -122,7 +122,7 @@ protected:
                                          SIZE_T nInboundSge, SIZE_T nOutboundSge,\r
                                          SIZE_T InboundReadLimit, SIZE_T OutboundReadLimit,\r
                                          SIZE_T* pMaxInlineData);\r
-       STDMETHODIMP_(void)     ConvertSgl(const ND_SGE* pSgl, SIZE_T nSge, WV_SGE *pWvSgl);\r
+       STDMETHODIMP_(SIZE_T) ConvertSgl(const ND_SGE* pSgl, SIZE_T nSge, WV_SGE *pWvSgl);\r
        STDMETHODIMP_(DWORD) ConvertSendFlags(DWORD Flags);\r
        STDMETHODIMP_(DWORD) ConvertAccessFlags(DWORD Flags);\r
 };\r
index 920a72b..f02ae6f 100644 (file)
  * 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
index ab50589..df43d0b 100644 (file)
@@ -46,13 +46,14 @@ Init(SIZE_T Backlog, INT Protocol, USHORT *pPort)
        WV_SOCKADDR addr;\r
        HRESULT hr;\r
 \r
-       if (Protocol != 6) {\r
+       /* All connection-oriented protocols map to IPPROTO_TCP */\r
+       if (Protocol == IPPROTO_UDP) {\r
                return ND_NOT_SUPPORTED;\r
        }\r
 \r
        hr = m_pAdapter->m_pWvProvider->CreateConnectEndpoint(&m_pWvConnEp);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
        if (m_pAdapter->m_Address.ss_family == AF_INET) {\r
@@ -85,7 +86,7 @@ Init(SIZE_T Backlog, INT Protocol, USHORT *pPort)
        return ND_SUCCESS;\r
 err:\r
        m_pWvConnEp->Release();\r
-       return hr;\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 CNDListen::~CNDListen()\r
@@ -124,22 +125,30 @@ Release(void)
 STDMETHODIMP CNDListen::\r
 CancelOverlappedRequests(void)\r
 {\r
-       return m_pWvConnEp->CancelOverlappedRequests();\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->CancelOverlappedRequests();\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDListen::\r
 GetOverlappedResult(OVERLAPPED *pOverlapped,\r
                                        SIZE_T *pNumberOfBytesTransferred, BOOL bWait)\r
 {\r
-       return m_pWvConnEp->GetOverlappedResult(pOverlapped,\r
-                                                                                       (DWORD *) pNumberOfBytesTransferred,\r
-                                                                                       bWait);\r
+       HRESULT hr;\r
+\r
+       hr = m_pWvConnEp->GetOverlappedResult(pOverlapped,\r
+                                                                                 (DWORD *) pNumberOfBytesTransferred,\r
+                                                                                 bWait);\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDListen::\r
 GetConnectionRequest(INDConnector* pConnector, OVERLAPPED* pOverlapped)\r
 {\r
        CNDConnector *conn = (CNDConnector *) pConnector;\r
+       HRESULT hr;\r
 \r
-       return m_pWvConnEp->GetRequest(conn->m_pWvConnEp, pOverlapped);\r
+       hr = m_pWvConnEp->GetRequest(conn->m_pWvConnEp, pOverlapped);\r
+       return NDConvertWVStatus(hr);\r
 }\r
index 6ffe16a..a27764d 100644 (file)
@@ -73,9 +73,9 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv)
        return S_OK;\r
 }\r
 \r
-int /*WSPAPI*/ WSPStartup(WORD wVersionRequested, LPWSPDATA lpWSPData,\r
-                                         LPWSAPROTOCOL_INFOW lpProtocolInfo,\r
-                                         WSPUPCALLTABLE UpcallTable, LPWSPPROC_TABLE lpProcTable)\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
index 64a8feb..61f5a7a 100644 (file)
@@ -39,7 +39,12 @@ CNDMemoryWindow::CNDMemoryWindow(CNDAdapter *pAdapter)
 STDMETHODIMP CNDMemoryWindow::\r
 Init(void)\r
 {\r
-       return m_pAdapter->m_pWvPd->AllocateMemoryWindow(&m_pWvMw);\r
+       HRESULT hr;\r
+\r
+       // Current WinOF drivers do not support MWs.\r
+       //hr = m_pAdapter->m_pWvPd->AllocateMemoryWindow(&m_pWvMw);\r
+       hr = ND_SUCCESS;\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 CNDMemoryWindow::~CNDMemoryWindow()\r
index 8f6f138..d0f0a40 100644 (file)
@@ -69,7 +69,7 @@ QueryAddressList(SOCKET_ADDRESS_LIST* pAddressList, SIZE_T* pBufferSize)
 \r
        hr = WvGetObject(IID_IWVProvider, (LPVOID *) &prov);\r
        if (FAILED(hr)) {\r
-               return hr;\r
+               return NDConvertWVStatus(hr);\r
        }\r
 \r
        hr = getaddrinfo("..localmachine", NULL, NULL, &res);\r
@@ -112,7 +112,7 @@ free:
        freeaddrinfo(res);\r
 release:\r
        prov->Release();\r
-       return hr;\r
+       return NDConvertWVStatus(hr);\r
 }\r
 \r
 STDMETHODIMP CNDProvider::\r