winverbs: remove QP from EP Disconnect call
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 11 Jun 2009 04:11:24 +0000 (04:11 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 11 Jun 2009 04:11:24 +0000 (04:11 +0000)
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.

Update librdmacm accordingly.

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

core/winverbs/user/wv_ep.cpp
core/winverbs/user/wv_ep.h
inc/user/rdma/winverbs.h
ulp/librdmacm/src/cma.cpp

index e9a96b3..5db0413 100644 (file)
@@ -75,6 +75,10 @@ CWVConnectEndpoint::~CWVConnectEndpoint()
 {\r
        DWORD   bytes;\r
 \r
+       if (m_pQp != NULL) {\r
+               m_pQp->Release();\r
+       }\r
+\r
        if (m_Id != 0) {\r
                WvDeviceIoControl(m_hFile, WV_IOCTL_EP_DESTROY, &m_Id, sizeof m_Id,\r
                                                  NULL, 0, &bytes, NULL);\r
@@ -293,8 +297,10 @@ Connect(IWVConnectQueuePair* pQp, const SOCKADDR* pAddress,
        DWORD                           bytes;\r
        HRESULT                         hr;\r
 \r
+       m_pQp = (CWVConnectQueuePair *) pQp;\r
+       m_pQp->AddRef();\r
        attr.Id = m_Id;\r
-       attr.QpId = ((CWVConnectQueuePair *) pQp)->m_Id;\r
+       attr.QpId = m_pQp->m_Id;\r
 \r
        if (pAddress->sa_family == AF_INET) {\r
                RtlCopyMemory(&attr.PeerAddress, pAddress, sizeof(SOCKADDR_IN));\r
@@ -316,16 +322,20 @@ Connect(IWVConnectQueuePair* pQp, const SOCKADDR* pAddress,
 STDMETHODIMP CWVConnectEndpoint::\r
 Accept(IWVConnectQueuePair* pQp, WV_CONNECT_PARAM* pParam, OVERLAPPED* pOverlapped)\r
 {\r
-       CWVConnectQueuePair     *qp = (CWVConnectQueuePair *) pQp;\r
        WV_IO_EP_ACCEPT         attr;\r
        DWORD                           bytes;\r
        HRESULT                         hr;\r
        void                            *pout;\r
        DWORD                           size;\r
 \r
+       if (m_pQp == NULL) {\r
+               m_pQp = (CWVConnectQueuePair *) pQp;\r
+               m_pQp->AddRef();\r
+       }\r
+\r
        attr.Id = m_Id;\r
-       attr.QpId = qp->m_Id;\r
-       qp->m_pVerbs->nd_modify_qp(qp->m_hVerbsQp, &pout, &size);\r
+       attr.QpId = m_pQp->m_Id;\r
+       m_pQp->m_pVerbs->nd_modify_qp(m_pQp->m_hVerbsQp, &pout, &size);\r
        WvIoConvertConnParam(&attr.Param, pParam);\r
 \r
        if (WvDeviceIoControl(m_hFile, WV_IOCTL_EP_ACCEPT, &attr, sizeof attr,\r
@@ -339,9 +349,8 @@ Accept(IWVConnectQueuePair* pQp, WV_CONNECT_PARAM* pParam, OVERLAPPED* pOverlapp
 }\r
 \r
 STDMETHODIMP CWVConnectEndpoint::\r
-Disconnect(IWVConnectQueuePair* pQp, OVERLAPPED* pOverlapped)\r
+Disconnect(OVERLAPPED* pOverlapped)\r
 {\r
-       CWVConnectQueuePair     *qp = (CWVConnectQueuePair *) pQp;\r
        WV_IO_EP_DISCONNECT     attr;\r
        DWORD                           bytes;\r
        HRESULT                         hr;\r
@@ -349,14 +358,8 @@ Disconnect(IWVConnectQueuePair* pQp, OVERLAPPED* pOverlapped)
        DWORD                           size;\r
 \r
        attr.Id = m_Id;\r
-       if (pQp != NULL) {\r
-               attr.QpId = qp->m_Id;\r
-               qp->m_pVerbs->nd_modify_qp(qp->m_hVerbsQp, &pout, &size);\r
-       } else {\r
-               attr.QpId = 0;\r
-               pout = NULL;\r
-               size = 0;\r
-       }\r
+       attr.QpId = m_pQp->m_Id;\r
+       m_pQp->m_pVerbs->nd_modify_qp(m_pQp->m_hVerbsQp, &pout, &size);\r
 \r
        if (WvDeviceIoControl(m_hFile, WV_IOCTL_EP_DISCONNECT,\r
                                                  &attr, sizeof attr, pout, size, &bytes, pOverlapped)) {\r
index fbbe7be..0d8422b 100644 (file)
@@ -35,6 +35,7 @@
 #include <rdma\winverbs.h>\r
 #include "wv_provider.h"\r
 #include "wv_base.h"\r
+#include "wv_qp.h"\r
 \r
 class CWVConnectEndpoint : IWVConnectEndpoint, public CWVBase\r
 {\r
@@ -61,7 +62,7 @@ public:
                                                 WV_CONNECT_PARAM* pParam, OVERLAPPED* pOverlapped);\r
        STDMETHODIMP Accept(IWVConnectQueuePair* pQp, WV_CONNECT_PARAM* pParam,\r
                                                OVERLAPPED* pOverlapped);\r
-       STDMETHODIMP Disconnect(IWVConnectQueuePair* pQp, OVERLAPPED* pOverlapped);\r
+       STDMETHODIMP Disconnect(OVERLAPPED* pOverlapped);\r
        STDMETHODIMP NotifyDisconnect(OVERLAPPED* pOverlapped);\r
        STDMETHODIMP Query(WV_CONNECT_ATTRIBUTES* pAttributes);\r
 \r
@@ -103,7 +104,8 @@ public:
        CWVProvider             *m_pProvider;\r
 \r
 protected:\r
-       SOCKET                  m_Socket;\r
+       SOCKET                          m_Socket;\r
+       CWVConnectQueuePair     *m_pQp;\r
 \r
        STDMETHODIMP Allocate();\r
 };\r
index c4d21ad..eb73b1b 100644 (file)
@@ -1168,9 +1168,9 @@ DECLARE_INTERFACE_(IWVEndpoint, IWVOverlapped)
 \r
 #undef INTERFACE\r
 #define INTERFACE IWVConnectEndpoint\r
-// {B7C6708E-EA9C-4cff-B2CF-35BCA9A3739A}\r
-DEFINE_GUID(IID_IWVConnectEndpoint, 0xb7c6708e, 0xea9c, 0x4cff,\r
-                       0xb2, 0xcf, 0x35, 0xbc, 0xa9, 0xa3, 0x73, 0x9a);\r
+// {8FDA0EE7-E7F7-48cc-83D3-17E9C871FEA3}\r
+DEFINE_GUID(IID_IWVConnectEndpoint, 0x8fda0ee7, 0xe7f7, 0x48cc,\r
+                       0x83, 0xd3, 0x17, 0xe9, 0xc8, 0x71, 0xfe, 0xa3);\r
 \r
 DECLARE_INTERFACE_(IWVConnectEndpoint, IWVEndpoint)\r
 {\r
@@ -1242,14 +1242,13 @@ DECLARE_INTERFACE_(IWVConnectEndpoint, IWVEndpoint)
 \r
        STDMETHOD(Accept)(\r
                THIS_\r
-               __in IWVConnectQueuePair* pQp,\r
+               __in_opt IWVConnectQueuePair* pQp,\r
                __in WV_CONNECT_PARAM* pParam,\r
                __in_opt OVERLAPPED* pOverlapped\r
                ) PURE;\r
 \r
        STDMETHOD(Disconnect)(\r
                THIS_\r
-               __in_opt IWVConnectQueuePair* pQp,\r
                __in_opt OVERLAPPED* pOverlapped\r
                ) PURE;\r
 \r
index 9fb0b25..6f4e5e1 100644 (file)
@@ -811,7 +811,7 @@ int rdma_disconnect(struct rdma_cm_id *id)
        } else {\r
                id_priv->state = cma_disconnected;\r
        }\r
-       hr = id->ep.connect->Disconnect(id->qp->conn_handle, NULL);\r
+       hr = id->ep.connect->Disconnect(NULL);\r
        if (FAILED(hr)) {\r
                return hr;\r
        }\r