[ofw] [RFC] [PATCH 10/12] winverbs: expand framework for IWVListen and IWVEndPoint

Sean Hefty sean.hefty at intel.com
Fri Mar 14 23:07:18 PDT 2008


Userspace WinVerb base implementation for end points and listen.
Full implementation is deferred.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Communication management interfaces will be added after verb
functionality is complete and tested.

Index: core/winverbs/user/wv_ep.cpp
===================================================================
--- core/winverbs/user/wv_ep.cpp	(revision 971)
+++ core/winverbs/user/wv_ep.cpp	(working copy)
@@ -30,81 +30,52 @@
 #include "wv_base.h"
 #include "wv_ep.h"
 
-STDMETHODIMP CWVEndpoint::
-QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
+CWVConnectEndpoint::CWVConnectEndpoint(CWVProvider *pProvider)
 {
-	UNREFERENCED_PARAMETER(riid);
-	UNREFERENCED_PARAMETER(ppvObj);
+	pProvider->AddRef();
+	m_pProvider = pProvider;
+	m_hFile = pProvider->m_hFile;
 
-	return E_NOTIMPL;
-}
+	m_Id = 0;
 
-STDMETHODIMP_(ULONG) CWVEndpoint::
-AddRef(void)
-{
-	return 0;
+	m_nRef = 1;
 }
 
-STDMETHODIMP_(ULONG) CWVEndpoint::
-Release(void)
+CWVConnectEndpoint::~CWVConnectEndpoint()
 {
-	return 0;
+	m_pProvider->Release();
 }
 
-STDMETHODIMP CWVEndpoint::
-CancelOverlappedRequests(void)
-{
-	return E_NOTIMPL;
-}
-
-STDMETHODIMP CWVEndpoint::
-GetOverlappedResult(OVERLAPPED *pOverlapped,
-					SIZE_T *pNumberOfBytesTransferred, BOOL bWait)
-{
-	UNREFERENCED_PARAMETER(pOverlapped);
-	UNREFERENCED_PARAMETER(pNumberOfBytesTransferred);
-	UNREFERENCED_PARAMETER(bWait);
-
-	return E_NOTIMPL;
-}
-
-STDMETHODIMP CWVEndpoint::
-BindAddress(const struct sockaddr* pAddress)
-{
-	UNREFERENCED_PARAMETER(pAddress);
-
-	return E_NOTIMPL;
-}
-
-STDMETHODIMP CWVEndpoint::
-Reject(const VOID* pPrivateData, SIZE_T PrivateDataLength)
-{
-	UNREFERENCED_PARAMETER(pPrivateData);
-	UNREFERENCED_PARAMETER(PrivateDataLength);
-
-	return E_NOTIMPL;
-}
-
-
 STDMETHODIMP CWVConnectEndpoint::
 QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
 {
-	UNREFERENCED_PARAMETER(riid);
-	UNREFERENCED_PARAMETER(ppvObj);
+	if (riid != IID_IUnknown && riid != IID_IWVEndpoint &&
+		riid != IID_IWVConnectEndpoint) {
+		*ppvObj = NULL;
+		return E_NOINTERFACE;
+	}
 
-	return E_NOTIMPL;
+	*ppvObj = this;
+	AddRef();
+	return WV_SUCCESS;
 }
 
 STDMETHODIMP_(ULONG) CWVConnectEndpoint::
 AddRef(void)
 {
-	return 0;
+	return InterlockedIncrement(&m_nRef);
 }
 
 STDMETHODIMP_(ULONG) CWVConnectEndpoint::
 Release(void)
 {
-	return 0;
+	ULONG ref;
+
+	ref = (ULONG) InterlockedDecrement(&m_nRef);
+	if (ref == 0) {
+		delete this;
+	}
+	return ref;
 }
 
 STDMETHODIMP CWVConnectEndpoint::
@@ -186,25 +157,52 @@
 }
 
 
+CWVDatagramEndpoint::CWVDatagramEndpoint(CWVProvider *pProvider)
+{
+	pProvider->AddRef();
+	m_pProvider = pProvider;
+	m_hFile = pProvider->m_hFile;
+
+	m_Id = 0;
+
+	m_nRef = 1;
+}
+
+CWVDatagramEndpoint::~CWVDatagramEndpoint()
+{
+	m_pProvider->Release();
+}
+
 STDMETHODIMP CWVDatagramEndpoint::
 QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
 {
-	UNREFERENCED_PARAMETER(riid);
-	UNREFERENCED_PARAMETER(ppvObj);
+	if (riid != IID_IUnknown && riid != IID_IWVEndpoint &&
+		riid != IID_IWVDatagramEndpoint) {
+		*ppvObj = NULL;
+		return E_NOINTERFACE;
+	}
 
-	return E_NOTIMPL;
+	*ppvObj = this;
+	AddRef();
+	return WV_SUCCESS;
 }
 
 STDMETHODIMP_(ULONG) CWVDatagramEndpoint::
 AddRef(void)
 {
-	return 0;
+	return InterlockedIncrement(&m_nRef);
 }
 
 STDMETHODIMP_(ULONG) CWVDatagramEndpoint::
 Release(void)
 {
-	return 0;
+	ULONG ref;
+
+	ref = (ULONG) InterlockedDecrement(&m_nRef);
+	if (ref == 0) {
+		delete this;
+	}
+	return ref;
 }
 
 STDMETHODIMP CWVDatagramEndpoint::
Index: core/winverbs/user/wv_ep.h
===================================================================
--- core/winverbs/user/wv_ep.h	(revision 971)
+++ core/winverbs/user/wv_ep.h	(working copy)
@@ -33,25 +33,8 @@
 #define _WV_EP_H_
 
 #include "rdma\winverbs.h"
+#include "wv_provider.h"
 
-class CWVEndpoint : IWVEndpoint
-{
-public:
-	// IUnknown methods
-	STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
-	STDMETHODIMP_(ULONG) AddRef();
-	STDMETHODIMP_(ULONG) Release();
-
-	// IWVOverlapped methods
-	STDMETHODIMP CancelOverlappedRequests();
-	STDMETHODIMP GetOverlappedResult(OVERLAPPED *pOverlapped,
-									 SIZE_T *pNumberOfBytesTransferred, BOOL bWait);
-
-	// IWVEndpoint methods
-	STDMETHODIMP BindAddress(const struct sockaddr* pAddress);
-	STDMETHODIMP Reject(const VOID* pPrivateData, SIZE_T PrivateDataLength);
-};
-
 class CWVConnectEndpoint : IWVConnectEndpoint
 {
 public:
@@ -77,6 +60,17 @@
 	STDMETHODIMP Disconnect(OVERLAPPED* pOverlapped);
 	STDMETHODIMP NotifyDisconnect(OVERLAPPED* pOverlapped);
 	STDMETHODIMP Query(WV_CONNECT_ATTRIBUTES* pAttributes);
+
+	CWVConnectEndpoint(CWVProvider *pProvider);
+	~CWVConnectEndpoint();
+
+	CWVProvider		*m_pProvider;
+	HANDLE			m_hFile;
+
+	UINT64			m_Id;
+
+protected:
+	volatile LONG	m_nRef;
 };
 
 class CWVDatagramEndpoint : IWVDatagramEndpoint
@@ -105,6 +99,17 @@
 	STDMETHODIMP LeaveMulticast(const struct sockaddr* pAddress,
 								OVERLAPPED* pOverlapped);
 	STDMETHODIMP Query(WV_DATAGRAM_ATTRIBUTES* pAttributes);
+
+	CWVDatagramEndpoint(CWVProvider *pProvider);
+	~CWVDatagramEndpoint();
+
+	CWVProvider		*m_pProvider;
+	HANDLE			m_hFile;
+
+	UINT64			m_Id;
+
+protected:
+	volatile LONG	m_nRef;
 };
 
 #endif // _WV_EP_H_
Index: core/winverbs/user/wv_listen.cpp
===================================================================
--- core/winverbs/user/wv_listen.cpp	(revision 971)
+++ core/winverbs/user/wv_listen.cpp	(working copy)
@@ -30,25 +30,51 @@
 #include "wv_base.h"
 #include "wv_listen.h"
 
+CWVListen::CWVListen(CWVProvider *pProvider)
+{
+	pProvider->AddRef();
+	m_pProvider = pProvider;
+	m_hFile = pProvider->m_hFile;
+
+	m_Id = 0;
+
+	m_nRef = 1;
+}
+
+CWVListen::~CWVListen()
+{
+	m_pProvider->Release();
+}
+
 STDMETHODIMP CWVListen::
 QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
 {
-	UNREFERENCED_PARAMETER(riid);
-	UNREFERENCED_PARAMETER(ppvObj);
+	if (riid != IID_IUnknown && riid != IID_IWVListen) {
+		*ppvObj = NULL;
+		return E_NOINTERFACE;
+	}
 
-	return E_NOTIMPL;
+	*ppvObj = this;
+	AddRef();
+	return WV_SUCCESS;
 }
 
 STDMETHODIMP_(ULONG) CWVListen::
 AddRef(void)
 {
-	return 0;
+	return InterlockedIncrement(&m_nRef);
 }
 
 STDMETHODIMP_(ULONG) CWVListen::
 Release(void)
 {
-	return 0;
+	ULONG ref;
+
+	ref = (ULONG) InterlockedDecrement(&m_nRef);
+	if (ref == 0) {
+		delete this;
+	}
+	return ref;
 }
 
 STDMETHODIMP CWVListen::
@@ -69,6 +95,15 @@
 }
 
 STDMETHODIMP CWVListen::
+Listen(const struct sockaddr* pAddress, SIZE_T Backlog)
+{
+	UNREFERENCED_PARAMETER(pAddress);
+	UNREFERENCED_PARAMETER(Backlog);
+
+	return E_NOTIMPL;
+}
+
+STDMETHODIMP CWVListen::
 GetRequest(IWVEndpoint* pEndpoint, OVERLAPPED* pOverlapped)
 {
 	UNREFERENCED_PARAMETER(pEndpoint);
Index: core/winverbs/user/wv_listen.h
===================================================================
--- core/winverbs/user/wv_listen.h	(revision 971)
+++ core/winverbs/user/wv_listen.h	(working copy)
@@ -33,9 +33,11 @@
 #define _WV_LISTEN_H_
 
 #include "rdma\winverbs.h"
+#include "wv_provider.h"
 
 class CWVListen : IWVListen
 {
+public:
 	// IUnknown methods
 	STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppvObj);
 	STDMETHODIMP_(ULONG) AddRef();
@@ -48,6 +50,19 @@
 
 	// IWVListen methods
 	STDMETHODIMP GetRequest(IWVEndpoint* pEndpoint, OVERLAPPED* pOverlapped);
+
+	STDMETHODIMP Listen(const struct sockaddr* pAddress, SIZE_T Backlog);
+
+	CWVListen(CWVProvider *pProvider);
+	~CWVListen();
+
+	CWVProvider		*m_pProvider;
+	HANDLE			m_hFile;
+
+	UINT64			m_Id;
+
+protected:
+	volatile LONG	m_nRef;
 };
 
 #endif // _WV_LISTEN_H_
\ No newline at end of file





More information about the ofw mailing list