From 3d6e37c48aad8696e6f944100458a8285c9ed270 Mon Sep 17 00:00:00 2001 From: shefty Date: Thu, 23 Apr 2009 19:29:41 +0000 Subject: [PATCH] winverbs: fixes to support OFED compatibility libraries and ND 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 git-svn-id: svn://openib.tc.cornell.edu/gen1@2128 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/core/winverbs/kernel/wv_ep.c | 33 ++++++++++++++---------- trunk/core/winverbs/user/wv_provider.cpp | 2 +- trunk/core/winverbs/user/wv_provider.h | 2 +- trunk/core/winverbs/wv_ioctl.h | 4 +-- trunk/inc/user/rdma/winverbs.h | 12 ++++----- 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/trunk/core/winverbs/kernel/wv_ep.c b/trunk/core/winverbs/kernel/wv_ep.c index fa7942d4..ee89253c 100644 --- a/trunk/core/winverbs/kernel/wv_ep.c +++ b/trunk/core/winverbs/kernel/wv_ep.c @@ -501,25 +501,26 @@ void WvEpConnect(WV_PROVIDER *pProvider, WDFREQUEST Request) WdfObjectAcquireLock(ep->Queue); if (ep->State != WvEpRouteResolved) { status = STATUS_NOT_SUPPORTED; - goto release; + goto unlock; } status = IbCmInterface.CM.create_id(WvEpIbCmHandler, ep, &ep->pIbCmId); if (!NT_SUCCESS(status)) { - goto release; + goto unlock; } ep->State = WvEpActiveConnect; - status = WdfRequestForwardToIoQueue(Request, ep->Queue); + status = IbCmInterface.CM.send_req(ep->pIbCmId, &req); if (NT_SUCCESS(status)) { - status = IbCmInterface.CM.send_req(ep->pIbCmId, &req); + status = WdfRequestForwardToIoQueue(Request, ep->Queue); } if (!NT_SUCCESS(status)) { ep->State = WvEpDisconnected; } -release: +unlock: WdfObjectReleaseLock(ep->Queue); +release: WvEpRelease(ep); complete: if (!NT_SUCCESS(status)) { @@ -618,9 +619,7 @@ static NTSTATUS WvEpAcceptActive(WDFREQUEST Request, UINT8 *pVerbsData, size_t V pEndpoint->State = WvEpConnected; status = IbCmInterface.CM.send_rtu(pEndpoint->pIbCmId, pAttr->Param.Data, pAttr->Param.DataLength); - if (NT_SUCCESS(status)) { - WdfRequestComplete(Request, STATUS_SUCCESS); - } else { + if (!NT_SUCCESS(status)) { pEndpoint->State = WvEpDisconnected; } @@ -722,6 +721,10 @@ void WvEpAccept(WV_PROVIDER *pProvider, WDFREQUEST Request) break; case WvEpPassiveConnect: status = WvEpAcceptPassive(Request, out, outlen, ep, pattr); + if (NT_SUCCESS(status)) { + WvEpRelease(ep); + return; + } break; default: status = STATUS_NOT_SUPPORTED; @@ -730,9 +733,7 @@ void WvEpAccept(WV_PROVIDER *pProvider, WDFREQUEST Request) WvEpRelease(ep); complete: - if (!NT_SUCCESS(status)) { - WdfRequestComplete(Request, status); - } + WdfRequestComplete(Request, status); } void WvEpReject(WV_PROVIDER *pProvider, WDFREQUEST Request) @@ -831,6 +832,11 @@ void WvEpDisconnectNotify(WV_PROVIDER *pProvider, WDFREQUEST Request) case WvEpConnected: case WvEpActiveDisconnect: status = WdfRequestForwardToIoQueue(Request, ep->Queue); + if (NT_SUCCESS(status)) { + WdfObjectReleaseLock(ep->Queue); + WvEpRelease(ep); + return; + } break; case WvEpPassiveDisconnect: case WvEpDisconnected: @@ -844,9 +850,7 @@ void WvEpDisconnectNotify(WV_PROVIDER *pProvider, WDFREQUEST Request) WvEpRelease(ep); complete: - if (!NT_SUCCESS(status)) { - WdfRequestComplete(Request, status); - } + WdfRequestComplete(Request, status); } static NTSTATUS WvEpIbListenHandler(iba_cm_id *pId, iba_cm_event *pEvent) @@ -864,6 +868,7 @@ static NTSTATUS WvEpIbListenHandler(iba_cm_id *pId, iba_cm_event *pEvent) goto release; } + ASSERT(!IsListEmpty(&listen->Entry)); ep = CONTAINING_RECORD(RemoveHeadList(&listen->Entry), WV_ENDPOINT, Entry); ep->pIbCmId = pId; pId->callback = WvEpIbCmHandler; diff --git a/trunk/core/winverbs/user/wv_provider.cpp b/trunk/core/winverbs/user/wv_provider.cpp index c5c5cd4f..65b0c878 100644 --- a/trunk/core/winverbs/user/wv_provider.cpp +++ b/trunk/core/winverbs/user/wv_provider.cpp @@ -134,7 +134,7 @@ out: } STDMETHODIMP CWVProvider:: -TranslateAddress(SOCKADDR* pAddress, WV_DEVICE_ADDRESS* pDeviceAddress) +TranslateAddress(const SOCKADDR* pAddress, WV_DEVICE_ADDRESS* pDeviceAddress) { HANDLE hIbat; IOCTL_IBAT_IP_TO_PORT_IN addr; diff --git a/trunk/core/winverbs/user/wv_provider.h b/trunk/core/winverbs/user/wv_provider.h index 581f83cd..5daa4c77 100644 --- a/trunk/core/winverbs/user/wv_provider.h +++ b/trunk/core/winverbs/user/wv_provider.h @@ -49,7 +49,7 @@ public: STDMETHODIMP_(HANDLE) GetFileHandle(); STDMETHODIMP QueryDeviceList(NET64* pGuidList, SIZE_T* pBufferSize); STDMETHODIMP QueryDevice(NET64 Guid, WV_DEVICE_ATTRIBUTES* pAttributes); - STDMETHODIMP TranslateAddress(SOCKADDR* pAddress, + STDMETHODIMP TranslateAddress(const SOCKADDR* pAddress, WV_DEVICE_ADDRESS* pDeviceAddress); STDMETHODIMP OpenDevice(NET64 Guid, IWVDevice** ppDevice); diff --git a/trunk/core/winverbs/wv_ioctl.h b/trunk/core/winverbs/wv_ioctl.h index 088cadeb..0470bc24 100644 --- a/trunk/core/winverbs/wv_ioctl.h +++ b/trunk/core/winverbs/wv_ioctl.h @@ -502,8 +502,8 @@ typedef struct _WV_IO_AH_CREATE } WV_IO_AH_CREATE; #define WV_CQ_ERROR 0 -#define WV_CQ_SOLICITED 1 -#define WV_CQ_NEXT_COMPLETION 2 +#define WV_CQ_NEXT_COMPLETION 1 +#define WV_CQ_SOLICITED 2 typedef struct _WV_IO_SRQ_ATTRIBUTES { diff --git a/trunk/inc/user/rdma/winverbs.h b/trunk/inc/user/rdma/winverbs.h index d2722244..9c0732ec 100644 --- a/trunk/inc/user/rdma/winverbs.h +++ b/trunk/inc/user/rdma/winverbs.h @@ -176,8 +176,8 @@ typedef struct _WV_DEVICE_ADDRESS typedef enum _WV_CQ_NOTIFY_TYPE { WvCqError, - WvCqSolicited, - WvCqNextCompletion + WvCqNextCompletion, + WvCqSolicited } WV_CQ_NOTIFY_TYPE; @@ -291,14 +291,14 @@ typedef struct _WV_SEND_REQUEST { struct { - NET64 RemoteAddress; + UINT64 RemoteAddress; NET32 Rkey; } Rdma; struct { - NET64 RemoteAddress; + UINT64 RemoteAddress; NET32 Rkey; NET64 Compare; NET64 Exchange; @@ -307,7 +307,7 @@ typedef struct _WV_SEND_REQUEST struct { - NET64 RemoteAddress; + UINT64 RemoteAddress; NET32 Rkey; NET64 Add; UINT64 Reserved; @@ -1487,7 +1487,7 @@ DECLARE_INTERFACE_(IWVProvider, IUnknown) STDMETHOD(TranslateAddress)( THIS_ - __in SOCKADDR* pAddress, + __in const SOCKADDR* pAddress, __out WV_DEVICE_ADDRESS* pDeviceAddress ) PURE; -- 2.46.0