]>
Commit | Line | Data |
---|---|---|
6e6d4a8b JP |
1 | /** |
2 | * @file | |
3 | * Statistics module | |
4 | * | |
5 | */ | |
6 | ||
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 | ||
47 | #include <string.h> | |
48 | ||
49 | struct stats_ lwip_stats; | |
50 | ||
51 | #if LWIP_STATS_DISPLAY | |
52 | void | |
53 | stats_display_proto(struct stats_proto *proto, char *name) | |
54 | { | |
55 | LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); | |
56 | LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); | |
57 | LWIP_PLATFORM_DIAG(("rexmit: %"STAT_COUNTER_F"\n\t", proto->rexmit)); | |
58 | LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); | |
59 | LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); | |
60 | LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); | |
61 | LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); | |
62 | LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); | |
63 | LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); | |
64 | LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); | |
65 | LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); | |
66 | LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); | |
67 | LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); | |
68 | LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); | |
69 | } | |
70 | ||
71 | void | |
72 | stats_display_igmp(struct stats_igmp *igmp) | |
73 | { | |
74 | LWIP_PLATFORM_DIAG(("\nIGMP\n\t")); | |
75 | LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr)); | |
76 | LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr)); | |
77 | LWIP_PLATFORM_DIAG(("v1_rxed: %"STAT_COUNTER_F"\n\t", igmp->v1_rxed)); | |
78 | LWIP_PLATFORM_DIAG(("join_sent: %"STAT_COUNTER_F"\n\t", igmp->join_sent)); | |
79 | LWIP_PLATFORM_DIAG(("leave_sent: %"STAT_COUNTER_F"\n\t", igmp->leave_sent)); | |
80 | LWIP_PLATFORM_DIAG(("unicast_query: %"STAT_COUNTER_F"\n\t", igmp->unicast_query)); | |
81 | LWIP_PLATFORM_DIAG(("report_sent: %"STAT_COUNTER_F"\n\t", igmp->report_sent)); | |
82 | LWIP_PLATFORM_DIAG(("report_rxed: %"STAT_COUNTER_F"\n\t", igmp->report_rxed)); | |
83 | LWIP_PLATFORM_DIAG(("group_query_rxed: %"STAT_COUNTER_F"\n", igmp->group_query_rxed)); | |
84 | } | |
85 | ||
86 | void | |
87 | stats_display_mem(struct stats_mem *mem, char *name) | |
88 | { | |
89 | LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name)); | |
90 | LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail)); | |
91 | LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used)); | |
92 | LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max)); | |
93 | LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err)); | |
94 | } | |
95 | ||
96 | void | |
97 | stats_display(void) | |
98 | { | |
99 | #if MEMP_STATS | |
100 | s16_t i; | |
101 | char * memp_names[] = { | |
102 | #define LWIP_MEMPOOL(name,num,size,desc) desc, | |
103 | #include "lwip/memp_std.h" | |
104 | }; | |
105 | #endif | |
106 | #if LINK_STATS | |
107 | stats_display_proto(&lwip_stats.link, "LINK"); | |
108 | #endif | |
109 | #if ETHARP_STATS | |
110 | stats_display_proto(&lwip_stats.etharp, "ETHARP"); | |
111 | #endif | |
112 | #if IPFRAG_STATS | |
113 | stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG"); | |
114 | #endif | |
115 | #if IP_STATS | |
116 | stats_display_proto(&lwip_stats.ip, "IP"); | |
117 | #endif | |
118 | #if ICMP_STATS | |
119 | stats_display_proto(&lwip_stats.icmp, "ICMP"); | |
120 | #endif | |
121 | #if IGMP_STATS | |
122 | stats_display_igmp(&lwip_stats.igmp); | |
123 | #endif | |
124 | #if UDP_STATS | |
125 | stats_display_proto(&lwip_stats.udp, "UDP"); | |
126 | #endif | |
127 | #if TCP_STATS | |
128 | stats_display_proto(&lwip_stats.tcp, "TCP"); | |
129 | #endif | |
130 | #if MEM_STATS | |
131 | stats_display_mem(&lwip_stats.mem, "HEAP"); | |
132 | #endif | |
133 | #if MEMP_STATS | |
134 | for (i = 0; i < MEMP_MAX; i++) { | |
135 | stats_display_mem(&lwip_stats.memp[i], memp_names[i]); | |
136 | } | |
137 | #endif | |
138 | } | |
139 | #endif /* LWIP_STATS_DISPLAY */ | |
140 | ||
141 | #endif /* LWIP_STATS */ | |
142 |