ReactOS 0.4.16-dev-570-g1868985
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
50struct stats_ lwip_stats;
51
52void
53stats_init(void)
54{
55#ifdef LWIP_DEBUG
56#if MEM_STATS
57 lwip_stats.mem.name = "MEM";
58#endif /* MEM_STATS */
59#endif /* LWIP_DEBUG */
60}
61
62#if LWIP_STATS_DISPLAY
63void
64stats_display_proto(struct stats_proto *proto, const char *name)
65{
66 LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
67 LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit));
68 LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv));
69 LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw));
70 LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop));
71 LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr));
72 LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr));
73 LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr));
74 LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr));
75 LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr));
76 LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr));
77 LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err));
78 LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit));
79}
80
81#if IGMP_STATS || MLD6_STATS
82void
83stats_display_igmp(struct stats_igmp *igmp, const char *name)
84{
85 LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
86 LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit));
87 LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv));
88 LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop));
89 LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr));
90 LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr));
91 LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr));
92 LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr));
93 LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1));
94 LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n\t", igmp->rx_group));
95 LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n\t", igmp->rx_general));
96 LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report));
97 LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join));
98 LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave));
99 LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n", igmp->tx_report));
100}
101#endif /* IGMP_STATS || MLD6_STATS */
102
103#if MEM_STATS || MEMP_STATS
104void
105stats_display_mem(struct stats_mem *mem, const char *name)
106{
107 LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name));
108 LWIP_PLATFORM_DIAG(("avail: %"MEM_SIZE_F"\n\t", mem->avail));
109 LWIP_PLATFORM_DIAG(("used: %"MEM_SIZE_F"\n\t", mem->used));
110 LWIP_PLATFORM_DIAG(("max: %"MEM_SIZE_F"\n\t", mem->max));
111 LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n", mem->err));
112}
113
114#if MEMP_STATS
115void
116stats_display_memp(struct stats_mem *mem, int idx)
117{
118 if (idx < MEMP_MAX) {
119 stats_display_mem(mem, mem->name);
120 }
121}
122#endif /* MEMP_STATS */
123#endif /* MEM_STATS || MEMP_STATS */
124
125#if SYS_STATS
126void
127stats_display_sys(struct stats_sys *sys)
128{
129 LWIP_PLATFORM_DIAG(("\nSYS\n\t"));
130 LWIP_PLATFORM_DIAG(("sem.used: %"STAT_COUNTER_F"\n\t", sys->sem.used));
131 LWIP_PLATFORM_DIAG(("sem.max: %"STAT_COUNTER_F"\n\t", sys->sem.max));
132 LWIP_PLATFORM_DIAG(("sem.err: %"STAT_COUNTER_F"\n\t", sys->sem.err));
133 LWIP_PLATFORM_DIAG(("mutex.used: %"STAT_COUNTER_F"\n\t", sys->mutex.used));
134 LWIP_PLATFORM_DIAG(("mutex.max: %"STAT_COUNTER_F"\n\t", sys->mutex.max));
135 LWIP_PLATFORM_DIAG(("mutex.err: %"STAT_COUNTER_F"\n\t", sys->mutex.err));
136 LWIP_PLATFORM_DIAG(("mbox.used: %"STAT_COUNTER_F"\n\t", sys->mbox.used));
137 LWIP_PLATFORM_DIAG(("mbox.max: %"STAT_COUNTER_F"\n\t", sys->mbox.max));
138 LWIP_PLATFORM_DIAG(("mbox.err: %"STAT_COUNTER_F"\n", sys->mbox.err));
139}
140#endif /* SYS_STATS */
141
142void
143stats_display(void)
144{
145 s16_t i;
146
161 for (i = 0; i < MEMP_MAX; i++) {
163 }
165}
166#endif /* LWIP_STATS_DISPLAY */
167
168#endif /* LWIP_STATS */
unsigned int idx
Definition: utils.c:41
#define LWIP_PLATFORM_DIAG(x)
Definition: cc.h:33
#define MEM_SIZE_F
Definition: mem.h:68
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
int16_t s16_t
Definition: arch.h:128
@ MEMP_MAX
Definition: memp.h:55
#define MLD6_STATS_DISPLAY()
Definition: stats.h:453
#define IP6_STATS_DISPLAY()
Definition: stats.h:429
#define stats_display_proto(proto, name)
Definition: stats.h:480
#define LINK_STATS_DISPLAY()
Definition: stats.h:385
#define TCP_STATS_DISPLAY()
Definition: stats.h:329
#define ETHARP_STATS_DISPLAY()
Definition: stats.h:377
#define stats_display_igmp(igmp, name)
Definition: stats.h:481
#define stats_display_memp(mem, index)
Definition: stats.h:483
#define MEMP_STATS_DISPLAY(i)
Definition: stats.h:408
#define ND6_STATS_DISPLAY()
Definition: stats.h:461
#define stats_init()
Definition: stats.h:318
#define ICMP_STATS_DISPLAY()
Definition: stats.h:345
#define IGMP_STATS_DISPLAY()
Definition: stats.h:353
#define stats_display_mem(mem, name)
Definition: stats.h:482
#define UDP_STATS_DISPLAY()
Definition: stats.h:337
#define ICMP6_STATS_DISPLAY()
Definition: stats.h:437
#define SYS_STATS_DISPLAY()
Definition: stats.h:421
#define IPFRAG_STATS_DISPLAY()
Definition: stats.h:369
#define stats_display_sys(sys)
Definition: stats.h:484
#define IP_STATS_DISPLAY()
Definition: stats.h:361
#define IP6_FRAG_STATS_DISPLAY()
Definition: stats.h:445
#define MEM_STATS_DISPLAY()
Definition: stats.h:399
#define stats_display()
Definition: stats.h:479
char * name
Definition: compiler.c:66
Definition: mem.c:349
u8_t used
Definition: mem.c:355
Definition: name.c:39