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