Dependents:   TimeZoneDemo EthernetJackTestCode MMEx_Challenge ntp_mem ... more

Committer:
segundo
Date:
Tue Nov 09 20:54:15 2010 +0000
Revision:
0:ac1725ba162c

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
segundo 0:ac1725ba162c 1 /*
segundo 0:ac1725ba162c 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
segundo 0:ac1725ba162c 3 * All rights reserved.
segundo 0:ac1725ba162c 4 *
segundo 0:ac1725ba162c 5 * Redistribution and use in source and binary forms, with or without modification,
segundo 0:ac1725ba162c 6 * are permitted provided that the following conditions are met:
segundo 0:ac1725ba162c 7 *
segundo 0:ac1725ba162c 8 * 1. Redistributions of source code must retain the above copyright notice,
segundo 0:ac1725ba162c 9 * this list of conditions and the following disclaimer.
segundo 0:ac1725ba162c 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
segundo 0:ac1725ba162c 11 * this list of conditions and the following disclaimer in the documentation
segundo 0:ac1725ba162c 12 * and/or other materials provided with the distribution.
segundo 0:ac1725ba162c 13 * 3. The name of the author may not be used to endorse or promote products
segundo 0:ac1725ba162c 14 * derived from this software without specific prior written permission.
segundo 0:ac1725ba162c 15 *
segundo 0:ac1725ba162c 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
segundo 0:ac1725ba162c 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
segundo 0:ac1725ba162c 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
segundo 0:ac1725ba162c 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
segundo 0:ac1725ba162c 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
segundo 0:ac1725ba162c 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
segundo 0:ac1725ba162c 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
segundo 0:ac1725ba162c 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
segundo 0:ac1725ba162c 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
segundo 0:ac1725ba162c 25 * OF SUCH DAMAGE.
segundo 0:ac1725ba162c 26 *
segundo 0:ac1725ba162c 27 * This file is part of the lwIP TCP/IP stack.
segundo 0:ac1725ba162c 28 *
segundo 0:ac1725ba162c 29 * Author: Adam Dunkels <adam@sics.se>
segundo 0:ac1725ba162c 30 *
segundo 0:ac1725ba162c 31 */
segundo 0:ac1725ba162c 32 #ifndef __LWIP_STATS_H__
segundo 0:ac1725ba162c 33 #define __LWIP_STATS_H__
segundo 0:ac1725ba162c 34
segundo 0:ac1725ba162c 35 #include "lwip/opt.h"
segundo 0:ac1725ba162c 36
segundo 0:ac1725ba162c 37 #include "lwip/mem.h"
segundo 0:ac1725ba162c 38 #include "lwip/memp.h"
segundo 0:ac1725ba162c 39
segundo 0:ac1725ba162c 40 #ifdef __cplusplus
segundo 0:ac1725ba162c 41 extern "C" {
segundo 0:ac1725ba162c 42 #endif
segundo 0:ac1725ba162c 43
segundo 0:ac1725ba162c 44 #if LWIP_STATS
segundo 0:ac1725ba162c 45
segundo 0:ac1725ba162c 46 #ifndef LWIP_STATS_LARGE
segundo 0:ac1725ba162c 47 #define LWIP_STATS_LARGE 0
segundo 0:ac1725ba162c 48 #endif
segundo 0:ac1725ba162c 49
segundo 0:ac1725ba162c 50 #if LWIP_STATS_LARGE
segundo 0:ac1725ba162c 51 #define STAT_COUNTER u32_t
segundo 0:ac1725ba162c 52 #define STAT_COUNTER_F U32_F
segundo 0:ac1725ba162c 53 #else
segundo 0:ac1725ba162c 54 #define STAT_COUNTER u16_t
segundo 0:ac1725ba162c 55 #define STAT_COUNTER_F U16_F
segundo 0:ac1725ba162c 56 #endif
segundo 0:ac1725ba162c 57
segundo 0:ac1725ba162c 58 struct stats_proto {
segundo 0:ac1725ba162c 59 STAT_COUNTER xmit; /* Transmitted packets. */
segundo 0:ac1725ba162c 60 STAT_COUNTER recv; /* Received packets. */
segundo 0:ac1725ba162c 61 STAT_COUNTER fw; /* Forwarded packets. */
segundo 0:ac1725ba162c 62 STAT_COUNTER drop; /* Dropped packets. */
segundo 0:ac1725ba162c 63 STAT_COUNTER chkerr; /* Checksum error. */
segundo 0:ac1725ba162c 64 STAT_COUNTER lenerr; /* Invalid length error. */
segundo 0:ac1725ba162c 65 STAT_COUNTER memerr; /* Out of memory error. */
segundo 0:ac1725ba162c 66 STAT_COUNTER rterr; /* Routing error. */
segundo 0:ac1725ba162c 67 STAT_COUNTER proterr; /* Protocol error. */
segundo 0:ac1725ba162c 68 STAT_COUNTER opterr; /* Error in options. */
segundo 0:ac1725ba162c 69 STAT_COUNTER err; /* Misc error. */
segundo 0:ac1725ba162c 70 STAT_COUNTER cachehit;
segundo 0:ac1725ba162c 71 };
segundo 0:ac1725ba162c 72
segundo 0:ac1725ba162c 73 struct stats_igmp {
segundo 0:ac1725ba162c 74 STAT_COUNTER xmit; /* Transmitted packets. */
segundo 0:ac1725ba162c 75 STAT_COUNTER recv; /* Received packets. */
segundo 0:ac1725ba162c 76 STAT_COUNTER drop; /* Dropped packets. */
segundo 0:ac1725ba162c 77 STAT_COUNTER chkerr; /* Checksum error. */
segundo 0:ac1725ba162c 78 STAT_COUNTER lenerr; /* Invalid length error. */
segundo 0:ac1725ba162c 79 STAT_COUNTER memerr; /* Out of memory error. */
segundo 0:ac1725ba162c 80 STAT_COUNTER proterr; /* Protocol error. */
segundo 0:ac1725ba162c 81 STAT_COUNTER rx_v1; /* Received v1 frames. */
segundo 0:ac1725ba162c 82 STAT_COUNTER rx_group; /* Received group-specific queries. */
segundo 0:ac1725ba162c 83 STAT_COUNTER rx_general; /* Received general queries. */
segundo 0:ac1725ba162c 84 STAT_COUNTER rx_report; /* Received reports. */
segundo 0:ac1725ba162c 85 STAT_COUNTER tx_join; /* Sent joins. */
segundo 0:ac1725ba162c 86 STAT_COUNTER tx_leave; /* Sent leaves. */
segundo 0:ac1725ba162c 87 STAT_COUNTER tx_report; /* Sent reports. */
segundo 0:ac1725ba162c 88 };
segundo 0:ac1725ba162c 89
segundo 0:ac1725ba162c 90 struct stats_mem {
segundo 0:ac1725ba162c 91 #ifdef LWIP_DEBUG
segundo 0:ac1725ba162c 92 const char *name;
segundo 0:ac1725ba162c 93 #endif /* LWIP_DEBUG */
segundo 0:ac1725ba162c 94 mem_size_t avail;
segundo 0:ac1725ba162c 95 mem_size_t used;
segundo 0:ac1725ba162c 96 mem_size_t max;
segundo 0:ac1725ba162c 97 STAT_COUNTER err;
segundo 0:ac1725ba162c 98 STAT_COUNTER illegal;
segundo 0:ac1725ba162c 99 };
segundo 0:ac1725ba162c 100
segundo 0:ac1725ba162c 101 struct stats_syselem {
segundo 0:ac1725ba162c 102 STAT_COUNTER used;
segundo 0:ac1725ba162c 103 STAT_COUNTER max;
segundo 0:ac1725ba162c 104 STAT_COUNTER err;
segundo 0:ac1725ba162c 105 };
segundo 0:ac1725ba162c 106
segundo 0:ac1725ba162c 107 struct stats_sys {
segundo 0:ac1725ba162c 108 struct stats_syselem sem;
segundo 0:ac1725ba162c 109 struct stats_syselem mutex;
segundo 0:ac1725ba162c 110 struct stats_syselem mbox;
segundo 0:ac1725ba162c 111 };
segundo 0:ac1725ba162c 112
segundo 0:ac1725ba162c 113 struct stats_ {
segundo 0:ac1725ba162c 114 #if LINK_STATS
segundo 0:ac1725ba162c 115 struct stats_proto link;
segundo 0:ac1725ba162c 116 #endif
segundo 0:ac1725ba162c 117 #if ETHARP_STATS
segundo 0:ac1725ba162c 118 struct stats_proto etharp;
segundo 0:ac1725ba162c 119 #endif
segundo 0:ac1725ba162c 120 #if IPFRAG_STATS
segundo 0:ac1725ba162c 121 struct stats_proto ip_frag;
segundo 0:ac1725ba162c 122 #endif
segundo 0:ac1725ba162c 123 #if IP_STATS
segundo 0:ac1725ba162c 124 struct stats_proto ip;
segundo 0:ac1725ba162c 125 #endif
segundo 0:ac1725ba162c 126 #if ICMP_STATS
segundo 0:ac1725ba162c 127 struct stats_proto icmp;
segundo 0:ac1725ba162c 128 #endif
segundo 0:ac1725ba162c 129 #if IGMP_STATS
segundo 0:ac1725ba162c 130 struct stats_igmp igmp;
segundo 0:ac1725ba162c 131 #endif
segundo 0:ac1725ba162c 132 #if UDP_STATS
segundo 0:ac1725ba162c 133 struct stats_proto udp;
segundo 0:ac1725ba162c 134 #endif
segundo 0:ac1725ba162c 135 #if TCP_STATS
segundo 0:ac1725ba162c 136 struct stats_proto tcp;
segundo 0:ac1725ba162c 137 #endif
segundo 0:ac1725ba162c 138 #if MEM_STATS
segundo 0:ac1725ba162c 139 struct stats_mem mem;
segundo 0:ac1725ba162c 140 #endif
segundo 0:ac1725ba162c 141 #if MEMP_STATS
segundo 0:ac1725ba162c 142 struct stats_mem memp[MEMP_MAX];
segundo 0:ac1725ba162c 143 #endif
segundo 0:ac1725ba162c 144 #if SYS_STATS
segundo 0:ac1725ba162c 145 struct stats_sys sys;
segundo 0:ac1725ba162c 146 #endif
segundo 0:ac1725ba162c 147 };
segundo 0:ac1725ba162c 148
segundo 0:ac1725ba162c 149 extern struct stats_ lwip_stats;
segundo 0:ac1725ba162c 150
segundo 0:ac1725ba162c 151 void stats_init(void);
segundo 0:ac1725ba162c 152
segundo 0:ac1725ba162c 153 #define STATS_INC(x) ++lwip_stats.x
segundo 0:ac1725ba162c 154 #define STATS_DEC(x) --lwip_stats.x
segundo 0:ac1725ba162c 155 #define STATS_INC_USED(x, y) do { lwip_stats.x.used += y; \
segundo 0:ac1725ba162c 156 if (lwip_stats.x.max < lwip_stats.x.used) { \
segundo 0:ac1725ba162c 157 lwip_stats.x.max = lwip_stats.x.used; \
segundo 0:ac1725ba162c 158 } \
segundo 0:ac1725ba162c 159 } while(0)
segundo 0:ac1725ba162c 160 #else /* LWIP_STATS */
segundo 0:ac1725ba162c 161 #define stats_init()
segundo 0:ac1725ba162c 162 #define STATS_INC(x)
segundo 0:ac1725ba162c 163 #define STATS_DEC(x)
segundo 0:ac1725ba162c 164 #define STATS_INC_USED(x)
segundo 0:ac1725ba162c 165 #endif /* LWIP_STATS */
segundo 0:ac1725ba162c 166
segundo 0:ac1725ba162c 167 #if TCP_STATS
segundo 0:ac1725ba162c 168 #define TCP_STATS_INC(x) STATS_INC(x)
segundo 0:ac1725ba162c 169 #define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP")
segundo 0:ac1725ba162c 170 #else
segundo 0:ac1725ba162c 171 #define TCP_STATS_INC(x)
segundo 0:ac1725ba162c 172 #define TCP_STATS_DISPLAY()
segundo 0:ac1725ba162c 173 #endif
segundo 0:ac1725ba162c 174
segundo 0:ac1725ba162c 175 #if UDP_STATS
segundo 0:ac1725ba162c 176 #define UDP_STATS_INC(x) STATS_INC(x)
segundo 0:ac1725ba162c 177 #define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP")
segundo 0:ac1725ba162c 178 #else
segundo 0:ac1725ba162c 179 #define UDP_STATS_INC(x)
segundo 0:ac1725ba162c 180 #define UDP_STATS_DISPLAY()
segundo 0:ac1725ba162c 181 #endif
segundo 0:ac1725ba162c 182
segundo 0:ac1725ba162c 183 #if ICMP_STATS
segundo 0:ac1725ba162c 184 #define ICMP_STATS_INC(x) STATS_INC(x)
segundo 0:ac1725ba162c 185 #define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP")
segundo 0:ac1725ba162c 186 #else
segundo 0:ac1725ba162c 187 #define ICMP_STATS_INC(x)
segundo 0:ac1725ba162c 188 #define ICMP_STATS_DISPLAY()
segundo 0:ac1725ba162c 189 #endif
segundo 0:ac1725ba162c 190
segundo 0:ac1725ba162c 191 #if IGMP_STATS
segundo 0:ac1725ba162c 192 #define IGMP_STATS_INC(x) STATS_INC(x)
segundo 0:ac1725ba162c 193 #define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp)
segundo 0:ac1725ba162c 194 #else
segundo 0:ac1725ba162c 195 #define IGMP_STATS_INC(x)
segundo 0:ac1725ba162c 196 #define IGMP_STATS_DISPLAY()
segundo 0:ac1725ba162c 197 #endif
segundo 0:ac1725ba162c 198
segundo 0:ac1725ba162c 199 #if IP_STATS
segundo 0:ac1725ba162c 200 #define IP_STATS_INC(x) STATS_INC(x)
segundo 0:ac1725ba162c 201 #define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP")
segundo 0:ac1725ba162c 202 #else
segundo 0:ac1725ba162c 203 #define IP_STATS_INC(x)
segundo 0:ac1725ba162c 204 #define IP_STATS_DISPLAY()
segundo 0:ac1725ba162c 205 #endif
segundo 0:ac1725ba162c 206
segundo 0:ac1725ba162c 207 #if IPFRAG_STATS
segundo 0:ac1725ba162c 208 #define IPFRAG_STATS_INC(x) STATS_INC(x)
segundo 0:ac1725ba162c 209 #define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG")
segundo 0:ac1725ba162c 210 #else
segundo 0:ac1725ba162c 211 #define IPFRAG_STATS_INC(x)
segundo 0:ac1725ba162c 212 #define IPFRAG_STATS_DISPLAY()
segundo 0:ac1725ba162c 213 #endif
segundo 0:ac1725ba162c 214
segundo 0:ac1725ba162c 215 #if ETHARP_STATS
segundo 0:ac1725ba162c 216 #define ETHARP_STATS_INC(x) STATS_INC(x)
segundo 0:ac1725ba162c 217 #define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP")
segundo 0:ac1725ba162c 218 #else
segundo 0:ac1725ba162c 219 #define ETHARP_STATS_INC(x)
segundo 0:ac1725ba162c 220 #define ETHARP_STATS_DISPLAY()
segundo 0:ac1725ba162c 221 #endif
segundo 0:ac1725ba162c 222
segundo 0:ac1725ba162c 223 #if LINK_STATS
segundo 0:ac1725ba162c 224 #define LINK_STATS_INC(x) STATS_INC(x)
segundo 0:ac1725ba162c 225 #define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK")
segundo 0:ac1725ba162c 226 #else
segundo 0:ac1725ba162c 227 #define LINK_STATS_INC(x)
segundo 0:ac1725ba162c 228 #define LINK_STATS_DISPLAY()
segundo 0:ac1725ba162c 229 #endif
segundo 0:ac1725ba162c 230
segundo 0:ac1725ba162c 231 #if MEM_STATS
segundo 0:ac1725ba162c 232 #define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y
segundo 0:ac1725ba162c 233 #define MEM_STATS_INC(x) STATS_INC(mem.x)
segundo 0:ac1725ba162c 234 #define MEM_STATS_INC_USED(x, y) STATS_INC_USED(mem, y)
segundo 0:ac1725ba162c 235 #define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y
segundo 0:ac1725ba162c 236 #define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP")
segundo 0:ac1725ba162c 237 #else
segundo 0:ac1725ba162c 238 #define MEM_STATS_AVAIL(x, y)
segundo 0:ac1725ba162c 239 #define MEM_STATS_INC(x)
segundo 0:ac1725ba162c 240 #define MEM_STATS_INC_USED(x, y)
segundo 0:ac1725ba162c 241 #define MEM_STATS_DEC_USED(x, y)
segundo 0:ac1725ba162c 242 #define MEM_STATS_DISPLAY()
segundo 0:ac1725ba162c 243 #endif
segundo 0:ac1725ba162c 244
segundo 0:ac1725ba162c 245 #if MEMP_STATS
segundo 0:ac1725ba162c 246 #define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y
segundo 0:ac1725ba162c 247 #define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x)
segundo 0:ac1725ba162c 248 #define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x)
segundo 0:ac1725ba162c 249 #define MEMP_STATS_INC_USED(x, i) STATS_INC_USED(memp[i], 1)
segundo 0:ac1725ba162c 250 #define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i)
segundo 0:ac1725ba162c 251 #else
segundo 0:ac1725ba162c 252 #define MEMP_STATS_AVAIL(x, i, y)
segundo 0:ac1725ba162c 253 #define MEMP_STATS_INC(x, i)
segundo 0:ac1725ba162c 254 #define MEMP_STATS_DEC(x, i)
segundo 0:ac1725ba162c 255 #define MEMP_STATS_INC_USED(x, i)
segundo 0:ac1725ba162c 256 #define MEMP_STATS_DISPLAY(i)
segundo 0:ac1725ba162c 257 #endif
segundo 0:ac1725ba162c 258
segundo 0:ac1725ba162c 259 #if SYS_STATS
segundo 0:ac1725ba162c 260 #define SYS_STATS_INC(x) STATS_INC(sys.x)
segundo 0:ac1725ba162c 261 #define SYS_STATS_DEC(x) STATS_DEC(sys.x)
segundo 0:ac1725ba162c 262 #define SYS_STATS_INC_USED(x) STATS_INC_USED(sys.x, 1)
segundo 0:ac1725ba162c 263 #define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys)
segundo 0:ac1725ba162c 264 #else
segundo 0:ac1725ba162c 265 #define SYS_STATS_INC(x)
segundo 0:ac1725ba162c 266 #define SYS_STATS_DEC(x)
segundo 0:ac1725ba162c 267 #define SYS_STATS_INC_USED(x)
segundo 0:ac1725ba162c 268 #define SYS_STATS_DISPLAY()
segundo 0:ac1725ba162c 269 #endif
segundo 0:ac1725ba162c 270
segundo 0:ac1725ba162c 271 /* Display of statistics */
segundo 0:ac1725ba162c 272 #if LWIP_STATS_DISPLAY
segundo 0:ac1725ba162c 273 void stats_display(void);
segundo 0:ac1725ba162c 274 void stats_display_proto(struct stats_proto *proto, char *name);
segundo 0:ac1725ba162c 275 void stats_display_igmp(struct stats_igmp *igmp);
segundo 0:ac1725ba162c 276 void stats_display_mem(struct stats_mem *mem, char *name);
segundo 0:ac1725ba162c 277 void stats_display_memp(struct stats_mem *mem, int index);
segundo 0:ac1725ba162c 278 void stats_display_sys(struct stats_sys *sys);
segundo 0:ac1725ba162c 279 #else /* LWIP_STATS_DISPLAY */
segundo 0:ac1725ba162c 280 #define stats_display()
segundo 0:ac1725ba162c 281 #define stats_display_proto(proto, name)
segundo 0:ac1725ba162c 282 #define stats_display_igmp(igmp)
segundo 0:ac1725ba162c 283 #define stats_display_mem(mem, name)
segundo 0:ac1725ba162c 284 #define stats_display_memp(mem, index)
segundo 0:ac1725ba162c 285 #define stats_display_sys(sys)
segundo 0:ac1725ba162c 286 #endif /* LWIP_STATS_DISPLAY */
segundo 0:ac1725ba162c 287
segundo 0:ac1725ba162c 288 #ifdef __cplusplus
segundo 0:ac1725ba162c 289 }
segundo 0:ac1725ba162c 290 #endif
segundo 0:ac1725ba162c 291
segundo 0:ac1725ba162c 292 #endif /* __LWIP_STATS_H__ */