Warning, cross-references for /kernel/include/lwip/stats.h need to be fixed.
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #ifndef __LWIP_STATS_H__
0033 #define __LWIP_STATS_H__
0034
0035 #include "lwip/opt.h"
0036
0037 #include "lwip/mem.h"
0038 #include "lwip/memp.h"
0039
0040 #ifdef __cplusplus
0041 extern "C" {
0042 #endif
0043
0044 #if LWIP_STATS
0045
0046 #ifndef LWIP_STATS_LARGE
0047 #define LWIP_STATS_LARGE 0
0048 #endif
0049
0050 #if LWIP_STATS_LARGE
0051 #define STAT_COUNTER u32_t
0052 #define STAT_COUNTER_F U32_F
0053 #else
0054 #define STAT_COUNTER u16_t
0055 #define STAT_COUNTER_F U16_F
0056 #endif
0057
0058 struct stats_proto {
0059 STAT_COUNTER xmit;
0060 STAT_COUNTER recv;
0061 STAT_COUNTER fw;
0062 STAT_COUNTER drop;
0063 STAT_COUNTER chkerr;
0064 STAT_COUNTER lenerr;
0065 STAT_COUNTER memerr;
0066 STAT_COUNTER rterr;
0067 STAT_COUNTER proterr;
0068 STAT_COUNTER opterr;
0069 STAT_COUNTER err;
0070 STAT_COUNTER cachehit;
0071 };
0072
0073 struct stats_igmp {
0074 STAT_COUNTER lenerr;
0075 STAT_COUNTER chkerr;
0076 STAT_COUNTER v1_rxed;
0077 STAT_COUNTER join_sent;
0078 STAT_COUNTER leave_sent;
0079 STAT_COUNTER unicast_query;
0080 STAT_COUNTER report_sent;
0081 STAT_COUNTER report_rxed;
0082 STAT_COUNTER group_query_rxed;
0083 };
0084
0085 struct stats_mem {
0086 mem_size_t avail;
0087 mem_size_t used;
0088 mem_size_t max;
0089 STAT_COUNTER err;
0090 STAT_COUNTER illegal;
0091 };
0092
0093 struct stats_syselem {
0094 STAT_COUNTER used;
0095 STAT_COUNTER max;
0096 STAT_COUNTER err;
0097 };
0098
0099 struct stats_sys {
0100 struct stats_syselem sem;
0101 struct stats_syselem mbox;
0102 };
0103
0104 struct stats_ {
0105 #if LINK_STATS
0106 struct stats_proto link;
0107 #endif
0108 #if ETHARP_STATS
0109 struct stats_proto etharp;
0110 #endif
0111 #if IPFRAG_STATS
0112 struct stats_proto ip_frag;
0113 #endif
0114 #if IP_STATS
0115 struct stats_proto ip;
0116 #endif
0117 #if ICMP_STATS
0118 struct stats_proto icmp;
0119 #endif
0120 #if IGMP_STATS
0121 struct stats_igmp igmp;
0122 #endif
0123 #if UDP_STATS
0124 struct stats_proto udp;
0125 #endif
0126 #if TCP_STATS
0127 struct stats_proto tcp;
0128 #endif
0129 #if MEM_STATS
0130 struct stats_mem mem;
0131 #endif
0132 #if MEMP_STATS
0133 struct stats_mem memp[MEMP_MAX];
0134 #endif
0135 #if SYS_STATS
0136 struct stats_sys sys;
0137 #endif
0138 };
0139
0140 extern struct stats_ lwip_stats;
0141
0142 #define stats_init()
0143
0144 #define STATS_INC(x) ++lwip_stats.x
0145 #define STATS_DEC(x) --lwip_stats.x
0146 #else
0147 #define stats_init()
0148 #define STATS_INC(x)
0149 #define STATS_DEC(x)
0150 #endif
0151
0152 #if TCP_STATS
0153 #define TCP_STATS_INC(x) STATS_INC(x)
0154 #define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP")
0155 #else
0156 #define TCP_STATS_INC(x)
0157 #define TCP_STATS_DISPLAY()
0158 #endif
0159
0160 #if UDP_STATS
0161 #define UDP_STATS_INC(x) STATS_INC(x)
0162 #define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP")
0163 #else
0164 #define UDP_STATS_INC(x)
0165 #define UDP_STATS_DISPLAY()
0166 #endif
0167
0168 #if ICMP_STATS
0169 #define ICMP_STATS_INC(x) STATS_INC(x)
0170 #define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP")
0171 #else
0172 #define ICMP_STATS_INC(x)
0173 #define ICMP_STATS_DISPLAY()
0174 #endif
0175
0176 #if IGMP_STATS
0177 #define IGMP_STATS_INC(x) STATS_INC(x)
0178 #define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp)
0179 #else
0180 #define IGMP_STATS_INC(x)
0181 #define IGMP_STATS_DISPLAY()
0182 #endif
0183
0184 #if IP_STATS
0185 #define IP_STATS_INC(x) STATS_INC(x)
0186 #define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP")
0187 #else
0188 #define IP_STATS_INC(x)
0189 #define IP_STATS_DISPLAY()
0190 #endif
0191
0192 #if IPFRAG_STATS
0193 #define IPFRAG_STATS_INC(x) STATS_INC(x)
0194 #define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG")
0195 #else
0196 #define IPFRAG_STATS_INC(x)
0197 #define IPFRAG_STATS_DISPLAY()
0198 #endif
0199
0200 #if ETHARP_STATS
0201 #define ETHARP_STATS_INC(x) STATS_INC(x)
0202 #define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP")
0203 #else
0204 #define ETHARP_STATS_INC(x)
0205 #define ETHARP_STATS_DISPLAY()
0206 #endif
0207
0208 #if LINK_STATS
0209 #define LINK_STATS_INC(x) STATS_INC(x)
0210 #define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK")
0211 #else
0212 #define LINK_STATS_INC(x)
0213 #define LINK_STATS_DISPLAY()
0214 #endif
0215
0216 #if MEM_STATS
0217 #define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y
0218 #define MEM_STATS_INC(x) STATS_INC(mem.x)
0219 #define MEM_STATS_INC_USED(x, y) do { lwip_stats.mem.used += y; \
0220 if (lwip_stats.mem.max < lwip_stats.mem.used) { \
0221 lwip_stats.mem.max = lwip_stats.mem.used; \
0222 } \
0223 } while(0)
0224 #define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y
0225 #define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP")
0226 #else
0227 #define MEM_STATS_AVAIL(x, y)
0228 #define MEM_STATS_INC(x)
0229 #define MEM_STATS_INC_USED(x, y)
0230 #define MEM_STATS_DEC_USED(x, y)
0231 #define MEM_STATS_DISPLAY()
0232 #endif
0233
0234 #if MEMP_STATS
0235 #define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y
0236 #define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x)
0237 #define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x)
0238 #define MEMP_STATS_INC_USED(x, i) do { ++lwip_stats.memp[i].used; \
0239 if (lwip_stats.memp[i].max < lwip_stats.memp[i].used) { \
0240 lwip_stats.memp[i].max = lwip_stats.memp[i].used; \
0241 } \
0242 } while(0)
0243 #define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i)
0244 #else
0245 #define MEMP_STATS_AVAIL(x, i, y)
0246 #define MEMP_STATS_INC(x, i)
0247 #define MEMP_STATS_DEC(x, i)
0248 #define MEMP_STATS_INC_USED(x, i)
0249 #define MEMP_STATS_DISPLAY(i)
0250 #endif
0251
0252 #if SYS_STATS
0253 #define SYS_STATS_INC(x) STATS_INC(sys.x)
0254 #define SYS_STATS_DEC(x) STATS_DEC(sys.x)
0255 #define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys)
0256 #else
0257 #define SYS_STATS_INC(x)
0258 #define SYS_STATS_DEC(x)
0259 #define SYS_STATS_DISPLAY()
0260 #endif
0261
0262
0263 #if LWIP_STATS_DISPLAY
0264 void stats_display(void);
0265 void stats_display_proto(struct stats_proto *proto, char *name);
0266 void stats_display_igmp(struct stats_igmp *igmp);
0267 void stats_display_mem(struct stats_mem *mem, char *name);
0268 void stats_display_memp(struct stats_mem *mem, int index);
0269 void stats_display_sys(struct stats_sys *sys);
0270 #else
0271 #define stats_display()
0272 #define stats_display_proto(proto, name)
0273 #define stats_display_igmp(igmp)
0274 #define stats_display_mem(mem, name)
0275 #define stats_display_memp(mem, index)
0276 #define stats_display_sys(sys)
0277 #endif
0278
0279 #ifdef __cplusplus
0280 }
0281 #endif
0282
0283 #endif