]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
Minor improvements to SDP send and shutdown. (Rev 84)
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 21 Nov 2005 12:14:33 +0000 (12:14 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 21 Nov 2005 12:14:33 +0000 (12:14 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@167 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/sdp/kernel/SdpBufferPool.cpp
trunk/ulp/sdp/kernel/SdpSocket.cpp
trunk/ulp/sdp/kernel/SdpSocket.h
trunk/ulp/sdp/kernel/SdpTrace.h

index 4f1310185db5a839d3078a16ca4c745b4eea0ec8..80cda011b99f65b5d46a1eb4d3d16f4285cdeea1 100644 (file)
@@ -91,7 +91,6 @@ BufferPool::GetBuffer(
                 ASSERT(*ppBufferDescriptor == NULL);\r
                 goto Cleanup;\r
             }\r
-            m_CurrentlyAllocated++;\r
             goto Cleanup;\r
         }        \r
     } \r
@@ -151,7 +150,7 @@ BufferPool::ReturnBuffer(BufferDescriptor *pBufferDescriptor)
 \r
 #if DBG    \r
     if (m_CurrentlySentBuffers == 1) {\r
-        SDP_PRINT(SDP_WARN, SDP_BUFFER_POOL, ("Currently no packets are bing sent m_ClientWaiting = %s\n", \r
+        SDP_PRINT(SDP_WARN, SDP_PERFORMANCE, ("Currently no packets are bing sent m_ClientWaiting = %s\n", \r
                 m_ClientWaiting ? "true" : "false"));        \r
     }\r
 #endif    \r
@@ -266,7 +265,9 @@ BufferPool::AllocateBuffer(BufferDescriptor ** ppBufferDescriptor)
 \r
 \r
 Cleanup:\r
-    if (!NT_SUCCESS(rc)) {\r
+    if (NT_SUCCESS(rc)) {\r
+        m_CurrentlyAllocated++;\r
+    } else {\r
         if (pBufferDescriptor != NULL) {\r
             if (pBufferDescriptor->pBuffer != NULL) {\r
                 ExFreePoolWithTag(pBufferDescriptor->pBuffer, SEND_BUFFERS_ALLOCATION_TAG);\r
@@ -274,7 +275,7 @@ Cleanup:
             ExFreePoolWithTag(pBufferDescriptor, SEND_BUFFERS_ALLOCATION_TAG);\r
             pBufferDescriptor = NULL;\r
         }        \r
-    }\r
+    } \r
     *ppBufferDescriptor = pBufferDescriptor;\r
     return rc;\r
 }\r
index 0a4e327180d3e2fd746e6f913cbf1a291941dcff..614292b480ceb0a5a8dfb97b81df901f2669bad5 100644 (file)
@@ -94,6 +94,7 @@ NTSTATUS SdpSocket::Init(
     m_Lock.Init(__send_cb2, this);\r
     pSocketOutParam->Errno = 0;// No error\r
     pSocketOutParam->pSocket = this; // give the user a handle to the socket\r
+    KeInitializeEvent(&m_ShutdownCompleteEvent, NotificationEvent , FALSE );\r
 \r
     return rc;\r
 }\r
@@ -1190,35 +1191,74 @@ VOID SdpSocket::CreateCmRequest(
     cm_req->pfn_cm_rep_cb = cm_rep_callback;\r
 }\r
 \r
+// static\r
+VOID SdpSocket::ShutdownCB(VOID* pContext)\r
+{\r
+    SdpSocket *pSocket = (SdpSocket *) pContext;\r
+    KeSetEvent(&pSocket->m_ShutdownCompleteEvent, IO_NO_INCREMENT, FALSE);;\r
+\r
+}\r
+\r
+// This is just a wrapper for some operations that have to be done for the code bellow\r
+// It will probably be converted to a macro\r
+VOID WaitForShutdownEvent(KEVENT *ShutdownCompleteEvent)\r
+{\r
+    NTSTATUS rc = STATUS_SUCCESS;\r
+    rc = MyKeWaitForSingleObject(\r
+        ShutdownCompleteEvent,\r
+        UserRequest,\r
+        UserMode,\r
+        FALSE,\r
+        NULL\r
+        );\r
+\r
+    ASSERT(NT_SUCCESS(rc));\r
+    ASSERT(rc == STATUS_SUCCESS);\r
+    KeClearEvent(ShutdownCompleteEvent);\r
+}\r
+\r
 VOID SdpSocket::Shutdown()\r
 {\r
+    SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("SdpSocket::Shutdown called this = 0x%p\n", this));   \r
+    NTSTATUS rc = STATUS_SUCCESS;\r
     \r
-    //???? locking\r
+    // locking ?????\r
     // if(m_shutdown - on the lock) ???\r
     ib_api_status_t     ib_status;\r
+    \r
     m_Lock.SignalShutdown();\r
 \r
-    SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("SdpSocket::Shutdown called this = 0x%p\n", this));\r
-\r
     if (m_qp != NULL) {\r
-        ib_destroy_qp(m_qp, NULL); //?????? CALL BACK ??? IMPLMENT\r
+        ib_status = ib_destroy_qp(m_qp, ShutdownCB);\r
+        ASSERT(ib_status == IB_SUCCESS);\r
+        m_qp = NULL;\r
+        WaitForShutdownEvent(&m_ShutdownCompleteEvent);        \r
     }\r
 \r
     if (m_scq != NULL) {\r
-        ib_destroy_cq(m_scq, NULL); //?????? CALL BACK ??? IMPLMENT\r
+        ib_destroy_cq(m_scq, ShutdownCB); \r
+        m_scq = NULL;\r
+        WaitForShutdownEvent(&m_ShutdownCompleteEvent);\r
     }\r
 \r
     if (m_rcq != NULL) {\r
-        ib_destroy_cq(m_rcq, NULL); //?????? CALL BACK ??? IMPLMENT\r
+        ib_destroy_cq(m_rcq, ShutdownCB); \r
+        m_rcq = NULL;\r
+        WaitForShutdownEvent(&m_ShutdownCompleteEvent);\r
     }\r
-\r
+    \r
     if (m_pd != NULL) {\r
-        ib_dealloc_pd(m_pd, NULL); //?????? CALL BACK ??? IMPLMENT\r
+        ib_dealloc_pd(m_pd, ShutdownCB); \r
+        m_pd = NULL;\r
+        WaitForShutdownEvent(&m_ShutdownCompleteEvent);\r
     }\r
 \r
     if (mh_Ca != NULL) {\r
-        ib_close_ca(mh_Ca, NULL); //?????? CALL BACK ??? IMPLMENT\r
+        ib_close_ca(mh_Ca, ShutdownCB); \r
+        mh_Ca = NULL;\r
+        WaitForShutdownEvent(&m_ShutdownCompleteEvent);\r
     }\r
+    \r
 \r
     // Now that all ibal operations have finished we can free the memory\r
     m_SendBufferPool.ShutDown();\r
index 8895c3958c66b38712ee04f52df2085a44e7d0ad..466c65f933c39a065ac8d1f3bfb2653f496a6415 100644 (file)
@@ -73,6 +73,7 @@ private:
     BufferPool              m_SendBufferPool;\r
 \r
     KEVENT                  m_ConnectCmCompleteEvent;\r
+    KEVENT                  m_ShutdownCompleteEvent;\r
 \r
     VOID SignalShutdown();\r
 \r
@@ -100,6 +101,8 @@ public:
 \r
     VOID Shutdown();\r
 \r
+    static VOID ShutdownCB(VOID* pContext);\r
+\r
 \r
     NTSTATUS CreateQp();\r
 \r
index e3e642eb76018e2a9a80246c42fb42a15784a4e4..45403e0c0042e823379fde2e5b5ace7875f9cedc 100644 (file)
@@ -17,6 +17,7 @@
 #define SDP_ARP             0x000010\r
 #define SDP_BUFFER_POOL     0x000020\r
 #define SDP_LOCK            0x000040\r
+#define SDP_PERFORMANCE     0x000080\r
 \r
 \r
 // BUGBUG: CONVERT TO A FUNCTION\r