NetTribute library with debug turned on in FShandler Donatien Garner -> Segundo Equipo -> this version

Committer:
hexley
Date:
Fri Nov 19 01:54:45 2010 +0000
Revision:
0:281d6ff68967

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hexley 0:281d6ff68967 1 /**
hexley 0:281d6ff68967 2 * @file
hexley 0:281d6ff68967 3 * Statistics module
hexley 0:281d6ff68967 4 *
hexley 0:281d6ff68967 5 */
hexley 0:281d6ff68967 6
hexley 0:281d6ff68967 7 /*
hexley 0:281d6ff68967 8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
hexley 0:281d6ff68967 9 * All rights reserved.
hexley 0:281d6ff68967 10 *
hexley 0:281d6ff68967 11 * Redistribution and use in source and binary forms, with or without modification,
hexley 0:281d6ff68967 12 * are permitted provided that the following conditions are met:
hexley 0:281d6ff68967 13 *
hexley 0:281d6ff68967 14 * 1. Redistributions of source code must retain the above copyright notice,
hexley 0:281d6ff68967 15 * this list of conditions and the following disclaimer.
hexley 0:281d6ff68967 16 * 2. Redistributions in binary form must reproduce the above copyright notice,
hexley 0:281d6ff68967 17 * this list of conditions and the following disclaimer in the documentation
hexley 0:281d6ff68967 18 * and/or other materials provided with the distribution.
hexley 0:281d6ff68967 19 * 3. The name of the author may not be used to endorse or promote products
hexley 0:281d6ff68967 20 * derived from this software without specific prior written permission.
hexley 0:281d6ff68967 21 *
hexley 0:281d6ff68967 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
hexley 0:281d6ff68967 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
hexley 0:281d6ff68967 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
hexley 0:281d6ff68967 25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
hexley 0:281d6ff68967 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
hexley 0:281d6ff68967 27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
hexley 0:281d6ff68967 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
hexley 0:281d6ff68967 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
hexley 0:281d6ff68967 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
hexley 0:281d6ff68967 31 * OF SUCH DAMAGE.
hexley 0:281d6ff68967 32 *
hexley 0:281d6ff68967 33 * This file is part of the lwIP TCP/IP stack.
hexley 0:281d6ff68967 34 *
hexley 0:281d6ff68967 35 * Author: Adam Dunkels <adam@sics.se>
hexley 0:281d6ff68967 36 *
hexley 0:281d6ff68967 37 */
hexley 0:281d6ff68967 38
hexley 0:281d6ff68967 39 #include "lwip/opt.h"
hexley 0:281d6ff68967 40
hexley 0:281d6ff68967 41 #if LWIP_STATS /* don't build if not configured for use in lwipopts.h */
hexley 0:281d6ff68967 42
hexley 0:281d6ff68967 43 #include "lwip/def.h"
hexley 0:281d6ff68967 44 #include "lwip/stats.h"
hexley 0:281d6ff68967 45 #include "lwip/mem.h"
hexley 0:281d6ff68967 46
hexley 0:281d6ff68967 47 #include <string.h>
hexley 0:281d6ff68967 48
hexley 0:281d6ff68967 49 struct stats_ lwip_stats;
hexley 0:281d6ff68967 50
hexley 0:281d6ff68967 51 void stats_init(void)
hexley 0:281d6ff68967 52 {
hexley 0:281d6ff68967 53 #ifdef LWIP_DEBUG
hexley 0:281d6ff68967 54 #if MEMP_STATS
hexley 0:281d6ff68967 55 const char * memp_names[] = {
hexley 0:281d6ff68967 56 #define LWIP_MEMPOOL(name,num,size,desc) desc,
hexley 0:281d6ff68967 57 #include "lwip/memp_std.h"
hexley 0:281d6ff68967 58 };
hexley 0:281d6ff68967 59 int i;
hexley 0:281d6ff68967 60 for (i = 0; i < MEMP_MAX; i++) {
hexley 0:281d6ff68967 61 lwip_stats.memp[i].name = memp_names[i];
hexley 0:281d6ff68967 62 }
hexley 0:281d6ff68967 63 #endif /* MEMP_STATS */
hexley 0:281d6ff68967 64 #if MEM_STATS
hexley 0:281d6ff68967 65 lwip_stats.mem.name = "MEM";
hexley 0:281d6ff68967 66 #endif /* MEM_STATS */
hexley 0:281d6ff68967 67 #endif /* LWIP_DEBUG */
hexley 0:281d6ff68967 68 }
hexley 0:281d6ff68967 69
hexley 0:281d6ff68967 70 #if LWIP_STATS_DISPLAY
hexley 0:281d6ff68967 71 void
hexley 0:281d6ff68967 72 stats_display_proto(struct stats_proto *proto, char *name)
hexley 0:281d6ff68967 73 {
hexley 0:281d6ff68967 74 LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
hexley 0:281d6ff68967 75 LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit));
hexley 0:281d6ff68967 76 LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv));
hexley 0:281d6ff68967 77 LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw));
hexley 0:281d6ff68967 78 LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop));
hexley 0:281d6ff68967 79 LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr));
hexley 0:281d6ff68967 80 LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr));
hexley 0:281d6ff68967 81 LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr));
hexley 0:281d6ff68967 82 LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr));
hexley 0:281d6ff68967 83 LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr));
hexley 0:281d6ff68967 84 LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr));
hexley 0:281d6ff68967 85 LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err));
hexley 0:281d6ff68967 86 LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit));
hexley 0:281d6ff68967 87 }
hexley 0:281d6ff68967 88
hexley 0:281d6ff68967 89 #if IGMP_STATS
hexley 0:281d6ff68967 90 void
hexley 0:281d6ff68967 91 stats_display_igmp(struct stats_igmp *igmp)
hexley 0:281d6ff68967 92 {
hexley 0:281d6ff68967 93 LWIP_PLATFORM_DIAG(("\nIGMP\n\t"));
hexley 0:281d6ff68967 94 LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit));
hexley 0:281d6ff68967 95 LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv));
hexley 0:281d6ff68967 96 LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop));
hexley 0:281d6ff68967 97 LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr));
hexley 0:281d6ff68967 98 LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr));
hexley 0:281d6ff68967 99 LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr));
hexley 0:281d6ff68967 100 LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr));
hexley 0:281d6ff68967 101 LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1));
hexley 0:281d6ff68967 102 LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n", igmp->rx_group));
hexley 0:281d6ff68967 103 LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n", igmp->rx_general));
hexley 0:281d6ff68967 104 LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report));
hexley 0:281d6ff68967 105 LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join));
hexley 0:281d6ff68967 106 LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave));
hexley 0:281d6ff68967 107 LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report));
hexley 0:281d6ff68967 108 }
hexley 0:281d6ff68967 109 #endif /* IGMP_STATS */
hexley 0:281d6ff68967 110
hexley 0:281d6ff68967 111 #if MEM_STATS || MEMP_STATS
hexley 0:281d6ff68967 112 void
hexley 0:281d6ff68967 113 stats_display_mem(struct stats_mem *mem, char *name)
hexley 0:281d6ff68967 114 {
hexley 0:281d6ff68967 115 LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name));
hexley 0:281d6ff68967 116 LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail));
hexley 0:281d6ff68967 117 LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used));
hexley 0:281d6ff68967 118 LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max));
hexley 0:281d6ff68967 119 LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err));
hexley 0:281d6ff68967 120 }
hexley 0:281d6ff68967 121
hexley 0:281d6ff68967 122 #if MEMP_STATS
hexley 0:281d6ff68967 123 void
hexley 0:281d6ff68967 124 stats_display_memp(struct stats_mem *mem, int index)
hexley 0:281d6ff68967 125 {
hexley 0:281d6ff68967 126 char * memp_names[] = {
hexley 0:281d6ff68967 127 #define LWIP_MEMPOOL(name,num,size,desc) desc,
hexley 0:281d6ff68967 128 #include "lwip/memp_std.h"
hexley 0:281d6ff68967 129 };
hexley 0:281d6ff68967 130 if(index < MEMP_MAX) {
hexley 0:281d6ff68967 131 stats_display_mem(mem, memp_names[index]);
hexley 0:281d6ff68967 132 }
hexley 0:281d6ff68967 133 }
hexley 0:281d6ff68967 134 #endif /* MEMP_STATS */
hexley 0:281d6ff68967 135 #endif /* MEM_STATS || MEMP_STATS */
hexley 0:281d6ff68967 136
hexley 0:281d6ff68967 137 #if SYS_STATS
hexley 0:281d6ff68967 138 void
hexley 0:281d6ff68967 139 stats_display_sys(struct stats_sys *sys)
hexley 0:281d6ff68967 140 {
hexley 0:281d6ff68967 141 LWIP_PLATFORM_DIAG(("\nSYS\n\t"));
hexley 0:281d6ff68967 142 LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used));
hexley 0:281d6ff68967 143 LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max));
hexley 0:281d6ff68967 144 LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err));
hexley 0:281d6ff68967 145 LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used));
hexley 0:281d6ff68967 146 LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max));
hexley 0:281d6ff68967 147 LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err));
hexley 0:281d6ff68967 148 LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used));
hexley 0:281d6ff68967 149 LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max));
hexley 0:281d6ff68967 150 LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err));
hexley 0:281d6ff68967 151 }
hexley 0:281d6ff68967 152 #endif /* SYS_STATS */
hexley 0:281d6ff68967 153
hexley 0:281d6ff68967 154 void
hexley 0:281d6ff68967 155 stats_display(void)
hexley 0:281d6ff68967 156 {
hexley 0:281d6ff68967 157 s16_t i;
hexley 0:281d6ff68967 158
hexley 0:281d6ff68967 159 LINK_STATS_DISPLAY();
hexley 0:281d6ff68967 160 ETHARP_STATS_DISPLAY();
hexley 0:281d6ff68967 161 IPFRAG_STATS_DISPLAY();
hexley 0:281d6ff68967 162 IP_STATS_DISPLAY();
hexley 0:281d6ff68967 163 IGMP_STATS_DISPLAY();
hexley 0:281d6ff68967 164 ICMP_STATS_DISPLAY();
hexley 0:281d6ff68967 165 UDP_STATS_DISPLAY();
hexley 0:281d6ff68967 166 TCP_STATS_DISPLAY();
hexley 0:281d6ff68967 167 MEM_STATS_DISPLAY();
hexley 0:281d6ff68967 168 for (i = 0; i < MEMP_MAX; i++) {
hexley 0:281d6ff68967 169 MEMP_STATS_DISPLAY(i);
hexley 0:281d6ff68967 170 }
hexley 0:281d6ff68967 171 SYS_STATS_DISPLAY();
hexley 0:281d6ff68967 172 }
hexley 0:281d6ff68967 173 #endif /* LWIP_STATS_DISPLAY */
hexley 0:281d6ff68967 174
hexley 0:281d6ff68967 175 #endif /* LWIP_STATS */
hexley 0:281d6ff68967 176