From a031c900ca6eb40a914327bfc9e9cca370016d56 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Thu, 3 Dec 2009 15:37:52 -0500 Subject: [PATCH] add rx packet trace debug dumping for unix revised version of a patch i've had for months to actually be clean. allow state of all packets to be dumped so you can see what's on what queues where. Change-Id: Ibaa692c835e9ced5e7cd3299922f5bac09344d28 Reviewed-on: http://gerrit.openafs.org/883 Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear --- src/rx/rx.c | 23 ++++++++++++++++++----- src/rx/rx_packet.c | 26 +++++++++++++++++++------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/rx/rx.c b/src/rx/rx.c index 48e724d6d..0918c09e4 100755 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -8197,20 +8197,30 @@ DllMain(HINSTANCE dllInstHandle, /* instance handle for this DLL module */ return FALSE; } } +#endif /* AFS_NT40_ENV */ int rx_DumpCalls(FILE *outputFile, char *cookie) { #ifdef RXDEBUG_PACKET - int zilch; #ifdef KDUMP_RX_LOCK struct rx_call_rx_lock *c; #else struct rx_call *c; #endif +#ifdef AFS_NT40_ENV + int zilch; char output[2048]; +#define RXDPRINTF sprintf +#define RXDPRINTOUT output +#else +#define RXDPRINTF fprintf +#define RXDPRINTOUT outputFile +#endif - sprintf(output, "%s - Start dumping all Rx Calls - count=%u\r\n", cookie, rx_stats.nCallStructs); + RXDPRINTF(RXDPRINTOUT, "%s - Start dumping all Rx Calls - count=%u\r\n", cookie, rx_stats.nCallStructs); +#ifdef AFS_NT40_ENV WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); +#endif for (c = rx_allCallsp; c; c = c->allNextp) { u_short rqc, tqc, iovqc; @@ -8221,7 +8231,7 @@ int rx_DumpCalls(FILE *outputFile, char *cookie) queue_Count(&c->tq, p, np, rx_packet, tqc); queue_Count(&c->iovq, p, np, rx_packet, iovqc); - sprintf(output, "%s - call=0x%p, id=%u, state=%u, mode=%u, conn=%p, epoch=%u, cid=%u, callNum=%u, connFlags=0x%x, flags=0x%x, " + RXDPRINTF(RXDPRINTOUT, "%s - call=0x%p, id=%u, state=%u, mode=%u, conn=%p, epoch=%u, cid=%u, callNum=%u, connFlags=0x%x, flags=0x%x, " "rqc=%u,%u, tqc=%u,%u, iovqc=%u,%u, " "lstatus=%u, rstatus=%u, error=%d, timeout=%u, " "resendEvent=%d, timeoutEvt=%d, keepAliveEvt=%d, delayedAckEvt=%d, delayedAbortEvt=%d, abortCode=%d, abortCount=%d, " @@ -8249,12 +8259,15 @@ int rx_DumpCalls(FILE *outputFile, char *cookie) ); MUTEX_EXIT(&c->lock); +#ifdef AFS_NT40_ENV WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); +#endif } - sprintf(output, "%s - End dumping all Rx Calls\r\n", cookie); + RXDPRINTF(RXDPRINTOUT, "%s - End dumping all Rx Calls\r\n", cookie); +#ifdef AFS_NT40_ENV WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); +#endif #endif /* RXDEBUG_PACKET */ return 0; } -#endif /* AFS_NT40_ENV */ diff --git a/src/rx/rx_packet.c b/src/rx/rx_packet.c index b35f4e134..c78fd1544 100644 --- a/src/rx/rx_packet.c +++ b/src/rx/rx_packet.c @@ -2762,7 +2762,7 @@ rxi_AdjustDgramPackets(int frags, int mtu) return (2 + (maxMTU / (RX_JUMBOBUFFERSIZE + RX_JUMBOHEADERSIZE))); } -#ifdef AFS_NT40_ENV +#ifndef KERNEL /* * This function can be used by the Windows Cache Manager * to dump the list of all rx packets so that we can determine @@ -2771,32 +2771,44 @@ rxi_AdjustDgramPackets(int frags, int mtu) int rx_DumpPackets(FILE *outputFile, char *cookie) { #ifdef RXDEBUG_PACKET - int zilch; struct rx_packet *p; +#ifdef AFS_NT40_ENV + int zilch; char output[2048]; +#define RXDPRINTF sprintf +#define RXDPRINTOUT output +#else +#define RXDPRINTF fprintf +#define RXDPRINTOUT outputFile +#endif NETPRI; MUTEX_ENTER(&rx_freePktQ_lock); - sprintf(output, "%s - Start dumping all Rx Packets - count=%u\r\n", cookie, rx_packet_id); + RXDPRINTF(RXDPRINTOUT, "%s - Start dumping all Rx Packets - count=%u\r\n", cookie, rx_packet_id); +#ifdef AFS_NT40_ENV WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); +#endif for (p = rx_mallocedP; p; p = p->allNextp) { - sprintf(output, "%s - packet=0x%p, id=%u, firstSent=%u.%08u, timeSent=%u.%08u, retryTime=%u.%08u, firstSerial=%u, niovecs=%u, flags=0x%x, backoff=%u, length=%u header: epoch=%u, cid=%u, callNum=%u, seq=%u, serial=%u, type=%u, flags=0x%x, userStatus=%u, securityIndex=%u, serviceId=%u\r\n", + RXDPRINTF(RXDPRINTOUT, "%s - packet=0x%p, id=%u, firstSent=%u.%08u, timeSent=%u.%08u, retryTime=%u.%08u, firstSerial=%u, niovecs=%u, flags=0x%x, backoff=%u, length=%u header: epoch=%u, cid=%u, callNum=%u, seq=%u, serial=%u, type=%u, flags=0x%x, userStatus=%u, securityIndex=%u, serviceId=%u\r\n", cookie, p, p->packetId, p->firstSent.sec, p->firstSent.usec, p->timeSent.sec, p->timeSent.usec, p->retryTime.sec, p->retryTime.usec, p->firstSerial, p->niovecs, (afs_uint32)p->flags, (afs_uint32)p->backoff, (afs_uint32)p->length, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.serial, (afs_uint32)p->header.type, (afs_uint32)p->header.flags, (afs_uint32)p->header.userStatus, (afs_uint32)p->header.securityIndex, (afs_uint32)p->header.serviceId); +#ifdef AFS_NT40_ENV WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); +#endif } - sprintf(output, "%s - End dumping all Rx Packets\r\n", cookie); + RXDPRINTF(RXDPRINTOUT, "%s - End dumping all Rx Packets\r\n", cookie); +#ifdef AFS_NT40_ENV WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL); +#endif MUTEX_EXIT(&rx_freePktQ_lock); USERPRI; #endif /* RXDEBUG_PACKET */ return 0; } -#endif /* AFS_NT40_ENV */ - +#endif -- 2.39.5