[ofw] [PATCH] winverbs: remove QP from EP Disconnect call

Sean Hefty sean.hefty at intel.com
Wed Jun 10 11:55:20 PDT 2009


The Endpoint class takes a QP parameter for Connect, Accept, and
Disconnect.  To simplify the interface, store the QP internally and
remove it from the Disconnect call.  Also allow it to be optional
for Accept on the active side of the connection.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
As long as the main winverbs interface is changing, squeeze in a couple of
other nice to have API fix-ups before an official release.

diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\core\winverbs/user/wv_ep.cpp
branches\winverbs\core\winverbs/user/wv_ep.cpp
--- trunk\core\winverbs/user/wv_ep.cpp	2009-05-27 12:11:06.650750000 -0700
+++ branches\winverbs\core\winverbs/user/wv_ep.cpp	2009-06-10 10:50:43.760399800 -0700
@@ -75,6 +75,10 @@ CWVConnectEndpoint::~CWVConnectEndpoint(
 {
 	DWORD	bytes;
 
+	if (m_pQp != NULL) {
+		m_pQp->Release();
+	}
+
 	if (m_Id != 0) {
 		WvDeviceIoControl(m_hFile, WV_IOCTL_EP_DESTROY, &m_Id, sizeof m_Id,
 						  NULL, 0, &bytes, NULL);
@@ -293,8 +297,10 @@ Connect(IWVConnectQueuePair* pQp, const 
 	DWORD				bytes;
 	HRESULT				hr;
 
+	m_pQp = (CWVConnectQueuePair *) pQp;
+	m_pQp->AddRef();
 	attr.Id = m_Id;
-	attr.QpId = ((CWVConnectQueuePair *) pQp)->m_Id;
+	attr.QpId = m_pQp->m_Id;
 
 	if (pAddress->sa_family == AF_INET) {
 		RtlCopyMemory(&attr.PeerAddress, pAddress, sizeof(SOCKADDR_IN));
@@ -316,16 +322,20 @@ Connect(IWVConnectQueuePair* pQp, const 
 STDMETHODIMP CWVConnectEndpoint::
 Accept(IWVConnectQueuePair* pQp, WV_CONNECT_PARAM* pParam, OVERLAPPED* pOverlapped)
 {
-	CWVConnectQueuePair	*qp = (CWVConnectQueuePair *) pQp;
 	WV_IO_EP_ACCEPT		attr;
 	DWORD				bytes;
 	HRESULT				hr;
 	void				*pout;
 	DWORD				size;
 
+	if (m_pQp == NULL) {
+		m_pQp = (CWVConnectQueuePair *) pQp;
+		m_pQp->AddRef();
+	}
+
 	attr.Id = m_Id;
-	attr.QpId = qp->m_Id;
-	qp->m_pVerbs->nd_modify_qp(qp->m_hVerbsQp, &pout, &size);
+	attr.QpId = m_pQp->m_Id;
+	m_pQp->m_pVerbs->nd_modify_qp(m_pQp->m_hVerbsQp, &pout, &size);
 	WvIoConvertConnParam(&attr.Param, pParam);
 
 	if (WvDeviceIoControl(m_hFile, WV_IOCTL_EP_ACCEPT, &attr, sizeof attr,
@@ -339,9 +349,8 @@ Accept(IWVConnectQueuePair* pQp, WV_CONN
 }
 
 STDMETHODIMP CWVConnectEndpoint::
-Disconnect(IWVConnectQueuePair* pQp, OVERLAPPED* pOverlapped)
+Disconnect(OVERLAPPED* pOverlapped)
 {
-	CWVConnectQueuePair	*qp = (CWVConnectQueuePair *) pQp;
 	WV_IO_EP_DISCONNECT	attr;
 	DWORD				bytes;
 	HRESULT				hr;
@@ -349,14 +358,8 @@ Disconnect(IWVConnectQueuePair* pQp, OVE
 	DWORD				size;
 
 	attr.Id = m_Id;
-	if (pQp != NULL) {
-		attr.QpId = qp->m_Id;
-		qp->m_pVerbs->nd_modify_qp(qp->m_hVerbsQp, &pout, &size);
-	} else {
-		attr.QpId = 0;
-		pout = NULL;
-		size = 0;
-	}
+	attr.QpId = m_pQp->m_Id;
+	m_pQp->m_pVerbs->nd_modify_qp(m_pQp->m_hVerbsQp, &pout, &size);
 
 	if (WvDeviceIoControl(m_hFile, WV_IOCTL_EP_DISCONNECT,
 						  &attr, sizeof attr, pout, size, &bytes, pOverlapped)) {
diff -up -r -X \mshefty\scm\winof\trunk\docs\dontdiff.txt -I '\$Id:' trunk\core\winverbs/user/wv_ep.h
branches\winverbs\core\winverbs/user/wv_ep.h
--- trunk\core\winverbs/user/wv_ep.h	2009-05-27 12:11:06.869500000 -0700
+++ branches\winverbs\core\winverbs/user/wv_ep.h	2009-06-10 10:52:51.464414400 -0700
@@ -35,6 +35,7 @@
 #include <rdma\winverbs.h>
 #include "wv_provider.h"
 #include "wv_base.h"
+#include "wv_qp.h"
 
 class CWVConnectEndpoint : IWVConnectEndpoint, public CWVBase
 {
@@ -61,7 +62,7 @@ public:
 						 WV_CONNECT_PARAM* pParam, OVERLAPPED* pOverlapped);
 	STDMETHODIMP Accept(IWVConnectQueuePair* pQp, WV_CONNECT_PARAM* pParam,
 						OVERLAPPED* pOverlapped);
-	STDMETHODIMP Disconnect(IWVConnectQueuePair* pQp, OVERLAPPED* pOverlapped);
+	STDMETHODIMP Disconnect(OVERLAPPED* pOverlapped);
 	STDMETHODIMP NotifyDisconnect(OVERLAPPED* pOverlapped);
 	STDMETHODIMP Query(WV_CONNECT_ATTRIBUTES* pAttributes);
 
@@ -103,7 +104,8 @@ public:
 	CWVProvider		*m_pProvider;
 
 protected:
-	SOCKET			m_Socket;
+	SOCKET				m_Socket;
+	CWVConnectQueuePair	*m_pQp;
 
 	STDMETHODIMP Allocate();
 };
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-10 10:57:41.621791200 -0700
@@ -1156,9 +1168,9 @@ DECLARE_INTERFACE_(IWVEndpoint, IWVOverl
 
 #undef INTERFACE
 #define INTERFACE IWVConnectEndpoint
-// {B7C6708E-EA9C-4cff-B2CF-35BCA9A3739A}
-DEFINE_GUID(IID_IWVConnectEndpoint, 0xb7c6708e, 0xea9c, 0x4cff,
-			0xb2, 0xcf, 0x35, 0xbc, 0xa9, 0xa3, 0x73, 0x9a);
+// {8FDA0EE7-E7F7-48cc-83D3-17E9C871FEA3}
+DEFINE_GUID(IID_IWVConnectEndpoint, 0x8fda0ee7, 0xe7f7, 0x48cc,
+			0x83, 0xd3, 0x17, 0xe9, 0xc8, 0x71, 0xfe, 0xa3);
 
 DECLARE_INTERFACE_(IWVConnectEndpoint, IWVEndpoint)
 {
@@ -1230,14 +1242,13 @@ DECLARE_INTERFACE_(IWVConnectEndpoint, I
 
 	STDMETHOD(Accept)(
 		THIS_
-		__in IWVConnectQueuePair* pQp,
+		__in_opt IWVConnectQueuePair* pQp,
 		__in WV_CONNECT_PARAM* pParam,
 		__in_opt OVERLAPPED* pOverlapped
 		) PURE;
 
 	STDMETHOD(Disconnect)(
 		THIS_
-		__in_opt IWVConnectQueuePair* pQp,
 		__in_opt OVERLAPPED* pOverlapped
 		) PURE;
 





More information about the ofw mailing list