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