Dependencies:   FatFileSystem mbed WeatherMeters SDFileSystem

Committer:
dcoban
Date:
Tue Apr 03 18:43:13 2012 +0000
Revision:
0:1a61c61d0845

        

Who changed what in which revision?

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