Add support for connection establishment over IB through the winverbs kernel
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sat, 24 Jan 2009 19:30:54 +0000 (19:30 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sat, 24 Jan 2009 19:30:54 +0000 (19:30 +0000)
driver.  This depends on exporting the IB CM interface.  Connections follow
the RDMA CM model.

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

14 files changed:
core/winverbs/dirs
core/winverbs/kernel/SOURCES
core/winverbs/kernel/winverbs.inx
core/winverbs/kernel/wv_cq.c
core/winverbs/kernel/wv_driver.c
core/winverbs/kernel/wv_driver.h
core/winverbs/kernel/wv_ep.h
core/winverbs/kernel/wv_provider.c
core/winverbs/kernel/wv_provider.h
core/winverbs/kernel/wv_qp.c
core/winverbs/kernel/wv_qp.h
core/winverbs/kernel/wv_srq.c
core/winverbs/wv_ioctl.h
inc/kernel/iba/ib_rdma_cm.h [new file with mode: 0644]

index 29cf99d..a5a581d 100644 (file)
@@ -1,2 +1,3 @@
-DIRS = \\r
-       kernel\r
+DIRS=\\r
+       kernel \\r
+       user\r
index 721f76f..3322a7d 100644 (file)
@@ -19,7 +19,8 @@ SOURCES = \
        wv_cq.c                 \\r
        wv_pd.c                 \\r
        wv_srq.c                \\r
-       wv_qp.c\r
+       wv_qp.c                 \\r
+       wv_ep.c\r
 \r
 INCLUDES = ..;..\..\..\inc;..\..\..\inc\kernel;..\..\..\inc\user;..\..\..\etc\kernel;\r
 \r
index c9c0930..225df71 100644 (file)
@@ -29,7 +29,7 @@
 \r
 [Version]\r
 Signature = "$WINDOWS NT$"\r
-Class=InfiniBandController\r
+Class = InfiniBandController\r
 ClassGUID = {58517E00-D3CF-40c9-A679-CEE5752F4491}\r
 Provider = %OFA%\r
 DriverVer = 05/20/2008\r
index 3c15333..6adcd15 100644 (file)
@@ -67,33 +67,18 @@ void WvCqRelease(WV_COMPLETION_QUEUE *pCq)
        WvCqPut(pCq);\r
 }\r
 \r
-static void WvCqCompleteRequests(WDFQUEUE Queue, NTSTATUS ReqStatus)\r
-{\r
-       WDFREQUEST      request;\r
-       NTSTATUS        status;\r
-\r
-       WdfObjectAcquireLock(Queue);\r
-       status = WdfIoQueueRetrieveNextRequest(Queue, &request);\r
-\r
-       while (NT_SUCCESS(status)) {\r
-               WdfRequestComplete(request, ReqStatus);\r
-               status = WdfIoQueueRetrieveNextRequest(Queue, &request);\r
-       }\r
-       WdfObjectReleaseLock(Queue);\r
-}\r
-\r
 static void WvCqEventHandler(ib_event_rec_t *pEvent)\r
 {\r
        WV_COMPLETION_QUEUE     *cq = pEvent->context;\r
-       WvCqCompleteRequests(cq->Queue, STATUS_UNEXPECTED_IO_ERROR);\r
-       WvCqCompleteRequests(cq->ErrorQueue, STATUS_UNEXPECTED_IO_ERROR);\r
+       WvFlushQueue(cq->Queue, STATUS_UNEXPECTED_IO_ERROR);\r
+       WvFlushQueue(cq->ErrorQueue, STATUS_UNEXPECTED_IO_ERROR);\r
 }\r
 \r
 static void WvCqHandler(void *Context)\r
 {\r
        WV_COMPLETION_QUEUE     *cq = Context;\r
 \r
-       WvCqCompleteRequests(cq->Queue, STATUS_SUCCESS);\r
+       WvFlushQueue(cq->Queue, STATUS_SUCCESS);\r
 }\r
 \r
 static NTSTATUS WvCqAlloc(WV_DEVICE *pDevice, UINT32 *pSize,\r
@@ -341,8 +326,8 @@ void WvCqCancel(WV_PROVIDER *pProvider, WDFREQUEST Request)
                goto out;\r
        }\r
 \r
-       WvCqCompleteRequests(cq->Queue, STATUS_CANCELLED);\r
-       WvCqCompleteRequests(cq->ErrorQueue, STATUS_CANCELLED);\r
+       WvFlushQueue(cq->Queue, STATUS_CANCELLED);\r
+       WvFlushQueue(cq->ErrorQueue, STATUS_CANCELLED);\r
        WvCqRelease(cq);\r
 \r
 out:\r
index 96a8121..38b8104 100644 (file)
@@ -53,6 +53,9 @@ WDFDEVICE                             ControlDevice;
 static LIST_ENTRY              DevList;\r
 static LIST_ENTRY              ProvList;\r
 static KGUARDED_MUTEX  Lock;\r
+ULONG                                  RandomSeed;\r
+\r
+INFINIBAND_INTERFACE_CM        IbCmInterface;\r
 \r
 static EVT_WDF_DRIVER_DEVICE_ADD                       WvRdmaDeviceAdd;\r
 static EVT_WDF_OBJECT_CONTEXT_CLEANUP          WvRdmaDeviceCleanup;\r
@@ -87,6 +90,44 @@ void WvRdmaDevicePut(WV_RDMA_DEVICE *pDevice)
        }\r
 }\r
 \r
+\r
+void WvCompleteRequests(WDFQUEUE Queue, NTSTATUS ReqStatus)\r
+{\r
+       WDFREQUEST      request;\r
+       NTSTATUS        status;\r
+\r
+       status = WdfIoQueueRetrieveNextRequest(Queue, &request);\r
+\r
+       while (NT_SUCCESS(status)) {\r
+               WdfRequestComplete(request, ReqStatus);\r
+               status = WdfIoQueueRetrieveNextRequest(Queue, &request);\r
+       }\r
+}\r
+\r
+void WvFlushQueue(WDFQUEUE Queue, NTSTATUS ReqStatus)\r
+{\r
+       WdfObjectAcquireLock(Queue);\r
+       WvCompleteRequests(Queue, ReqStatus);\r
+       WdfObjectReleaseLock(Queue);\r
+}\r
+\r
+void WvCompleteRequestsWithInformation(WDFQUEUE Queue, NTSTATUS ReqStatus)\r
+{\r
+       WDFREQUEST      request;\r
+       NTSTATUS        status;\r
+       UINT8           *out;\r
+       size_t          outlen;\r
+\r
+       status = WdfIoQueueRetrieveNextRequest(Queue, &request);\r
+\r
+       while (NT_SUCCESS(status)) {\r
+               outlen = 0;\r
+               WdfRequestRetrieveOutputBuffer(request, 0, &out, &outlen);\r
+               WdfRequestCompleteWithInformation(request, ReqStatus, outlen);\r
+               status = WdfIoQueueRetrieveNextRequest(Queue, &request);\r
+       }\r
+}\r
+\r
 static void WvGuidQuery(WDFREQUEST Request)\r
 {\r
        WV_IO_GUID_LIST *list;\r
@@ -280,77 +321,53 @@ static VOID WvIoDeviceControl(WDFQUEUE Queue, WDFREQUEST Request,
        case WV_IOCTL_QP_CANCEL:\r
                WvQpCancel(prov, Request);\r
                break;\r
-       case WV_IOCTL_ADDRESS_QUERY:\r
-               //WvAddressQuery(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
-               break;\r
        case WV_IOCTL_EP_CREATE:\r
-               //WvEpCreate(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpCreate(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_DESTROY:\r
-               //WvEpDestroy(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpDestroy(prov, Request);\r
+               break;\r
+       case WV_IOCTL_EP_MODIFY:\r
+               WvEpModify(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_BIND:\r
-               //WvEpBind(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpBind(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_REJECT:\r
-               //WvEpReject(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpReject(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_CONNECT:\r
-               //WvEpConnect(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpConnect(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_ACCEPT:\r
-               //WvEpAccept(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpAccept(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_DISCONNECT:\r
-               //WvEpDisconnect(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpDisconnect(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_DISCONNECT_NOTIFY:\r
-               //WvEpDisconnectNotify(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpDisconnectNotify(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_QUERY:\r
-               //WvEpQuery(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpQuery(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_LOOKUP:\r
-               //WvEpLookup(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpLookup(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_MULTICAST_JOIN:\r
-               //WvEpMulticastJoin(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpMulticastJoin(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_MULTICAST_LEAVE:\r
-               //WvEpMulticastLeave(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpMulticastLeave(prov, Request);\r
                break;\r
        case WV_IOCTL_EP_CANCEL:\r
-               //WvEpCancel(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+               WvEpCancel(prov, Request);\r
                break;\r
-       case WV_IOCTL_LISTEN:\r
-               //WvListen(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+       case WV_IOCTL_EP_LISTEN:\r
+               WvEpListen(prov, Request);\r
                break;\r
-       case WV_IOCTL_LISTEN_DESTROY:\r
-               //WvListenDestroy(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
-               break;\r
-       case WV_IOCTL_LISTEN_GET_REQUEST:\r
-               //WvListenGetRequest(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
-               break;\r
-       case WV_IOCTL_LISTEN_CANCEL:\r
-               //WvListenCancel(prov, Request);\r
-               WdfRequestComplete(Request, STATUS_NOT_IMPLEMENTED);\r
+       case WV_IOCTL_EP_GET_REQUEST:\r
+               WvEpGetRequest(prov, Request);\r
                break;\r
        default:\r
                WdfRequestComplete(Request, STATUS_PROCEDURE_NOT_FOUND);\r
@@ -362,9 +379,8 @@ static VOID WvFileCreate(WDFDEVICE Device, WDFREQUEST Request,
                                                 WDFFILEOBJECT FileObject)\r
 {\r
        WV_PROVIDER     *prov = WvProviderGetContext(FileObject);\r
-       UNREFERENCED_PARAMETER(Device);\r
 \r
-       WvProviderInit(prov);\r
+       WvProviderInit(Device, prov);\r
        KeAcquireGuardedMutex(&Lock);\r
        InsertHeadList(&ProvList, &prov->Entry);\r
        KeReleaseGuardedMutex(&Lock);\r
@@ -470,9 +486,13 @@ static NTSTATUS WvPowerD0Entry(WDFDEVICE Device, WDF_POWER_DEVICE_STATE Previous
 \r
        if (create) {\r
                WvCreateControlDevice(WdfGetDriver());\r
+               status = WdfFdoQueryForInterface(Device, &GUID_INFINIBAND_INTERFACE_CM,\r
+                                                                                (PINTERFACE) &IbCmInterface,\r
+                                                                                sizeof(IbCmInterface),\r
+                                                                                IbaCmVersion(1, 0), NULL);\r
        }\r
 \r
-       return STATUS_SUCCESS;\r
+       return status;\r
 }\r
 \r
 static NTSTATUS WvRdmaDeviceAdd(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit)\r
@@ -534,8 +554,13 @@ static VOID WvRdmaDeviceCleanup(WDFDEVICE Device)
                KeWaitForSingleObject(&pdev->Event, Executive, KernelMode, FALSE, NULL);\r
        }\r
 \r
-       pdev->Interface.InterfaceHeader.\r
-               InterfaceDereference(pdev->Interface.InterfaceHeader.Context);\r
+       if (IbCmInterface.CM.create_id != NULL) {\r
+               IbCmInterface.InterfaceHeader.InterfaceDereference(IbCmInterface.\r
+                                                                                                                  InterfaceHeader.Context);\r
+       }\r
+\r
+       pdev->Interface.InterfaceHeader.InterfaceDereference(pdev->Interface.\r
+                                                                                                                InterfaceHeader.Context);\r
 \r
        if (destroy) {\r
                WdfObjectDelete(ctrldev);\r
@@ -551,6 +576,7 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
        InitializeListHead(&DevList);\r
        InitializeListHead(&ProvList);\r
        KeInitializeGuardedMutex(&Lock);\r
+       RandomSeed = (ULONG) (ULONG_PTR) DriverObject;\r
 \r
        WDF_DRIVER_CONFIG_INIT(&config, WvRdmaDeviceAdd);\r
        status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES,\r
index 22d9ae6..a9e884e 100644 (file)
 \r
 #include <iba\ib_types.h>\r
 #include <iba\ib_ci.h>\r
+#include <iba\ib_cm_ifc.h>\r
 #include <rdma\verbs.h>\r
 #include "wv_ioctl.h"\r
 \r
 #if WINVER <= _WIN32_WINNT_WINXP\r
-#define KGUARDED_MUTEX FAST_MUTEX\r
+#define KGUARDED_MUTEX                  FAST_MUTEX\r
 #define KeInitializeGuardedMutex ExInitializeFastMutex\r
-#define KeAcquireGuardedMutex ExAcquireFastMutex\r
-#define KeReleaseGuardedMutex ExReleaseFastMutex\r
+#define KeAcquireGuardedMutex   ExAcquireFastMutex\r
+#define KeReleaseGuardedMutex   ExReleaseFastMutex\r
 #endif\r
 \r
-extern WDFDEVICE                       ControlDevice;\r
+extern WDFDEVICE                               ControlDevice;\r
+extern INFINIBAND_INTERFACE_CM IbCmInterface;\r
+extern ULONG                                   RandomSeed;\r
 \r
 typedef struct _WV_RDMA_DEVICE\r
 {\r
@@ -74,4 +77,8 @@ static inline void WvInitVerbsData(ci_umv_buf_t *pVerbsData, UINT32 Command,
        pVerbsData->status = 0;\r
 }\r
 \r
+void WvCompleteRequests(WDFQUEUE Queue, NTSTATUS ReqStatus);\r
+void WvFlushQueue(WDFQUEUE Queue, NTSTATUS ReqStatus);\r
+void WvCompleteRequestsWithInformation(WDFQUEUE Queue, NTSTATUS ReqStatus);\r
+\r
 #endif // _WV_DRIVER_H_\r
index faaad5e..703a964 100644 (file)
 #ifndef _WV_EP_H_\r
 #define _WV_EP_H_\r
 \r
+#include <ntddk.h>\r
 #include <wdm.h>\r
+\r
 #include <iba\ib_types.h>\r
 #include <iba\ib_ci.h>\r
 #include "wv_provider.h"\r
+#include "wv_ioctl.h"\r
 \r
-typedef struct _WV_CONNECT_ENDPOINT\r
+typedef enum _WV_ENDPOINT_STATE\r
 {\r
-       WV_PROVIDER             *pProvider;\r
-       UINT64                  Id;\r
-       LONG                    nRef;\r
+       WvEpIdle,\r
+       WvEpAddressBound,\r
+       WvEpListening,\r
+       WvEpQueued,\r
+       WvEpRouteResolved,\r
+       WvEpPassiveConnect,\r
+       WvEpActiveConnect,\r
+       WvEpConnected,\r
+       WvEpActiveDisconnect,\r
+       WvEpPassiveDisconnect,\r
+       WvEpDisconnected\r
 \r
-}      WV_CONNECT_ENDPOINT;\r
+}      WV_ENDPOINT_STATE;\r
 \r
-typedef struct _WV_DATAGRAM_ENDPOINT\r
+typedef struct _WV_ENDPOINT\r
 {\r
-       WV_PROVIDER             *pProvider;\r
-       UINT64                  Id;\r
-       LONG                    m_nRef;\r
+       WV_PROVIDER                     *pProvider;\r
+       LIST_ENTRY                      Entry;\r
+       WV_ENDPOINT_STATE       State;\r
+\r
+       iba_cm_id                       *pIbCmId;\r
+       WV_IO_EP_ATTRIBUTES     Attributes;\r
+       ib_path_rec_t           Route;\r
+\r
+       UINT16                          EpType;\r
+       KEVENT                          Event;\r
+       LONG                            Ref;\r
+       WDFQUEUE                        Queue;\r
+\r
+}      WV_ENDPOINT;\r
+\r
+void WvEpCreate(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpDestroy(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpFree(WV_ENDPOINT *pEndpoint);\r
+void WvEpCancelListen(WV_ENDPOINT *pEndpoint);\r
+\r
+void WvEpQuery(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpModify(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpBind(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpCancel(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+\r
+void WvEpConnect(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpAccept(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpReject(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpDisconnect(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpDisconnectNotify(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+\r
+void WvEpListen(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpGetRequest(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
 \r
-}      WV_DATAGRAM_ENDPOINT;\r
+void WvEpLookup(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpMulticastJoin(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvEpMulticastLeave(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
 \r
 #endif // _WV_EP_H_\r
index 0411641..dbf2286 100644 (file)
@@ -38,6 +38,7 @@
 #include "wv_srq.h"\r
 #include "wv_cq.h"\r
 #include "wv_qp.h"\r
+#include "wv_ep.h"\r
 \r
 void WvProviderGet(WV_PROVIDER *pProvider)\r
 {\r
@@ -51,7 +52,7 @@ void WvProviderPut(WV_PROVIDER *pProvider)
        }\r
 }\r
 \r
-void WvProviderInit(WV_PROVIDER *pProvider)\r
+void WvProviderInit(WDFDEVICE Device, WV_PROVIDER *pProvider)\r
 {\r
        IndexListInit(&pProvider->DevIndex);\r
        IndexListInit(&pProvider->CqIndex);\r
@@ -60,6 +61,7 @@ void WvProviderInit(WV_PROVIDER *pProvider)
        IndexListInit(&pProvider->QpIndex);\r
        IndexListInit(&pProvider->MwIndex);\r
        IndexListInit(&pProvider->AhIndex);\r
+       IndexListInit(&pProvider->EpIndex);\r
 \r
        KeInitializeGuardedMutex(&pProvider->Lock);\r
        pProvider->Ref = 1;\r
@@ -81,7 +83,19 @@ void WvProviderCleanup(WV_PROVIDER *pProvider)
        WV_QUEUE_PAIR                   *qp;\r
        WV_MEMORY_WINDOW                *mw;\r
        WV_ADDRESS_HANDLE               *ah;\r
+       WV_ENDPOINT                             *ep;\r
+       SIZE_T                                  i;\r
 \r
+       IndexListForEach(&pProvider->EpIndex, i) {\r
+               ep = (WV_ENDPOINT *) IndexListAt(&pProvider->EpIndex, i);\r
+               if (ep->State == WvEpListening) {\r
+                       WvEpCancelListen(ep);\r
+               }\r
+       }\r
+       while ((ep = IndexListRemoveHead(&pProvider->EpIndex)) != NULL) {\r
+               RemoveEntryList(&ep->Entry);\r
+               WvEpFree(ep);\r
+       }\r
        while ((ah = IndexListRemoveHead(&pProvider->AhIndex)) != NULL) {\r
                RemoveEntryList(&ah->Entry);\r
                WvAhFree(ah);\r
@@ -114,6 +128,7 @@ void WvProviderCleanup(WV_PROVIDER *pProvider)
                KeWaitForSingleObject(&pProvider->Event, Executive, KernelMode, FALSE, NULL);\r
        }\r
 \r
+       IndexListDestroy(&pProvider->EpIndex);\r
        IndexListDestroy(&pProvider->AhIndex);\r
        IndexListDestroy(&pProvider->MwIndex);\r
        IndexListDestroy(&pProvider->QpIndex);\r
index efcea29..2054551 100644 (file)
@@ -53,6 +53,7 @@ typedef struct _WV_PROVIDER
        INDEX_LIST              QpIndex;\r
        INDEX_LIST              MwIndex;\r
        INDEX_LIST              AhIndex;\r
+       INDEX_LIST              EpIndex;\r
 \r
        KGUARDED_MUTEX  Lock;\r
        LONG                    Ref;\r
@@ -67,7 +68,7 @@ typedef struct _WV_PROVIDER
 \r
 void WvProviderGet(WV_PROVIDER *pProvider);\r
 void WvProviderPut(WV_PROVIDER *pProvider);\r
-void WvProviderInit(WV_PROVIDER *pProvider);\r
+void WvProviderInit(WDFDEVICE Device, WV_PROVIDER *pProvider);\r
 void WvProviderCleanup(WV_PROVIDER *pProvider);\r
 \r
 void WvProviderRemoveHandler(WV_PROVIDER *pProvider, WV_RDMA_DEVICE *pDevice);\r
index 3d1ed9d..5b93992 100644 (file)
@@ -458,6 +458,7 @@ void WvQpCreate(WV_PROVIDER *pProvider, WDFREQUEST Request)
                goto err3;\r
        }\r
 \r
+       qp->Qpn = ib_attr.num;\r
        KeAcquireGuardedMutex(&pProvider->Lock);\r
        outattr->Id.Id = IndexListInsertHead(&pProvider->QpIndex, qp);\r
        if (outattr->Id.Id == 0) {\r
@@ -572,6 +573,7 @@ void WvQpQuery(WV_PROVIDER *pProvider, WDFREQUEST Request)
                goto complete;\r
        }\r
 \r
+       RtlZeroMemory(&attr, sizeof attr);\r
        qp->pVerbs->query_qp(qp->hVerbsQp, &attr, NULL);\r
        WvQpRelease(qp);\r
 \r
index 680a6e4..449de59 100644 (file)
@@ -51,6 +51,7 @@ typedef struct _WV_QUEUE_PAIR
        WV_SHARED_RECEIVE_QUEUE *pSrq;\r
        ci_interface_t                  *pVerbs;\r
        ib_qp_handle_t                  hVerbsQp;\r
+       UINT32                                  Qpn;\r
        LIST_ENTRY                              Entry;\r
        LIST_ENTRY                              McList;\r
 \r
@@ -64,6 +65,9 @@ void WvQpDestroy(WV_PROVIDER *pProvider, WDFREQUEST Request);
 void WvQpFree(WV_QUEUE_PAIR *pQp);\r
 void WvQpRemoveHandler(WV_QUEUE_PAIR *pQp);\r
 \r
+WV_QUEUE_PAIR *WvQpAcquire(WV_PROVIDER *pProvider, UINT64 Id);\r
+void WvQpRelease(WV_QUEUE_PAIR *pQp);\r
+\r
 void WvQpModify(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
 void WvQpQuery(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
 void WvQpAttach(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
index 2be9e56..e2379ee 100644 (file)
@@ -75,32 +75,19 @@ static void WvVerbsConvertSrq(ib_srq_attr_t *pVerbsAttr,
        pVerbsAttr->srq_limit = pAttr->SrqLimit;\r
 }\r
 \r
-static void WvSrqCompleteRequests(WV_SHARED_RECEIVE_QUEUE *pSrq, NTSTATUS ReqStatus)\r
-{\r
-       WDFREQUEST      request;\r
-       NTSTATUS        status;\r
-\r
-       WdfObjectAcquireLock(pSrq->Queue);\r
-       status = WdfIoQueueRetrieveNextRequest(pSrq->Queue, &request);\r
-\r
-       while (NT_SUCCESS(status)) {\r
-               WdfRequestComplete(request, ReqStatus);\r
-               status = WdfIoQueueRetrieveNextRequest(pSrq->Queue, &request);\r
-       }\r
-       WdfObjectReleaseLock(pSrq->Queue);\r
-}\r
-\r
 static void WvSrqEventHandler(ib_event_rec_t *pEvent)\r
 {\r
+       WV_SHARED_RECEIVE_QUEUE *srq = pEvent->context;\r
+\r
        switch (pEvent->type) {\r
        case IB_AE_SRQ_LIMIT_REACHED:\r
-               WvSrqCompleteRequests(pEvent->context, STATUS_ALERTED);\r
+               WvFlushQueue(srq->Queue, STATUS_ALERTED);\r
                break;\r
        case IB_AE_SRQ_QP_LAST_WQE_REACHED:\r
-               WvSrqCompleteRequests(pEvent->context, STATUS_NOTIFY_CLEANUP);\r
+               WvFlushQueue(srq->Queue, STATUS_NOTIFY_CLEANUP);\r
                break;\r
        default:\r
-               WvSrqCompleteRequests(pEvent->context, STATUS_UNEXPECTED_IO_ERROR);\r
+               WvFlushQueue(srq->Queue, STATUS_UNEXPECTED_IO_ERROR);\r
                break;\r
        }\r
 }\r
@@ -383,7 +370,7 @@ void WvSrqCancel(WV_PROVIDER *pProvider, WDFREQUEST Request)
                goto out;\r
        }\r
 \r
-       WvSrqCompleteRequests(srq, STATUS_CANCELLED);\r
+       WvFlushQueue(srq->Queue, STATUS_CANCELLED);\r
        WvSrqRelease(srq);\r
 \r
 out:\r
index 5086e79..088cade 100644 (file)
@@ -81,9 +81,9 @@ enum {
        WV_IO_FUNCTION_QP_ATTACH,\r
        WV_IO_FUNCTION_QP_DETACH,\r
        WV_IO_FUNCTION_QP_CANCEL,\r
-       WV_IO_FUNCTION_ADDRESS_QUERY,\r
        WV_IO_FUNCTION_EP_CREATE,\r
        WV_IO_FUNCTION_EP_DESTROY,\r
+       WV_IO_FUNCTION_EP_MODIFY,\r
        WV_IO_FUNCTION_EP_BIND,\r
        WV_IO_FUNCTION_EP_REJECT,\r
        WV_IO_FUNCTION_EP_CONNECT,\r
@@ -95,10 +95,8 @@ enum {
        WV_IO_FUNCTION_EP_MULTICAST_JOIN,\r
        WV_IO_FUNCTION_EP_MULTICAST_LEAVE,\r
        WV_IO_FUNCTION_EP_CANCEL,\r
-       WV_IO_FUNCTION_LISTEN,\r
-       WV_IO_FUNCTION_LISTEN_DESTROY,\r
-       WV_IO_FUNCTION_LISTEN_GET_REQUEST,\r
-       WV_IO_FUNCTION_LISTEN_CANCEL,\r
+       WV_IO_FUNCTION_EP_LISTEN,\r
+       WV_IO_FUNCTION_EP_GET_REQUEST,\r
        WV_IO_FUNCTION_MAX\r
 };\r
 \r
@@ -230,7 +228,7 @@ enum {
 #define WV_IOCTL_QP_QUERY                              WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_QP_QUERY)\r
 \r
-// WV_IO_QP_ATTRIBUTES / none\r
+// WV_IO_QP_ATTRIBUTES / verbs specific\r
 #define WV_IOCTL_QP_MODIFY                             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_QP_MODIFY)\r
 \r
@@ -246,43 +244,69 @@ enum {
 #define WV_IOCTL_QP_CANCEL                             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_QP_CANCEL)\r
 \r
-// TODO\r
-#define WV_IOCTL_ADDRESS_QUERY                 WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
-                                                                                                WV_IO_FUNCTION_ADDRESS_QUERY)\r
+// UINT64 EpType / UINT64 Id\r
 #define WV_IOCTL_EP_CREATE                             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_CREATE)\r
+\r
+// UINT64 Id / none\r
 #define WV_IOCTL_EP_DESTROY                            WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_DESTROY)\r
+\r
+// WV_IO_ID + UINT8[] / none\r
+#define WV_IOCTL_EP_MODIFY                             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
+                                                                                                WV_IO_FUNCTION_EP_MODIFY)\r
+\r
+// WV_IO_EP_BIND / WV_IO_EP_BIND\r
 #define WV_IOCTL_EP_BIND                               WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_BIND)\r
+\r
+// WV_IO_ID + UINT8[] / none\r
 #define WV_IOCTL_EP_REJECT                             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_REJECT)\r
+\r
+// WV_IO_EP_CONNECT / none\r
 #define WV_IOCTL_EP_CONNECT                            WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_CONNECT)\r
+\r
+// WV_IO_EP_ACCEPT / verbs specific\r
 #define WV_IOCTL_EP_ACCEPT                             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_ACCEPT)\r
+\r
+// UINT64 Id / none\r
 #define WV_IOCTL_EP_DISCONNECT                 WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_DISCONNECT)\r
+\r
+// UINT64 Id / none\r
 #define WV_IOCTL_EP_DISCONNECT_NOTIFY  WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_DISCONNECT_NOTIFY)\r
+\r
+// UINT64 Id / WV_IO_EP_ATTRIBUTES\r
 #define WV_IOCTL_EP_QUERY                              WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_QUERY)\r
+\r
+// TODO\r
 #define WV_IOCTL_EP_LOOKUP                             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_LOOKUP)\r
+\r
+// TODO\r
 #define WV_IOCTL_EP_MULTICAST_JOIN             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_MULTICAST_JOIN)\r
+\r
+// TODO\r
 #define WV_IOCTL_EP_MULTICAST_LEAVE            WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_MULTICAST_LEAVE)\r
+\r
+// UINT64 Id / none\r
 #define WV_IOCTL_EP_CANCEL                             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_EP_CANCEL)\r
-#define WV_IOCTL_LISTEN                                        WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
-                                                                                                WV_IO_FUNCTION_LISTEN)\r
-#define WV_IOCTL_LISTEN_DESTROY                        WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
-                                                                                                WV_IO_FUNCTION_LISTEN_DESTROY)\r
-#define WV_IOCTL_LISTEN_GET_REQUEST            WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
-                                                                                                WV_IO_FUNCTION_LISTEN_GET_REQUEST)\r
-#define WV_IOCTL_LISTEN_CANCEL                 WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
-                                                                                                WV_IO_FUNCTION_LISTEN_CANCEL)\r
+\r
+// WV_IO_EP_LISTEN / none\r
+#define WV_IOCTL_EP_LISTEN                             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
+                                                                                                WV_IO_FUNCTION_EP_LISTEN)\r
+\r
+// WV_IO_EP_GET_REQUEST / none\r
+#define WV_IOCTL_EP_GET_REQUEST                        WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
+                                                                                                WV_IO_FUNCTION_EP_GET_REQUEST)\r
 \r
 #define WV_IOCTL_MIN                                   WV_IO_FUNCTION_BASE + WV_IO_FUNCTION_MIN\r
 #define WV_IOCTL_MAX                                   WV_IO_FUNCTION_BASE + WV_IO_FUNCTION_MAX\r
@@ -592,20 +616,125 @@ typedef struct _WV_IO_QP_MULTICAST
 \r
 }      WV_IO_QP_MULTICAST;\r
 \r
-// TODO:\r
-//WV_IO_ADDRESS_QUERY\r
-//WV_IO_EP_CREATE\r
-//WV_IO_EP_BIND\r
-//WV_IO_EP_REJECT\r
-//WV_IO_EP_CONNECT\r
-//WV_IO_EP_ACCEPT\r
-//WV_IO_EP_DISCONNECT\r
-//WV_IO_EP_DISCONNECT_NOTIFY\r
-//WV_IO_EP_QUERY\r
-//WV_IO_EP_LOOKUP\r
-//WV_IO_EP_MULTICAST_JOIN\r
-//WV_IO_EP_MULTICAST_LEAVE\r
-//WV_IO_LISTEN\r
-//WV_IO_LISTEN_GET_REQUEST\r
+// Windows kernel does not define sockaddr* pre-Vista\r
+typedef struct _WV_IO_SOCKADDR\r
+{\r
+       UINT16                  SaFamily;\r
+       UINT8                   SaData[14];\r
+\r
+}      WV_IO_SOCKADDR;\r
+\r
+typedef struct _WV_IO_SOCKADDR_IN\r
+{\r
+       UINT16                  SinFamily;\r
+       UINT16                  SinPort;\r
+       UINT32                  SinAddr;\r
+       UINT8                   SinZero[8];\r
+\r
+}      WV_IO_SOCKADDR_IN;\r
+\r
+typedef struct _WV_IO_SOCKADDR_IN6\r
+{\r
+       UINT16                  Sin6Family;\r
+       UINT16                  Sin6Port;\r
+       UINT32                  Sin6FlowInfo;\r
+       UINT8                   Sin6Addr[16];\r
+       UINT32                  Sin6ScopeId;\r
+\r
+}      WV_IO_SOCKADDR_IN6;\r
+\r
+typedef struct _WV_IO_SOCKADDR_DATA\r
+{\r
+       union\r
+       {\r
+               WV_IO_SOCKADDR          Sa;\r
+               WV_IO_SOCKADDR_IN       In;\r
+               WV_IO_SOCKADDR_IN6      In6;\r
+\r
+       }       SockAddr;\r
+\r
+       UINT32                                  Reserved;\r
+\r
+}      WV_IO_SOCKADDR_DATA;\r
+\r
+typedef struct _WV_IO_DEVICE_ADDRESS\r
+{\r
+       NET64                   DeviceGuid;\r
+       NET16                   Pkey;\r
+       UINT8                   PortNumber;\r
+       UINT8                   Reserved[5];\r
+\r
+}      WV_IO_DEVICE_ADDRESS;\r
+\r
+typedef struct _WV_IO_EP_BIND\r
+{\r
+       UINT64                                  Id;\r
+       WV_IO_SOCKADDR_DATA             Address;\r
+       WV_IO_DEVICE_ADDRESS    Device;\r
+\r
+}      WV_IO_EP_BIND;\r
+\r
+#define WV_IO_EP_OPTION_ROUTE          0x00000001\r
+\r
+#define WV_IO_EP_TYPE_CONNECT          0x0106\r
+#define WV_IO_EP_TYPE_DATAGRAM         0x0111\r
+\r
+typedef struct _WV_IO_EP_LISTEN\r
+{\r
+       UINT64                  Id;\r
+       UINT64                  Backlog;\r
+\r
+}      WV_IO_EP_LISTEN;\r
+\r
+typedef struct _WV_IO_EP_GET_REQUEST\r
+{\r
+       UINT64                  Id;\r
+       UINT64                  EpId;\r
+\r
+}      WV_IO_EP_GET_REQUEST;\r
+\r
+typedef struct _WV_IO_CONNECT_PARAM\r
+{\r
+       UINT64                  ResponderResources;\r
+       UINT64                  InitiatorDepth;\r
+       UINT8                   RetryCount;\r
+       UINT8                   RnrRetryCount;\r
+       UINT8                   DataLength;\r
+       UINT8                   Reserved[5];\r
+       UINT8                   Data[56];\r
+\r
+}      WV_IO_CONNECT_PARAM;\r
+\r
+typedef struct _WV_IO_EP_CONNECT\r
+{\r
+       UINT64                                  Id;\r
+       UINT64                                  QpId;\r
+       WV_IO_SOCKADDR_DATA             PeerAddress;\r
+       WV_IO_CONNECT_PARAM             Param;\r
+\r
+}      WV_IO_EP_CONNECT;\r
+\r
+typedef struct _WV_IO_EP_ACCEPT\r
+{\r
+       UINT64                                  Id;\r
+       UINT64                                  QpId;\r
+       WV_IO_CONNECT_PARAM             Param;\r
+\r
+}      WV_IO_EP_ACCEPT;\r
+\r
+typedef struct _WV_IO_EP_ATTRIBUTES\r
+{\r
+       WV_IO_SOCKADDR_DATA             LocalAddress;\r
+       WV_IO_SOCKADDR_DATA             PeerAddress;\r
+       WV_IO_DEVICE_ADDRESS    Device;\r
+\r
+       union {\r
+               WV_IO_CONNECT_PARAM     Connect;\r
+               UINT64                          Backlog;\r
+\r
+       }       Param;\r
+\r
+\r
+}      WV_IO_EP_ATTRIBUTES;\r
 \r
 #endif // _WV_IOCTL_H_\r
diff --git a/inc/kernel/iba/ib_rdma_cm.h b/inc/kernel/iba/ib_rdma_cm.h
new file mode 100644 (file)
index 0000000..b6f01f1
--- /dev/null
@@ -0,0 +1,65 @@
+/*\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
+#pragma once\r
+\r
+#ifndef _IB_RDMA_CM_H_\r
+#define _IB_RDMA_CM_H_\r
+\r
+#include <ntddk.h>\r
+\r
+#define IB_CMA_VERSION 0x00\r
+\r
+#define IB_CMA_SERVICE_ID       0x0000000001000000\r
+#define IB_CMA_SERVICE_ID_MASK  0xFFFFFFFFFF000000\r
+#define IB_CMA_CM_RESPONSE_TIMEOUT                             20\r
+#define IB_CMA_MAX_CM_RETRIES                                  15\r
+\r
+typedef union _IB_CMA_IP_ADDRESS\r
+{\r
+       UINT8                           Ip6Address[16];\r
+       struct {\r
+               UINT32                  Pad[3];\r
+               UINT32                  Address;\r
+\r
+       }       Ip4;\r
+\r
+}      IB_CMA_IP_ADDRESS;\r
+\r
+typedef struct _IB_CMA_HEADER\r
+{\r
+       UINT8                           CmaVersion;\r
+       UINT8                           IpVersion;              // IP Version: 7:4\r
+       UINT16                          Port;\r
+       IB_CMA_IP_ADDRESS       SrcAddress;\r
+       IB_CMA_IP_ADDRESS       DstAddress;\r
+\r
+}      IB_CMA_HEADER;\r
+\r
+#endif // _IB_RDMA_CM_H_
\ No newline at end of file