[ofw] [PATCH] winverbs: make PD derive from IWVOverlapped

Sean Hefty sean.hefty at intel.com
Tue Jun 9 14:53:09 PDT 2009


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 at intel.com>
---
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\core\winverbs/kernel/wv_driver.c
branches\winverbs\core\winverbs/kernel/wv_driver.c
--- trunk\core\winverbs/kernel/wv_driver.c	2009-05-27 12:11:06.088250000 -0700
+++ branches\winverbs\core\winverbs/kernel/wv_driver.c	2009-06-09 14:20:43.228703600 -0700
@@ -245,6 +245,9 @@ static VOID WvIoDeviceControl(WDFQUEUE Q
 	case WV_IOCTL_PD_ALLOCATE:
 		WvPdAllocate(prov, Request);
 		break;
+	case WV_IOCTL_PD_CANCEL:
+		WvPdCancel(prov, Request);
+		break;
 	case WV_IOCTL_PD_DEALLOCATE:
 		WvPdDeallocate(prov, Request);
 		break;
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\core\winverbs/kernel/wv_pd.c
branches\winverbs\core\winverbs/kernel/wv_pd.c
--- trunk\core\winverbs/kernel/wv_pd.c	2008-07-17 14:10:04.268936000 -0700
+++ branches\winverbs\core\winverbs/kernel/wv_pd.c	2009-06-09 14:24:31.940134600 -0700
@@ -191,6 +191,30 @@ out:
 	WdfRequestComplete(Request, status);
 }
 
+void WvPdCancel(WV_PROVIDER *pProvider, WDFREQUEST Request)
+{
+	WV_PROTECTION_DOMAIN	*pd;
+	UINT64					*id;
+	NTSTATUS				status;
+
+	status = WdfRequestRetrieveInputBuffer(Request, sizeof(UINT64), &id, NULL);
+	if (!NT_SUCCESS(status)) {
+		goto complete;
+	}
+
+	pd = WvPdAcquire(pProvider, *id);
+	if (pd == NULL) {
+		status = STATUS_NOT_FOUND;
+		goto complete;
+	}
+
+	// Registration is currently synchronous - nothing to do.
+	WvPdRelease(pd);
+
+complete:
+	WdfRequestComplete(Request, status);
+}
+
 void WvPdFree(WV_PROTECTION_DOMAIN *pPd)
 {
 	WV_MEMORY_REGION	*mr;
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\core\winverbs/kernel/wv_pd.h
branches\winverbs\core\winverbs/kernel/wv_pd.h
--- trunk\core\winverbs/kernel/wv_pd.h	2009-01-24 11:41:22.234375000 -0800
+++ branches\winverbs\core\winverbs/kernel/wv_pd.h	2009-06-09 14:21:00.884388600 -0700
@@ -66,6 +66,7 @@ void WvPdPut(WV_PROTECTION_DOMAIN *pPd);
 
 void WvPdAllocate(WV_PROVIDER *pProvider, WDFREQUEST Request);
 void WvPdDeallocate(WV_PROVIDER *pProvider, WDFREQUEST Request);
+void WvPdCancel(WV_PROVIDER *pProvider, WDFREQUEST Request);
 void WvPdFree(WV_PROTECTION_DOMAIN *pPd);
 void WvPdRemoveHandler(WV_PROTECTION_DOMAIN *pPd);
 
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\core\winverbs/user/wv_pd.cpp
branches\winverbs\core\winverbs/user/wv_pd.cpp
--- trunk\core\winverbs/user/wv_pd.cpp	2008-12-01 23:16:23.475375000 -0800
+++ branches\winverbs\core\winverbs/user/wv_pd.cpp	2009-06-09 14:14:33.928021600 -0700
@@ -133,6 +133,24 @@ Release(void)
 }
 
 STDMETHODIMP CWVProtectionDomain::
+CancelOverlappedRequests(void)
+{
+	DWORD	bytes;
+
+	return WvDeviceIoControl(m_hFile, WV_IOCTL_PD_CANCEL, &m_Id, sizeof m_Id,
+							 NULL, 0, &bytes, NULL) ?
+							 WV_SUCCESS : HRESULT_FROM_WIN32(GetLastError());
+}
+
+STDMETHODIMP CWVProtectionDomain::
+GetOverlappedResult(OVERLAPPED *pOverlapped,
+					DWORD *pNumberOfBytesTransferred, BOOL bWait)
+{
+	::GetOverlappedResult(m_hFile, pOverlapped, pNumberOfBytesTransferred, bWait);
+	return (HRESULT) pOverlapped->Internal;
+}
+
+STDMETHODIMP CWVProtectionDomain::
 CreateSharedReceiveQueue(SIZE_T MaxWr, SIZE_T MaxSge,
 						 SIZE_T SrqLimit, IWVSharedReceiveQueue** ppSrq)
 {
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\core\winverbs/user/wv_pd.h
branches\winverbs\core\winverbs/user/wv_pd.h
--- trunk\core\winverbs/user/wv_pd.h	2008-07-18 12:45:25.617473800 -0700
+++ branches\winverbs\core\winverbs/user/wv_pd.h	2009-06-09 14:12:36.150540600 -0700
@@ -45,6 +45,11 @@ public:
 	STDMETHODIMP_(ULONG) AddRef();
 	STDMETHODIMP_(ULONG) Release();
 
+	// IWVOverlapped methods
+	STDMETHODIMP CancelOverlappedRequests();
+	STDMETHODIMP GetOverlappedResult(OVERLAPPED *pOverlapped,
+									 DWORD *pNumberOfBytesTransferred, BOOL bWait);
+
 	// IWVProtectionDomain methods
 	STDMETHODIMP CreateSharedReceiveQueue(SIZE_T MaxWr, SIZE_T MaxSge, SIZE_T SrqLimit,
 										  IWVSharedReceiveQueue** ppSrq);
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\core\winverbs/wv_ioctl.h
branches\winverbs\core\winverbs/wv_ioctl.h
--- trunk\core\winverbs/wv_ioctl.h	2009-05-27 12:11:07.010125000 -0700
+++ branches\winverbs\core\winverbs/wv_ioctl.h	2009-06-09 14:19:00.810106100 -0700
@@ -97,6 +97,7 @@ enum {
 	WV_IO_FUNCTION_EP_CANCEL,
 	WV_IO_FUNCTION_EP_LISTEN,
 	WV_IO_FUNCTION_EP_GET_REQUEST,
+	WV_IO_FUNCTION_PD_CANCEL,
 	WV_IO_FUNCTION_MAX
 };
 
@@ -148,6 +149,10 @@ enum {
 #define WV_IOCTL_PD_DEALLOCATE			WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_PD_DEALLOCATE)
 
+// UINT64 Id / none
+#define WV_IOCTL_PD_CANCEL				WV_IOCTL(WV_IO_FUNCTION_BASE + \
+												 WV_IO_FUNCTION_PD_CANCEL)
+
 // WV_IO_MEMORY_REGISTER / WV_IO_MEMORY_KEYS
 #define WV_IOCTL_MEMORY_REGISTER		WV_IOCTL(WV_IO_FUNCTION_BASE + \
 												 WV_IO_FUNCTION_MEMORY_REGISTER)
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\inc\user\rdma/winverbs.h
branches\winverbs\inc\user\rdma/winverbs.h
--- trunk\inc\user\rdma/winverbs.h	2009-06-02 13:23:44.246541100 -0700
+++ branches\winverbs\inc\user\rdma/winverbs.h	2009-06-09 14:12:36.322410100 -0700
@@ -1022,11 +1022,11 @@ DECLARE_INTERFACE_(IWVDatagramQueuePair,
 
 #undef INTERFACE
 #define INTERFACE IWVProtectionDomain
-// {a5633a12-dffc-4060-927d-9a600d7efb63}
-DEFINE_GUID(IID_IWVProtectionDomain, 0xa5633a12, 0xdffc, 0x4060,
-			0x92, 0x7d, 0x9a, 0x60, 0x0d, 0x7e, 0xfb, 0x63);
+// {E3657ABE-8C4E-4994-BE32-45B49BAE95E4}
+DEFINE_GUID(IID_IWVProtectionDomain, 0xe3657abe, 0x8c4e, 0x4994,
+			0xbe, 0x32, 0x45, 0xb4, 0x9b, 0xae, 0x95, 0xe4);
 
-DECLARE_INTERFACE_(IWVProtectionDomain, IUnknown)
+DECLARE_INTERFACE_(IWVProtectionDomain, IWVOverlapped)
 {
 	// IUnknown methods
 	__override STDMETHOD(QueryInterface)(
@@ -1043,6 +1043,18 @@ DECLARE_INTERFACE_(IWVProtectionDomain, 
 		THIS
 		) PURE;
 
+	// IWVOverlapped methods
+	STDMETHOD(CancelOverlappedRequests)(
+		THIS
+		) PURE;
+
+	STDMETHOD(GetOverlappedResult)(
+		THIS_
+		__inout_opt OVERLAPPED *pOverlapped,
+		__out DWORD *pNumberOfBytesTransferred,
+		__in BOOL bWait
+		) PURE;
+
 	// IWVProtectionDomain methods
 	STDMETHOD(CreateSharedReceiveQueue)(
 		THIS_
@@ -1449,9 +1461,9 @@ DECLARE_INTERFACE_(IWVDevice, IWVOverlap
 
 #undef INTERFACE
 #define INTERFACE IWVProvider
-// {060E95D6-EC54-43b2-83FC-B578FD037259}
-DEFINE_GUID(IID_IWVProvider, 0x60e95d6, 0xec54, 0x43b2,
-			0x83, 0xfc, 0xb5, 0x78, 0xfd, 0x3, 0x72, 0x59);
+// {75AD0EDA-23C9-4687-8FFF-D1B34E1EF5BE}
+DEFINE_GUID(IID_IWVProvider, 0x75ad0eda, 0x23c9, 0x4687,
+			0x8f, 0xff, 0xd1, 0xb3, 0x4e, 0x1e, 0xf5, 0xbe);
 
 DECLARE_INTERFACE_(IWVProvider, IUnknown)
 {





More information about the ofw mailing list