From: tzachid Date: Mon, 19 Dec 2005 09:04:26 +0000 (+0000) Subject: [SDP] SDP support WPP X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=44c405023f5010af740df04fed6c498f71cf4e0a;p=~shefty%2Frdma-win.git [SDP] SDP support WPP add define EVEENT_TRACING that move all SDP_PRINT calls to use WPP in check version if tracing is not enabled then use regular kdprint. (Rev 826) git-svn-id: svn://openib.tc.cornell.edu/gen1@208 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/ulp/sdp/kernel/SOURCES b/trunk/ulp/sdp/kernel/SOURCES index e5a3e4ef..59cceaf0 100644 --- a/trunk/ulp/sdp/kernel/SOURCES +++ b/trunk/ulp/sdp/kernel/SOURCES @@ -2,6 +2,8 @@ TARGETNAME=Sdp TARGETPATH=..\..\..\bin\kernel\obj$(BUILD_ALT_DIR) TARGETTYPE=DRIVER +ENABLE_EVENT_TRACING=1 + SOURCES= Sdp.rc \ SdpDriver.cpp \ SdpUserFile.cpp \ @@ -34,6 +36,15 @@ TARGETLIBS= \ TARGETLIBS= $(TARGETLIBS) $(DDK_LIB_PATH)\ntstrsafe.lib !endif +!IFDEF ENABLE_EVENT_TRACING + +C_DEFINES = $(C_DEFINES) -DEVENT_TRACING + +RUN_WPP= $(SOURCES) -km -dll -ext: .c .cpp .h .C .CPP .H\ + -preserveext:.cpp .h\ + -func:SDP_PRINT(LEVEL,FLAGS,MSG,...) +!ENDIF + MSC_WARNING_LEVEL= /W3 PRECOMPILED_INCLUDE=Precompile.h diff --git a/trunk/ulp/sdp/kernel/SdpArp.cpp b/trunk/ulp/sdp/kernel/SdpArp.cpp index 75556008..87ab2288 100644 --- a/trunk/ulp/sdp/kernel/SdpArp.cpp +++ b/trunk/ulp/sdp/kernel/SdpArp.cpp @@ -34,10 +34,19 @@ #pragma warning(disable: 4244 ) +#if defined(EVENT_TRACING) +#ifdef offsetof +#undef offsetof +#endif +#include "SdpArp.tmh" +#endif + + + NTSTATUS SdpArp::Init(PDRIVER_OBJECT DriverObject) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET,("Entering")); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"Entering"); NTSTATUS rc = STATUS_SUCCESS; UNICODE_STRING DevName1; @@ -67,7 +76,7 @@ SdpArp::Init(PDRIVER_OBJECT DriverObject) 0, FILE_NON_DIRECTORY_FILE ); if (!NT_SUCCESS( rc )) { - SDP_PRINT(SDP_ERR, SDP_ARP, ("ZwOpenFile failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"ZwOpenFile failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -81,7 +90,7 @@ SdpArp::Init(PDRIVER_OBJECT DriverObject) (PVOID *) &m_FileObject, NULL ); if (!NT_SUCCESS( rc )) { - SDP_PRINT(SDP_ERR, SDP_ARP, ("ObReferenceObjectByHandle failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"ObReferenceObjectByHandle failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -106,7 +115,7 @@ Cleanup: VOID SdpArp::Shutdown() { - SDP_PRINT(SDP_TRACE, SDP_SOCKET,("this = %p\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = %p\n", this); if (m_FileHandle) { ZwClose(m_FileHandle); m_FileHandle = NULL; @@ -126,12 +135,11 @@ SdpArp::SourcePortGidFromIP( OUT ib_net64_t *SrcCaGuid ) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET,("IP = %d.%d.%d.%d\n", + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "IP = %d.%d.%d.%d\n", (SourceAddr & 0xff000000) >> 24, (SourceAddr & 0xff0000) >> 16, (SourceAddr & 0xff00) >> 8 , - SourceAddr & 0xff - )); + SourceAddr & 0xff); NTSTATUS rc = STATUS_SUCCESS; KEVENT event; PIRP irp; @@ -163,7 +171,7 @@ SdpArp::SourcePortGidFromIP( if(NULL == irp) { rc = STATUS_INSUFFICIENT_RESOURCES; - SDP_PRINT(SDP_ERR, SDP_ARP, ("IoBuildDeviceIoControlRequest failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"IoBuildDeviceIoControlRequest failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -176,12 +184,12 @@ SdpArp::SourcePortGidFromIP( } if(!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_ARP, ("IoCallDriver failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"IoCallDriver failed rc = 0x%x\n", rc ); goto Cleanup; } if (pipoib_ports_out->Size > sizeof temp) { // The number of bytes that we have allocated wasn't enough - SDP_PRINT(SDP_ERR, SDP_ARP, ("pipoib_ports_out.Size = %d\n", pipoib_ports_out->Size )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"pipoib_ports_out.Size = %d\n", pipoib_ports_out->Size ); rc = STATUS_INSUFFICIENT_RESOURCES; goto Cleanup; // BUGBUG: We should try again, with a bigger buffer @@ -189,7 +197,7 @@ SdpArp::SourcePortGidFromIP( rc = SourcePortGidFromPorts(SourceAddr, pipoib_ports_out, SrcPortGuid, SrcCaGuid); if(!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_ARP, ("SourcePortGidFromPorts failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"SourcePortGidFromPorts failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -205,7 +213,7 @@ SdpArp::SourcePortGidFromPorts( OUT ib_net64_t *SrcCaGuid ) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET,("Entered\n")); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"Entered\n"); NTSTATUS rc = STATUS_SUCCESS; KEVENT event; PIRP irp; @@ -221,9 +229,8 @@ SdpArp::SourcePortGidFromPorts( addresses_in.Version = IBAT_IOCTL_VERSION; for (i = 0 ; i < pPorts->NumPorts; i++) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ( - "%d: ca guid = 0x%I64x port guid=0x%I64x\n", - i, CL_NTOH64(pPorts->Ports[i].CaGuid), CL_NTOH64(pPorts->Ports[i].PortGuid))); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "%d: ca guid = 0x%I64x port guid=0x%I64x\n", + i, CL_NTOH64(pPorts->Ports[i].CaGuid), CL_NTOH64(pPorts->Ports[i].PortGuid)); // Do a quary to find out if this is the correct port ASSERT(m_DeviceObject != NULL); @@ -245,7 +252,7 @@ SdpArp::SourcePortGidFromPorts( if(NULL == irp) { rc = STATUS_INSUFFICIENT_RESOURCES; - SDP_PRINT(SDP_ERR, SDP_ARP, ("IoBuildDeviceIoControlRequest failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"IoBuildDeviceIoControlRequest failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -258,12 +265,12 @@ SdpArp::SourcePortGidFromPorts( } if(!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_ARP, ("IoCallDriver failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"IoCallDriver failed rc = 0x%x\n", rc ); goto Cleanup; } if (addresses_out->Size > sizeof temp) { // The number of bytes that we have allocated wasn't enough - SDP_PRINT(SDP_ERR, SDP_ARP, ("addresses_out.Size = %d\n", addresses_out->Size )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"addresses_out.Size = %d\n", addresses_out->Size ); rc = STATUS_INSUFFICIENT_RESOURCES; goto Cleanup; // BUGBUG: We should try again, with a bigger buffer @@ -276,9 +283,9 @@ SdpArp::SourcePortGidFromPorts( ASSERT(addresses_out->Address[j].IpVersion == 4); pIp = (ULONG *) (&addresses_out->Address[j].Address[12]); if (*pIp == CL_NTOH32(SourceAddr)) { - SDP_PRINT(SDP_TRACE, SDP_ARP, - ("Found the IP: ca guid = 0x%I64x port guid=0x%I64x\n", - CL_NTOH64(pPorts->Ports[i].CaGuid), CL_NTOH64(pPorts->Ports[i].PortGuid))); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_ARP, + "Found the IP: ca guid = 0x%I64x port guid=0x%I64x\n", + CL_NTOH64(pPorts->Ports[i].CaGuid), CL_NTOH64(pPorts->Ports[i].PortGuid)); ASSERT(rc == STATUS_SUCCESS); *SrcPortGuid = pPorts->Ports[i].PortGuid; *SrcCaGuid = pPorts->Ports[i].CaGuid; @@ -289,13 +296,13 @@ SdpArp::SourcePortGidFromPorts( } // If we have reached here the data was not found - SDP_PRINT(SDP_WARN, SDP_ARP, - ("HCA not found for ip=%d.%d.%d.%d\n", + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_ARP, + "HCA not found for ip=%d.%d.%d.%d\n", (SourceAddr & 0xff000000) >> 24, (SourceAddr & 0xff0000) >> 16, (SourceAddr & 0xff00) >> 8 , SourceAddr & 0xff - )); + ); rc = STATUS_NOT_FOUND; Cleanup: @@ -310,7 +317,7 @@ SdpArp::DestPortGidFromMac( IN MAC_ADDR DestMac, OUT ib_gid_t *pDestPortGid) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET,("MAC = ????\n")); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"MAC = ????\n"); NTSTATUS rc = STATUS_SUCCESS; KEVENT event; @@ -344,7 +351,7 @@ SdpArp::DestPortGidFromMac( if(NULL == irp) { rc = STATUS_INSUFFICIENT_RESOURCES; - SDP_PRINT(SDP_ERR, SDP_ARP, ("IoBuildDeviceIoControlRequest failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"IoBuildDeviceIoControlRequest failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -357,7 +364,7 @@ SdpArp::DestPortGidFromMac( } if(!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_ARP, ("IoCallDriver failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"IoCallDriver failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -394,19 +401,19 @@ SdpArp::QueryPathRecord( query_context.path_rec = path_rec; - SDP_PRINT( SDP_TRACE, SDP_ARP, ("Query for path from %I64x to %I64x\n", - SrcPortGuid, DestPortGid.unicast.interface_id) ); + SDP_PRINT( TRACE_LEVEL_INFORMATION, SDP_ARP, "Query for path from %I64x to %I64x\n", + SrcPortGuid, DestPortGid.unicast.interface_id); ib_status = ib_query( g_pSdpDriver->m_al_handle, &query_req, &query_handle ); if ( ib_status != IB_SUCCESS) { - SDP_PRINT(SDP_ERR, SDP_ARP, ("ib_query failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"ib_query failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } if( query_context.status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_ARP, ("query_context.status failed ib_status = 0x%d\n", query_context.status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_ARP,"query_context.status failed ib_status = 0x%d\n", query_context.status ); rc = IB2Status(query_context.status); goto Cleanup; } @@ -437,7 +444,7 @@ SdpArp::query_pr_callback( ib_api_status_t status; - SDP_PRINT( SDP_TRACE, SDP_ARP,("query_pr_callback status is %d irql=%d\n", p_query_rec->status, KeGetCurrentIrql()) ); + SDP_PRINT( TRACE_LEVEL_INFORMATION, SDP_ARP,"query_pr_callback status is %d irql=%d\n", p_query_rec->status, KeGetCurrentIrql()); query_context->status = p_query_rec->status; @@ -459,7 +466,7 @@ SdpArp::query_pr_callback( ASSERT(status == IB_SUCCESS); if( status != IB_SUCCESS ) { - SDP_PRINT( SDP_ERR, SDP_ARP, ("ib_put_mad failed (%d)\n", status) ); + SDP_PRINT( TRACE_LEVEL_ERROR, SDP_ARP,"ib_put_mad failed "); } } else { // When do we free this mad ??? diff --git a/trunk/ulp/sdp/kernel/SdpBufferPool.cpp b/trunk/ulp/sdp/kernel/SdpBufferPool.cpp index 17c93df3..c58d34eb 100644 --- a/trunk/ulp/sdp/kernel/SdpBufferPool.cpp +++ b/trunk/ulp/sdp/kernel/SdpBufferPool.cpp @@ -30,16 +30,26 @@ // Author: Tzachi Dar -#pragma warning(disable: 4244 ) #include "preCompile.h" +#pragma warning(disable: 4244 ) + +#if defined(EVENT_TRACING) +#ifdef offsetof +#undef offsetof +#endif +#include "SdpBufferPool.tmh" +#endif + + + //static NTSTATUS BufferDescriptor::AllocateBuffer(BufferDescriptor ** ppBufferDescriptor, int BufferSize, int Tag) { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("\n")); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL,"\n"); NTSTATUS rc = STATUS_SUCCESS; BufferDescriptor *pBufferDescriptor = NULL; @@ -53,7 +63,7 @@ BufferDescriptor::AllocateBuffer(BufferDescriptor ** ppBufferDescriptor, int Buf ); if (pBufferDescriptor == NULL) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("ExAllocatePoolWithTag failed \n")); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"ExAllocatePoolWithTag failed \n"); rc = STATUS_NO_MEMORY; goto Cleanup; } @@ -65,7 +75,7 @@ BufferDescriptor::AllocateBuffer(BufferDescriptor ** ppBufferDescriptor, int Buf pBufferDescriptor->pBuffer = MmAllocateContiguousMemory(BufferSize, mem); if (pBufferDescriptor->pBuffer == NULL) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("ExAllocatePoolWithTag failed BufferSize = %d irql=%d\n",BufferSize, KeGetCurrentIrql())); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"ExAllocatePoolWithTag failed BufferSize = %d irql=%d\n",BufferSize, KeGetCurrentIrql()); rc = STATUS_NO_MEMORY; goto Cleanup; } @@ -130,7 +140,7 @@ BufferPool::Init( ) { - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL,"this = 0x%p \n",this); m_MaxBuffers = MaxBuffers; m_MaxConcurrentSends = MaxConcurrentSends; m_MaxMessageSize = MaxMessageSize; @@ -165,7 +175,7 @@ BufferPool::GetBuffer( BufferDescriptor **ppBufferDescriptor ) { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL, "this = 0x%p \n",this); AssertLocked(); NTSTATUS rc = STATUS_SUCCESS; @@ -179,7 +189,7 @@ BufferPool::GetBuffer( // we need to alocate a new buffer rc = BufferDescriptor::AllocateBuffer(ppBufferDescriptor, m_MaxMessageSize, SEND_BUFFERS_ALLOCATION_TAG); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("AllocateBuffer failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL, "AllocateBuffer failed rc = 0x%x\n", rc ); ASSERT(*ppBufferDescriptor == NULL); goto Cleanup; } @@ -201,8 +211,8 @@ queue NTSTATUS BufferPool::AddBufferToQueuedList(BufferDescriptor *pBufferDescriptor) { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p pBufferDescriptor = 0x%x\n",this, - pBufferDescriptor)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL, "this = 0x%p pBufferDescriptor = 0x%p\n",this, + pBufferDescriptor); AssertLocked(); NTSTATUS rc = STATUS_SUCCESS; @@ -218,7 +228,7 @@ BufferPool::AddBufferToQueuedList(BufferDescriptor *pBufferDescriptor) m_QueuedPackets.InsertTailList(&pBufferDescriptor->BuffersList); rc = SendBuffersIfCan(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("SendBuffersIfCan failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"SendBuffersIfCan failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -234,7 +244,7 @@ Cleanup: NTSTATUS BufferPool::ReturnBuffer(BufferDescriptor *pBufferDescriptor) { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p buffer=0x%p\n",this, pBufferDescriptor)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL,"this = 0x%p buffer=0x%p\n",this, pBufferDescriptor); AssertLocked(); bool CreditUpdate = false; bool DissconnectMessage = false; @@ -242,7 +252,7 @@ BufferPool::ReturnBuffer(BufferDescriptor *pBufferDescriptor) #if DBG if (m_CurrentlySentBuffers == 1) { - SDP_PRINT(SDP_WARN, SDP_PERFORMANCE, ("Currently no packets are bing sent\n")); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_PERFORMANCE, "Currently no packets are bing sent \n"); } #endif ASSERT( pBufferDescriptor->GetFlags() == CREDIT_UPDATE || @@ -262,7 +272,7 @@ BufferPool::ReturnBuffer(BufferDescriptor *pBufferDescriptor) m_PostCreditsWhenCan = false; rc = PostCredits(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("PostCredits failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"PostCredits failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -287,7 +297,7 @@ BufferPool::ReturnBuffer(BufferDescriptor *pBufferDescriptor) if ((RemainingToCopy(pIrp) < m_MaxMessageSize * m_FreePackets.Size())) { rc = m_pSdpSocket->RequestCallBack(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("RequestCallBack failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL, "PostCredits failed rc = 0x%x\n", rc ); goto Cleanup; } m_CallBackPending = true; @@ -295,7 +305,7 @@ BufferPool::ReturnBuffer(BufferDescriptor *pBufferDescriptor) } if (DissconnectMessage) { - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("We have recieved a DissconnectMessage complition\n" )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL,"We have recieved a DissconnectMessage complition\n" ); m_pSdpSocket->DisconectSentEvent(); } } @@ -305,7 +315,7 @@ BufferPool::ReturnBuffer(BufferDescriptor *pBufferDescriptor) */ rc = SendBuffersIfCan(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("SendBuffersIfCan failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL, "SendBuffersIfCan failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -328,7 +338,7 @@ BufferPool::AddToUserBuffers( IRP* pIrp ) { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL, "this = 0x%p \n",this); AssertLocked(); NTSTATUS rc = STATUS_SUCCESS; @@ -378,7 +388,7 @@ the user mode thread as fast as possible. NTSTATUS BufferPool::UsersThreadCallBack() { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL, "this = 0x%p \n",this); AssertLocked(); ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); IRP *pIrp = NULL; @@ -394,7 +404,7 @@ BufferPool::UsersThreadCallBack() while (m_UserPackets.Size() > 0) { rc = GetBuffer(&pBufferDescriptor); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("GetBuffer failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "GetBuffer failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -415,7 +425,7 @@ BufferPool::UsersThreadCallBack() rc = pBufferDescriptor->WriteData((CHAR *)GetUserBuffer(pIrp) + GetCoppied(pIrp), CopySize); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("pBufferDescriptor->WriteData failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "pBufferDescriptor->WriteData failed rc = 0x%x\n", rc ); // free the buffer that you have rc1 = ReturnBuffer(pBufferDescriptor); ASSERT(NT_SUCCESS(rc1)); @@ -428,7 +438,7 @@ BufferPool::UsersThreadCallBack() pBufferDescriptor->SetMid(SDP_MID_DATA); rc = AddBufferToQueuedList(pBufferDescriptor); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("AddBufferToQueuedList failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "AddBufferToQueuedList failed rc = 0x%x\n", rc ); // free the buffer that you have rc1 = ReturnBuffer(pBufferDescriptor); ASSERT(NT_SUCCESS(rc1)); @@ -466,7 +476,7 @@ Cleanup: NTSTATUS BufferPool::SendBuffersIfCan() { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL,"this = 0x%p \n",this); AssertLocked(); NTSTATUS rc = STATUS_SUCCESS; @@ -475,7 +485,7 @@ BufferPool::SendBuffersIfCan() m_PostCreditsWhenCan = false; rc = PostCredits(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("PostCredits failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"PostCredits failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -488,7 +498,7 @@ BufferPool::SendBuffersIfCan() BufferDescriptor *pBufferDescriptor = CONTAINING_RECORD(item, BufferDescriptor , BuffersList); rc = SendBuffer(pBufferDescriptor); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("SendBuffer failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"SendBuffer failed rc = 0x%x\n", rc ); m_FreePackets.InsertTailList(&pBufferDescriptor->BuffersList); goto Cleanup; } @@ -512,7 +522,7 @@ BufferPool::CloseSocket() LIST_ENTRY *item = NULL; IRP *pIrp = NULL; - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p \n")); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL, "this = 0x%p \n",this); AssertLocked(); // All IRP's that were not compleated, will be compleated as cancelled while (m_UserPackets.Size() > 0 ) { @@ -534,7 +544,7 @@ BufferPool::CloseSocket() VOID BufferPool::ShutDown() { - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL,"this = 0x%p \n",this); //AssertLocked(); BufferDescriptor *pBufferDescriptor = NULL; @@ -571,7 +581,7 @@ BufferPool::ShutDown() NTSTATUS BufferPool::SendBuffer(BufferDescriptor *pBufferDescriptor) { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL,"this = 0x%p \n",this); AssertLocked(); NTSTATUS rc = STATUS_SUCCESS; @@ -604,15 +614,13 @@ BufferPool::SendBuffer(BufferDescriptor *pBufferDescriptor) send_wr.ds_array = &pBufferDescriptor->ds_array; - SDP_PRINT(SDP_DEBUG, SDP_CREDITS, ("Sending buffer pHeader->recv_bufs = %d pHeader->seq_ack = %d\n", - CL_NTOH16(pHeader->recv_bufs), - CL_NTOH32(pHeader->seq_ack) - )); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_CREDITS, "Sending buffer pHeader->recv_bufs = %d pHeader->seq_ack = %d\n", CL_NTOH16(pHeader->recv_bufs), + CL_NTOH32(pHeader->seq_ack)); ib_api_status_t ib_status = ib_post_send(m_qp, &send_wr, NULL); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("ib_post_send failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"ib_post_send failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -629,7 +637,7 @@ Cleanup: NTSTATUS BufferPool::PostCredits() { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL,"this = 0x%p \n",this); AssertLocked(); NTSTATUS rc = STATUS_SUCCESS; @@ -644,8 +652,8 @@ BufferPool::PostCredits() } if (m_pSdpSocket->GetState() != SS_CONNECTED) { - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p - Not sending credits," - " because state = %s \n",this, SdpSocket::SS2String(m_pSdpSocket->GetState() ))); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL, "this = 0x%p - Not sending credits," + " because state = %s \n",this, SdpSocket::SS2String(m_pSdpSocket->GetState() )); // We will have to send them once we can m_PostCreditsWhenCan = true; goto Cleanup; @@ -660,7 +668,7 @@ BufferPool::PostCredits() SEND_BUFFERS_ALLOCATION_TAG ); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("AllocateBuffer failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"AllocateBuffer failed rc = 0x%x\n", rc ); ASSERT(m_CreditdBufferDescriptor == NULL); goto Cleanup; } @@ -673,7 +681,7 @@ BufferPool::PostCredits() m_CreditdBufferDescriptor->SetMid(SDP_MID_DATA); rc = SendBuffer(m_CreditdBufferDescriptor); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("SendBuffer failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"SendBuffer failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -687,7 +695,7 @@ Cleanup: NTSTATUS BufferPool::PostDisConn() { - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL,"this = 0x%p \n",this); AssertLocked(); NTSTATUS rc = STATUS_SUCCESS; BufferDescriptor *pBufferDescriptor = NULL; @@ -698,7 +706,7 @@ NTSTATUS BufferPool::PostDisConn() SEND_BUFFERS_ALLOCATION_TAG ); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("AllocateBuffer failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"AllocateBuffer failed rc = 0x%x\n", rc ); ASSERT(m_CreditdBufferDescriptor == NULL); goto Cleanup; } @@ -710,7 +718,7 @@ NTSTATUS BufferPool::PostDisConn() pBufferDescriptor->SetMid(SDP_MID_DISCONNECT); rc = AddBufferToQueuedList(pBufferDescriptor); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("AddBufferToQueuedList failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"AddBufferToQueuedList failed rc = 0x%x\n", rc ); goto Cleanup; } diff --git a/trunk/ulp/sdp/kernel/SdpBufferPool.h b/trunk/ulp/sdp/kernel/SdpBufferPool.h index bfa8a8bb..ac7108e7 100644 --- a/trunk/ulp/sdp/kernel/SdpBufferPool.h +++ b/trunk/ulp/sdp/kernel/SdpBufferPool.h @@ -75,7 +75,7 @@ public: while (current != Item) { if (current == & m_Data) { ASSERT(FALSE); - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("Object is not in the list\n")); + //SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"Object is not in the list\n"); } current = current->Flink; } @@ -109,7 +109,7 @@ public: char *pStart = (char *) pBuffer + sizeof msg_hdr_bsdh; rc = CopyFromUser(pStart, pData, Size); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("CopyFromUser failed rc = 0x%x\n", rc )); + //SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"CopyFromUser failed rc = 0x%x\n", rc ); goto Cleanup; } DataSize = Size; @@ -125,7 +125,7 @@ public: char *pStart = (char *) pBuffer + DataStart; rc = ::CopyToUser(pData, pStart, Size); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("CopyToUser failed rc = 0x%x\n", rc )); + //SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"CopyToUser failed rc = 0x%x\n", rc ); goto Cleanup; } DataStart += Size; @@ -256,7 +256,7 @@ public: VOID SetRemoteRecvBuf (uint16_t rRecvBuf) { if (m_rRecvBuf == 2) { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL,("m_rRecvBuf = %d, it is being set to %d seqnum = %d\n", m_rRecvBuf, rRecvBuf, m_SendSeq)); + //SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL,"m_rRecvBuf = %d, it is being set to %d seqnum = %d\n", m_rRecvBuf, rRecvBuf, m_SendSeq); } ASSERT(rRecvBuf < 1000); m_rRecvBuf = rRecvBuf; diff --git a/trunk/ulp/sdp/kernel/SdpConnectionList.cpp b/trunk/ulp/sdp/kernel/SdpConnectionList.cpp index fd5c8693..c4df3662 100644 --- a/trunk/ulp/sdp/kernel/SdpConnectionList.cpp +++ b/trunk/ulp/sdp/kernel/SdpConnectionList.cpp @@ -32,10 +32,18 @@ #include "Precompile.h" +#if defined(EVENT_TRACING) +#ifdef offsetof +#undef offsetof +#endif +#include "SdpConnectionList.tmh" +#endif + + VOID ConnectionList::Init(SdpSocket *pSdpSocket) { - SDP_PRINT(SDP_TRACE, SDP_CONNECTION_LIST, ("this = 0x%p \n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_CONNECTION_LIST,"this = 0x%p \n", this); m_pSdpSocket = pSdpSocket; m_ClientWaiting = false; KeInitializeEvent(&m_WaitForConnection, NotificationEvent , FALSE ); @@ -51,8 +59,8 @@ ConnectionList::Init(SdpSocket *pSdpSocket) VOID ConnectionList::CloseSocket() { - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p m_WaitingClients = %s\n", - m_ClientWaiting ? "true" : "false")); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL, "this = 0x%p m_WaitingClients = %s\n",this, + m_ClientWaiting ? "true" : "false"); AssertLocked(); if (m_ClientWaiting) { @@ -67,7 +75,7 @@ ConnectionList::CloseSocket() VOID ConnectionList::Shutdown() { //?????AssertLocked(); - SDP_PRINT(SDP_TRACE, SDP_CONNECTION_LIST, ("this = 0x%p \n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_CONNECTION_LIST,"this = 0x%p \n", this); // Go over both lists, and shutdown all their objects LIST_ENTRY *item = NULL; SdpSocket *pSocket = NULL; @@ -93,7 +101,7 @@ VOID ConnectionList::Shutdown() bool ConnectionList::IsFull() { - SDP_PRINT(SDP_TRACE, SDP_CONNECTION_LIST, ("this = 0x%p \n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_CONNECTION_LIST,"this = 0x%p \n", this); AssertLocked(); int CurrentConnections = m_ReplySentConnections.Size() + m_ReadyConnections.Size(); @@ -103,7 +111,7 @@ ConnectionList::IsFull() NTSTATUS ConnectionList::AddConnectionToReplySent(SdpSocket *pNewSocket) { - SDP_PRINT(SDP_TRACE, SDP_CONNECTION_LIST, ("this = 0x%p \n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_CONNECTION_LIST,"this = 0x%p \n", this); AssertLocked(); m_ReplySentConnections.InsertTailList(&pNewSocket->m_ListeningSocketList); pNewSocket->AddRef(); @@ -115,7 +123,7 @@ ConnectionList::AddConnectionToReplySent(SdpSocket *pNewSocket) NTSTATUS ConnectionList::VerifyConnictionInReplySent(SdpSocket *pNewSocket) { - SDP_PRINT(SDP_TRACE, SDP_CONNECTION_LIST, ("this = 0x%p \n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_CONNECTION_LIST,"this = 0x%p \n", this); AssertLocked(); SdpSocket *pSocket = NULL; #if DBG @@ -141,7 +149,7 @@ ConnectionList::VerifyConnictionInReplySent(SdpSocket *pNewSocket) VOID ConnectionList::MoveConnectionFromReplyToReady(SdpSocket *pNewSocket) { - SDP_PRINT(SDP_TRACE, SDP_CONNECTION_LIST, ("this = 0x%p \n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_CONNECTION_LIST,"this = 0x%p \n", this); AssertLocked(); pNewSocket->AssertLocked(); // just take it out from one list and put it in the other @@ -154,7 +162,7 @@ ConnectionList::MoveConnectionFromReplyToReady(SdpSocket *pNewSocket) VOID ConnectionList::FreeWaitingIfCan() { - SDP_PRINT(SDP_TRACE, SDP_CONNECTION_LIST, ("this = 0x%p \n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_CONNECTION_LIST,"this = 0x%p \n", this); AssertLocked(); if (m_ClientWaiting) { ASSERT(m_ReadyConnections.Size() > 0); @@ -169,7 +177,7 @@ ConnectionList::AcceptAReadyConnection( KEVENT **ppEvent ) { - SDP_PRINT(SDP_TRACE, SDP_CONNECTION_LIST, ("this = 0x%p \n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_CONNECTION_LIST,"this = 0x%p \n", this); ASSERT(*ppEvent == NULL); ASSERT(*ppNewSocket == NULL); diff --git a/trunk/ulp/sdp/kernel/SdpDriver.cpp b/trunk/ulp/sdp/kernel/SdpDriver.cpp index 11585270..3d52f827 100644 --- a/trunk/ulp/sdp/kernel/SdpDriver.cpp +++ b/trunk/ulp/sdp/kernel/SdpDriver.cpp @@ -29,9 +29,18 @@ */ // Author: Tzachi Dar - #include "Precompile.h" + +#if defined(EVENT_TRACING) +#ifdef offsetof +#undef offsetof +#endif +#include "SdpDriver.tmh" +#endif + + + SdpDriver *g_pSdpDriver = NULL; FAST_IO_DISPATCH FastIoDispatch = @@ -54,7 +63,7 @@ VOID DriverUnload ( IN PDRIVER_OBJECT pDriverObject ) { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("called pDriverObject = 0x%x\n", pDriverObject )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"called pDriverObject = 0x%x\n", (uint32_t)pDriverObject ); ib_api_status_t ib_status; g_pSdpDriver->Shutdown(); @@ -63,7 +72,9 @@ VOID DriverUnload ( ib_status = ib_close_al(g_pSdpDriver->m_al_handle); g_pSdpDriver->m_al_handle = NULL; ASSERT( ib_status == IB_SUCCESS); - +#if defined(EVENT_TRACING) + WPP_CLEANUP(pDriverObject); +#endif UNICODE_STRING LinkName; RtlInitUnicodeString( &LinkName, SDP_LINK_NAME ); @@ -87,8 +98,10 @@ extern "C" NTSTATUS DriverEntry ( bool LinkCreated = false; UNICODE_STRING DevName1, LinkName; int i; - - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("called\n" )); +#if defined(EVENT_TRACING) + WPP_INIT_TRACING(pDriverObject, pRegistryPath); +#endif + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"called\n" ); // fill the device functions pDriverObject->DriverUnload = DriverUnload; @@ -114,7 +127,7 @@ extern "C" NTSTATUS DriverEntry ( FALSE, &pDevObj ); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("IoCreateDevice failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"IoCreateDevice failed rc = 0x%x\n", rc ); goto Cleanup; } DeviceCreated = true; @@ -123,7 +136,7 @@ extern "C" NTSTATUS DriverEntry ( rc = pSdpDriver->Init(pDevObj, pDriverObject); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpDriver->Init failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpDriver->Init failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -135,7 +148,7 @@ extern "C" NTSTATUS DriverEntry ( ); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("IoCreateSymbolicLink failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"IoCreateSymbolicLink failed rc = 0x%x\n", rc ); goto Cleanup; } LinkCreated = true; @@ -144,7 +157,7 @@ extern "C" NTSTATUS DriverEntry ( ib_status = ib_open_al(&pSdpDriver->m_al_handle); #pragma warning( pop ) if ( ib_status != IB_SUCCESS) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("ib_open_al failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"ib_open_al failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -258,17 +271,17 @@ NTSTATUS SdpDriver::Dispatch( switch (pIrpSp->MajorFunction) { case IRP_MJ_CREATE: { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IRP_MJ_CREATE pIrpSp->FileObject = 0x%x\n", - pIrpSp->FileObject )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER, "IRP_MJ_CREATE pIrpSp->FileObject = 0x%x\n", + (uint32_t)pIrpSp->FileObject ); pSdpUserFile = new SdpUserFile; if (pSdpUserFile == NULL) { rc = STATUS_NO_MEMORY; - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("new SdpUserFile failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"new SdpUserFile failed rc = 0x%x\n", rc ); goto Cleanup; } rc = pSdpUserFile->Init(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpUserFile->Init failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpUserFile->Init failed rc = 0x%x\n", rc ); goto Cleanup; } // Everything went well, and windows is still using this object. @@ -282,8 +295,8 @@ NTSTATUS SdpDriver::Dispatch( } case IRP_MJ_CLEANUP: { // All IRPs that were associated with this device should be cleaned - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IRP_MJ_CLEANUP pIrpSp->FileObject = 0x%x\n", - pIrpSp->FileObject )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"IRP_MJ_CLEANUP pIrpSp->FileObject = 0x%p\n", + pIrpSp->FileObject ); pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; // The object is being shutdown, and it's cleaning should // be started @@ -300,16 +313,16 @@ NTSTATUS SdpDriver::Dispatch( // Receipt of this request indicates that the last handle of the file object // that is associated with the target device object has been closed and //released. All outstanding I/O requests have been completed or canceled. - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IRP_MJ_CLOSE pIrpSp->FileObject = 0x%x\n", - pIrpSp->FileObject )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER, "IRP_MJ_CLOSE pIrpSp->FileObject = 0x%p\n", + pIrpSp->FileObject); pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; // Nothing to do, the referance count will be removed once // we leave the function break; } case IRP_MJ_DEVICE_CONTROL: { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IRP_MJ_DEVICE_CONTROL pIrpSp->FileObject = 0x%x\n", - pIrpSp->FileObject )); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IRP_MJ_DEVICE_CONTROL pIrpSp->FileObject = 0x%p\n", + pIrpSp->FileObject); // IOCTLs are allowed only for user mode processes if (UserMode != pIrp->RequestorMode) { @@ -370,8 +383,8 @@ NTSTATUS SdpDriver::Dispatch( } __except(EXCEPTION_EXECUTE_HANDLER) { rc = STATUS_ACCESS_VIOLATION; - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("IRP_MJ_DEVICE_CONTROL Access " - "violition when trying to read/write data\n" )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"IRP_MJ_DEVICE_CONTROL Access " + "violition when trying to read/write data\n"); ASSERT(FALSE); goto Cleanup; @@ -413,8 +426,7 @@ Cleanup: #define VERIFY_BUFFERS(InputBufferLength, OutputBufferLength, InStruct, OutStruct) \ if ((InputBufferLength < sizeof (InStruct)) || \ (OutputBufferLength < sizeof (OutStruct))) { \ - SDP_PRINT(SDP_ERR, SDP_DRIVER, \ - ("DispatchDeviceIoControl bad buffer sizes\n" )); \ + /*SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER, "DispatchDeviceIoControl bad buffer sizes\n" ); */ \ ASSERT(FALSE); \ rc = STATUS_ACCESS_VIOLATION; \ goto Cleanup; \ @@ -427,13 +439,13 @@ SdpDriver::Init(PDEVICE_OBJECT pDevObj, PDRIVER_OBJECT DriverObject) m_pDevObj = pDevObj; m_pSdpArp = new SdpArp; if (m_pSdpArp == NULL) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("new SdpArp failed \n")); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"new SdpArp failed \n"); rc = STATUS_NO_MEMORY; goto Cleanup; } rc = m_pSdpArp->Init(DriverObject); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("m_pSdpArp->Init failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"m_pSdpArp->Init failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -478,7 +490,7 @@ SdpDriver::DispatchDeviceIoControl( switch (IoControlCode) { case IOCTL_WSP_SOCKET : { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IOCTL_WSP_SOCKET recieved\n" )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"IOCTL_WSP_SOCKET recieved\n" ); VERIFY_BUFFERS(InputBufferLength, OutputBufferLength, WspSocketIn, WspSocketOut); OutputDataSize = sizeof (WspSocketOut); @@ -489,17 +501,17 @@ SdpDriver::DispatchDeviceIoControl( pSdpSocket = new SdpSocket; if (pSdpSocket == NULL) { rc = STATUS_NO_MEMORY; - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("new SdpSocket failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"new SdpSocket failed rc = 0x%x\n", rc ); goto Cleanup; } rc = pSdpSocket->Init(&wspSocketIn, pWspSocketOut, pSdpUserFile); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpSocket->Init failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpSocket->Init failed rc = 0x%x\n", rc ); goto Cleanup; } rc = pSdpUserFile->AddSocket(pSdpSocket); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpUserFile->AddSocket failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpUserFile->AddSocket failed rc = 0x%x\n", rc ); pSdpSocket->Shutdown(); goto Cleanup; } @@ -508,7 +520,7 @@ SdpDriver::DispatchDeviceIoControl( case IOCTL_WSP_CONNECT : { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IOCTL_WSP_CONNECT recieved\n" )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"IOCTL_WSP_CONNECT recieved\n" ); VERIFY_BUFFERS(InputBufferLength, OutputBufferLength, WspConnectIn, WspConnectOut); OutputDataSize = sizeof (WspConnectOut); @@ -518,14 +530,14 @@ SdpDriver::DispatchDeviceIoControl( pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; pSdpSocket = pSdpUserFile->SocketByPointer(wspConnectIn.pSocket); if (pSdpSocket == NULL) { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IOCTL_WSP_CONNECT socket %x not found\n",wspConnectIn.pSocket)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IOCTL_WSP_CONNECT socket %p not found\n",wspConnectIn.pSocket); // This is a well defined winsock error pWspConnectOut->Errno = WSAENOTSOCK; goto Cleanup; } rc = pSdpSocket->WSPConnect(&wspConnectIn, pWspConnectOut); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpSocket->WSPConnect failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpSocket->WSPConnect failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -533,7 +545,7 @@ SdpDriver::DispatchDeviceIoControl( case IOCTL_WSP_SEND : { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IOCTL_WSP_SEND recieved\n" )); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IOCTL_WSP_SEND recieved\n" ); VERIFY_BUFFERS(InputBufferLength, OutputBufferLength, WspSendIn, WspSendOut); OutputDataSize = sizeof (WspSendOut); @@ -543,14 +555,14 @@ SdpDriver::DispatchDeviceIoControl( pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; pSdpSocket = pSdpUserFile->SocketByPointer(wspSendIn.pSocket); if (pSdpSocket == NULL) { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IOCTL_WSP_SEND socket %x not found\n",wspSendIn.pSocket)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IOCTL_WSP_SEND socket %p not found\n",wspSendIn.pSocket); // This is a well defined winsock error pWspSendOut->Errno = WSAENOTSOCK; goto Cleanup; } rc = pSdpSocket->WSPSend(&wspSendIn, pWspSendOut, pIrp); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpSocket->WSPSend failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpSocket->WSPSend failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -558,7 +570,7 @@ SdpDriver::DispatchDeviceIoControl( case IOCTL_WSP_RECV : { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IOCTL_WSP_RECV recieved\n" )); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IOCTL_WSP_RECV recieved\n" ); VERIFY_BUFFERS(InputBufferLength, OutputBufferLength, WspRecvIn, WspRecvOut); OutputDataSize = sizeof (WspRecvOut); @@ -568,14 +580,14 @@ SdpDriver::DispatchDeviceIoControl( pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; pSdpSocket = pSdpUserFile->SocketByPointer(wspRecvIn.pSocket); if (pSdpSocket == NULL) { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IOCTL_WSP_RECV socket %x not found\n",wspRecvIn.pSocket)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IOCTL_WSP_RECV socket %p not found\n",wspRecvIn.pSocket); // This is a well defined winsock error pWspRecvOut->Errno = WSAENOTSOCK; goto Cleanup; } rc = pSdpSocket->WSPRecv(&wspRecvIn, pWspRecvOut); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpSocket->WSPRecv failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpSocket->WSPRecv failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -583,7 +595,7 @@ SdpDriver::DispatchDeviceIoControl( case IOCTL_WSP_BIND: { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IOCTL_WSP_BIND recieved\n" )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"IOCTL_WSP_BIND recieved\n" ); VERIFY_BUFFERS(InputBufferLength, OutputBufferLength, WspBindIn, WspBindOut); OutputDataSize = sizeof (WspBindOut); @@ -593,14 +605,14 @@ SdpDriver::DispatchDeviceIoControl( pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; pSdpSocket = pSdpUserFile->SocketByPointer(wspBindIn.pSocket); if (pSdpSocket == NULL) { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IOCTL_WSP_BIND socket %x not found\n", wspBindIn.pSocket)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IOCTL_WSP_BIND socket %p not found\n", wspBindIn.pSocket); // This is a well defined winsock error pWspBindOut->Errno = WSAENOTSOCK; goto Cleanup; } rc = pSdpSocket->WSPBind(&wspBindIn, pWspBindOut); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpSocket->WSPBind failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpSocket->WSPBind failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -608,7 +620,7 @@ SdpDriver::DispatchDeviceIoControl( case IOCTL_WSP_LISTEN: { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IOCTL_WSP_LISTEN recieved\n" )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"IOCTL_WSP_LISTEN recieved\n" ); VERIFY_BUFFERS(InputBufferLength, OutputBufferLength, WspListenIn, WspListenOut); OutputDataSize = sizeof (WspListenOut); @@ -618,14 +630,14 @@ SdpDriver::DispatchDeviceIoControl( pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; pSdpSocket = pSdpUserFile->SocketByPointer(wspListenIn.pSocket); if (pSdpSocket == NULL) { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IOCTL_WSP_LISTEN socket %x not found\n",wspListenIn.pSocket)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IOCTL_WSP_LISTEN socket %p not found\n",wspListenIn.pSocket); // This is a well defined winsock error pWspListenOut->Errno = WSAENOTSOCK; goto Cleanup; } rc = pSdpSocket->WSPListen(&wspListenIn, pWspListenOut); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpSocket->WSPListen failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpSocket->WSPListen failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -633,7 +645,7 @@ SdpDriver::DispatchDeviceIoControl( case IOCTL_WSP_ACCEPT: { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IOCTL_WSP_ACCEPT recieved\n" )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"IOCTL_WSP_ACCEPT recieved\n" ); VERIFY_BUFFERS(InputBufferLength, OutputBufferLength, WspAcceptIn, WspAcceptOut); OutputDataSize = sizeof (WspAcceptOut); @@ -643,21 +655,21 @@ SdpDriver::DispatchDeviceIoControl( pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; pSdpSocket = pSdpUserFile->SocketByPointer(wspAcceptIn.pSocket); if (pSdpSocket == NULL) { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IOCTL_WSP_ACCEPT socket %x not found\n",wspAcceptIn.pSocket)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IOCTL_WSP_ACCEPT socket %p not found\n",wspAcceptIn.pSocket); // This is a well defined winsock error pWspAcceptOut->Errno = WSAENOTSOCK; goto Cleanup; } rc = pSdpSocket->WSPAccept(&wspAcceptIn, pWspAcceptOut); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpSocket->WSPAccept failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpSocket->WSPAccept failed rc = 0x%x\n", rc ); goto Cleanup; } if (pWspAcceptOut->pAccaptedSocket != NULL) { pAcceptedSdpSocket = (SdpSocket *) pWspAcceptOut->pAccaptedSocket; rc = pSdpUserFile->AddSocket(pAcceptedSdpSocket); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpUserFile->AddSocket failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpUserFile->AddSocket failed rc = 0x%x\n", rc ); pAcceptedSdpSocket->Shutdown(); goto Cleanup; } @@ -667,7 +679,7 @@ SdpDriver::DispatchDeviceIoControl( case IOCTL_WSP_GET_XXX_NAME: { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IOCTL_WSP_GET_XXX_NAME recieved\n" )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"IOCTL_WSP_GET_XXX_NAME recieved\n" ); VERIFY_BUFFERS(InputBufferLength, OutputBufferLength, WspGetSockXXIn, WspGetSockXXOut); OutputDataSize = sizeof (WspGetSockXXOut); @@ -677,21 +689,21 @@ SdpDriver::DispatchDeviceIoControl( pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; pSdpSocket = pSdpUserFile->SocketByPointer(wspGetSockXXin.pSocket); if (pSdpSocket == NULL) { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IOCTL_WSP_GET_XXX_NAME socket %x not found\n", wspGetSockXXin.pSocket)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IOCTL_WSP_GET_XXX_NAME socket %p not found\n", wspGetSockXXin.pSocket); // This is a well defined winsock error pWspGetSockXXOut->Errno = WSAENOTSOCK; goto Cleanup; } rc = pSdpSocket->WSPGetXXXName(&wspGetSockXXin, pWspGetSockXXOut); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpSocket->WSPGetXXXName failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpSocket->WSPGetXXXName failed rc = 0x%x\n", rc ); goto Cleanup; } } break; case IOCTL_WSP_CLOSE_SOCKET : { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IOCTL_WSP_CLOSE_SOCKET recieved\n" )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"IOCTL_WSP_CLOSE_SOCKET recieved\n" ); VERIFY_BUFFERS(InputBufferLength, OutputBufferLength, WspSocketCloseIn, WspSocketCloseOut); OutputDataSize = sizeof (WspSocketCloseOut); @@ -701,14 +713,14 @@ SdpDriver::DispatchDeviceIoControl( pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; pSdpSocket = pSdpUserFile->SocketByPointer(wspSocketCloseIn.pSocket); if (pSdpSocket == NULL) { - SDP_PRINT(SDP_DEBUG, SDP_DRIVER, ("IOCTL_WSP_CLOSE_SOCKET socket %x not found\n",wspSocketCloseIn.pSocket)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER,"IOCTL_WSP_CLOSE_SOCKET socket %p not found\n",wspSocketCloseIn.pSocket); // This is a well defined winsock error pWspSocketCloseOut->Errno = WSAENOTSOCK; goto Cleanup; } rc = pSdpSocket->WSPCloseSocket(&wspSocketCloseIn, pWspSocketCloseOut); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("pSdpSocket->WSPCloseSocket failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"pSdpSocket->WSPCloseSocket failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -716,7 +728,7 @@ SdpDriver::DispatchDeviceIoControl( case IOCTL_WSP_USER_THREAD : { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("IOCTL_WSP_USER_THREAD recieved\n" )); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_DRIVER, "IOCTL_WSP_USER_THREAD recieved\n" ); pSdpUserFile = (SdpUserFile *)pIrpSp->FileObject->FsContext; /* Ignore Error = */ pSdpUserFile->UsersThread(); @@ -726,7 +738,7 @@ SdpDriver::DispatchDeviceIoControl( default: // This is an unrecgnized IOCTL ASSERT(FALSE); - SDP_PRINT(SDP_ERR, SDP_DRIVER, ("unknow IOCTL code = 0x%x\n", IoControlCode )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_DRIVER,"unknow IOCTL code = 0x%x\n", IoControlCode ); rc = STATUS_INVALID_PARAMETER; goto Cleanup; @@ -746,7 +758,7 @@ Cleanup: VOID SdpDriver::AddThread(ThreadHandle *pThreadHandle) { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("this = 0x%x\n", this )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"this = 0x%p\n", this ); // Check if there is any next thread that can be removed from the queue LARGE_INTEGER WaitTime; WaitTime.QuadPart = 0; // Don't wait for them to die @@ -764,7 +776,7 @@ SdpDriver::AddThread(ThreadHandle *pThreadHandle) VOID SdpDriver::WaitForAllThreadsToDie() { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("this = 0x%x\n", this )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"this = 0x%p\n", this ); ExAcquireFastMutex(&m_ThreadsMutex); // Timeout of null will cause a wait forever @@ -777,7 +789,7 @@ SdpDriver::WaitForAllThreadsToDie() VOID SdpDriver::WaitForThreadsToDie(LARGE_INTEGER *pWaitTime) { - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("this = 0x%x\n", this )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"this = 0x%p\n", this ); // Check if there is any next thread that can be removed from the queue NTSTATUS rc = STATUS_SUCCESS; @@ -799,12 +811,12 @@ SdpDriver::WaitForThreadsToDie(LARGE_INTEGER *pWaitTime) if (rc == STATUS_TIMEOUT) { // Nothing that we should do, the thread is not ready yet - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("this = 0x%x Former thread is not dead yet\n", this )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"this = 0x%p Former thread is not dead yet\n", this ); break; } // SUCESS means that the thread is dead, we can remove it // from the list - SDP_PRINT(SDP_TRACE, SDP_DRIVER, ("this = 0x%x Former thread is already dead\n", this )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_DRIVER,"this = 0x%p Former thread is already dead\n", this ); m_ShutDownThreads.RemoveHeadList(); ObDereferenceObject(pNextThreadHandle->ThreadObject); diff --git a/trunk/ulp/sdp/kernel/SdpGenUtils.cpp b/trunk/ulp/sdp/kernel/SdpGenUtils.cpp index 651fb541..77626886 100644 --- a/trunk/ulp/sdp/kernel/SdpGenUtils.cpp +++ b/trunk/ulp/sdp/kernel/SdpGenUtils.cpp @@ -32,7 +32,12 @@ #include "Precompile.h" -//#define DONT_COPY_DATA +#if defined(EVENT_TRACING) +#ifdef offsetof +#undef offsetof +#endif +#include "SdpGenUtils.tmh" +#endif USHORT ntohs(USHORT in) { @@ -86,7 +91,7 @@ NTSTATUS ); if (!NT_SUCCESS(rc)) { ASSERT(FALSE); - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("KeWaitForSingleObject failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"KeWaitForSingleObject failed rc = 0x%x\n", rc ); // No meter what we do the program can't continue, let's crush it int *i = NULL; *i = 5; @@ -100,11 +105,11 @@ NTSTATUS if (rc != STATUS_USER_APC) { break; } else { - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("KeWaitForSingleObject was stoped because of STATUS_USER_APC\n" )); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET,"KeWaitForSingleObject was stoped because of STATUS_USER_APC\n" ); } } if (i == 20) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("!!!! KeWaitForSingleObject was Exhausted STATUS_USER_APC\n" )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"!!!! KeWaitForSingleObject was Exhausted STATUS_USER_APC\n" ); // This is probably fine if we are runnign for a user thread ASSERT((WaitReason == UserRequest) && (WaitMode == UserMode)); } @@ -135,7 +140,7 @@ CopyFromUser( } __except(EXCEPTION_EXECUTE_HANDLER) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("copying memory from user failed\n")); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"copying memory from user failed\n"); ASSERT(FALSE); return STATUS_ACCESS_DENIED; } @@ -166,7 +171,7 @@ CopyToUser( } __except(EXCEPTION_EXECUTE_HANDLER) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("copying memory from user failed\n")); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"copying memory from user failed\n"); ASSERT(FALSE); return STATUS_ACCESS_DENIED; } @@ -202,14 +207,14 @@ NTSTATUS Sleep(ULONG HandredNanos) LARGE_INTEGER Timeout = TimeFromLong(HandredNanos); - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("Before Sleep\n")); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL,"Before Sleep\n"); rc = MyKeWaitForSingleObject( &Event, UserRequest, UserMode, FALSE, &Timeout); - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("After Sleep rc = 0x%x\n", rc)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL,"After Sleep rc = 0x%x\n", rc); return rc; } diff --git a/trunk/ulp/sdp/kernel/SdpLock.h b/trunk/ulp/sdp/kernel/SdpLock.h index 4f8d122f..5637044b 100644 --- a/trunk/ulp/sdp/kernel/SdpLock.h +++ b/trunk/ulp/sdp/kernel/SdpLock.h @@ -141,7 +141,7 @@ public: KeReleaseSpinLock(&m_SpinLock, OldIrql); rc = MyKeWaitForSingleObject(&m_Event, UserRequest, UserMode, false, NULL); if (( rc == STATUS_ALERTED ) ||( rc == STATUS_USER_APC )) { - SDP_PRINT(SDP_WARN, SDP_LOCK, ("MyKeWaitForSingleObject was alerted = 0x%x\n", rc )); + //SDP_PRINT(TRACE_LEVEL_WARNING, SDP_LOCK,"MyKeWaitForSingleObject was alerted = 0x%x\n", rc ); rc = STATUS_UNEXPECTED_IO_ERROR; Locked = false; goto Cleanup; @@ -159,7 +159,7 @@ public: KeReleaseSpinLock(&m_SpinLock, OldIrql); rc = HandleFlags(OldFlags); if(!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_LOCK, ("HandleFlags failed rc = 0x%x\n", rc )); + //SDP_PRINT(SDP_ERR, SDP_LOCK, ("HandleFlags failed rc = 0x%x\n", rc )); } if ((Force == false) && (!NT_SUCCESS(rc) || @@ -168,7 +168,7 @@ public: )) { // We have to signal the error to the calling side if(!NT_SUCCESS(rc1)) { - SDP_PRINT(SDP_ERR, SDP_LOCK, ("m_CheckSocketState failed rc1 = 0x%x\n", rc1 )); + //SDP_PRINT(SDP_ERR, SDP_LOCK, ("m_CheckSocketState failed rc1 = 0x%x\n", rc1 )); } Locked = false; KeAcquireSpinLock(&m_SpinLock, &OldIrql); @@ -185,7 +185,7 @@ public: } while (true); Cleanup: - SDP_PRINT(SDP_DEBUG, SDP_LOCK,("Lock is returing %s\n", Locked ? "true" : "false")); + //SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_LOCK,"Lock is returing %s\n", Locked ? "true" : "false"); return Locked; } @@ -233,7 +233,7 @@ Cleanup: rc = HandleFlags(OldFlags); if (!NT_SUCCESS(rc)) { // We have to signal the error to the calling side - SDP_PRINT(SDP_ERR, SDP_LOCK, ("HandleFlags failed rc = 0x%x\n", rc )); + //SDP_PRINT(TRACE_LEVEL_ERROR, SDP_LOCK,"HandleFlags failed rc = 0x%x\n", rc ); ASSERT(m_flags & ERROR_SIGNALLED); } // At the time that we were handeling the flags, someone might have @@ -276,7 +276,7 @@ Cleanup: rc = HandleFlags(OldFlags); if (!NT_SUCCESS(rc)) { // We have to signal the error to the calling side - SDP_PRINT(SDP_ERR, SDP_LOCK, ("HandleFlags failed rc = 0x%x\n", rc )); + //SDP_PRINT(TRACE_LEVEL_ERROR, SDP_LOCK,"HandleFlags failed rc = 0x%x\n", rc ); ASSERT(m_flags & ERROR_SIGNALLED); } KeAcquireSpinLock(&m_SpinLock, &OldIrql); @@ -309,7 +309,7 @@ Cleanup: // We need to handle the send CB rc = m_SendCBHandler(m_pSdpSocket); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("m_SendCBHandler failed rc = 0x%x\n", rc )); + //SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"m_SendCBHandler failed rc = 0x%x\n", rc ); m_flags |= ERROR_SIGNALLED; // We continue from here since, there might be other things to handle, // and this might be in a DPC context @@ -319,7 +319,7 @@ Cleanup: // We need to handle the send CB rc = m_RecvCBHandler(m_pSdpSocket); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("m_RecvCBHandler failed rc = 0x%x\n", rc )); + //SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"m_RecvCBHandler failed rc = 0x%x\n", rc ); m_flags |= ERROR_SIGNALLED; // We continue from here since, there might be other things to handle, // and this might be in a DPC context diff --git a/trunk/ulp/sdp/kernel/SdpRecvPool.cpp b/trunk/ulp/sdp/kernel/SdpRecvPool.cpp index 333f7f48..edbacaaf 100644 --- a/trunk/ulp/sdp/kernel/SdpRecvPool.cpp +++ b/trunk/ulp/sdp/kernel/SdpRecvPool.cpp @@ -32,6 +32,15 @@ #include "preCompile.h" +#if defined(EVENT_TRACING) +#ifdef offsetof +#undef offsetof +#endif +#include "SdpRecvPool.tmh" +#endif + + + RecvPool::RecvPool() { m_RecvSeq = 0; @@ -57,7 +66,7 @@ RecvPool::Init( SdpSocket *pSdpSocket ) { - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p \n", pSdpSocket)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL,"this = 0x%p \n", m_pSdpSocket); m_MaxBuffers = MaxBuffers; m_MaxConcurrentRecieves = MaxConcurrentRecieves; m_MaxMessageSize = MaxMessageSize; @@ -78,7 +87,7 @@ RecvPool::Init( for (int i=0;i < MAX_RECV_PACKETS; i++) { rc = BufferDescriptor::AllocateBuffer(&pBufferDescriptor, m_MaxMessageSize, RECV_BUFFERS_ALLOCATION_TAG); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("BufferDescriptor::AllocateBuffer failed rc=0x%x \n", rc)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"BufferDescriptor::AllocateBuffer failed rc=0x%x \n", rc); goto Cleanup; } @@ -108,8 +117,8 @@ Cleanup: NTSTATUS RecvPool::RecievedBuffer(BufferDescriptor *pBufferDescriptor, bool error) { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p pBufferDescriptor = 0x%p sucess = %s\n" - ,m_pSdpSocket, pBufferDescriptor, error ? "false" : "true")); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL, "this = 0x%p pBufferDescriptor = 0x%p sucess = %s\n" + ,m_pSdpSocket, pBufferDescriptor, error ? "false" : "true"); AssertLocked(); NTSTATUS rc = STATUS_SUCCESS; @@ -143,11 +152,11 @@ RecvPool::RecievedBuffer(BufferDescriptor *pBufferDescriptor, bool error) abs ( (int)m_pSdpSocket->m_SendBufferPool.GetSendSeq()- (int)pHeader->seq_ack); - SDP_PRINT(SDP_DEBUG, SDP_CREDITS,("SetRemoteRecvBuf rRecvBuf = %d, pHeader->recv_bufs = %d, SendSeq = %d , pHeader->seq_ack = %d\n", + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_CREDITS,"SetRemoteRecvBuf rRecvBuf = %d, pHeader->recv_bufs = %d, SendSeq = %d , pHeader->seq_ack = %d\n", rRecvBuf, pHeader->recv_bufs, (int)m_pSdpSocket->m_SendBufferPool.GetSendSeq(), - (int)pHeader->seq_ack)); + (int)pHeader->seq_ack); m_pSdpSocket->m_SendBufferPool.SetRemoteRecvBuf(rRecvBuf); // m_DisConnRecieved is the last "real" message that should be recieved @@ -193,7 +202,7 @@ RecvPool::RecievedBuffer(BufferDescriptor *pBufferDescriptor, bool error) SDP_RECV_CREDIT_UPDATE) { rc = m_pSdpSocket->m_SendBufferPool.PostCredits(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("m_SendBufferPool.PostCredits failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"m_SendBufferPool.PostCredits failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -201,14 +210,14 @@ RecvPool::RecievedBuffer(BufferDescriptor *pBufferDescriptor, bool error) // Wake up the clients of the send (new credits were added) rc = m_pSdpSocket->m_SendBufferPool.SendBuffersIfCan(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("SendBuffersIfCan failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"SendBuffersIfCan failed rc = 0x%x\n", rc ); goto Cleanup; } // We might be able to post a new recieve buffer now ASSERT(m_CurrentlyPostedRecievedBuffers < m_MaxConcurrentRecieves); rc = ReceiveIfCan(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("RecieveIfCan failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"RecieveIfCan failed rc = 0x%x\n", rc ); goto Cleanup; } Cleanup: @@ -240,8 +249,8 @@ RecvPool::GetData( bool *pNoMoreData ) { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p FirstBuffer = %s\n", m_pSdpSocket, - FirstBuffer ? "TRUE" : "FALSE")); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL, "this = 0x%p FirstBuffer = %s\n", m_pSdpSocket, + FirstBuffer ? "TRUE" : "FALSE"); AssertLocked(); bool BufferFreed = false; *Copied = 0; @@ -277,7 +286,7 @@ RecvPool::GetData( ASSERT(CopySize > *Copied); rc = pBufferDescriptor->CopyToUser(pData + *Copied, CopySize - *Copied); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("pBufferDescriptor->CopyToUser failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"pBufferDescriptor->CopyToUser failed rc = 0x%x\n", rc ); goto Cleanup; } *Copied += CopySize - *Copied; @@ -286,7 +295,7 @@ RecvPool::GetData( // We copy the entire buffer and remove it rc = pBufferDescriptor->CopyToUser(pData + *Copied, OldDataSize); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("pBufferDescriptor->CopyToUser failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"pBufferDescriptor->CopyToUser failed rc = 0x%x\n", rc ); goto Cleanup; } *Copied += OldDataSize; @@ -325,7 +334,7 @@ Cleanup: VOID RecvPool::AllowOthersToGet() { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p \n", m_pSdpSocket)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL,"this = 0x%p \n", m_pSdpSocket); ASSERT(m_ClientBeingServed == true); m_ClientBeingServed = false; @@ -336,8 +345,8 @@ RecvPool::AllowOthersToGet() NTSTATUS RecvPool::ReceiveIfCan() { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p m_CurrentlyPostedRecievedBuffers = %d m_LocaleAdvertisedBuffers = %d\n", - m_pSdpSocket, m_CurrentlyPostedRecievedBuffers, m_LocaleAdvertisedBuffers)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL, "this = 0x%p m_CurrentlyPostedRecievedBuffers = %d m_LocaleAdvertisedBuffers = %d\n", + m_pSdpSocket, m_CurrentlyPostedRecievedBuffers, m_LocaleAdvertisedBuffers); AssertLocked(); BufferDescriptor *pBufferDescriptor = NULL; NTSTATUS rc = STATUS_SUCCESS; @@ -353,7 +362,7 @@ RecvPool::ReceiveIfCan() // We can allocate more buffers rc = BufferDescriptor::AllocateBuffer(&pBufferDescriptor, m_MaxMessageSize, RECV_BUFFERS_ALLOCATION_TAG); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("AllocateBuffer failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"AllocateBuffer failed rc = 0x%x\n", rc ); goto Cleanup; } m_CurrentlyAllocated++; @@ -367,7 +376,7 @@ RecvPool::ReceiveIfCan() rc = PostReceiveBuffer(pBufferDescriptor); if (!NT_SUCCESS(rc)) { m_FreePackets.InsertTailList(&pBufferDescriptor->BuffersList); - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("PostReceiveBuffer failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"PostReceiveBuffer failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -376,7 +385,7 @@ RecvPool::ReceiveIfCan() // other side that he has more credits rc = m_pSdpSocket->m_SendBufferPool.PostCredits(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("m_SendBufferPool.PostCredits failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"m_SendBufferPool.PostCredits failed rc = 0x%x\n", rc ); goto Cleanup; } } @@ -395,7 +404,7 @@ RecvPool::ShutDown() { // Lock is not taken here, but we should be gurantied that no // one can be racing us in here - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p \n", m_pSdpSocket)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL,"this = 0x%p \n", m_pSdpSocket); BufferDescriptor *pBufferDescriptor = NULL; LIST_ENTRY *item = NULL; @@ -421,10 +430,10 @@ RecvPool::ShutDown() VOID RecvPool::CloseSocket() { - SDP_PRINT(SDP_TRACE, SDP_BUFFER_POOL, ("this = 0x%p m_WaitingClients = %s waiting buffer = %d\n", + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_BUFFER_POOL, "this = 0x%p m_WaitingClients = %s waiting buffer = %d\n", this, m_ClientWaiting ? "true" : "false", - m_FullPackets.Size()) + m_FullPackets.Size() ); AssertLocked(); @@ -439,7 +448,7 @@ RecvPool::CloseSocket() NTSTATUS RecvPool::PostReceiveBuffer(BufferDescriptor *pBufferDescriptor) { - SDP_PRINT(SDP_DEBUG, SDP_BUFFER_POOL, ("this = 0x%p \n", m_pSdpSocket)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_BUFFER_POOL,"this = 0x%p \n", m_pSdpSocket); AssertLocked(); NTSTATUS rc = STATUS_SUCCESS; @@ -455,7 +464,7 @@ RecvPool::PostReceiveBuffer(BufferDescriptor *pBufferDescriptor) ib_api_status_t ib_status = ib_post_recv(m_qp, &recv_wr, NULL); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_BUFFER_POOL, ("ib_post_recv failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_BUFFER_POOL,"ib_post_recv failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } diff --git a/trunk/ulp/sdp/kernel/SdpSocket.cpp b/trunk/ulp/sdp/kernel/SdpSocket.cpp index 65118007..81f6328b 100644 --- a/trunk/ulp/sdp/kernel/SdpSocket.cpp +++ b/trunk/ulp/sdp/kernel/SdpSocket.cpp @@ -31,8 +31,17 @@ // Author: Tzachi Dar #include "Precompile.h" + #pragma warning(disable: 4244 ) +#if defined(EVENT_TRACING) +#ifdef offsetof +#undef offsetof +#endif +#include "SdpSocket.tmh" +#endif + + NTSTATUS sdp_cm_hello_ack_check(struct sdp_msg_hello_ack *hello_ack); NTSTATUS sdp_cm_hello_check(struct sdp_msg_hello *msg_hello); static NTSTATUS __send_cb2(SdpSocket * pSdpSocket); @@ -42,7 +51,7 @@ static NTSTATUS __accept_requests(SdpSocket * pSdpSocket); static void AL_API cm_rej_callback(IN ib_cm_rej_rec_t *p_cm_rej_rec ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("dispatch level = %d\n", KeGetCurrentIrql())); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"dispatch level = %d\n", KeGetCurrentIrql()); // BUGBUG: This should be used to return error to the connecting side } @@ -58,7 +67,7 @@ static void AL_API cm_mra_callback( IN ib_cm_mra_rec_t *p_cm_mra_rec ) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("cm_mra_callback called")); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"cm_mra_callback called"); ASSERT(FALSE); } @@ -70,7 +79,7 @@ static void AL_API cm_apr_callback( IN ib_cm_apr_rec_t *p_cm_apr_rec ) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("cm_apr_callback called")); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"cm_apr_callback called"); ASSERT(FALSE); } @@ -85,7 +94,7 @@ static void AL_API cm_lap_callback( IN ib_cm_lap_rec_t *p_cm_lap_rec ) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("dispatch level = %d\n", KeGetCurrentIrql())); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"dispatch level = %d\n", KeGetCurrentIrql()); ASSERT(FALSE); } @@ -93,7 +102,7 @@ void cm_rtu_callback( IN ib_cm_rtu_rec_t *p_cm_rtu_rec ) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("dispatch level = %d\n", KeGetCurrentIrql())); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"dispatch level = %d\n", KeGetCurrentIrql()); // Note - Referance count is not increased here since this is a call // back, and we are gurantied that shuting down ibal will only end // after all callbacks are finished. @@ -173,7 +182,7 @@ NTSTATUS SdpSocket::Init( SdpUserFile *pSdpUserFile) { NTSTATUS rc = STATUS_SUCCESS; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p\n", this); m_CreationFlags = pSocketInParam->dwFlags; @@ -189,7 +198,7 @@ NTSTATUS SdpSocket::Init( // we won't be in trouble after the thread was created m_pCloseSocketThread = new ThreadHandle; if (m_pCloseSocketThread == NULL) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to allocate new SocketThread this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Failed to allocate new SocketThread this = 0x%p \n",this); rc = STATUS_NO_MEMORY; goto Cleanup; } @@ -218,7 +227,7 @@ NTSTATUS SdpSocket::WSPSend( IRP *pIrp ) { - SDP_PRINT(SDP_DEBUG, SDP_SOCKET, ("this = 0x%p size = %d \n",this, pWspSendIn->BufferSize)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_SOCKET,"this = 0x%p size = %d \n",this, pWspSendIn->BufferSize); NTSTATUS rc = STATUS_SUCCESS; BufferDescriptor * pBufferDescriptor = NULL; @@ -231,21 +240,20 @@ NTSTATUS SdpSocket::WSPSend( // For zero bytes send we currently don't do anything and return with status // success if (pWspSendIn->BufferSize == 0) { - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("this = 0x%p - zero size send \n",this)); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET,"this = 0x%p - zero size send \n",this); goto Cleanup; } if (!m_Lock.Lock()) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to lock this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "Failed to lock this = 0x%p \n",this); rc = STATUS_SHUTDOWN_IN_PROGRESS; goto Cleanup; } if ((m_state != SS_CONNECTED)) { // We can not send now. - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("Can't send now, m_state = %s\n", - SS2String(m_state) - )); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET,"Can't send now, m_state = %s\n", + SS2String(m_state)); rc = STATUS_SHUTDOWN_IN_PROGRESS; pWspSendOut->Errno = WSAENOTCONN; @@ -268,7 +276,7 @@ NTSTATUS SdpSocket::WSPSend( if (!NT_SUCCESS(rc)) { // No need to complete the IRP, as it will be be deleted // when all other IRPs will be - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "m_Lock.Unlock() failed rc = 0x%x\n", rc ); goto Cleanup; } // This IRP will be pending (make sure to change this after the unlock) @@ -285,7 +293,7 @@ NTSTATUS SdpSocket::WSPSend( rc = m_SendBufferPool.GetBuffer(&pBufferDescriptor); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_SendBufferPool.GetBuffer failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_SendBufferPool.GetBuffer failed rc = 0x%x\n", rc ); m_Lock.Unlock(); // Error ignored as this is already an error pass goto Cleanup; } @@ -305,7 +313,7 @@ NTSTATUS SdpSocket::WSPSend( rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); // No need to complete the IRP, as it will be be deleted // when all other IRPs will be goto Cleanup; @@ -319,7 +327,7 @@ NTSTATUS SdpSocket::WSPSend( rc = pBufferDescriptor->WriteData(pWspSendIn->pData + Coppied, CopySize); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("pBufferDescriptor->WriteData failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"pBufferDescriptor->WriteData failed rc = 0x%x\n", rc ); // free the buffer that you have rc1 = m_SendBufferPool.ReturnBuffer(pBufferDescriptor); ASSERT(NT_SUCCESS(rc1)); @@ -332,7 +340,7 @@ NTSTATUS SdpSocket::WSPSend( pBufferDescriptor->SetMid(SDP_MID_DATA); rc = m_SendBufferPool.AddBufferToQueuedList(pBufferDescriptor); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_SendBufferPool.AddBufferToQueuedList failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_SendBufferPool.AddBufferToQueuedList failed rc = 0x%x\n", rc ); // free the buffer that you have rc1 = m_SendBufferPool.ReturnBuffer(pBufferDescriptor); ASSERT(NT_SUCCESS(rc1)); @@ -343,7 +351,7 @@ NTSTATUS SdpSocket::WSPSend( rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); goto Cleanup; } @@ -363,7 +371,7 @@ Cleanup: // Some default value pWspSendOut->Errno = WSAENOBUFS; } - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("this = 0x%p rc = 0x%x\n",this, rc)); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "this = 0x%p rc = 0x%x\n",this, rc); // is indeed the case. } return rc; @@ -375,7 +383,7 @@ SdpSocket::WSPRecv( WspRecvOut *pWspRecvOut ) { - SDP_PRINT(SDP_DEBUG, SDP_SOCKET, ("this = 0x%p BufferSize = %d\n",this, pWspRecvIn->BufferSize)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_SOCKET,"this = 0x%p BufferSize = %d\n",this, pWspRecvIn->BufferSize); NTSTATUS rc = STATUS_SUCCESS; bool First = true; @@ -385,13 +393,13 @@ SdpSocket::WSPRecv( bool NoMoreData; if (pWspRecvIn->BufferSize == 0) { - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("this = 0x%p - zero size recv \n",this)); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET,"this = 0x%p - zero size recv \n",this); goto Cleanup; } while (Coppied < pWspRecvIn->BufferSize) { if ((Locked == false) && !m_Lock.Lock()) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to lock this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Failed to lock this = 0x%p \n",this); rc = STATUS_SHUTDOWN_IN_PROGRESS; goto Cleanup; } @@ -400,9 +408,8 @@ SdpSocket::WSPRecv( if ((m_state != SS_CONNECTED && m_state!= SS_CONNECTED_DREP_SENT ) ) { // We can not recv now. - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("Can't recv now, m_state = %s this = %p\n", - SS2String(m_state), this - )); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "Can't recv now, m_state = %s this = %p\n", + SS2String(m_state), this); rc = STATUS_SHUTDOWN_IN_PROGRESS; pWspRecvOut->Errno = WSAENOTCONN; @@ -420,7 +427,7 @@ SdpSocket::WSPRecv( &NoMoreData ); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_RecvBufferPool.GetData failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_RecvBufferPool.GetData failed rc = 0x%x\n", rc ); m_Lock.Unlock(); // Error ignored as this is already an error pass Locked = false; goto Cleanup; @@ -441,7 +448,7 @@ SdpSocket::WSPRecv( rc = m_Lock.Unlock(); Locked = false; if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); goto Cleanup; } @@ -456,7 +463,7 @@ SdpSocket::WSPRecv( if (( rc == STATUS_ALERTED ) ||( rc == STATUS_USER_APC )) { // BUGBUG: Think what to do here, we should be able to stop the // connect, and quit (probably shutdown should be enough) - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("MyKeWaitForSingleObject was alerted rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET,"MyKeWaitForSingleObject was alerted rc = 0x%x\n", rc ); rc = STATUS_UNEXPECTED_IO_ERROR; //pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error Shutdown(); @@ -469,7 +476,7 @@ SdpSocket::WSPRecv( ASSERT(Locked == true); rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); goto Cleanup; } @@ -488,7 +495,7 @@ Cleanup: } // Currently in any case, the flags are not being used: pWspRecvOut->dwFlags = 0; - SDP_PRINT(SDP_DEBUG, SDP_SOCKET, ("this = 0x%p returning %d bytes \n",this, pWspRecvOut->NumberOfBytesRecieved)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_SOCKET,"this = 0x%p returning %d bytes \n",this, pWspRecvOut->NumberOfBytesRecieved); return rc; } @@ -505,19 +512,19 @@ NTSTATUS SdpSocket::WSPConnect( ib_path_rec_t path_rec; ULONG SrcIp = 0; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p remote addresses ip=%d.%d.%d.%d:%d\n", + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "this = 0x%p remote addresses ip=%d.%d.%d.%d:%d\n", this, (pWspConnectIn->DestIP & 0XFF000000) >> 24, (pWspConnectIn->DestIP & 0XFF0000) >> 16, (pWspConnectIn->DestIP & 0XFF00) >> 8, (pWspConnectIn->DestIP & 0XFF), pWspConnectIn->DestPort - )); + ); if((pWspConnectIn->DestIP == 0) || (pWspConnectIn->DestPort == 0) || (pWspConnectIn->SrcIP == 0)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Invalid Addresses")); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Invalid Addresses"); pWspConnectOut->Errno = WSAEADDRNOTAVAIL; goto Cleanup; } @@ -526,9 +533,8 @@ NTSTATUS SdpSocket::WSPConnect( m_Lock.Lock();//??? retval if ((m_state != SS_IDLE)) { // We can not connect in this state - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("Can't send now, m_state = %s\n", - SS2String(m_state) - )); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "Can't send now, m_state = %s\n", + SS2String(m_state)); rc = STATUS_SHUTDOWN_IN_PROGRESS; pWspConnectOut->Errno = WSAENOTCONN; @@ -557,7 +563,7 @@ NTSTATUS SdpSocket::WSPConnect( if (m_SrcPort == 0) { rc = g_pSdpDriver->m_pSdpArp->GetPort(m_SrcIp, &m_SrcPort); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->GetPort failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_pSdpArp->GetPort failed rc = 0x%x\n", rc ); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error m_Lock.Unlock(); // Error ignored as this is already an error pass goto Cleanup; @@ -569,7 +575,7 @@ NTSTATUS SdpSocket::WSPConnect( rc = g_pSdpDriver->m_pSdpArp->SourcePortGidFromIP(SrcIp, &m_SrcPortGuid, &m_SrcCaGuid); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->SourcePortGidFromIP failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_pSdpArp->SourcePortGidFromIP failed rc = 0x%x\n", rc ); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error m_Lock.Unlock(); // Error ignored as this is already an error pass goto Cleanup; @@ -577,7 +583,7 @@ NTSTATUS SdpSocket::WSPConnect( rc = g_pSdpDriver->m_pSdpArp->DestPortGidFromMac(m_SrcPortGuid, pWspConnectIn->DestMac, &DestPortGid); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->DestPortGidFromIP failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_pSdpArp->DestPortGidFromIP failed rc = 0x%x\n", rc ); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error m_Lock.Unlock(); // Error ignored as this is already an error pass goto Cleanup; @@ -593,7 +599,7 @@ NTSTATUS SdpSocket::WSPConnect( rc = g_pSdpDriver->m_pSdpArp->QueryPathRecord( m_SrcPortGuid, DestPortGid, &path_rec ); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->QueryPathRecord failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_pSdpArp->QueryPathRecord failed rc = 0x%x\n", rc ); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error goto Cleanup; } @@ -601,14 +607,14 @@ NTSTATUS SdpSocket::WSPConnect( // Verify that we are in the correct state (just looking - without the lock) if (m_state != SS_CONNECTING_QPR_SENT) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("wrong state after QueryPathRecord\n" )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"wrong state after QueryPathRecord\n" ); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error goto Cleanup; } rc = CreateQp(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("CreateQp failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"CreateQp failed rc = 0x%x\n", rc ); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error goto Cleanup; } @@ -630,7 +636,7 @@ NTSTATUS SdpSocket::WSPConnect( ib_status = ib_cm_req( &cm_req ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_cm_req failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_cm_req failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error goto Cleanup; @@ -646,7 +652,7 @@ NTSTATUS SdpSocket::WSPConnect( if (( rc == STATUS_ALERTED ) ||( rc == STATUS_USER_APC )) { // BUGBUG: Think what to do here, we should be able to stop the // connect, and quit (probably shutdown should be enough) - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("MyKeWaitForSingleObject was alerted rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET,"MyKeWaitForSingleObject was alerted rc = 0x%x\n", rc ); rc = STATUS_UNEXPECTED_IO_ERROR; pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error Shutdown(); @@ -661,7 +667,7 @@ NTSTATUS SdpSocket::WSPConnect( rc = CmSendRTU(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("CmSendRTU failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"CmSendRTU failed rc = 0x%x\n", rc ); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error goto Cleanup; } @@ -687,8 +693,8 @@ Cleanup: ASSERT(((pWspConnectOut->Errno == 0) && (NT_SUCCESS(rc))) | ((pWspConnectOut->Errno != 0) && (!NT_SUCCESS(rc)))); - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("connect is returning %s this = 0x%p\n", - NT_SUCCESS(rc) ? "SUCCESS" : "FAILURE", this )); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"connect is returning %s this = 0x%p\n", + NT_SUCCESS(rc) ? "SUCCESS" : "FAILURE", this); return rc; } @@ -701,26 +707,25 @@ SdpSocket::WSPBind( { NTSTATUS rc = STATUS_SUCCESS; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p bind address ip=%d.%d.%d.%d:%d\n", + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "this = 0x%p bind address ip=%d.%d.%d.%d:%d\n", this, (pWspBindIn->IP & 0XFF000000) >> 24, (pWspBindIn->IP & 0XFF0000) >> 16, (pWspBindIn->IP & 0XFF00) >> 8, (pWspBindIn->IP & 0XFF), pWspBindIn->Port - )); + ); if (!m_Lock.Lock()) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to lock this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Failed to lock this = 0x%p \n",this); rc = STATUS_SHUTDOWN_IN_PROGRESS; goto Cleanup; } /* Verify the state of the socket */ if( m_state != SS_IDLE) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("socket is in invalid state %s this = 0x%p \n", - this, - SS2String(m_state))); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "socket is in invalid state %s this = 0x%p \n", + SS2String(m_state),this ); m_Lock.Unlock(); // Error ignored as this is already an error pass rc = STATUS_INVALID_DEVICE_STATE; pWspBindOut->Errno = WSAEINVAL; @@ -734,7 +739,7 @@ SdpSocket::WSPBind( ASSERT(m_SrcCaGuid == NULL); rc = g_pSdpDriver->m_pSdpArp->SourcePortGidFromIP(pWspBindIn->IP, &m_SrcPortGuid, &m_SrcCaGuid); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->SourcePortGidFromIP failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_pSdpArp->SourcePortGidFromIP failed rc = 0x%x\n", rc ); pWspBindOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error m_Lock.Unlock(); // Error ignored as this is already an error pass goto Cleanup; @@ -749,7 +754,7 @@ SdpSocket::WSPBind( /* Time to allocate our IB QP */ rc = CreateQp(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("CreateQp failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"CreateQp failed rc = 0x%x\n", rc ); pWspBindOut->Errno = WSAENOBUFS; m_Lock.Unlock(); // Error ignored as this is already an error pass goto Cleanup; @@ -761,7 +766,7 @@ SdpSocket::WSPBind( m_SrcPort = 0; rc = g_pSdpDriver->m_pSdpArp->GetPort(pWspBindIn->IP, &m_SrcPort); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->GetPort failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_pSdpArp->GetPort failed rc = 0x%x\n", rc ); pWspBindOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error m_Lock.Unlock(); // Error ignored as this is already an error pass goto Cleanup; @@ -778,7 +783,7 @@ SdpSocket::WSPBind( m_state = SS_BOUND; rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); goto Cleanup; } @@ -804,18 +809,17 @@ NTSTATUS SdpSocket::WSPListen( ib_cm_listen_t param; ib_api_status_t ib_status; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p \n",this); if (!m_Lock.Lock()) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to lock this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Failed to lock this = 0x%p \n",this); rc = STATUS_SHUTDOWN_IN_PROGRESS; goto Cleanup; } /* Verify the state of the socket */ if( m_state != SS_BOUND) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("socket is in invalid state %s this = 0x%p \n", - this, - SS2String(m_state))); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "socket is in invalid state %s this = 0x%p \n", + SS2String(m_state),this); m_Lock.Unlock(); // Error ignored as this is already an error pass rc = STATUS_INVALID_DEVICE_STATE; pWspListenOut->Errno = WSAEINVAL; @@ -865,7 +869,7 @@ NTSTATUS SdpSocket::WSPListen( ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_cm_listen failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_cm_listen failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); pWspListenOut->Errno = IbalToWsaError( ib_status ); m_Lock.Unlock(); // Error ignored as this is already an error pass @@ -876,7 +880,7 @@ NTSTATUS SdpSocket::WSPListen( m_state = SS_LISTENING; rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); goto Cleanup; } @@ -902,11 +906,11 @@ SdpSocket::WSPAccept( SdpSocket *pNewSocket = NULL; PRKEVENT pAcceptEvent = NULL; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p \n",this); while (true) { if ((Locked == false) && !m_Lock.Lock()) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to lock this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Failed to lock this = 0x%p \n",this); rc = STATUS_SHUTDOWN_IN_PROGRESS; goto Cleanup; } @@ -915,9 +919,8 @@ SdpSocket::WSPAccept( /* Verify the state of the socket */ if( m_state != SS_LISTENING) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("socket is in invalid state %s this = 0x%p \n", - this, - SS2String(m_state))); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"socket is in invalid state %s this = 0x%p \n", + SS2String(m_state),this); m_Lock.Unlock(); // Error ignored as this is already an error pass Locked = false; rc = STATUS_INVALID_DEVICE_STATE; @@ -927,7 +930,7 @@ SdpSocket::WSPAccept( rc = m_ConnectionList.AcceptAReadyConnection(&pNewSocket, &pAcceptEvent); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_ConnectionList.AcceptAReadyConnection failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_ConnectionList.AcceptAReadyConnection failed rc = 0x%x\n", rc ); m_Lock.Unlock(); // Error ignored as this is already an error pass Locked = false; goto Cleanup; @@ -944,7 +947,7 @@ SdpSocket::WSPAccept( rc = m_Lock.Unlock(); Locked = false; if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); goto Cleanup; } @@ -959,7 +962,7 @@ SdpSocket::WSPAccept( if (( rc == STATUS_ALERTED ) ||( rc == STATUS_USER_APC )) { // BUGBUG: Think what to do here, we should be able to stop the // connect, and quit (probably shutdown should be enough) - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("MyKeWaitForSingleObject was alerted = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET,"MyKeWaitForSingleObject was alerted = 0x%x\n", rc ); rc = STATUS_UNEXPECTED_IO_ERROR; //pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error Shutdown(); @@ -976,14 +979,14 @@ SdpSocket::WSPAccept( rc = m_Lock.Unlock(); Locked = false; if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); goto Cleanup; } Cleanup: ASSERT(Locked == false); if (NT_SUCCESS(rc) ) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p returning socket 0x%p \n",this, pNewSocket)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p returning socket 0x%p \n",this, pNewSocket); pWspAcceptOut->pAccaptedSocket = pNewSocket; pWspAcceptOut->IP = IP; pWspAcceptOut->Port = Port; @@ -1011,10 +1014,10 @@ SdpSocket::WSPGetXXXName( NTSTATUS rc = STATUS_SUCCESS; ib_api_status_t ib_status; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p \n",this); rc = m_Lock.LockRc(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to lock this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Failed to lock this = 0x%p \n",this); pWspGetSockXXOut->Errno = WSAENETDOWN; goto Cleanup; } @@ -1030,7 +1033,7 @@ SdpSocket::WSPGetXXXName( } rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); pWspGetSockXXOut->Errno = WSAENETDOWN; goto Cleanup; } @@ -1094,20 +1097,20 @@ SdpSocket::WSPCloseSocket( ) { NTSTATUS rc = STATUS_SUCCESS; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p state = %s \n",this, SS2String(m_state))); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p state = %s \n",this, SS2String(m_state)); OBJECT_ATTRIBUTES attr; HANDLE ThreadHandle; if (!m_Lock.Lock()) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to lock this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Failed to lock this = 0x%p \n",this); rc = STATUS_SHUTDOWN_IN_PROGRESS; goto Cleanup; } /* Verify the state of the socket */ if(m_state == SS_IDLE) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("socket is in idle state this = 0x%p \n", - this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"socket is in idle state this = 0x%p \n", + this); m_Lock.Unlock(); // Error ignored as this is already a Shutdown pass Shutdown(); pWspSocketCloseOut->Errno = 0; @@ -1129,7 +1132,7 @@ SdpSocket::WSPCloseSocket( // Need to send the DisConn message to the remote side and wait rc = m_SendBufferPool.PostDisConn(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_SendBufferPool.PostDisConn failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_SendBufferPool.PostDisConn failed rc = 0x%x\n", rc ); m_Lock.Unlock(); // Error ignored as this is already an error pass goto Cleanup; } @@ -1157,7 +1160,7 @@ SdpSocket::WSPCloseSocket( ); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("PsCreateSystemThread failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"PsCreateSystemThread failed rc = 0x%x\n", rc ); m_Lock.Unlock(); // Error ignored as this is already an error pass // The thread wasn't created so we should remove the refferance Release(); @@ -1188,7 +1191,7 @@ SdpSocket::WSPCloseSocket( rc = STATUS_SUCCESS; } if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); goto Cleanup; } @@ -1202,8 +1205,8 @@ Cleanup: // In the current model, we call shutdown in any case (to kill the socket) Shutdown(); } - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p returning Errno = %d\n", - this , pWspSocketCloseOut->Errno)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "this = 0x%p returning Errno = %d\n", + this , pWspSocketCloseOut->Errno); return rc; @@ -1218,7 +1221,7 @@ Cleanup: VOID SdpSocket::DisconectSentEvent() { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p\n",this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "this = 0x%p\n",this); KeSetEvent( &m_DisconectSentEvent, IO_NO_INCREMENT, FALSE ); } @@ -1230,7 +1233,7 @@ VOID SdpSocket::DisconectSentEvent() VOID SdpSocket::CloseSocketThread() { NTSTATUS rc = STATUS_SUCCESS; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p\n",this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p\n",this); // wait for the last thread to end. LARGE_INTEGER WaitTime; @@ -1245,7 +1248,7 @@ VOID SdpSocket::CloseSocketThread() ); if (rc == STATUS_TIMEOUT) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Wait failed with time out this = 0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Wait failed with time out\n"); } ASSERT(NT_SUCCESS(rc)); @@ -1271,12 +1274,12 @@ NTSTATUS SdpSocket::CmSendRTU() ib_api_status_t ib_status; NTSTATUS rc = STATUS_SUCCESS; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p \n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p \n", this); if (m_state != SS_CONNECTING_REQ_SENT) { // There was some error, we can release the waiting thread. // The error will be handled there - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("this = 0x%p invalid state %s\n", this, SS2String(m_state))); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET,"this = 0x%p invalid state %s\n", this, SS2String(m_state)); rc = STATUS_UNEXPECTED_IO_ERROR; goto Cleanup; } @@ -1288,7 +1291,7 @@ NTSTATUS SdpSocket::CmSendRTU() rc = sdp_cm_hello_ack_check(&m_hello_ack); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("sdp_cm_hello_ack_check failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"sdp_cm_hello_ack_check failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -1296,13 +1299,13 @@ NTSTATUS SdpSocket::CmSendRTU() rc = m_SendBufferPool.Init(MAX_SEND_PACKETS, SDP_QP_ATTRIB_SQ_DEPTH, MaxMessageSize, m_pd, m_qp, m_lkey, this); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_SendBufferPool.Init failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_SendBufferPool.Init failed rc = 0x%x\n", rc ); goto Cleanup; } rc = m_RecvBufferPool.Init(MAX_RECV_PACKETS, QP_ATTRIB_RQ_DEPTH, MaxMessageSize, m_pd, m_qp, m_lkey, this); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_RecvBufferPool.Init failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_RecvBufferPool.Init failed rc = 0x%x\n", rc ); goto Cleanup; } m_SendBufferPool.SetRemoteRecvBuf(m_hello_ack.bsdh.recv_bufs); @@ -1345,7 +1348,7 @@ NTSTATUS SdpSocket::CmSendRTU() ib_status = ib_cm_rtu( m_cm_handle_t, &cm_rtu ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_cm_rtu failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_cm_rtu failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -1356,14 +1359,14 @@ NTSTATUS SdpSocket::CmSendRTU() // we now arm the CQs ib_status = ib_rearm_cq(m_rcq, FALSE); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_rearm_cq failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_rearm_cq failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } ib_status = ib_rearm_cq(m_scq, FALSE); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_rearm_cq failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_rearm_cq failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -1372,14 +1375,14 @@ NTSTATUS SdpSocket::CmSendRTU() rc = m_Lock.LockRc(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Lock failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Lock failed rc = 0x%x\n", rc ); goto Cleanup; } rc = m_RecvBufferPool.ReceiveIfCan(); //??? error m_Lock.Unlock(); // error ???? if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_RecvBufferPool.ReceiveIfCan failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_RecvBufferPool.ReceiveIfCan failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -1390,13 +1393,13 @@ Cleanup: VOID SdpSocket::CmRepCallback(IN ib_cm_rep_rec_t *p_cm_rep_rec) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p\n", this); ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); if (m_state != SS_CONNECTING_REQ_SENT) { // This is not the state that we waited for, not much that we can // do. (This might happen in shutdown) - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Not the expacted state %s\n", SS2String(m_state))); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Not the expacted state %s\n", SS2String(m_state)); ASSERT(FALSE); return; } @@ -1412,7 +1415,7 @@ VOID SdpSocket::CmRepCallback(IN ib_cm_rep_rec_t *p_cm_rep_rec) VOID SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p\n", this); NTSTATUS rc = STATUS_SUCCESS; ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); @@ -1425,34 +1428,34 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) rc = sdp_cm_hello_check(msg_hello); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("sdp_cm_hello_ack_check failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"sdp_cm_hello_ack_check failed rc = 0x%x\n", rc ); goto Cleanup; } // Take the lock and verify the state rc = m_Lock.LockRc(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Lock failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Lock failed rc = 0x%x\n", rc ); goto Cleanup; } if (m_state != SS_LISTENING) { // This is not the state that we waited for, we drop the request - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Not the expacted state %s\n", SS2String(m_state))); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Not the expacted state %s\n", SS2String(m_state)); ASSERT(FALSE); goto ErrorLocked; } // Check that we haven't passed the backlog for this connection if (m_ConnectionList.IsFull()) { - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("Dropping the connection, because of a backlog that is too small\n")); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET,"Dropping the connection, because of a backlog that is too small\n"); goto ErrorLocked; } // Create a new socket for this request pNewSocket = new SdpSocket; if (pNewSocket == NULL) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("new pNewSocket failed\n")); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"new pNewSocket failed\n"); goto ErrorLocked; } @@ -1462,7 +1465,7 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) SocketInParam.dwFlags = 0; rc = pNewSocket->Init(&SocketInParam, &SocketOutParam, m_pSdpUserFile); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("pNewSocket.Init() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"pNewSocket.Init()"); goto ErrorLocked; } ASSERT(SocketOutParam.Errno == 0); @@ -1503,7 +1506,7 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) rc = g_pSdpDriver->m_pSdpArp->SourcePortGidFromIP(pNewSocket->m_SrcIp, &SrcPortGuid, &SrcCaGuid); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->SourcePortGidFromIP failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_pSdpArp->SourcePortGidFromIP failed rc = 0x%x\n", rc ); goto ErrorLocked; } @@ -1516,14 +1519,14 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) // MAke sure that the port that was recieved muches the one that we // get based on the source IP. if (SrcPortGuid != p_cm_req_rec->primary_path.sgid.unicast.interface_id) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Recieved guid is not what we have expected\n" )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Recieved guid is not what we have expected\n" ); ASSERT(0); goto ErrorLocked; } rc = pNewSocket->CreateQp(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("pNewSocket.CreateQp() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"pNewSocket.CreateQp()"); goto ErrorLocked; } @@ -1532,13 +1535,13 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) rc = pNewSocket->m_SendBufferPool.Init(MAX_SEND_PACKETS, SDP_QP_ATTRIB_SQ_DEPTH, MaxMessageSize, pNewSocket->m_pd, pNewSocket->m_qp, pNewSocket->m_lkey, pNewSocket); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_SendBufferPool.Init failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_SendBufferPool.Init failed rc = 0x%x\n", rc ); goto ErrorLocked; } rc = pNewSocket->m_RecvBufferPool.Init(MAX_RECV_PACKETS, QP_ATTRIB_RQ_DEPTH, MaxMessageSize, pNewSocket->m_pd, pNewSocket->m_qp, pNewSocket->m_lkey, pNewSocket); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_RecvBufferPool.Init failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_RecvBufferPool.Init failed rc = 0x%x\n", rc ); goto ErrorLocked; } pNewSocket->m_SendBufferPool.SetRemoteRecvBuf(msg_hello->bsdh.recv_bufs); @@ -1605,7 +1608,7 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) ib_status = ib_cm_rep( p_cm_req_rec->h_cm_req, &cm_rep ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_cm_rep failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_cm_rep failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto ErrorLocked; } @@ -1613,19 +1616,19 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) // Add this socket to the list of sockets ?????? should this also be done on errors ???? rc = m_ConnectionList.AddConnectionToReplySent(pNewSocket); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("pNewSocket.Init() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"pNewSocket.Init()"); goto ErrorLocked; } rc = pNewSocket->m_Lock.LockRc(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("pNewSocket.Init() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"pNewSocket.Init()"); goto ErrorLocked; } rc = pNewSocket->m_RecvBufferPool.ReceiveIfCan(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("pNewSocket.Init() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"pNewSocket.Init()"); pNewSocket->m_Lock.Unlock(); // Error is ignored, since this is already an error path goto ErrorLocked; } @@ -1633,7 +1636,7 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) // we now arm the CQs (after that a call back might happen) ib_status = ib_rearm_cq(pNewSocket->m_rcq, FALSE); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_rearm_cq failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_rearm_cq failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); pNewSocket->m_Lock.Unlock(); // Error is ignored, since this is already an error path goto ErrorLocked; @@ -1641,7 +1644,7 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) ib_status = ib_rearm_cq(pNewSocket->m_scq, FALSE); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_rearm_cq failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_rearm_cq failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto ErrorLocked; } @@ -1651,14 +1654,14 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) rc = pNewSocket->m_Lock.Unlock(); // ???????? Error is ignored, since this is already an error path if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("pNewSocket->m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"pNewSocket->m_Lock.Unlock()"); // BUGBUG: who is responsibale for the cleanup ??????? goto ErrorLocked; } rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); // BUGBUG: who is responsibale for the cleanup ??????? } @@ -1675,7 +1678,7 @@ ErrorLocked: // Previous rc doesn't mater as this function is void rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); // BUGBUG: who is responsibale for the cleanup ??????? } goto Cleanup; @@ -1689,7 +1692,7 @@ SdpSocket::CmRtuCallback(IN ib_cm_rtu_rec_t *p_cm_rtu_rec) ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); SdpSocket *pSocket = (SdpSocket *) p_cm_rtu_rec->qp_context; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p pSocket = 0x%p\n", this, pSocket)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p pSocket = 0x%p\n", this, pSocket); // In order to make our model more consistent we increase the refcount here. // (This is not a must since this is a callback and we are gurantied that the last @@ -1700,13 +1703,13 @@ SdpSocket::CmRtuCallback(IN ib_cm_rtu_rec_t *p_cm_rtu_rec) // Take the lock and verify the state rc = m_Lock.LockRc(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Lock failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Lock failed rc = 0x%x\n", rc ); goto Cleanup; } if (m_state != SS_LISTENING) { // This is not the state that we waited for, we drop the request - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Not the expacted state %s\n", SS2String(m_state))); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Not the expacted state %s\n", SS2String(m_state)); ASSERT(FALSE); // Can this happen on shutdown ? goto ErrorLocked; } @@ -1714,7 +1717,7 @@ SdpSocket::CmRtuCallback(IN ib_cm_rtu_rec_t *p_cm_rtu_rec) // First step is to verify that we have the new socket rc = m_ConnectionList.VerifyConnictionInReplySent(pSocket); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_ConnectionList.GetConnection failed (got a call back on a not existing connection) rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_ConnectionList.GetConnection failed (got a call back on a not existing connection)"); ASSERT(FALSE); goto ErrorLocked; } @@ -1722,7 +1725,7 @@ SdpSocket::CmRtuCallback(IN ib_cm_rtu_rec_t *p_cm_rtu_rec) // Next step is to move the new socket to the SS_CONNECTED state rc = pSocket->m_Lock.LockRc(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Lock failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Lock failed rc = 0x%x\n", rc ); goto ErrorLocked; } if (pSocket->m_state != SS_REP_SENT) { @@ -1741,7 +1744,7 @@ SdpSocket::CmRtuCallback(IN ib_cm_rtu_rec_t *p_cm_rtu_rec) m_ConnectionList.MoveConnectionFromReplyToReady(pSocket); rc = pSocket->m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("pSocket->m_Lock.Lock failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"pSocket->m_Lock.Lock failed rc = 0x%x\n", rc ); goto ErrorLocked; } @@ -1749,7 +1752,7 @@ SdpSocket::CmRtuCallback(IN ib_cm_rtu_rec_t *p_cm_rtu_rec) m_ConnectionList.FreeWaitingIfCan(); rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Lock failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Lock failed rc = 0x%x\n", rc ); goto Cleanup; } @@ -1766,7 +1769,7 @@ ErrorLocked: // Previous rc doesn't mater as this function is void rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); // BUGBUG: who is responsibale for the cleanup ??????? } goto Cleanup; @@ -1776,7 +1779,7 @@ ErrorLocked: VOID SdpSocket::CmDreqCallback(IN ib_cm_dreq_rec_t *p_cm_dreq_rec) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p, dispatch level = %d\n", this, KeGetCurrentIrql())); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p, dispatch level = %d\n", this, KeGetCurrentIrql()); ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); NTSTATUS rc = STATUS_SUCCESS; ib_cm_drep_t cm_drep; @@ -1789,13 +1792,13 @@ SdpSocket::CmDreqCallback(IN ib_cm_dreq_rec_t *p_cm_dreq_rec) // BUGBUG: It seems that even when the lock fails we should send // drep if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Lock failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Lock failed rc = 0x%x\n", rc ); goto Cleanup; } if (m_state != SS_CONNECTED) { // This is not the state that we waited for, we drop the request - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Not the expacted state %s\n", SS2String(m_state))); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Not the expacted state %s\n", SS2String(m_state)); ASSERT(FALSE); // Can this happen on shutdown ? goto ErrorLocked; } @@ -1805,7 +1808,7 @@ SdpSocket::CmDreqCallback(IN ib_cm_dreq_rec_t *p_cm_dreq_rec) ib_status = ib_cm_drep( p_cm_dreq_rec->h_cm_dreq, &cm_drep ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_cm_drep failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_cm_drep failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto ErrorLocked; } @@ -1817,7 +1820,7 @@ SdpSocket::CmDreqCallback(IN ib_cm_dreq_rec_t *p_cm_dreq_rec) rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); // BUGBUG: who is responsibale for the cleanup ??????? } @@ -1832,7 +1835,7 @@ ErrorLocked: // Previous rc doesn't mater as this function is void rc = m_Lock.Unlock(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock() failed rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_Lock.Unlock()"); // BUGBUG: who is responsibale for the cleanup ??????? } goto Cleanup; @@ -1845,7 +1848,7 @@ SdpSocket::__recv_cb1( IN const ib_cq_handle_t h_cq, IN void *cq_context ) { - SDP_PRINT(SDP_DEBUG, SDP_SOCKET, ("__recv_cb1\n")); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_SOCKET,"__recv_cb1\n"); SdpSocket *pSocket = (SdpSocket *) cq_context; pSocket->m_Lock.SignalCB(RECV_CB_CALLED); @@ -1854,7 +1857,7 @@ SdpSocket::__recv_cb1( NTSTATUS SdpSocket::recv_cb() { - SDP_PRINT(SDP_DEBUG, SDP_SOCKET, ("this = 0x%p \n", this)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_SOCKET,"this = 0x%p \n", this); NTSTATUS rc = STATUS_SUCCESS, rc1 = STATUS_SUCCESS; ib_api_status_t ib_status; ib_wc_t *p_free, *p_wc1; @@ -1873,7 +1876,7 @@ SdpSocket::recv_cb() ib_status = ib_poll_cq( m_rcq, &p_free, &p_wc1 ); if( (ib_status != IB_SUCCESS) && (ib_status != IB_NOT_FOUND) ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_poll_cq failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_poll_cq failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -1890,7 +1893,7 @@ SdpSocket::recv_cb() if (p_wc->status == IB_WCS_WR_FLUSHED_ERR) { // We have an error, but we still need to return the packet to the caller pBufferDescriptor = (BufferDescriptor *)p_wc->wr_id; - SDP_PRINT(SDP_DEBUG, SDP_SOCKET, ("p_wc->status == IB_WCS_WR_FLUSHED_ERR \n" )); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_SOCKET,"p_wc->status == IB_WCS_WR_FLUSHED_ERR \n" ); // we can not handle it, but we can and should return it to the pool of recieved buffers rc1 = m_RecvBufferPool.RecievedBuffer(pBufferDescriptor, true); ASSERT(rc1 == STATUS_SUCCESS); // return with error can not fail @@ -1903,7 +1906,7 @@ SdpSocket::recv_cb() ASSERT(len >= sizeof msg_hdr_bsdh); if (len < sizeof msg_hdr_bsdh) { // This is a message that is not big enough - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Recieved a message with a buffer that is too short len = %d\n", len )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Recieved a message with a buffer that is too short len = %d\n", len ); // we can not handle it, but we can and should return it to the pool of recieved buffers rc1 = m_RecvBufferPool.RecievedBuffer(pBufferDescriptor, true); ASSERT(rc1 == STATUS_SUCCESS); // return with error can not fail @@ -1916,7 +1919,7 @@ SdpSocket::recv_cb() ASSERT(pHeader->size >= 0x10); if (len != pHeader->size) { // This is a message that is not formated well - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Recieved a message with a len != pHeader->size = %d : %d\n", len , pHeader->size )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Recieved a message with a len != pHeader->size = %d : %d\n", len , pHeader->size ); // we can not handle it, but we can and should return it to the pool of recieved buffers rc1 = m_RecvBufferPool.RecievedBuffer(pBufferDescriptor, true); ASSERT(rc1 == STATUS_SUCCESS); // return with error can not fail @@ -1932,7 +1935,7 @@ SdpSocket::recv_cb() rc1 = m_RecvBufferPool.RecievedBuffer(pBufferDescriptor, false); if (!NT_SUCCESS(rc1)) { // We have an error, but we should continue, or we will have a leak - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_RecvBufferPool.RecievedBuffer failed rc = 0x%x\n", rc1 )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"m_RecvBufferPool.RecievedBuffer failed rc = 0x%x\n", rc1 ); UpdateRc(&rc, rc1); continue; } @@ -1946,7 +1949,7 @@ Cleanup: if (NT_SUCCESS(rc)) { ib_status = ib_rearm_cq(m_rcq, FALSE ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_rearm_cq failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_rearm_cq failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); // get out of this function } @@ -1964,7 +1967,7 @@ SdpSocket::__send_cb1( IN void *cq_context ) { SdpSocket *pSocket = (SdpSocket *) cq_context; - SDP_PRINT(SDP_DEBUG, SDP_SOCKET, ("called this = 0x%x\n", pSocket )); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_SOCKET,"called this = 0x%p\n", pSocket ); pSocket->m_Lock.SignalCB(SEND_CB_CALLED); } @@ -1988,7 +1991,7 @@ static NTSTATUS __accept_requests(SdpSocket * pSdpSocket) NTSTATUS SdpSocket::send_cb() { - SDP_PRINT(SDP_DEBUG, SDP_SOCKET, ("called this =0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_SOCKET,"called this =0x%p\n", this); NTSTATUS rc = STATUS_SUCCESS, rc1 = STATUS_SUCCESS, rc2 = STATUS_SUCCESS; AssertLocked(); ib_api_status_t ib_status; @@ -2007,11 +2010,11 @@ NTSTATUS SdpSocket::send_cb() ib_status = ib_poll_cq( m_scq, &p_free, &p_wc ); ASSERT( ib_status == IB_SUCCESS || ib_status == IB_NOT_FOUND); if (ib_status == IB_NOT_FOUND) { - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("ib_poll_cq returned IB_NOT_FOUND, this =0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET,"ib_poll_cq returned IB_NOT_FOUND, this =0x%p\n", this); break; } if (ib_status != IB_SUCCESS) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_poll_cq failed ib_status=%d, this =0x%p\n", ib_status,this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_poll_cq failed ib_status=%d, this =0x%p\n", ib_status,this); ASSERT(ib_status == IB_INVALID_CQ_HANDLE || ib_status == IB_NOT_FOUND); rc = IB2Status(ib_status); goto Cleanup; @@ -2032,11 +2035,11 @@ NTSTATUS SdpSocket::send_cb() break; case IB_WCS_WR_FLUSHED_ERR: - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Flushed send completion. this =0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "Flushed send completion. this =0x%p\n", this); // Intentainly fall down default: - SDP_PRINT( SDP_ERR, SDP_SOCKET, ("Send failed with %s\n", - ib_get_wc_status_str( p_wc->status )) ); + SDP_PRINT( TRACE_LEVEL_ERROR, SDP_SOCKET, "Send failed with %s\n", + ib_get_wc_status_str( p_wc->status )); m_Lock.SignalError(IB2Status(ib_status)); } @@ -2045,7 +2048,7 @@ NTSTATUS SdpSocket::send_cb() /* If we didn't use up every WC, break out. */ } while( !p_free ); if (!NT_SUCCESS(rc1)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Error was detected on ReturnBuffer rc1 = 0x%x\n", rc1 )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "Error was detected on ReturnBuffer rc1 = 0x%x\n", rc1 ); ASSERT(NT_SUCCESS(rc)); rc = rc1; goto Cleanup; @@ -2054,7 +2057,7 @@ NTSTATUS SdpSocket::send_cb() /* Rearm the CQ. */ ib_status = ib_rearm_cq(m_scq, FALSE ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_rearm_cq failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "ib_rearm_cq failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -2062,7 +2065,7 @@ NTSTATUS SdpSocket::send_cb() /* Resume any sends awaiting resources. */ rc = m_SendBufferPool.SendBuffersIfCan(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_SendBufferPool.Init SendBuffersIfCan rc = 0x%x\n", rc )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "m_SendBufferPool.Init SendBuffersIfCan rc = 0x%x\n", rc ); goto Cleanup; } @@ -2093,7 +2096,7 @@ __qp_event1( UNUSED_PARAM( p_event_rec ); ASSERT( p_event_rec->context ); /* Place holder for proper error handler. */ - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("Async QP event: %d\n", p_event_rec->code)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"Async QP event: %d\n", p_event_rec->code); ASSERT( p_event_rec->code == IB_AE_UNKNOWN ); } @@ -2111,7 +2114,7 @@ NTSTATUS SdpSocket::CreateQp() net32_t rkey; - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p\n", this); ASSERT(m_SrcCaGuid != 0); /* Open the CA. */ ib_status = ib_open_ca( @@ -2122,7 +2125,7 @@ NTSTATUS SdpSocket::CreateQp() &mh_Ca ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_open_ca failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_open_ca failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -2137,7 +2140,7 @@ NTSTATUS SdpSocket::CreateQp() if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_alloc_pd failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_alloc_pd failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -2156,7 +2159,7 @@ NTSTATUS SdpSocket::CreateQp() ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_create_cq failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_create_cq failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -2174,7 +2177,7 @@ NTSTATUS SdpSocket::CreateQp() ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_create_cq failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_create_cq failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -2192,7 +2195,7 @@ NTSTATUS SdpSocket::CreateQp() qp_create.sq_signaled = TRUE; ib_status = ib_create_qp( m_pd, &qp_create, this, __qp_event1, &m_qp ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_create_qp failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_create_qp failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -2203,10 +2206,10 @@ NTSTATUS SdpSocket::CreateQp() m_qp, &qp_attr ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_query_qp failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_query_qp failed ib_status = 0x%d\n", ib_status ); // ignore the error, this is only needed for debug } - SDP_PRINT(SDP_TRACE, SDP_SOCKET,("QP number is %x\n", CL_NTOH32(qp_attr.num))); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"QP number is %x\n", CL_NTOH32(qp_attr.num)); #endif const net64_t MEM_REG_SIZE = 0xFFFFFFFFFFFFFFFF; @@ -2228,7 +2231,7 @@ NTSTATUS SdpSocket::CreateQp() &rkey, &m_mr ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_reg_phys failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_reg_phys failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); goto Cleanup; } @@ -2247,7 +2250,7 @@ VOID SdpSocket::CreateHelloHeader( ) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p\n", this); ASSERT(DestIp != 0); ASSERT(m_SrcPort != 0); ASSERT(m_SrcIp != 0); @@ -2281,7 +2284,7 @@ VOID SdpSocket::CreateHelloAckHeader( sdp_msg_hello_ack* hello_ack_msg ) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("called this = 0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"called this = 0x%p\n", this); memset(hello_ack_msg, 0, sizeof(struct sdp_msg_hello_ack)); hello_ack_msg->bsdh.recv_bufs = QP_ATTRIB_RQ_DEPTH; //????conn->l_advt_bf; @@ -2359,7 +2362,7 @@ VOID SdpSocket::UsersThreadCallBack(bool Send) NTSTATUS rc = STATUS_SUCCESS; if (!m_Lock.Lock()) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Failed to lock this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "Failed to lock this = 0x%p \n",this); // Error is ignored, as it is a callback path, socket is already at an error state goto Cleanup; } @@ -2367,8 +2370,8 @@ VOID SdpSocket::UsersThreadCallBack(bool Send) InitializeListHead(&m_CallBackRequestList); rc = m_SendBufferPool.UsersThreadCallBack(); if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_SendBufferPool.UsersThreadCallBack failed this = 0x%p, rc = 0x%x \n", - this, rc)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "m_SendBufferPool.UsersThreadCallBack failed this = 0x%p, rc = 0x%x \n", + this, rc); m_Lock.Unlock(); // Error is ignored, as this is already an error path Shutdown(); goto Cleanup; @@ -2378,8 +2381,8 @@ VOID SdpSocket::UsersThreadCallBack(bool Send) rc = m_Lock.Unlock(); // Error is ignored, as it is a callback path if (!NT_SUCCESS(rc)) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_Lock.Unlock failed this = 0x%p, rc = 0x%x \n", - this, rc)); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "m_Lock.Unlock failed this = 0x%p, rc = 0x%x \n", + this, rc); Shutdown(); goto Cleanup; } @@ -2419,7 +2422,7 @@ VOID WaitForShutdownEvent(KEVENT *ShutdownCompleteEvent) ); if (rc == STATUS_TIMEOUT) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Wait failed with time out \n")); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"Wait failed with time out\n"); ASSERT(FALSE); } @@ -2439,10 +2442,10 @@ VOID WaitForShutdownEvent(KEVENT *ShutdownCompleteEvent) VOID SdpSocket::DyingProcessDetected() { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("called this = 0x%p\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "called this = 0x%p\n", this); m_Lock.Lock(true); //????? verify must succeed if (m_CloseSocketCalled) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p m_CloseSocketCalled, letting it finish his job\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "this = 0x%p m_CloseSocketCalled, letting it finish his job\n", this); m_Lock.Unlock(); // Error is ignored since this is already // shutdown call return; @@ -2454,12 +2457,8 @@ VOID SdpSocket::DyingProcessDetected() VOID SdpSocket::Shutdown() { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("called this = 0x%p\n", this)); - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("this = 0x%p m_NumberOfBytesSent = %d m_NumberOfBytesSentAndAcked = %d " - "m_NumberOfBuffersRecievedSuccessfully = %d, m_NumberOfBuffersRecievedWithError = %d\n", - this, m_SendBufferPool.m_NumberOfBytesSent, m_SendBufferPool.m_NumberOfBytesSentAndAcked, - m_RecvBufferPool.m_NumberOfBuffersRecievedSuccessfully, m_RecvBufferPool.m_NumberOfBuffersRecievedWithError)); - + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "called this = 0x%p\n", this); + NTSTATUS rc = STATUS_SUCCESS; ib_api_status_t ib_status; ib_qp_mod_t qp_mod; @@ -2492,7 +2491,7 @@ VOID SdpSocket::Shutdown() if (m_ListenHandle != NULL) { ib_status = ib_cm_cancel( m_ListenHandle, ShutdownCB ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_cm_cancel failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_cm_cancel failed ib_status = 0x%d\n", ib_status ); rc = IB2Status(ib_status); } else { WaitForShutdownEvent(&m_ShutdownCompleteEvent); @@ -2503,17 +2502,17 @@ VOID SdpSocket::Shutdown() m_ConnectionList.Shutdown(); - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("111111\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"111111%p\n", this); if (m_qp != NULL) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("222222\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"222222%p\n", this); cl_memclr( &qp_mod, sizeof(ib_qp_mod_t) ); qp_mod.req_state = IB_QPS_ERROR; ib_status = ib_modify_qp( m_qp, &qp_mod ); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_modify_qp failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_modify_qp failed ib_status = 0x%d\n", ib_status ); ASSERT(FALSE); // We are probably going to leak, but we have to continue } @@ -2530,7 +2529,7 @@ VOID SdpSocket::Shutdown() } } - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("333333\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"333333%p\n", this); if (m_scq != NULL) { ib_status = ib_destroy_cq(m_scq, ShutdownCB); @@ -2540,7 +2539,7 @@ VOID SdpSocket::Shutdown() } //?????m_scq = NULL; } - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("444444\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"444444%p\n", this); if (m_rcq != NULL) { ib_status = ib_destroy_cq(m_rcq, ShutdownCB); @@ -2551,7 +2550,7 @@ VOID SdpSocket::Shutdown() //??????m_rcq = NULL; } - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("555555\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"555555%p\n", this); if (m_pd != NULL) { ib_status = ib_dealloc_pd(m_pd, ShutdownCB); //???ASSERT(ib_status == IB_SUCCESS); @@ -2561,7 +2560,7 @@ VOID SdpSocket::Shutdown() //?????m_pd = NULL; } - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("666666\n", this)); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"666666%p\n", this); if (mh_Ca != NULL) { ib_status = ib_close_ca(mh_Ca, ShutdownCB); @@ -2600,7 +2599,7 @@ VOID SdpSocket::Shutdown() if (m_mr != NULL) { ib_status = ib_dereg_mr(m_mr); if( ib_status != IB_SUCCESS ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_dereg_mr failed ib_status = 0x%d\n", ib_status )); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET,"ib_dereg_mr failed ib_status = 0x%d\n", ib_status ); ASSERT( ib_status == IB_SUCCESS ); } m_mr = NULL; @@ -2623,44 +2622,42 @@ NTSTATUS sdp_cm_hello_ack_check(struct sdp_msg_hello_ack *hello_ack) * validation and consistency checks */ if (hello_ack->bsdh.size != sizeof(struct sdp_msg_hello_ack)) { - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("hello ack, size mismatch. (2) <%d:%d>", + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "hello ack, size mismatch. (2) <%d:%d>", hello_ack->bsdh.size, - sizeof(struct sdp_msg_hello_ack))); + sizeof(struct sdp_msg_hello_ack)); return STATUS_UNEXPECTED_IO_ERROR; } if (SDP_MID_HELLO_ACK != hello_ack->bsdh.mid) { - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("hello ack, unexpected message. <%d>", - hello_ack->bsdh.mid - )); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "hello ack, unexpected message. <%d>", + hello_ack->bsdh.mid); return STATUS_UNEXPECTED_IO_ERROR; } if (hello_ack->hah.max_adv <= 0) { - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("hello ack, bad zcopy advertisment. <%d>", - hello_ack->hah.max_adv - )); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "hello ack, bad zcopy advertisment. <%d>", + hello_ack->hah.max_adv); return STATUS_UNEXPECTED_IO_ERROR; } if ((0xF0 & hello_ack->hah.version) != (0xF0 & SDP_MSG_VERSION)) { - SDP_PRINT(SDP_WARN, SDP_SOCKET, ("hello ack, version mismatch. <%d:%d>", + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "hello ack, version mismatch. <%d:%d>", ((0xF0 & hello_ack->hah.version) >> 4), - ((0xF0 & SDP_MSG_VERSION) >> 4))); + ((0xF0 & SDP_MSG_VERSION) >> 4)); return STATUS_UNEXPECTED_IO_ERROR; } - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("Hello Ack BSDH <%04x:%02x:%02x:%08x:%08x:%08x>", + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "Hello Ack BSDH <%04x:%02x:%02x:%08x:%08x:%08x>", hello_ack->bsdh.recv_bufs, hello_ack->bsdh.flags, hello_ack->bsdh.mid, hello_ack->bsdh.size, hello_ack->bsdh.seq_num, - hello_ack->bsdh.seq_ack)); - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("Hello Ack HAH <%02x:%02x:%08x", + hello_ack->bsdh.seq_ack); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "Hello Ack HAH <%02x:%02x:%08x", hello_ack->hah.max_adv, hello_ack->hah.version, - hello_ack->hah.l_rcv_size)); + hello_ack->hah.l_rcv_size); return STATUS_SUCCESS; } @@ -2677,28 +2674,28 @@ NTSTATUS sdp_cm_hello_check(struct sdp_msg_hello *msg_hello) */ if (msg_hello->bsdh.size != sizeof(struct sdp_msg_hello)) { - SDP_PRINT(SDP_WARN, SDP_SOCKET,( "hello msg size mismatch. (2) <%d:%Zu>", + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "hello msg size mismatch. (2) <%d:%d>", msg_hello->bsdh.size, - sizeof(struct sdp_msg_hello))); + sizeof(struct sdp_msg_hello)); return STATUS_UNEXPECTED_IO_ERROR; } if (SDP_MID_HELLO != msg_hello->bsdh.mid) { - SDP_PRINT(SDP_WARN, SDP_SOCKET,("hello msg unexpected ID. <%d>", - msg_hello->bsdh.mid)); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "hello msg unexpected ID. <%d>", + msg_hello->bsdh.mid); return STATUS_UNEXPECTED_IO_ERROR; } if (msg_hello->hh.max_adv <= 0) { - SDP_PRINT(SDP_WARN, SDP_SOCKET,("hello msg, bad zcopy count <%d>", - msg_hello->hh.max_adv)); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "hello msg, bad zcopy count <%d>", + msg_hello->hh.max_adv); return STATUS_UNEXPECTED_IO_ERROR; } if ((0xF0 & msg_hello->hh.version) != (0xF0 & SDP_MSG_VERSION)) { - SDP_PRINT(SDP_WARN, SDP_SOCKET,("hello msg, version mismatch. <%d:%d>", + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "hello msg, version mismatch. <%d:%d>", ((0xF0 & msg_hello->hh.version) >> 4), - ((0xF0 & SDP_MSG_VERSION) >> 4))); + ((0xF0 & SDP_MSG_VERSION) >> 4)); return STATUS_UNEXPECTED_IO_ERROR; } #ifdef _SDP_MS_APRIL_ERROR_COMPAT @@ -2706,20 +2703,19 @@ NTSTATUS sdp_cm_hello_check(struct sdp_msg_hello *msg_hello) #else if ((SDP_MSG_IPVER & 0xF0) != (msg_hello->hh.ip_ver & 0xF0)) { #endif - SDP_PRINT(SDP_WARN, SDP_SOCKET,( "hello msg, ip version mismatch. <%d:%d>", - msg_hello->hh.ip_ver, SDP_MSG_IPVER)); + SDP_PRINT(TRACE_LEVEL_WARNING, SDP_SOCKET, "hello msg, ip version mismatch. <%d:%d>", + msg_hello->hh.ip_ver, SDP_MSG_IPVER); return STATUS_UNEXPECTED_IO_ERROR; } - SDP_PRINT(SDP_TRACE, SDP_SOCKET,("Hello BSDH <%04x:%02x:%02x:%08x:%08x:%08x>", + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "Hello BSDH <%04x:%02x:%02x:%08x:%08x:%08x>", msg_hello->bsdh.recv_bufs, msg_hello->bsdh.flags, msg_hello->bsdh.mid, msg_hello->bsdh.size, msg_hello->bsdh.seq_num, - msg_hello->bsdh.seq_ack)); - SDP_PRINT(SDP_TRACE, SDP_SOCKET,( - "Hello HH <%02x:%02x:%02x:%08x:%08x:%04x:%08x:%08x>", + msg_hello->bsdh.seq_ack); + SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET, "Hello HH <%02x:%02x:%02x:%08x:%08x:%04x:%08x:%08x>", msg_hello->hh.max_adv, msg_hello->hh.ip_ver, msg_hello->hh.version, @@ -2727,7 +2723,7 @@ NTSTATUS sdp_cm_hello_check(struct sdp_msg_hello *msg_hello) msg_hello->hh.l_rcv_size, msg_hello->hh.port, msg_hello->hh.src.ipv4.addr, - msg_hello->hh.dst.ipv4.addr)); + msg_hello->hh.dst.ipv4.addr); return STATUS_SUCCESS; } diff --git a/trunk/ulp/sdp/kernel/SdpSocket.h b/trunk/ulp/sdp/kernel/SdpSocket.h index b44c36cc..2f477828 100644 --- a/trunk/ulp/sdp/kernel/SdpSocket.h +++ b/trunk/ulp/sdp/kernel/SdpSocket.h @@ -41,6 +41,7 @@ It keeps a list of all the objects so we know when to remove them. #ifndef _SDP_SOCKET_H #define _SDP_SOCKET_H + const int MAX_SEND_BUFFER_SIZE = 1*4096; // This is the maximum send packet size const int MAX_RECV_BUFFER_SIZE = 1*4096; // This is the maximum send packet size @@ -173,7 +174,7 @@ public: SdpSocket(); ~SdpSocket() { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p\n", this)); + //SDP_PRINT(TRACE_LEVEL_INFORMATION, SDP_SOCKET,"this = 0x%p\n", this); } NTSTATUS Init( @@ -280,7 +281,7 @@ public: // Used to allow the user file to remember us LIST_ENTRY m_UserFileList; -#if DBG + static char * SS2String(SocketStates state) { switch (state) { @@ -301,7 +302,7 @@ public: return "Unknown state"; } -#endif + VOID AssertLocked(); }; diff --git a/trunk/ulp/sdp/kernel/SdpTrace.cpp b/trunk/ulp/sdp/kernel/SdpTrace.cpp index 3f70eee4..5b8e388a 100644 --- a/trunk/ulp/sdp/kernel/SdpTrace.cpp +++ b/trunk/ulp/sdp/kernel/SdpTrace.cpp @@ -31,17 +31,77 @@ // Author: Tzachi Dar #include "Precompile.h" +#include +#include +#include -//int g_SdpDbgLevel = SDP_WARN; -int g_SdpDbgLevel = SDP_TRACE; -//int g_SdpDbgLevel = SDP_DEBUG; -BOOLEAN CheckCondition(int sev, int top, char *file, int line, char * func) -{ - if (sev < g_SdpDbgLevel) return FALSE; - if (top == SDP_PERFORMANCE) return FALSE; +#if !defined(EVENT_TRACING) + + +#if DBG +//int g_SdpDbgLevel = TRACE_LEVEL_WARNING; +uint32_t g_SdpDbgLevel = TRACE_LEVEL_INFORMATION; +//int g_SdpDbgLevel = TRACE_LEVEL_VERBOSE; +uint32_t g_SdpDbgFlags= SDP_API; +#endif + +VOID +SDP_PRINT ( + IN ULONG lvl, + IN ULONG flags, + IN PCCHAR msg, + ... + ) + +/*++ + +Routine Description: + + Debug print for the sample driver. + +Arguments: + + DebugPrintLevel - print level between 0 and 3, with 3 the most verbose + +Return Value: + + None. + + --*/ + { +#if DBG +#define TEMP_BUFFER_SIZE 1024 + va_list list; + UCHAR debugMessageBuffer[TEMP_BUFFER_SIZE]; + NTSTATUS status; + + va_start(list, msg); - DbgPrint ("%s: ", func); - if (sev == SDP_ERR) DbgPrint ("ERROR - "); - return TRUE; -} \ No newline at end of file + if (msg) { + + // + // Using new safe string functions instead of _vsnprintf. This function takes + // care of NULL terminating if the message is longer than the buffer. + // + status = RtlStringCbVPrintfA(msg, sizeof(msg), + msg, list); + if(!NT_SUCCESS(status)) { + + KdPrint ((": RtlStringCbVPrintfA failed %x\n", status)); + return; + } + if (lvl <= TRACE_LEVEL_INFORMATION || (lvl <= g_SdpDbgLevel && + ((flags & g_SdpDbgFlags) == flags))) { + KdPrint(("%s:",__FUNCTION__)); + if(lvl == TRACE_LEVEL_ERROR) KdPrint (("ERROR - ")); + KdPrint ((":%s", msg)); + } + } + va_end(list); + + return; +#endif +} + +#endif \ No newline at end of file diff --git a/trunk/ulp/sdp/kernel/SdpTrace.h b/trunk/ulp/sdp/kernel/SdpTrace.h index 9a8029e5..ad1b1d96 100644 --- a/trunk/ulp/sdp/kernel/SdpTrace.h +++ b/trunk/ulp/sdp/kernel/SdpTrace.h @@ -32,13 +32,41 @@ #ifndef H_SDP_TRACE_H #define H_SDP_TRACE_H +extern "C" { +#include +#include +} +#if defined(EVENT_TRACING) -// Debug level masks -#define SDP_ALL 0x00000001 -#define SDP_DEBUG 0x00000002 // also per packet, (would probably change) -#define SDP_TRACE 0x00000004 // No - per packet (data) print -#define SDP_WARN 0x00000008 -#define SDP_ERR 0x00000010 +// +// Software Tracing Definitions +// +#define WPP_CONTROL_GUIDS \ + WPP_DEFINE_CONTROL_GUID(SdpCtlGuid,(2D4C03CC, E071, 48e2, BDBD, 526A0D69D6C9), \ + WPP_DEFINE_BIT( SDP_API) \ + WPP_DEFINE_BIT( SDP_CONNECT) \ + WPP_DEFINE_BIT( SDP_DRIVER) \ + WPP_DEFINE_BIT( SDP_SOCKET) \ + WPP_DEFINE_BIT( SDP_ARP) \ + WPP_DEFINE_BIT( SDP_BUFFER_POOL) \ + WPP_DEFINE_BIT( SDP_LOCK) \ + WPP_DEFINE_BIT( SDP_PERFORMANCE) \ + WPP_DEFINE_BIT( SDP_CONNECTION_LIST) \ + WPP_DEFINE_BIT( SDP_CREDITS)) + +#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl) +#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags) +#define WPP_FLAG_ENABLED(flags)(WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= TRACE_LEVEL_VERBOSE) +#define WPP_FLAG_LOGGER(flags) WPP_LEVEL_LOGGER(flags) + +// begin_wpp config +// SDP_ENTER(FLAG); +// SDP_EXIT(FLAG); +// USESUFFIX(SDP_ENTER, "%!FUNC!["); +// USESUFFIX(SDP_ENTER, "%!FUNC!]"); +// end_wpp + +#else // Debug toppics #define SDP_API 0x000001 @@ -54,16 +82,13 @@ -// BUGBUG: CONVERT TO A FUNCTION - -BOOLEAN CheckCondition(int sev, int top, char *file, int line, char * func); +VOID + SDP_PRINT( + IN ULONG lvl, + IN ULONG flags, + IN PCCHAR msg, + ...); -#if DBG -#define SDP_PRINT(sev, toppic ,var_args) \ - if (CheckCondition(sev, toppic ,__FILE__, __LINE__,__FUNCTION__) != FALSE) \ - DbgPrint var_args -#else -#define SDP_PRINT(sev, toppic ,var_args) #endif diff --git a/trunk/ulp/sdp/kernel/SdpUserFile.cpp b/trunk/ulp/sdp/kernel/SdpUserFile.cpp index e4932cc7..257d0e28 100644 --- a/trunk/ulp/sdp/kernel/SdpUserFile.cpp +++ b/trunk/ulp/sdp/kernel/SdpUserFile.cpp @@ -32,6 +32,14 @@ #include "Precompile.h" + +#if defined(EVENT_TRACING) +#ifdef offsetof +#undef offsetof +#endif +#include "SdpUserFile.tmh" +#endif + SdpUserFile::SdpUserFile() { InitializeListHead(&m_SocketsList); @@ -50,7 +58,7 @@ NTSTATUS SdpUserFile::Init() void SdpUserFile::Shutdown() { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("Called this = 0x%p \n",this)); + SDP_PRINT(TRACE_LEVEL_VERBOSE, SDP_SOCKET, "Called this = 0x%p \n",this); // go over the entire list, and release it's objects CSpinLockWrapper Lock(m_Lock); Lock.Lock(); @@ -213,7 +221,7 @@ SdpUserFile::UsersThread() long NumberOfThreads = InterlockedIncrement(&m_NumberOfUserThreads); if(NumberOfThreads != 1) { // It seems that more than one uesr is here, don't let him - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("More than one user thread !!! \n")); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "More than one user thread !!! \n"); ASSERT(FALSE); return STATUS_ACCESS_DENIED; } @@ -252,7 +260,7 @@ SdpUserFile::UsersThread() rc = MyKeWaitForSingleObject(&m_UsersCallEvent, UserRequest, UserMode, TRUE, NULL); if (rc == STATUS_USER_APC ) { - SDP_PRINT(SDP_ERR, SDP_SOCKET, ("Worker thread has recieved a user APC, shuting down the process \n")); + SDP_PRINT(TRACE_LEVEL_ERROR, SDP_SOCKET, "Worker thread has recieved a user APC, shuting down the process \n"); Shutdown(); return STATUS_SUCCESS; }