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