From 6ee76f8e2510d9e1b62c0a6b13a81a70ac515c57 Mon Sep 17 00:00:00 2001 From: tzachid Date: Mon, 21 Nov 2005 12:14:33 +0000 Subject: [PATCH] Minor improvements to SDP send and shutdown. (Rev 84) git-svn-id: svn://openib.tc.cornell.edu/gen1@167 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/ulp/sdp/kernel/SdpBufferPool.cpp | 9 ++-- trunk/ulp/sdp/kernel/SdpSocket.cpp | 58 ++++++++++++++++++++++---- trunk/ulp/sdp/kernel/SdpSocket.h | 3 ++ trunk/ulp/sdp/kernel/SdpTrace.h | 1 + 4 files changed, 58 insertions(+), 13 deletions(-) diff --git a/trunk/ulp/sdp/kernel/SdpBufferPool.cpp b/trunk/ulp/sdp/kernel/SdpBufferPool.cpp index 4f131018..80cda011 100644 --- a/trunk/ulp/sdp/kernel/SdpBufferPool.cpp +++ b/trunk/ulp/sdp/kernel/SdpBufferPool.cpp @@ -91,7 +91,6 @@ BufferPool::GetBuffer( ASSERT(*ppBufferDescriptor == NULL); goto Cleanup; } - m_CurrentlyAllocated++; goto Cleanup; } } @@ -151,7 +150,7 @@ BufferPool::ReturnBuffer(BufferDescriptor *pBufferDescriptor) #if DBG if (m_CurrentlySentBuffers == 1) { - SDP_PRINT(SDP_WARN, SDP_BUFFER_POOL, ("Currently no packets are bing sent m_ClientWaiting = %s\n", + SDP_PRINT(SDP_WARN, SDP_PERFORMANCE, ("Currently no packets are bing sent m_ClientWaiting = %s\n", m_ClientWaiting ? "true" : "false")); } #endif @@ -266,7 +265,9 @@ BufferPool::AllocateBuffer(BufferDescriptor ** ppBufferDescriptor) Cleanup: - if (!NT_SUCCESS(rc)) { + if (NT_SUCCESS(rc)) { + m_CurrentlyAllocated++; + } else { if (pBufferDescriptor != NULL) { if (pBufferDescriptor->pBuffer != NULL) { ExFreePoolWithTag(pBufferDescriptor->pBuffer, SEND_BUFFERS_ALLOCATION_TAG); @@ -274,7 +275,7 @@ Cleanup: ExFreePoolWithTag(pBufferDescriptor, SEND_BUFFERS_ALLOCATION_TAG); pBufferDescriptor = NULL; } - } + } *ppBufferDescriptor = pBufferDescriptor; return rc; } diff --git a/trunk/ulp/sdp/kernel/SdpSocket.cpp b/trunk/ulp/sdp/kernel/SdpSocket.cpp index 0a4e3271..614292b4 100644 --- a/trunk/ulp/sdp/kernel/SdpSocket.cpp +++ b/trunk/ulp/sdp/kernel/SdpSocket.cpp @@ -94,6 +94,7 @@ NTSTATUS SdpSocket::Init( m_Lock.Init(__send_cb2, this); pSocketOutParam->Errno = 0;// No error pSocketOutParam->pSocket = this; // give the user a handle to the socket + KeInitializeEvent(&m_ShutdownCompleteEvent, NotificationEvent , FALSE ); return rc; } @@ -1190,35 +1191,74 @@ VOID SdpSocket::CreateCmRequest( cm_req->pfn_cm_rep_cb = cm_rep_callback; } +// static +VOID SdpSocket::ShutdownCB(VOID* pContext) +{ + SdpSocket *pSocket = (SdpSocket *) pContext; + KeSetEvent(&pSocket->m_ShutdownCompleteEvent, IO_NO_INCREMENT, FALSE);; + +} + +// This is just a wrapper for some operations that have to be done for the code bellow +// It will probably be converted to a macro +VOID WaitForShutdownEvent(KEVENT *ShutdownCompleteEvent) +{ + NTSTATUS rc = STATUS_SUCCESS; + rc = MyKeWaitForSingleObject( + ShutdownCompleteEvent, + UserRequest, + UserMode, + FALSE, + NULL + ); + + ASSERT(NT_SUCCESS(rc)); + ASSERT(rc == STATUS_SUCCESS); + KeClearEvent(ShutdownCompleteEvent); +} + VOID SdpSocket::Shutdown() { + SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("SdpSocket::Shutdown called this = 0x%p\n", this)); + NTSTATUS rc = STATUS_SUCCESS; - //???? locking + // locking ????? // if(m_shutdown - on the lock) ??? ib_api_status_t ib_status; + m_Lock.SignalShutdown(); - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("SdpSocket::Shutdown called this = 0x%p\n", this)); - if (m_qp != NULL) { - ib_destroy_qp(m_qp, NULL); //?????? CALL BACK ??? IMPLMENT + ib_status = ib_destroy_qp(m_qp, ShutdownCB); + ASSERT(ib_status == IB_SUCCESS); + m_qp = NULL; + WaitForShutdownEvent(&m_ShutdownCompleteEvent); } if (m_scq != NULL) { - ib_destroy_cq(m_scq, NULL); //?????? CALL BACK ??? IMPLMENT + ib_destroy_cq(m_scq, ShutdownCB); + m_scq = NULL; + WaitForShutdownEvent(&m_ShutdownCompleteEvent); } if (m_rcq != NULL) { - ib_destroy_cq(m_rcq, NULL); //?????? CALL BACK ??? IMPLMENT + ib_destroy_cq(m_rcq, ShutdownCB); + m_rcq = NULL; + WaitForShutdownEvent(&m_ShutdownCompleteEvent); } - + if (m_pd != NULL) { - ib_dealloc_pd(m_pd, NULL); //?????? CALL BACK ??? IMPLMENT + ib_dealloc_pd(m_pd, ShutdownCB); + m_pd = NULL; + WaitForShutdownEvent(&m_ShutdownCompleteEvent); } if (mh_Ca != NULL) { - ib_close_ca(mh_Ca, NULL); //?????? CALL BACK ??? IMPLMENT + ib_close_ca(mh_Ca, ShutdownCB); + mh_Ca = NULL; + WaitForShutdownEvent(&m_ShutdownCompleteEvent); } + // Now that all ibal operations have finished we can free the memory m_SendBufferPool.ShutDown(); diff --git a/trunk/ulp/sdp/kernel/SdpSocket.h b/trunk/ulp/sdp/kernel/SdpSocket.h index 8895c395..466c65f9 100644 --- a/trunk/ulp/sdp/kernel/SdpSocket.h +++ b/trunk/ulp/sdp/kernel/SdpSocket.h @@ -73,6 +73,7 @@ private: BufferPool m_SendBufferPool; KEVENT m_ConnectCmCompleteEvent; + KEVENT m_ShutdownCompleteEvent; VOID SignalShutdown(); @@ -100,6 +101,8 @@ public: VOID Shutdown(); + static VOID ShutdownCB(VOID* pContext); + NTSTATUS CreateQp(); diff --git a/trunk/ulp/sdp/kernel/SdpTrace.h b/trunk/ulp/sdp/kernel/SdpTrace.h index e3e642eb..45403e0c 100644 --- a/trunk/ulp/sdp/kernel/SdpTrace.h +++ b/trunk/ulp/sdp/kernel/SdpTrace.h @@ -17,6 +17,7 @@ #define SDP_ARP 0x000010 #define SDP_BUFFER_POOL 0x000020 #define SDP_LOCK 0x000040 +#define SDP_PERFORMANCE 0x000080 // BUGBUG: CONVERT TO A FUNCTION -- 2.41.0