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