diff --git a/CHANGELOG b/CHANGELOG index 48148cf7..57412a43 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,13 @@ HISTORY ++ New features: + 2007-03-22 Frédéric Bernon + * stats.h, stats.c, msg_in.c: Stats counters can be change to u32_t if necessary with the + new option LWIP_STATS_LARGE. If you need this option, define LWIP_STATS_LARGE to 1 in + your lwipopts.h. More, unused counters are not defined in the stats structs, and not + display by stats_display(). Note that some options (SYS_STATS and RAW_STATS) are defined + but never used. Fix msg_in.c with the correct #if test for a stat display. + 2007-03-21 Kieran Mansley * netif.c, netif.h: Apply patch#4197 with some changes (originator: rireland@hmgsl.com). Provides callback on netif up/down state change. diff --git a/src/core/snmp/msg_in.c b/src/core/snmp/msg_in.c index 95d27a42..e1088ebe 100644 --- a/src/core/snmp/msg_in.c +++ b/src/core/snmp/msg_in.c @@ -121,7 +121,7 @@ snmp_ok_response(struct snmp_msg_pstat *msg_ps) if (err_ret == ERR_MEM) { /* serious memory problem, can't return tooBig */ -#if LWIP_STATS +#if PBUF_STATS LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event pbufs.used = %"U16_F"\n",lwip_stats.pbuf.used)); #endif } diff --git a/src/core/stats.c b/src/core/stats.c index b1b45b36..fbbf1a69 100644 --- a/src/core/stats.c +++ b/src/core/stats.c @@ -53,31 +53,31 @@ void stats_display_proto(struct stats_proto *proto, char *name) { LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); - LWIP_PLATFORM_DIAG(("xmit: %"S16_F"\n\t", proto->xmit)); - LWIP_PLATFORM_DIAG(("rexmit: %"S16_F"\n\t", proto->rexmit)); - LWIP_PLATFORM_DIAG(("recv: %"S16_F"\n\t", proto->recv)); - LWIP_PLATFORM_DIAG(("fw: %"S16_F"\n\t", proto->fw)); - LWIP_PLATFORM_DIAG(("drop: %"S16_F"\n\t", proto->drop)); - LWIP_PLATFORM_DIAG(("chkerr: %"S16_F"\n\t", proto->chkerr)); - LWIP_PLATFORM_DIAG(("lenerr: %"S16_F"\n\t", proto->lenerr)); - LWIP_PLATFORM_DIAG(("memerr: %"S16_F"\n\t", proto->memerr)); - LWIP_PLATFORM_DIAG(("rterr: %"S16_F"\n\t", proto->rterr)); - LWIP_PLATFORM_DIAG(("proterr: %"S16_F"\n\t", proto->proterr)); - LWIP_PLATFORM_DIAG(("opterr: %"S16_F"\n\t", proto->opterr)); - LWIP_PLATFORM_DIAG(("err: %"S16_F"\n\t", proto->err)); - LWIP_PLATFORM_DIAG(("cachehit: %"S16_F"\n", proto->cachehit)); + LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); + LWIP_PLATFORM_DIAG(("rexmit: %"STAT_COUNTER_F"\n\t", proto->rexmit)); + LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); + LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); + LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); + LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); + LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); + LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); + LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); + LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); + LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); + LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); + LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); } void stats_display_pbuf(struct stats_pbuf *pbuf) { LWIP_PLATFORM_DIAG(("\nPBUF\n\t")); - LWIP_PLATFORM_DIAG(("avail: %"S16_F"\n\t", pbuf->avail)); - LWIP_PLATFORM_DIAG(("used: %"S16_F"\n\t", pbuf->used)); - LWIP_PLATFORM_DIAG(("max: %"S16_F"\n\t", pbuf->max)); - LWIP_PLATFORM_DIAG(("err: %"S16_F"\n\t", pbuf->err)); - LWIP_PLATFORM_DIAG(("alloc_locked: %"S16_F"\n\t", pbuf->alloc_locked)); - LWIP_PLATFORM_DIAG(("refresh_locked: %"S16_F"\n", pbuf->refresh_locked)); + LWIP_PLATFORM_DIAG(("avail: %"STAT_COUNTER_F"\n\t", pbuf->avail)); + LWIP_PLATFORM_DIAG(("used: %"STAT_COUNTER_F"\n\t", pbuf->used)); + LWIP_PLATFORM_DIAG(("max: %"STAT_COUNTER_F"\n\t", pbuf->max)); + LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", pbuf->err)); + LWIP_PLATFORM_DIAG(("alloc_locked: %"STAT_COUNTER_F"\n\t", pbuf->alloc_locked)); + LWIP_PLATFORM_DIAG(("refresh_locked: %"STAT_COUNTER_F"\n", pbuf->refresh_locked)); } void @@ -94,6 +94,7 @@ stats_display_mem(struct stats_mem *mem, char *name) void stats_display(void) { +#if MEMP_STATS s16_t i; char * memp_names[] = { "PBUF", @@ -110,19 +111,36 @@ stats_display(void) #endif "SYS_TIMEOUT" }; - +#endif +#if LINK_STATS stats_display_proto(&lwip_stats.link, "LINK"); +#endif +#if IPFRAG_STATS stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG"); +#endif +#if IP_STATS stats_display_proto(&lwip_stats.ip, "IP"); +#endif +#if ICMP_STATS stats_display_proto(&lwip_stats.icmp, "ICMP"); +#endif +#if UDP_STATS stats_display_proto(&lwip_stats.udp, "UDP"); +#endif +#if TCP_STATS stats_display_proto(&lwip_stats.tcp, "TCP"); +#endif +#if PBUF_STATS stats_display_pbuf(&lwip_stats.pbuf); +#endif +#if MEM_STATS stats_display_mem(&lwip_stats.mem, "HEAP"); +#endif +#if MEMP_STATS for (i = 0; i < MEMP_MAX; i++) { stats_display_mem(&lwip_stats.memp[i], memp_names[i]); } - +#endif } #endif /* LWIP_STATS_DISPLAY */ #endif /* LWIP_STATS */ diff --git a/src/include/lwip/stats.h b/src/include/lwip/stats.h index 71acfd06..e18970cc 100644 --- a/src/include/lwip/stats.h +++ b/src/include/lwip/stats.h @@ -40,20 +40,32 @@ #if LWIP_STATS +#ifndef LWIP_STATS_LARGE +#define LWIP_STATS_LARGE 0 +#endif + +#if LWIP_STATS_LARGE +#define STAT_COUNTER u32_t +#define STAT_COUNTER_F U32_F +#else +#define STAT_COUNTER u16_t +#define STAT_COUNTER_F U16_F +#endif + struct stats_proto { - u16_t xmit; /* Transmitted packets. */ - u16_t rexmit; /* Retransmitted packets. */ - u16_t recv; /* Received packets. */ - u16_t fw; /* Forwarded packets. */ - u16_t drop; /* Dropped packets. */ - u16_t chkerr; /* Checksum error. */ - u16_t lenerr; /* Invalid length error. */ - u16_t memerr; /* Out of memory error. */ - u16_t rterr; /* Routing error. */ - u16_t proterr; /* Protocol error. */ - u16_t opterr; /* Error in options. */ - u16_t err; /* Misc error. */ - u16_t cachehit; + STAT_COUNTER xmit; /* Transmitted packets. */ + STAT_COUNTER rexmit; /* Retransmitted packets. */ + STAT_COUNTER recv; /* Received packets. */ + STAT_COUNTER fw; /* Forwarded packets. */ + STAT_COUNTER drop; /* Dropped packets. */ + STAT_COUNTER chkerr; /* Checksum error. */ + STAT_COUNTER lenerr; /* Invalid length error. */ + STAT_COUNTER memerr; /* Out of memory error. */ + STAT_COUNTER rterr; /* Routing error. */ + STAT_COUNTER proterr; /* Protocol error. */ + STAT_COUNTER opterr; /* Error in options. */ + STAT_COUNTER err; /* Misc error. */ + STAT_COUNTER cachehit; }; struct stats_mem { @@ -64,19 +76,19 @@ struct stats_mem { }; struct stats_pbuf { - u16_t avail; - u16_t used; - u16_t max; - u16_t err; + STAT_COUNTER avail; + STAT_COUNTER used; + STAT_COUNTER max; + STAT_COUNTER err; - u16_t alloc_locked; - u16_t refresh_locked; + STAT_COUNTER alloc_locked; + STAT_COUNTER refresh_locked; }; struct stats_syselem { - u16_t used; - u16_t max; - u16_t err; + STAT_COUNTER used; + STAT_COUNTER max; + STAT_COUNTER err; }; struct stats_sys { @@ -85,21 +97,40 @@ struct stats_sys { }; struct stats_ { +#if LINK_STATS struct stats_proto link; +#endif +#if IPFRAG_STATS struct stats_proto ip_frag; +#endif +#if IP_STATS struct stats_proto ip; +#endif +#if ICMP_STATS struct stats_proto icmp; +#endif +#if UDP_STATS struct stats_proto udp; +#endif +#if TCP_STATS struct stats_proto tcp; +#endif +#if PBUF_STATS struct stats_pbuf pbuf; +#endif +#if MEM_STATS struct stats_mem mem; +#endif +#if MEMP_STATS struct stats_mem memp[MEMP_MAX]; +#endif +#if SYS_STATS struct stats_sys sys; +#endif }; extern struct stats_ lwip_stats; - void stats_init(void); #define STATS_INC(x) ++lwip_stats.x @@ -149,10 +180,6 @@ void stats_init(void); void stats_display(void); #else #define stats_display() -#endif +#endif /* LWIP_STATS_DISPLAY */ #endif /* __LWIP_STATS_H__ */ - - - -