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