winverbs: fixes to support OFED compatibility libraries and ND
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 23 Apr 2009 19:29:41 +0000 (19:29 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 23 Apr 2009 19:29:41 +0000 (19:29 +0000)
Winverbs fixes based on testing the DAPL openib_scm provider, which uses the
libibverbs compatibility library.

Simplify endpoint connect locking and code structure so it's clear when the
user's request is completed.

Add const to TranslateAddress to avoid a compiler warning when building the
ND provider.

Renumber CQ notification types to align with underlying code.

Take the RemoteAddress in a send work request in host order, to align with
the UVP.  (This will be revisited, but is required for RDMA over winverbs to
work for now.)

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

core/winverbs/kernel/wv_ep.c
core/winverbs/user/wv_provider.cpp
core/winverbs/user/wv_provider.h
core/winverbs/wv_ioctl.h
inc/user/rdma/winverbs.h

index fa7942d..ee89253 100644 (file)
@@ -501,25 +501,26 @@ void WvEpConnect(WV_PROVIDER *pProvider, WDFREQUEST Request)
        WdfObjectAcquireLock(ep->Queue);\r
        if (ep->State != WvEpRouteResolved) {\r
                status = STATUS_NOT_SUPPORTED;\r
-               goto release;\r
+               goto unlock;\r
        }\r
 \r
        status = IbCmInterface.CM.create_id(WvEpIbCmHandler, ep, &ep->pIbCmId);\r
        if (!NT_SUCCESS(status)) {\r
-               goto release;\r
+               goto unlock;\r
        }\r
 \r
        ep->State = WvEpActiveConnect;\r
-       status = WdfRequestForwardToIoQueue(Request, ep->Queue);\r
+       status = IbCmInterface.CM.send_req(ep->pIbCmId, &req);\r
        if (NT_SUCCESS(status)) {\r
-               status = IbCmInterface.CM.send_req(ep->pIbCmId, &req);\r
+               status = WdfRequestForwardToIoQueue(Request, ep->Queue);\r
        }\r
 \r
        if (!NT_SUCCESS(status)) {\r
                ep->State = WvEpDisconnected;\r
        }\r
-release:\r
+unlock:\r
        WdfObjectReleaseLock(ep->Queue);\r
+release:\r
        WvEpRelease(ep);\r
 complete:\r
        if (!NT_SUCCESS(status)) {\r
@@ -618,9 +619,7 @@ static NTSTATUS WvEpAcceptActive(WDFREQUEST Request, UINT8 *pVerbsData, size_t V
        pEndpoint->State = WvEpConnected;\r
        status = IbCmInterface.CM.send_rtu(pEndpoint->pIbCmId, pAttr->Param.Data,\r
                                                                           pAttr->Param.DataLength);\r
-       if (NT_SUCCESS(status)) {\r
-               WdfRequestComplete(Request, STATUS_SUCCESS);\r
-       } else {\r
+       if (!NT_SUCCESS(status)) {\r
                pEndpoint->State = WvEpDisconnected;\r
        }\r
 \r
@@ -722,6 +721,10 @@ void WvEpAccept(WV_PROVIDER *pProvider, WDFREQUEST Request)
                break;\r
        case WvEpPassiveConnect:\r
                status = WvEpAcceptPassive(Request, out, outlen, ep, pattr);\r
+               if (NT_SUCCESS(status)) {\r
+                       WvEpRelease(ep);\r
+                       return;\r
+               }\r
                break;\r
        default:\r
                status = STATUS_NOT_SUPPORTED;\r
@@ -730,9 +733,7 @@ void WvEpAccept(WV_PROVIDER *pProvider, WDFREQUEST Request)
 \r
        WvEpRelease(ep);\r
 complete:\r
-       if (!NT_SUCCESS(status)) {\r
-               WdfRequestComplete(Request, status);\r
-       }\r
+       WdfRequestComplete(Request, status);\r
 }\r
 \r
 void WvEpReject(WV_PROVIDER *pProvider, WDFREQUEST Request)\r
@@ -831,6 +832,11 @@ void WvEpDisconnectNotify(WV_PROVIDER *pProvider, WDFREQUEST Request)
        case WvEpConnected:\r
        case WvEpActiveDisconnect:\r
                status = WdfRequestForwardToIoQueue(Request, ep->Queue);\r
+               if (NT_SUCCESS(status)) {\r
+                       WdfObjectReleaseLock(ep->Queue);\r
+                       WvEpRelease(ep);\r
+                       return;\r
+               }\r
                break;\r
        case WvEpPassiveDisconnect:\r
        case WvEpDisconnected:\r
@@ -844,9 +850,7 @@ void WvEpDisconnectNotify(WV_PROVIDER *pProvider, WDFREQUEST Request)
 \r
        WvEpRelease(ep);\r
 complete:\r
-       if (!NT_SUCCESS(status)) {\r
-               WdfRequestComplete(Request, status);\r
-       }\r
+       WdfRequestComplete(Request, status);\r
 }\r
 \r
 static NTSTATUS WvEpIbListenHandler(iba_cm_id *pId, iba_cm_event *pEvent)\r
@@ -864,6 +868,7 @@ static NTSTATUS WvEpIbListenHandler(iba_cm_id *pId, iba_cm_event *pEvent)
                goto release;\r
        }\r
 \r
+       ASSERT(!IsListEmpty(&listen->Entry));\r
        ep = CONTAINING_RECORD(RemoveHeadList(&listen->Entry), WV_ENDPOINT, Entry);\r
        ep->pIbCmId = pId;\r
        pId->callback = WvEpIbCmHandler;\r
index c5c5cd4..65b0c87 100644 (file)
@@ -134,7 +134,7 @@ out:
 }\r
 \r
 STDMETHODIMP CWVProvider::\r
-TranslateAddress(SOCKADDR* pAddress, WV_DEVICE_ADDRESS* pDeviceAddress)\r
+TranslateAddress(const SOCKADDR* pAddress, WV_DEVICE_ADDRESS* pDeviceAddress)\r
 {\r
        HANDLE hIbat;\r
        IOCTL_IBAT_IP_TO_PORT_IN addr;\r
index 581f83c..5daa4c7 100644 (file)
@@ -49,7 +49,7 @@ public:
        STDMETHODIMP_(HANDLE) GetFileHandle();\r
        STDMETHODIMP QueryDeviceList(NET64* pGuidList, SIZE_T* pBufferSize);\r
        STDMETHODIMP QueryDevice(NET64 Guid, WV_DEVICE_ATTRIBUTES* pAttributes);\r
-       STDMETHODIMP TranslateAddress(SOCKADDR* pAddress,\r
+       STDMETHODIMP TranslateAddress(const SOCKADDR* pAddress,\r
                                                                  WV_DEVICE_ADDRESS* pDeviceAddress);\r
 \r
        STDMETHODIMP OpenDevice(NET64 Guid, IWVDevice** ppDevice);\r
index 088cade..0470bc2 100644 (file)
@@ -502,8 +502,8 @@ typedef struct _WV_IO_AH_CREATE
 }      WV_IO_AH_CREATE;\r
 \r
 #define WV_CQ_ERROR                            0\r
-#define        WV_CQ_SOLICITED                 1\r
-#define        WV_CQ_NEXT_COMPLETION   2\r
+#define        WV_CQ_NEXT_COMPLETION   1\r
+#define        WV_CQ_SOLICITED                 2\r
 \r
 typedef struct _WV_IO_SRQ_ATTRIBUTES\r
 {\r
index d272224..9c0732e 100644 (file)
@@ -176,8 +176,8 @@ typedef struct _WV_DEVICE_ADDRESS
 typedef enum _WV_CQ_NOTIFY_TYPE\r
 {\r
        WvCqError,\r
-       WvCqSolicited,\r
-       WvCqNextCompletion\r
+       WvCqNextCompletion,\r
+       WvCqSolicited\r
 \r
 }      WV_CQ_NOTIFY_TYPE;\r
 \r
@@ -291,14 +291,14 @@ typedef struct _WV_SEND_REQUEST
        {\r
                struct\r
                {\r
-                       NET64                   RemoteAddress;\r
+                       UINT64                  RemoteAddress;\r
                        NET32                   Rkey;\r
 \r
                }       Rdma;\r
 \r
                struct\r
                {\r
-                       NET64                   RemoteAddress;\r
+                       UINT64                  RemoteAddress;\r
                        NET32                   Rkey;\r
                        NET64                   Compare;\r
                        NET64                   Exchange;\r
@@ -307,7 +307,7 @@ typedef struct _WV_SEND_REQUEST
 \r
                struct\r
                {\r
-                       NET64                   RemoteAddress;\r
+                       UINT64                  RemoteAddress;\r
                        NET32                   Rkey;\r
                        NET64                   Add;\r
                        UINT64                  Reserved;\r
@@ -1487,7 +1487,7 @@ DECLARE_INTERFACE_(IWVProvider, IUnknown)
 \r
        STDMETHOD(TranslateAddress)(\r
                THIS_\r
-               __in SOCKADDR* pAddress,\r
+               __in const SOCKADDR* pAddress,\r
                __out WV_DEVICE_ADDRESS* pDeviceAddress\r
                ) PURE;\r
 \r