winverbs: make PD derive from IWVOverlapped
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 11 Jun 2009 04:06:23 +0000 (04:06 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 11 Jun 2009 04:06:23 +0000 (04:06 +0000)
Memory registration is asynchronous and part of the PD interface.
Make the PD derive from overlapped, rather than unknown base class, and
add support for canceling asynchronous operations (i.e. register
memory) on the PD.

This is an oversight of the initial API caught by implementing the ND
provider.

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

core/winverbs/kernel/wv_driver.c
core/winverbs/kernel/wv_pd.c
core/winverbs/kernel/wv_pd.h
core/winverbs/user/wv_pd.cpp
core/winverbs/user/wv_pd.h
core/winverbs/wv_ioctl.h
inc/user/rdma/winverbs.h

index 89984c4..ee96f19 100644 (file)
@@ -245,6 +245,9 @@ static VOID WvIoDeviceControl(WDFQUEUE Queue, WDFREQUEST Request,
        case WV_IOCTL_PD_ALLOCATE:\r
                WvPdAllocate(prov, Request);\r
                break;\r
+       case WV_IOCTL_PD_CANCEL:\r
+               WvPdCancel(prov, Request);\r
+               break;\r
        case WV_IOCTL_PD_DEALLOCATE:\r
                WvPdDeallocate(prov, Request);\r
                break;\r
index d74402e..5ae2629 100644 (file)
@@ -191,6 +191,30 @@ out:
        WdfRequestComplete(Request, status);\r
 }\r
 \r
+void WvPdCancel(WV_PROVIDER *pProvider, WDFREQUEST Request)\r
+{\r
+       WV_PROTECTION_DOMAIN    *pd;\r
+       UINT64                                  *id;\r
+       NTSTATUS                                status;\r
+\r
+       status = WdfRequestRetrieveInputBuffer(Request, sizeof(UINT64), &id, NULL);\r
+       if (!NT_SUCCESS(status)) {\r
+               goto complete;\r
+       }\r
+\r
+       pd = WvPdAcquire(pProvider, *id);\r
+       if (pd == NULL) {\r
+               status = STATUS_NOT_FOUND;\r
+               goto complete;\r
+       }\r
+\r
+       // Registration is currently synchronous - nothing to do.\r
+       WvPdRelease(pd);\r
+\r
+complete:\r
+       WdfRequestComplete(Request, status);\r
+}\r
+\r
 void WvPdFree(WV_PROTECTION_DOMAIN *pPd)\r
 {\r
        WV_MEMORY_REGION        *mr;\r
index e0cd9b1..f30cf4e 100644 (file)
@@ -66,6 +66,7 @@ void WvPdPut(WV_PROTECTION_DOMAIN *pPd);
 \r
 void WvPdAllocate(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
 void WvPdDeallocate(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
+void WvPdCancel(WV_PROVIDER *pProvider, WDFREQUEST Request);\r
 void WvPdFree(WV_PROTECTION_DOMAIN *pPd);\r
 void WvPdRemoveHandler(WV_PROTECTION_DOMAIN *pPd);\r
 \r
index c7b11a7..ea93e22 100644 (file)
@@ -132,6 +132,24 @@ Release(void)
        return CWVBase::Release();\r
 }\r
 \r
+STDMETHODIMP CWVProtectionDomain::\r
+CancelOverlappedRequests(void)\r
+{\r
+       DWORD   bytes;\r
+\r
+       return WvDeviceIoControl(m_hFile, WV_IOCTL_PD_CANCEL, &m_Id, sizeof m_Id,\r
+                                                        NULL, 0, &bytes, NULL) ?\r
+                                                        WV_SUCCESS : HRESULT_FROM_WIN32(GetLastError());\r
+}\r
+\r
+STDMETHODIMP CWVProtectionDomain::\r
+GetOverlappedResult(OVERLAPPED *pOverlapped,\r
+                                       DWORD *pNumberOfBytesTransferred, BOOL bWait)\r
+{\r
+       ::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);\r
+       return (HRESULT) pOverlapped->Internal;\r
+}\r
+\r
 STDMETHODIMP CWVProtectionDomain::\r
 CreateSharedReceiveQueue(SIZE_T MaxWr, SIZE_T MaxSge,\r
                                                 SIZE_T SrqLimit, IWVSharedReceiveQueue** ppSrq)\r
index 209894a..5f4c21a 100644 (file)
@@ -45,6 +45,11 @@ public:
        STDMETHODIMP_(ULONG) AddRef();\r
        STDMETHODIMP_(ULONG) Release();\r
 \r
+       // IWVOverlapped methods\r
+       STDMETHODIMP CancelOverlappedRequests();\r
+       STDMETHODIMP GetOverlappedResult(OVERLAPPED *pOverlapped,\r
+                                                                        DWORD *pNumberOfBytesTransferred, BOOL bWait);\r
+\r
        // IWVProtectionDomain methods\r
        STDMETHODIMP CreateSharedReceiveQueue(SIZE_T MaxWr, SIZE_T MaxSge, SIZE_T SrqLimit,\r
                                                                                  IWVSharedReceiveQueue** ppSrq);\r
index 7499d4b..898a392 100644 (file)
@@ -97,6 +97,7 @@ enum {
        WV_IO_FUNCTION_EP_CANCEL,\r
        WV_IO_FUNCTION_EP_LISTEN,\r
        WV_IO_FUNCTION_EP_GET_REQUEST,\r
+       WV_IO_FUNCTION_PD_CANCEL,\r
        WV_IO_FUNCTION_MAX\r
 };\r
 \r
@@ -148,6 +149,10 @@ enum {
 #define WV_IOCTL_PD_DEALLOCATE                 WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_PD_DEALLOCATE)\r
 \r
+// UINT64 Id / none\r
+#define WV_IOCTL_PD_CANCEL                             WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
+                                                                                                WV_IO_FUNCTION_PD_CANCEL)\r
+\r
 // WV_IO_MEMORY_REGISTER / WV_IO_MEMORY_KEYS\r
 #define WV_IOCTL_MEMORY_REGISTER               WV_IOCTL(WV_IO_FUNCTION_BASE + \\r
                                                                                                 WV_IO_FUNCTION_MEMORY_REGISTER)\r
index 4deef0a..c4d21ad 100644 (file)
@@ -1022,11 +1022,11 @@ DECLARE_INTERFACE_(IWVDatagramQueuePair, IWVQueuePair)
 \r
 #undef INTERFACE\r
 #define INTERFACE IWVProtectionDomain\r
-// {a5633a12-dffc-4060-927d-9a600d7efb63}\r
-DEFINE_GUID(IID_IWVProtectionDomain, 0xa5633a12, 0xdffc, 0x4060,\r
-                       0x92, 0x7d, 0x9a, 0x60, 0x0d, 0x7e, 0xfb, 0x63);\r
+// {E3657ABE-8C4E-4994-BE32-45B49BAE95E4}\r
+DEFINE_GUID(IID_IWVProtectionDomain, 0xe3657abe, 0x8c4e, 0x4994,\r
+                       0xbe, 0x32, 0x45, 0xb4, 0x9b, 0xae, 0x95, 0xe4);\r
 \r
-DECLARE_INTERFACE_(IWVProtectionDomain, IUnknown)\r
+DECLARE_INTERFACE_(IWVProtectionDomain, IWVOverlapped)\r
 {\r
        // IUnknown methods\r
        __override STDMETHOD(QueryInterface)(\r
@@ -1043,6 +1043,18 @@ DECLARE_INTERFACE_(IWVProtectionDomain, IUnknown)
                THIS\r
                ) PURE;\r
 \r
+       // IWVOverlapped methods\r
+       STDMETHOD(CancelOverlappedRequests)(\r
+               THIS\r
+               ) PURE;\r
+\r
+       STDMETHOD(GetOverlappedResult)(\r
+               THIS_\r
+               __inout_opt OVERLAPPED *pOverlapped,\r
+               __out DWORD *pNumberOfBytesTransferred,\r
+               __in BOOL bWait\r
+               ) PURE;\r
+\r
        // IWVProtectionDomain methods\r
        STDMETHOD(CreateSharedReceiveQueue)(\r
                THIS_\r
@@ -1449,9 +1461,9 @@ DECLARE_INTERFACE_(IWVDevice, IWVOverlapped)
 \r
 #undef INTERFACE\r
 #define INTERFACE IWVProvider\r
-// {060E95D6-EC54-43b2-83FC-B578FD037259}\r
-DEFINE_GUID(IID_IWVProvider, 0x60e95d6, 0xec54, 0x43b2,\r
-                       0x83, 0xfc, 0xb5, 0x78, 0xfd, 0x3, 0x72, 0x59);\r
+// {75AD0EDA-23C9-4687-8FFF-D1B34E1EF5BE}\r
+DEFINE_GUID(IID_IWVProvider, 0x75ad0eda, 0x23c9, 0x4687,\r
+                       0x8f, 0xff, 0xd1, 0xb3, 0x4e, 0x1e, 0xf5, 0xbe);\r
 \r
 DECLARE_INTERFACE_(IWVProvider, IUnknown)\r
 {\r