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