Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/lwip/core/stats.c need to be fixed.

0001 /**
0002  * @file
0003  * Statistics module
0004  *
0005  */
0006 
0007 /*
0008  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
0009  * All rights reserved. 
0010  * 
0011  * Redistribution and use in source and binary forms, with or without modification, 
0012  * are permitted provided that the following conditions are met:
0013  *
0014  * 1. Redistributions of source code must retain the above copyright notice,
0015  *    this list of conditions and the following disclaimer.
0016  * 2. Redistributions in binary form must reproduce the above copyright notice,
0017  *    this list of conditions and the following disclaimer in the documentation
0018  *    and/or other materials provided with the distribution.
0019  * 3. The name of the author may not be used to endorse or promote products
0020  *    derived from this software without specific prior written permission. 
0021  *
0022  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
0023  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
0024  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
0025  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
0026  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
0027  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
0030  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
0031  * OF SUCH DAMAGE.
0032  *
0033  * This file is part of the lwIP TCP/IP stack.
0034  * 
0035  * Author: Adam Dunkels <adam@sics.se>
0036  *
0037  */
0038 
0039 #include "lwip/opt.h"
0040 
0041 #if LWIP_STATS /* don't build if not configured for use in lwipopts.h */
0042 
0043 #include "lwip/def.h"
0044 #include "lwip/stats.h"
0045 #include "lwip/mem.h"
0046 
0047 #include <string.h>
0048 
0049 struct stats_ lwip_stats;
0050 
0051 #if LWIP_STATS_DISPLAY
0052 void
0053 stats_display_proto(struct stats_proto *proto, char *name)
0054 {
0055   LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
0056   LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); 
0057   LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); 
0058   LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); 
0059   LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); 
0060   LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); 
0061   LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); 
0062   LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); 
0063   LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); 
0064   LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); 
0065   LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); 
0066   LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); 
0067   LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); 
0068 }
0069 
0070 #if IGMP_STATS
0071 void
0072 stats_display_igmp(struct stats_igmp *igmp)
0073 {
0074   LWIP_PLATFORM_DIAG(("\nIGMP\n\t"));
0075   LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr)); 
0076   LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr)); 
0077   LWIP_PLATFORM_DIAG(("v1_rxed: %"STAT_COUNTER_F"\n\t", igmp->v1_rxed)); 
0078   LWIP_PLATFORM_DIAG(("join_sent: %"STAT_COUNTER_F"\n\t", igmp->join_sent)); 
0079   LWIP_PLATFORM_DIAG(("leave_sent: %"STAT_COUNTER_F"\n\t", igmp->leave_sent)); 
0080   LWIP_PLATFORM_DIAG(("unicast_query: %"STAT_COUNTER_F"\n\t", igmp->unicast_query)); 
0081   LWIP_PLATFORM_DIAG(("report_sent: %"STAT_COUNTER_F"\n\t", igmp->report_sent)); 
0082   LWIP_PLATFORM_DIAG(("report_rxed: %"STAT_COUNTER_F"\n\t", igmp->report_rxed)); 
0083   LWIP_PLATFORM_DIAG(("group_query_rxed: %"STAT_COUNTER_F"\n", igmp->group_query_rxed));
0084 }
0085 #endif /* IGMP_STATS */
0086 
0087 #if MEM_STATS || MEMP_STATS
0088 void
0089 stats_display_mem(struct stats_mem *mem, char *name)
0090 {
0091   LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name));
0092   LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail)); 
0093   LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used)); 
0094   LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max)); 
0095   LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err));
0096 }
0097 
0098 #if MEMP_STATS
0099 void
0100 stats_display_memp(struct stats_mem *mem, int index)
0101 {
0102   char * memp_names[] = {
0103 #define LWIP_MEMPOOL(name,num,size,desc) desc,
0104 #include "lwip/memp_std.h"
0105   };
0106   if(index < MEMP_MAX) {
0107     stats_display_mem(mem, memp_names[index]);
0108   }
0109 }
0110 #endif /* MEMP_STATS */
0111 #endif /* MEM_STATS || MEMP_STATS */
0112 
0113 #if SYS_STATS
0114 void
0115 stats_display_sys(struct stats_sys *sys)
0116 {
0117   LWIP_PLATFORM_DIAG(("\nSYS\n\t"));
0118   LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used)); 
0119   LWIP_PLATFORM_DIAG(("sem.max:  %"U32_F"\n\t", (u32_t)sys->sem.max)); 
0120   LWIP_PLATFORM_DIAG(("sem.err:  %"U32_F"\n\t", (u32_t)sys->sem.err)); 
0121   LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used)); 
0122   LWIP_PLATFORM_DIAG(("mbox.max:  %"U32_F"\n\t", (u32_t)sys->mbox.max)); 
0123   LWIP_PLATFORM_DIAG(("mbox.err:  %"U32_F"\n\t", (u32_t)sys->mbox.err)); 
0124 }
0125 #endif /* SYS_STATS */
0126 
0127 void
0128 stats_display(void)
0129 {
0130   s16_t i;
0131 
0132   LINK_STATS_DISPLAY();
0133   ETHARP_STATS_DISPLAY();
0134   IPFRAG_STATS_DISPLAY();
0135   IP_STATS_DISPLAY();
0136   IGMP_STATS_DISPLAY();
0137   ICMP_STATS_DISPLAY();
0138   UDP_STATS_DISPLAY();
0139   TCP_STATS_DISPLAY();
0140   MEM_STATS_DISPLAY();
0141   for (i = 0; i < MEMP_MAX; i++) {
0142     MEMP_STATS_DISPLAY(i);
0143   }
0144   SYS_STATS_DISPLAY();
0145 }
0146 #endif /* LWIP_STATS_DISPLAY */
0147 
0148 #endif /* LWIP_STATS */
0149