UbixOS V2  2.0
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 "net/opt.h"
40 
41 #if LWIP_STATS /* don't build if not configured for use in lwipopts.h */
42 
43 #include "net/def.h"
44 #include "net/stats.h"
45 #include "net/mem.h"
46 #include "net/debug.h"
47 
48 #include <string.h>
49 
50 struct stats_ lwip_stats;
51 
52 void
53 stats_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
63 void
64 stats_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
82 void
83 stats_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
104 void
105 stats_display_mem(struct stats_mem *mem, const char *name)
106 {
107  LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name));
108  LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail));
109  LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used));
110  LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max));
111  LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err));
112 }
113 
114 #if MEMP_STATS
115 void
116 stats_display_memp(struct stats_mem *mem, int index)
117 {
118  if (index < 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
126 void
127 stats_display_sys(struct stats_sys *sys)
128 {
129  LWIP_PLATFORM_DIAG(("\nSYS\n\t"));
130  LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used));
131  LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max));
132  LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err));
133  LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used));
134  LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max));
135  LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err));
136  LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used));
137  LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max));
138  LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n", (u32_t)sys->mbox.err));
139 }
140 #endif /* SYS_STATS */
141 
142 void
143 stats_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 */
169 
IP6_FRAG_STATS_DISPLAY
#define IP6_FRAG_STATS_DISPLAY()
Definition: stats.h:445
opt.h
s16_t
int16_t s16_t
Definition: arch.h:125
def.h
MLD6_STATS_DISPLAY
#define MLD6_STATS_DISPLAY()
Definition: stats.h:453
stats_display_proto
#define stats_display_proto(proto, name)
Definition: stats.h:480
mem
Definition: mem.c:264
string.h
MEMP_MAX
Definition: memp.h:55
u32_t
uint32_t u32_t
Definition: arch.h:126
mem::used
u8_t used
Definition: mem.c:270
IP6_STATS_DISPLAY
#define IP6_STATS_DISPLAY()
Definition: stats.h:429
ETHARP_STATS_DISPLAY
#define ETHARP_STATS_DISPLAY()
Definition: stats.h:377
TCP_STATS_DISPLAY
#define TCP_STATS_DISPLAY()
Definition: stats.h:329
ICMP_STATS_DISPLAY
#define ICMP_STATS_DISPLAY()
Definition: stats.h:345
stats.h
MEM_STATS_DISPLAY
#define MEM_STATS_DISPLAY()
Definition: stats.h:399
IP_STATS_DISPLAY
#define IP_STATS_DISPLAY()
Definition: stats.h:361
IGMP_STATS_DISPLAY
#define IGMP_STATS_DISPLAY()
Definition: stats.h:353
stats_display_memp
#define stats_display_memp(mem, index)
Definition: stats.h:483
stats_display_igmp
#define stats_display_igmp(igmp, name)
Definition: stats.h:481
IPFRAG_STATS_DISPLAY
#define IPFRAG_STATS_DISPLAY()
Definition: stats.h:369
SYS_STATS_DISPLAY
#define SYS_STATS_DISPLAY()
Definition: stats.h:421
stats_display_mem
#define stats_display_mem(mem, name)
Definition: stats.h:482
stats_display
#define stats_display()
Definition: stats.h:479
name
const char * name
Definition: pci.c:37
MEMP_STATS_DISPLAY
#define MEMP_STATS_DISPLAY(i)
Definition: stats.h:408
stats_init
#define stats_init()
Definition: stats.h:318
LINK_STATS_DISPLAY
#define LINK_STATS_DISPLAY()
Definition: stats.h:385
LWIP_PLATFORM_DIAG
#define LWIP_PLATFORM_DIAG(x)
Definition: arch.h:82
U32_F
#define U32_F
Definition: arch.h:157
UDP_STATS_DISPLAY
#define UDP_STATS_DISPLAY()
Definition: stats.h:337
stats_display_sys
#define stats_display_sys(sys)
Definition: stats.h:484
mem.h
ND6_STATS_DISPLAY
#define ND6_STATS_DISPLAY()
Definition: stats.h:461
ICMP6_STATS_DISPLAY
#define ICMP6_STATS_DISPLAY()
Definition: stats.h:437
debug.h