2002-10-19 12:59:30 +00:00
|
|
|
/*
|
2004-02-07 00:30:03 +00:00
|
|
|
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
2002-10-19 12:59:30 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
|
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
|
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
|
|
|
* OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This file is part of the lwIP TCP/IP stack.
|
|
|
|
*
|
|
|
|
* Author: Adam Dunkels <adam@sics.se>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-07-04 23:43:38 +00:00
|
|
|
#include <string.h>
|
2002-10-19 12:59:30 +00:00
|
|
|
|
|
|
|
#include "lwip/opt.h"
|
|
|
|
|
|
|
|
#include "lwip/def.h"
|
|
|
|
|
|
|
|
#include "lwip/stats.h"
|
|
|
|
#include "lwip/mem.h"
|
|
|
|
|
|
|
|
|
2003-03-19 12:37:46 +00:00
|
|
|
#if LWIP_STATS
|
2002-12-18 12:49:01 +00:00
|
|
|
struct stats_ lwip_stats;
|
2003-11-14 13:17:23 +00:00
|
|
|
|
2002-10-19 12:59:30 +00:00
|
|
|
void
|
|
|
|
stats_init(void)
|
|
|
|
{
|
2002-12-18 12:49:01 +00:00
|
|
|
memset(&lwip_stats, 0, sizeof(struct stats_));
|
2002-10-19 12:59:30 +00:00
|
|
|
}
|
2004-03-26 12:47:57 +00:00
|
|
|
#if LWIP_STATS_DISPLAY
|
2004-03-26 12:40:58 +00:00
|
|
|
void
|
|
|
|
stats_display_proto(struct stats_proto *proto, char *name)
|
|
|
|
{
|
|
|
|
LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
|
2007-03-22 16:36:45 +00:00
|
|
|
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));
|
2004-03-26 12:40:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
stats_display_mem(struct stats_mem *mem, char *name)
|
|
|
|
{
|
|
|
|
LWIP_PLATFORM_DIAG(("\n MEM %s\n\t", name));
|
2006-10-11 12:04:04 +00:00
|
|
|
LWIP_PLATFORM_DIAG(("avail: %"MEM_SIZE_F"\n\t", mem->avail));
|
|
|
|
LWIP_PLATFORM_DIAG(("used: %"MEM_SIZE_F"\n\t", mem->used));
|
|
|
|
LWIP_PLATFORM_DIAG(("max: %"MEM_SIZE_F"\n\t", mem->max));
|
|
|
|
LWIP_PLATFORM_DIAG(("err: %"MEM_SIZE_F"\n", mem->err));
|
2004-03-26 12:40:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
stats_display(void)
|
|
|
|
{
|
2007-03-22 16:36:45 +00:00
|
|
|
#if MEMP_STATS
|
2005-11-25 12:03:38 +00:00
|
|
|
s16_t i;
|
2007-03-20 18:12:06 +00:00
|
|
|
char * memp_names[] = {
|
2007-05-16 13:49:44 +00:00
|
|
|
"PBUF_REF/ROM",
|
2007-03-20 18:12:06 +00:00
|
|
|
"RAW_PCB",
|
|
|
|
"UDP_PCB",
|
|
|
|
"TCP_PCB",
|
|
|
|
"TCP_PCB_LISTEN",
|
|
|
|
"TCP_SEG",
|
|
|
|
"NETBUF",
|
|
|
|
"NETCONN",
|
|
|
|
"TCPIP_MSG",
|
2007-07-18 20:30:21 +00:00
|
|
|
#if ARP_QUEUEING
|
2007-03-20 18:12:06 +00:00
|
|
|
"ARP_QUEUE",
|
2007-07-18 20:30:21 +00:00
|
|
|
#endif
|
2007-05-16 13:49:44 +00:00
|
|
|
"PBUF_POOL",
|
2007-07-18 20:30:21 +00:00
|
|
|
"SYS_TIMEOUT",
|
|
|
|
#if MEM_USE_POOLS
|
|
|
|
"MEMP_MEM_POOL_1",
|
|
|
|
"MEMP_MEM_POOL_2",
|
|
|
|
"MEMP_MEM_POOL_3",
|
|
|
|
"MEMP_MEM_POOL_4",
|
|
|
|
#endif
|
2007-03-20 18:12:06 +00:00
|
|
|
};
|
2007-03-22 16:36:45 +00:00
|
|
|
#endif
|
|
|
|
#if LINK_STATS
|
2004-03-26 12:40:58 +00:00
|
|
|
stats_display_proto(&lwip_stats.link, "LINK");
|
2007-03-22 16:36:45 +00:00
|
|
|
#endif
|
|
|
|
#if IPFRAG_STATS
|
2004-03-26 12:40:58 +00:00
|
|
|
stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG");
|
2007-03-22 16:36:45 +00:00
|
|
|
#endif
|
|
|
|
#if IP_STATS
|
2004-03-26 12:40:58 +00:00
|
|
|
stats_display_proto(&lwip_stats.ip, "IP");
|
2007-03-22 16:36:45 +00:00
|
|
|
#endif
|
|
|
|
#if ICMP_STATS
|
2004-03-26 12:40:58 +00:00
|
|
|
stats_display_proto(&lwip_stats.icmp, "ICMP");
|
2007-03-22 16:36:45 +00:00
|
|
|
#endif
|
|
|
|
#if UDP_STATS
|
2004-03-26 12:40:58 +00:00
|
|
|
stats_display_proto(&lwip_stats.udp, "UDP");
|
2007-03-22 16:36:45 +00:00
|
|
|
#endif
|
|
|
|
#if TCP_STATS
|
2004-03-26 12:40:58 +00:00
|
|
|
stats_display_proto(&lwip_stats.tcp, "TCP");
|
2007-03-22 16:36:45 +00:00
|
|
|
#endif
|
|
|
|
#if MEM_STATS
|
2004-03-26 12:40:58 +00:00
|
|
|
stats_display_mem(&lwip_stats.mem, "HEAP");
|
2007-03-22 16:36:45 +00:00
|
|
|
#endif
|
|
|
|
#if MEMP_STATS
|
2004-03-26 12:40:58 +00:00
|
|
|
for (i = 0; i < MEMP_MAX; i++) {
|
|
|
|
stats_display_mem(&lwip_stats.memp[i], memp_names[i]);
|
|
|
|
}
|
2007-03-22 16:36:45 +00:00
|
|
|
#endif
|
2004-03-26 12:40:58 +00:00
|
|
|
}
|
2004-03-26 12:47:57 +00:00
|
|
|
#endif /* LWIP_STATS_DISPLAY */
|
2003-03-19 12:37:46 +00:00
|
|
|
#endif /* LWIP_STATS */
|
2003-11-14 13:17:23 +00:00
|
|
|
|