Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os by
lwip_stats.c
00001 /** 00002 * @file 00003 * Statistics module 00004 * 00005 */ 00006 00007 /* 00008 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00009 * All rights reserved. 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 00014 * 1. Redistributions of source code must retain the above copyright notice, 00015 * this list of conditions and the following disclaimer. 00016 * 2. Redistributions in binary form must reproduce the above copyright notice, 00017 * this list of conditions and the following disclaimer in the documentation 00018 * and/or other materials provided with the distribution. 00019 * 3. The name of the author may not be used to endorse or promote products 00020 * derived from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00023 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00024 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00025 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00026 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00027 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00030 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00031 * OF SUCH DAMAGE. 00032 * 00033 * This file is part of the lwIP TCP/IP stack. 00034 * 00035 * Author: Adam Dunkels <adam@sics.se> 00036 * 00037 */ 00038 00039 #include "lwip/opt.h" 00040 00041 #if LWIP_STATS /* don't build if not configured for use in lwipopts.h */ 00042 00043 #include "lwip/def.h" 00044 #include "lwip/stats.h" 00045 #include "lwip/mem.h" 00046 #include "lwip/debug.h" 00047 00048 #include <string.h> 00049 00050 struct stats_ lwip_stats; 00051 00052 void 00053 stats_init(void) 00054 { 00055 #ifdef LWIP_DEBUG 00056 #if MEM_STATS 00057 lwip_stats.mem.name = "MEM"; 00058 #endif /* MEM_STATS */ 00059 #endif /* LWIP_DEBUG */ 00060 } 00061 00062 #if LWIP_STATS_DISPLAY 00063 void 00064 stats_display_proto(struct stats_proto *proto, const char *name) 00065 { 00066 LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); 00067 LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); 00068 LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); 00069 LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); 00070 LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); 00071 LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); 00072 LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); 00073 LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); 00074 LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); 00075 LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); 00076 LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); 00077 LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); 00078 LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); 00079 } 00080 00081 #if IGMP_STATS || MLD6_STATS 00082 void 00083 stats_display_igmp(struct stats_igmp *igmp, const char *name) 00084 { 00085 LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); 00086 LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit)); 00087 LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv)); 00088 LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop)); 00089 LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr)); 00090 LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr)); 00091 LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr)); 00092 LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr)); 00093 LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1)); 00094 LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n\t", igmp->rx_group)); 00095 LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n\t", igmp->rx_general)); 00096 LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report)); 00097 LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join)); 00098 LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave)); 00099 LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report)); 00100 } 00101 #endif /* IGMP_STATS || MLD6_STATS */ 00102 00103 #if MEM_STATS || MEMP_STATS 00104 void 00105 stats_display_mem(struct stats_mem *mem, const char *name) 00106 { 00107 LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name)); 00108 LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail)); 00109 LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used)); 00110 LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max)); 00111 LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err)); 00112 } 00113 00114 #if MEMP_STATS 00115 void 00116 stats_display_memp(struct stats_mem *mem, int index) 00117 { 00118 if (index < MEMP_MAX) { 00119 stats_display_mem(mem, mem->name); 00120 } 00121 } 00122 #endif /* MEMP_STATS */ 00123 #endif /* MEM_STATS || MEMP_STATS */ 00124 00125 #if SYS_STATS 00126 void 00127 stats_display_sys(struct stats_sys *sys) 00128 { 00129 LWIP_PLATFORM_DIAG(("\nSYS\n\t")); 00130 LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used)); 00131 LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max)); 00132 LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err)); 00133 LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used)); 00134 LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max)); 00135 LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err)); 00136 LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used)); 00137 LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max)); 00138 LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err)); 00139 } 00140 #endif /* SYS_STATS */ 00141 00142 void 00143 stats_display(void) 00144 { 00145 s16_t i; 00146 00147 LINK_STATS_DISPLAY(); 00148 ETHARP_STATS_DISPLAY(); 00149 IPFRAG_STATS_DISPLAY(); 00150 IP6_FRAG_STATS_DISPLAY(); 00151 IP_STATS_DISPLAY(); 00152 ND6_STATS_DISPLAY(); 00153 IP6_STATS_DISPLAY(); 00154 IGMP_STATS_DISPLAY(); 00155 MLD6_STATS_DISPLAY(); 00156 ICMP_STATS_DISPLAY(); 00157 ICMP6_STATS_DISPLAY(); 00158 UDP_STATS_DISPLAY(); 00159 TCP_STATS_DISPLAY(); 00160 MEM_STATS_DISPLAY(); 00161 for (i = 0; i < MEMP_MAX; i++) { 00162 MEMP_STATS_DISPLAY(i); 00163 } 00164 SYS_STATS_DISPLAY(); 00165 } 00166 #endif /* LWIP_STATS_DISPLAY */ 00167 00168 #endif /* LWIP_STATS */ 00169
Generated on Tue Jul 12 2022 13:15:54 by
