[ofw] [RFC] [PATCH 9/12] winverbs: expand framework for IWVQueuePair

Sean Hefty sean.hefty at intel.com
Fri Mar 14 23:06:15 PDT 2008


Minor updates to WinVerb queue pair interface.  Defines some necessary
variables, but still lacks basic implementation of class.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Index: core/winverbs/user/wv_qp.cpp
===================================================================
--- core/winverbs/user/wv_qp.cpp	(revision 971)
+++ core/winverbs/user/wv_qp.cpp	(working copy)
@@ -30,25 +30,60 @@
 #include "wv_base.h"
 #include "wv_qp.h"
 
+CWVQueuePair::CWVQueuePair(CWVProtectionDomain *pPd)
+{
+	pPd->AddRef();
+	m_pPd = pPd;
+	m_pVerbs = pPd->m_pVerbs;
+	m_hFile = pPd->m_hFile;
+
+	m_hVerbsQp = NULL;
+	m_Id = 0;
+
+	m_nRef = 1;
+}
+
 STDMETHODIMP CWVQueuePair::
-QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
+Create(WV_QP_CREATE* pAttributes)
 {
-	UNREFERENCED_PARAMETER(riid);
-	UNREFERENCED_PARAMETER(ppvObj);
+	UNREFERENCED_PARAMETER(pAttributes);
 
 	return E_NOTIMPL;
 }
 
+CWVQueuePair::~CWVQueuePair()
+{
+	m_pPd->Release();
+}
+
+STDMETHODIMP CWVQueuePair::
+QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
+{
+	if (riid != IID_IUnknown && riid != IID_IWVQueuePair) {
+		*ppvObj = NULL;
+		return E_NOINTERFACE;
+	}
+
+	*ppvObj = this;
+	AddRef();
+	return WV_SUCCESS;}
+
 STDMETHODIMP_(ULONG) CWVQueuePair::
 AddRef(void)
 {
-	return 0;
+	return InterlockedIncrement(&m_nRef);
 }
 
 STDMETHODIMP_(ULONG) CWVQueuePair::
 Release(void)
 {
-	return 0;
+	ULONG ref;
+
+	ref = (ULONG) InterlockedDecrement(&m_nRef);
+	if (ref == 0) {
+		delete this;
+	}
+	return ref;
 }
 
 STDMETHODIMP CWVQueuePair::
Index: core/winverbs/user/wv_qp.h
===================================================================
--- core/winverbs/user/wv_qp.h	(revision 971)
+++ core/winverbs/user/wv_qp.h	(working copy)
@@ -33,6 +33,7 @@
 #define _WV_QP_H_
 
 #include "rdma\winverbs.h"
+#include "wv_pd.h"
 
 class CWVQueuePair : IWVQueuePair
 {
@@ -52,6 +53,22 @@
 	STDMETHODIMP Modify(WV_QP_ATTRIBUTES* pAttributes, DWORD Options,
 						OVERLAPPED* pOverlapped);
 	STDMETHODIMP PostReceive(UINT64 WrId, const WV_SGE* pSgl, SIZE_T nSge);
+
+	CWVQueuePair(CWVProtectionDomain *pPd);
+	~CWVQueuePair();
+	STDMETHODIMP Create(WV_QP_CREATE* pAttributes);
+
+	CWVProtectionDomain	*m_pPd;
+	uvp_interface_t		*m_pVerbs;
+	HANDLE				m_hFile;
+
+	ib_qp_handle_t		m_hVerbsQp;
+	UINT64				m_Id;
+
+	VOID				*m_Context;
+
+protected:
+	volatile LONG		m_nRef;
 };
 
 class CWVConnectQueuePair : IWVConnectQueuePair





More information about the ofw mailing list