lwip: refractor to esp specific counter

1. Add tcp debug counter
2. Refractor other ESP specific counter
This commit is contained in:
Liu Zhi Fu
2017-04-05 15:21:55 +08:00
parent 81f71522b6
commit ece61944f4
15 changed files with 263 additions and 194 deletions

View File

@@ -71,7 +71,7 @@ extern const struct memp_desc* const memp_pools[MEMP_MAX];
#include "lwip/mem.h"
#define memp_init()
#if ESP_CNT_DEBUG
#if ESP_STATS_MEM
static inline void* memp_malloc(int type)
{
ESP_CNT_MEM_MALLOC_INC(type);

View File

@@ -140,7 +140,7 @@ struct memp_desc {
#endif /* MEMP_MEM_MALLOC */
};
#if (ESP_CNT_DEBUG == 1)
#if (ESP_STATS_MEM == 1)
extern uint32_t g_lwip_mem_cnt[MEMP_MAX][2];
#define ESP_CNT_MEM_MALLOC_INC(type) g_lwip_mem_cnt[type][0]++
#define ESP_CNT_MEM_FREE_INC(type) g_lwip_mem_cnt[type][1]++

View File

@@ -282,7 +282,7 @@ struct stats_ {
#if MIB2_STATS
struct stats_mib2 mib2;
#endif
#if ESP_STATS
#if ESP_STATS_DROP
struct stats_esp esp;
#endif
};
@@ -458,12 +458,12 @@ void stats_init(void);
#define MIB2_STATS_INC(x)
#endif
#if ESP_STATS
#define ESP_STATS_INC(x) STATS_INC(x)
#define ESP_STATS_DISPLAY() stats_display_esp(&lwip_stats.esp);
#if ESP_STATS_DROP
#define ESP_STATS_DROP_INC(x) STATS_INC(x)
#define ESP_STATS_DROP_DISPLAY() stats_display_esp(&lwip_stats.esp);
#else
#define ESP_STATS_INC(x)
#define ESP_STATS_DISPLAY()
#define ESP_STATS_DROP_INC(x)
#define ESP_STATS_DROP_DISPLAY()
#endif
/* Display of statistics */

View File

@@ -310,8 +310,29 @@ struct tcp_pcb {
u8_t snd_scale;
u8_t rcv_scale;
#endif
#if ESP_STATS_TCP
#define ESP_STATS_TCP_ARRAY_SIZE 20
u16_t retry_cnt[TCP_MAXRTX];
u16_t rto_cnt[ESP_STATS_TCP_ARRAY_SIZE];
#endif
};
#if ESP_STATS_TCP
#define ESP_STATS_TCP_PCB(_pcb) do {\
if ((_pcb)->unacked) {\
(_pcb)->retry_cnt[(_pcb)->nrtx]++;\
if ((_pcb)->rto < ESP_STATS_TCP_ARRAY_SIZE) {\
(_pcb)->rto_cnt[(_pcb)->rto]++;\
} else {\
(_pcb)->rto_cnt[ESP_STATS_TCP_ARRAY_SIZE-1] ++;\
}\
}\
} while(0)
#else
#define ESP_STATS_TCP_PCB(pcb)
#endif
struct tcp_pcb_listen {
/* Common members of all PCB types */
IP_PCB;

View File

@@ -601,8 +601,11 @@
#define ESP_IP4_ATON 1
#define ESP_LIGHT_SLEEP 1
#define ESP_L2_TO_L3_COPY CONFIG_L2_TO_L3_COPY
#define ESP_CNT_DEBUG 0
#define ESP_STATS_MEM 0
#define ESP_STATS_DROP 0
#define ESP_STATS_TCP 0
#define ESP_DHCP_TIMER 1
#define ESP_LWIP_LOGI(...) ESP_LOGI("lwip", __VA_ARGS__)
#define TCP_WND_DEFAULT (4*TCP_MSS)
#define TCP_SND_BUF_DEFAULT (2*TCP_MSS)
@@ -642,7 +645,6 @@ enum {
#define DHCP_DEBUG LWIP_DBG_OFF
#define LWIP_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define ESP_STATS 0
#define CHECKSUM_CHECK_UDP 0
#define CHECKSUM_CHECK_IP 0