ReactOS 0.4.15-dev-7958-gcd0bb1a
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
47#include <string.h>
48
49struct stats_ lwip_stats;
50
51void stats_init(void)
52{
53#ifdef LWIP_DEBUG
54#if MEMP_STATS
55 const char * memp_names[] = {
56#define LWIP_MEMPOOL(name,num,size,desc) desc,
57#include "lwip/memp_std.h"
58 };
59 int i;
60 for (i = 0; i < MEMP_MAX; i++) {
61 lwip_stats.memp[i].name = memp_names[i];
62 }
63#endif /* MEMP_STATS */
64#if MEM_STATS
65 lwip_stats.mem.name = "MEM";
66#endif /* MEM_STATS */
67#endif /* LWIP_DEBUG */
68}
69
70#if LWIP_STATS_DISPLAY
71void
72stats_display_proto(struct stats_proto *proto, const char *name)
73{
74 LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
75 LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit));
76 LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv));
77 LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw));
78 LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop));
79 LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr));
80 LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr));
81 LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr));
82 LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr));
83 LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr));
84 LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr));
85 LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err));
86 LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit));
87}
88
89#if IGMP_STATS
90void
91stats_display_igmp(struct stats_igmp *igmp)
92{
93 LWIP_PLATFORM_DIAG(("\nIGMP\n\t"));
94 LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit));
95 LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv));
96 LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop));
97 LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr));
98 LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr));
99 LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr));
100 LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr));
101 LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1));
102 LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n", igmp->rx_group));
103 LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n", igmp->rx_general));
104 LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report));
105 LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join));
106 LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave));
107 LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report));
108}
109#endif /* IGMP_STATS */
110
111#if MEM_STATS || MEMP_STATS
112void
113stats_display_mem(struct stats_mem *mem, const char *name)
114{
115 LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name));
116 LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail));
117 LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used));
118 LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max));
119 LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err));
120}
121
122#if MEMP_STATS
123void
124stats_display_memp(struct stats_mem *mem, int index)
125{
126 char * memp_names[] = {
127#define LWIP_MEMPOOL(name,num,size,desc) desc,
128#include "lwip/memp_std.h"
129 };
130 if(index < MEMP_MAX) {
131 stats_display_mem(mem, memp_names[index]);
132 }
133}
134#endif /* MEMP_STATS */
135#endif /* MEM_STATS || MEMP_STATS */
136
137#if SYS_STATS
138void
139stats_display_sys(struct stats_sys *sys)
140{
141 LWIP_PLATFORM_DIAG(("\nSYS\n\t"));
142 LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used));
143 LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max));
144 LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err));
145 LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used));
146 LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max));
147 LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err));
148 LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used));
149 LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max));
150 LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err));
151}
152#endif /* SYS_STATS */
153
154void
155stats_display(void)
156{
157 s16_t i;
158
168 for (i = 0; i < MEMP_MAX; i++) {
170 }
172}
173#endif /* LWIP_STATS_DISPLAY */
174
175#endif /* LWIP_STATS */
176
signed short s16_t
Definition: cc.h:29
#define LWIP_PLATFORM_DIAG(x)
Definition: cc.h:50
unsigned long u32_t
Definition: cc.h:25
#define U32_F
Definition: cc.h:39
GLuint index
Definition: glext.h:6031
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ MEMP_MAX
Definition: memp.h:46
#define stats_display_proto(proto, name)
Definition: stats.h:281
#define LINK_STATS_DISPLAY()
Definition: stats.h:228
#define TCP_STATS_DISPLAY()
Definition: stats.h:172
#define ETHARP_STATS_DISPLAY()
Definition: stats.h:220
#define stats_display_memp(mem, index)
Definition: stats.h:284
#define MEMP_STATS_DISPLAY(i)
Definition: stats.h:256
#define stats_display_igmp(igmp)
Definition: stats.h:282
#define stats_init()
Definition: stats.h:161
#define ICMP_STATS_DISPLAY()
Definition: stats.h:188
#define IGMP_STATS_DISPLAY()
Definition: stats.h:196
#define stats_display_mem(mem, name)
Definition: stats.h:283
#define UDP_STATS_DISPLAY()
Definition: stats.h:180
#define SYS_STATS_DISPLAY()
Definition: stats.h:268
#define IPFRAG_STATS_DISPLAY()
Definition: stats.h:212
#define stats_display_sys(sys)
Definition: stats.h:285
#define IP_STATS_DISPLAY()
Definition: stats.h:204
#define MEM_STATS_DISPLAY()
Definition: stats.h:242
#define stats_display()
Definition: stats.h:280
Definition: mem.c:156
u8_t used
Definition: mem.c:162
Definition: name.c:39