http://mbed.org/users/okini3939/notebook/logger/

Dependencies:   mbed

Committer:
okini3939
Date:
Sat Apr 16 15:15:48 2011 +0000
Revision:
0:a3c892f39cc1

        

Who changed what in which revision?

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