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