]> granicus.if.org Git - esp-idf/commitdiff
lwip: refractor to esp specific counter
authorLiu Zhi Fu <liuzhifu@espressif.com>
Wed, 5 Apr 2017 07:21:55 +0000 (15:21 +0800)
committerLiu Zhi Fu <liuzhifu@espressif.com>
Mon, 10 Apr 2017 06:46:48 +0000 (14:46 +0800)
1. Add tcp debug counter
2. Refractor other ESP specific counter

15 files changed:
components/lwip/api/api_msg.c
components/lwip/api/lwip_debug.c [deleted file]
components/lwip/api/tcpip.c
components/lwip/component.mk
components/lwip/core/stats.c
components/lwip/core/tcp.c
components/lwip/core/tcp_out.c
components/lwip/include/lwip/lwip/memp.h
components/lwip/include/lwip/lwip/priv/memp_priv.h
components/lwip/include/lwip/lwip/stats.h
components/lwip/include/lwip/lwip/tcp.h
components/lwip/include/lwip/port/lwipopts.h
components/lwip/port/debug/lwip_debug.c [new file with mode: 0644]
components/lwip/port/freertos/sys_arch.c
components/lwip/port/netif/wlanif.c

index 878cd289b06643e7bf03593ea1b6f26a98d768c7..b49d26041d6f524415e896f61cf475cf76323ad5 100755 (executable)
@@ -128,7 +128,7 @@ recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p,
 
       len = q->tot_len;
       if (sys_mbox_trypost(&conn->recvmbox, buf) != ERR_OK) {
-        ESP_STATS_INC(esp.rx_rawmbox_post_fail);
+        ESP_STATS_DROP_INC(esp.rx_rawmbox_post_fail);
         netbuf_delete(buf);
         return 0;
       } else {
@@ -210,7 +210,7 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
 
   len = p->tot_len;
   if (sys_mbox_trypost(&conn->recvmbox, buf) != ERR_OK) {
-    ESP_STATS_INC(esp.rx_udpmbox_post_fail);
+    ESP_STATS_DROP_INC(esp.rx_udpmbox_post_fail);
     netbuf_delete(buf);
     return;
   } else {
@@ -270,7 +270,7 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
   }
 
   if (sys_mbox_trypost(&conn->recvmbox, p) != ERR_OK) {
-    ESP_STATS_INC(esp.rx_tcpmbox_post_fail);
+    ESP_STATS_DROP_INC(esp.rx_tcpmbox_post_fail);
     /* don't deallocate p: it is presented to us later again from tcp_fasttmr! */
     return ERR_MEM;
   } else {
@@ -401,14 +401,14 @@ err_tcp(void *arg, err_t err)
   if (sys_mbox_valid(&conn->recvmbox)) {
     /* use trypost to prevent deadlock */
     if (sys_mbox_trypost(&conn->recvmbox, NULL) != ERR_OK){
-      ESP_STATS_INC(esp.err_tcp_rxmbox_post_fail);
+      ESP_STATS_DROP_INC(esp.err_tcp_rxmbox_post_fail);
     }
   }
   /* pass NULL-message to acceptmbox to wake up pending accept */
   if (sys_mbox_valid(&conn->acceptmbox)) {
     /* use trypost to preven deadlock */
     if (sys_mbox_trypost(&conn->acceptmbox, NULL) != ERR_OK) {
-      ESP_STATS_INC(esp.err_tcp_rxmbox_post_fail);
+      ESP_STATS_DROP_INC(esp.err_tcp_rxmbox_post_fail);
     }
   }
 
@@ -489,7 +489,7 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
   newconn->last_err = err;
 
   if (sys_mbox_trypost(&conn->acceptmbox, newconn) != ERR_OK) {
-    ESP_STATS_INC(esp.acceptmbox_post_fail);
+    ESP_STATS_DROP_INC(esp.acceptmbox_post_fail);
     /* When returning != ERR_OK, the pcb is aborted in tcp_process(),
        so do nothing here! */
     /* remove all references to this netconn from the pcb */
diff --git a/components/lwip/api/lwip_debug.c b/components/lwip/api/lwip_debug.c
deleted file mode 100644 (file)
index 89a0712..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "lwip/lwip_debug.h"
-#include "lwip/api.h"
-#include "lwip/netbuf.h"
-#include "lwip/tcp.h"
-#include "lwip/udp.h"
-#include "lwip/priv/tcp_priv.h"
-#include "lwip/stats.h"
-#include "lwip/priv/memp_priv.h"
-#include "lwip/memp.h"
-
-#define DBG_LWIP_IP_SHOW(info, ip)  printf("%s type=%d ip=%x\n", (info), (ip).type, (ip).u_addr.ip4.addr)
-#define DBG_LWIP_IP_PCB_SHOW(pcb) \
-        DBG_LWIP_IP_SHOW("local ip", (pcb)->local_ip);\
-        DBG_LWIP_IP_SHOW("remote ip", (pcb)->local_ip);\
-        printf("so_options=%x, tos=%d ttl=%d\n", (pcb)->so_options, (pcb)->tos, (pcb)->ttl)
-
-#define DBG_LWIP_SEG_SHOW(seg) while(seg) { printf("\tseg=%p next=%p pbuf=%p flags=%x\n", (seg), (seg)->next, (seg)->p, (seg)->flags); (seg)=(seg)->next;}
-    
-
-static void dbg_lwip_tcp_pcb_one_show(struct tcp_pcb* pcb)
-{
-    struct tcp_seg *seg = NULL;
-
-    if (!pcb) {
-        return;
-    }
-
-    printf("\npcb=%p next=%p cb_arg=%p\n", pcb, pcb->next, pcb->callback_arg);
-    DBG_LWIP_IP_PCB_SHOW(pcb);
-    printf("state=%x\n", pcb->state);
-    printf("prio=%d\n", pcb->prio);
-    printf("local_port=%d, remote_port=%d\n", pcb->local_port, pcb->remote_port);
-    printf("flags=%x\n", pcb->flags);
-    printf("pooltmr=%d pollinterval=%d, last_tmr=%d tmr=%d rtmer=%d\n", pcb->polltmr, pcb->pollinterval, pcb->last_timer, pcb->tmr, pcb->rtime);
-    printf("recv_nxt=%d recv_wnd=%d recv_ann_wnd=%d recv_ann_right_edge=%d\n", pcb->rcv_nxt, pcb->rcv_wnd, pcb->rcv_ann_wnd, pcb->rcv_ann_right_edge);
-    printf("mss=%d\n", pcb->mss);
-    printf("rttest=%d rtseq=%d sa=%d sv=%d\n", pcb->rttest, pcb->rtseq, pcb->sa, pcb->sv);
-    printf("rto=%d nrtx=%d\n", pcb->rto, pcb->nrtx);
-    printf("dupacks=%d lastack=%d\n", pcb->dupacks, pcb->lastack);
-#if ESP_PER_SOC_TCP_WND
-    printf("per_soc_window=%d per_soc_snd_buf=%d\n", pcb->per_soc_tcp_wnd, pcb->per_soc_tcp_snd_buf);
-#endif
-    printf("cwnd=%d ssthreash=%d\n", pcb->cwnd, pcb->ssthresh);
-    printf("snd_next=%d snd_wl1=%d snd_wl2=%d\n", pcb->snd_nxt, pcb->snd_wl1, pcb->snd_wl2);
-    printf("snd_lbb=%d snd_wnd=%d snd_wnd_max=%d\n", pcb->snd_lbb, pcb->snd_wnd, pcb->snd_wnd_max);
-    printf("acked=%d\n", pcb->acked);
-    printf("snd_buf=%d snd_queuelen=%d\n", pcb->snd_buf, pcb->snd_queuelen);
-    printf("unsent_oversize=%d\n", pcb->unsent_oversize);
-    printf("keep_idle=%d keep_intvl=%d keep_cnt=%d\n", pcb->keep_idle, pcb->keep_intvl, pcb->keep_cnt);
-    printf("persist_cnt=%d persist_backoff=%d\n", pcb->persist_cnt, pcb->persist_backoff);
-    printf("keep_cnt_sent=%d\n", pcb->keep_cnt_sent);
-
-    printf("unsent segments:\n");
-    seg = pcb->unsent;
-    DBG_LWIP_SEG_SHOW(seg) 
-
-    printf("unacked segments:\n");
-    seg = pcb->unacked;
-    DBG_LWIP_SEG_SHOW(seg);
-
-    printf("ooseg semengts:\n");
-    seg = pcb->ooseq;
-    DBG_LWIP_SEG_SHOW(seg);
-
-    printf("refused data=%p\n", pcb->refused_data);
-}
-
-static void dbg_lwip_tcp_pcb_list_show(struct tcp_pcb* pcb)
-{
-    while(pcb){
-        dbg_lwip_tcp_pcb_one_show(pcb);
-        pcb = pcb->next;
-    }
-}
-
-extern struct tcp_pcb *tcp_bound_pcbs;
-extern struct tcp_pcb *tcp_active_pcbs;
-extern struct tcp_pcb *tcp_tw_pcbs;
-void dbg_lwip_tcp_pcb_show(void)
-{
-    printf("-------------active pcbs------------\n");
-    dbg_lwip_tcp_pcb_list_show(tcp_active_pcbs);
-    printf("-------------bound pcbs-------------\n");
-    dbg_lwip_tcp_pcb_list_show(tcp_bound_pcbs);
-    printf("-------------tw     pcbs------------\n");
-    dbg_lwip_tcp_pcb_list_show(tcp_tw_pcbs);
-}
-
-void dbg_lwip_udp_pcb_one_show(struct udp_pcb *pcb)
-{
-    printf("pcb=%p next=%p\n", pcb, (void*)pcb->next);
-    DBG_LWIP_IP_PCB_SHOW(pcb);
-    printf("flags=%x\n", pcb->flags);
-    printf("local_port=%d remote_port=%d\n", pcb->local_port, pcb->remote_port);
-    printf("recv cb=%p recv_arg=%p\n", pcb->recv, pcb->recv_arg);
-}
-
-extern struct udp_pcb *udp_pcbs;
-void dbg_lwip_udp_pcb_show(void)
-{
-    struct udp_pcb *pcb = udp_pcbs;
-
-    while (pcb){
-        dbg_lwip_udp_pcb_one_show(pcb);
-        pcb = pcb->next;
-    }
-}
-
-void dbg_lwip_tcp_rxtx_show(void)
-{
-    printf("TBC\n");
-}
-
-void dbg_lwip_udp_rxtx_show(void)
-{
-    printf("TBC\n");
-}
-
-void dbg_lwip_stats_show(void)
-{
-    TCP_STATS_DISPLAY();
-    UDP_STATS_DISPLAY();
-    ICMP_STATS_DISPLAY();
-    IGMP_STATS_DISPLAY();
-    IP_STATS_DISPLAY();
-    IPFRAG_STATS_DISPLAY();
-    ETHARP_STATS_DISPLAY();
-    LINK_STATS_DISPLAY();
-    MEM_STATS_DISPLAY();
-    SYS_STATS_DISPLAY();
-    IP6_STATS_DISPLAY();
-    ICMP6_STATS_DISPLAY();
-    IP6_FRAG_STATS_DISPLAY();
-    MLD6_STATS_DISPLAY();
-    ND6_STATS_DISPLAY();
-    ESP_STATS_DISPLAY();
-}
-
-#if (ESP_CNT_DEBUG == 1)
-
-uint32_t g_lwip_mem_cnt[MEMP_MAX][2];
-extern const struct memp_desc * const memp_pools[MEMP_MAX];
-
-void dbg_lwip_cnt_show(void)
-{
-    int i=0;
-
-    printf("-----lwip memory counter-----\n");
-    printf("%6s %8s %8s\n", "index", "alloc", "free");
-    for (i=0; i<MEMP_MAX; i++){
-        printf("%6u %8u %8u\n", i, g_lwip_mem_cnt[i][0], g_lwip_mem_cnt[i][1]);
-    }
-}
-
-
-#endif
-
index ac6a711ee12a6c9128b2d16542395181ad67a65c..143cf917cdd6410069fa661cd5d298cbd910c27b 100755 (executable)
@@ -227,7 +227,7 @@ tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn)
 #endif
 
   if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
-    ESP_STATS_INC(esp.tcpip_inpkt_post_fail);
+    ESP_STATS_DROP_INC(esp.tcpip_inpkt_post_fail);
     memp_free(MEMP_TCPIP_MSG_INPKT, msg);
     return ERR_MEM;
   }
@@ -284,7 +284,7 @@ tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block)
       sys_mbox_post(&mbox, msg);
     } else {
       if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
-        ESP_STATS_INC(esp.tcpip_cb_post_fail);
+        ESP_STATS_DROP_INC(esp.tcpip_cb_post_fail);
         memp_free(MEMP_TCPIP_MSG_API, msg);
         return ERR_MEM;
       }
index 9444d229e8ab6772ebdcca3a6f8ec63773fddf40..0f47dc3e9e698e4f58b1c0027241ab1849bff235 100644 (file)
@@ -4,7 +4,7 @@
 
 COMPONENT_ADD_INCLUDEDIRS := include/lwip include/lwip/port include/lwip/posix apps/ping
 
-COMPONENT_SRCDIRS := api apps/sntp apps/ping apps core/ipv4 core/ipv6 core netif port/freertos port/netif port
+COMPONENT_SRCDIRS := api apps/sntp apps/ping apps core/ipv4 core/ipv6 core netif port/freertos port/netif port/debug port
 
 CFLAGS += -Wno-address  # lots of LWIP source files evaluate macros that check address of stack variables
 
index 9936615918d4d71a110ac111b2e483f81595966d..c92ef6d3738ff5c786bee0048bdc73eb2669bbbd 100755 (executable)
@@ -180,7 +180,7 @@ stats_display(void)
 }
 #endif /* LWIP_STATS_DISPLAY */
 
-#if ESP_STATS
+#if ESP_STATS_DROP
 void stats_display_esp(struct stats_esp *esp)
 {
   LWIP_PLATFORM_DIAG(("\nESP\n\t"));
index 5be686435694bed1a6d118889b16203c3a9bc4dd..227f38054c056f6f4a31375b225ccc3627417898 100755 (executable)
@@ -906,6 +906,8 @@ tcp_slowtmr_start:
                                       " pcb->rto %"S16_F"\n",
                                       pcb->rtime, pcb->rto));
 
+          ESP_STATS_TCP_PCB(pcb);
+
           /* Double retransmission time-out unless we are trying to
            * connect to somebody (i.e., we are in SYN_SENT). */
           if (pcb->state != SYN_SENT) {
index fbe879124a127393118ff3569bd50d266e9a40fa..6bf7238b10ac6ee0b3252ec07bb8e56c98019cf3 100755 (executable)
@@ -213,6 +213,7 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno,
   TCPH_HDRLEN_FLAGS_SET(seg->tcphdr, (5 + optlen / 4), flags);
   /* wnd and chksum are set in tcp_output */
   seg->tcphdr->urgp = 0;
+
   return seg;
 }
 
@@ -1424,6 +1425,7 @@ tcp_rexmit(struct tcp_pcb *pcb)
   }
 #endif /* TCP_OVERSIZE */
 
+  ESP_STATS_TCP_PCB(pcb);
   ++pcb->nrtx;
 
   /* Don't take any rtt measurements after retransmitting. */
index fc45d54ad4fde706fa10bbc9e67a5483380f7597..abb8e57f66ccff0b497d50806d17694df82fc36a 100755 (executable)
@@ -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);
index 7bfa94d789e6363bc17e384d251d7992f10d25a9..abb5ebcf72a5ac0151f63ea0d89e5626d65b1c34 100755 (executable)
@@ -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]++
index fd6a4076a76b5f5042a71d4d47be79a852023f29..a4c700b2c486e01948dace5723dc71b8d6a8d5f4 100755 (executable)
@@ -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 */
index 6b8c4b6c48d5ea548c76f7fcb67e235cfb0cc90a..f7a46b2e830d8a645a63f9c472e62e2e98a3f93f 100755 (executable)
@@ -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;
index 60d7ecf212030b86c480c7f91f380782af2c3550..21a5ac4175e0c4be563ce519848d9bc1cd29adaf 100644 (file)
 #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
diff --git a/components/lwip/port/debug/lwip_debug.c b/components/lwip/port/debug/lwip_debug.c
new file mode 100644 (file)
index 0000000..155941c
--- /dev/null
@@ -0,0 +1,213 @@
+// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "lwip/lwip_debug.h"
+#include "lwip/api.h"
+#include "lwip/netbuf.h"
+#include "lwip/tcp.h"
+#include "lwip/udp.h"
+#include "lwip/priv/tcp_priv.h"
+#include "lwip/stats.h"
+#include "lwip/priv/memp_priv.h"
+#include "lwip/memp.h"
+#include "esp_log.h"
+
+#define DBG_LWIP_IP_SHOW(info, ip)  ESP_LWIP_LOGI("%s type=%d ip=%x", (info), (ip).type, (ip).u_addr.ip4.addr)
+#define DBG_LWIP_IP_PCB_SHOW(pcb) \
+        DBG_LWIP_IP_SHOW("local ip", (pcb)->local_ip);\
+        DBG_LWIP_IP_SHOW("remote ip", (pcb)->local_ip);\
+        ESP_LWIP_LOGI("so_options=%x, tos=%d ttl=%d", (pcb)->so_options, (pcb)->tos, (pcb)->ttl)
+
+#define DBG_LWIP_SEG_SHOW(seg) while(seg) { ESP_LWIP_LOGI("\tseg=%p next=%p pbuf=%p flags=%x", (seg), (seg)->next, (seg)->p, (seg)->flags); (seg)=(seg)->next;}
+#define DBG_LWIP_ITEM_NUMBER_PER_LINE 9
+
+#if ESP_STATS_TCP
+static void dbg_lwip_tcp_pcb_cnt_show(struct tcp_pcb *pcb)
+{
+    int len = 0;
+    char *buf;
+    char *p;
+    int i;
+
+    buf = malloc(512);
+    if (!buf) {
+        return;
+    }
+
+    p = buf;
+    len += sprintf(p + len, "%11s", "tcp_retry: ");
+    for (i=0; i<TCP_MAXRTX; i++) {
+        len += sprintf(p + len, "%-2d=%-5d ", i+1, pcb->retry_cnt[i]);
+    }
+    ESP_LWIP_LOGI("%s", buf);
+    p = buf;
+    len = 0;
+    len += sprintf(p + len, "%11s", "tcp_rto#0:");
+    for (i=0; i<ESP_STATS_TCP_ARRAY_SIZE; i++) {
+        if ((i!=0) && (i%DBG_LWIP_ITEM_NUMBER_PER_LINE==0)) {
+            ESP_LWIP_LOGI("%s", buf);
+            len = 0;
+            p = buf;
+            len += sprintf(p + len, "%11s", "tcp_rto#1:");
+        }
+        len += sprintf(p + len, "%-2d=%-5d ", i+1, pcb->rto_cnt[i]);
+    }
+    ESP_LWIP_LOGI("%s", buf);
+    free(buf);
+}
+#endif
+
+static void dbg_lwip_tcp_pcb_one_show(struct tcp_pcb* pcb)
+{
+    struct tcp_seg *seg = NULL;
+
+    if (!pcb) {
+        return;
+    }
+
+    ESP_LWIP_LOGI("pcb=%p next=%p cb_arg=%p", pcb, pcb->next, pcb->callback_arg);
+    DBG_LWIP_IP_PCB_SHOW(pcb);
+    ESP_LWIP_LOGI("state=%x", pcb->state);
+    ESP_LWIP_LOGI("prio=%d", pcb->prio);
+    ESP_LWIP_LOGI("local_port=%d, remote_port=%d", pcb->local_port, pcb->remote_port);
+    ESP_LWIP_LOGI("flags=%x", pcb->flags);
+    ESP_LWIP_LOGI("pooltmr=%d pollinterval=%d, last_tmr=%d tmr=%d rtmer=%d", pcb->polltmr, pcb->pollinterval, pcb->last_timer, pcb->tmr, pcb->rtime);
+    ESP_LWIP_LOGI("recv_nxt=%d recv_wnd=%d recv_ann_wnd=%d recv_ann_right_edge=%d", pcb->rcv_nxt, pcb->rcv_wnd, pcb->rcv_ann_wnd, pcb->rcv_ann_right_edge);
+    ESP_LWIP_LOGI("mss=%d", pcb->mss);
+    ESP_LWIP_LOGI("rttest=%d rtseq=%d sa=%d sv=%d", pcb->rttest, pcb->rtseq, pcb->sa, pcb->sv);
+    ESP_LWIP_LOGI("rto=%d nrtx=%d", pcb->rto, pcb->nrtx);
+    ESP_LWIP_LOGI("dupacks=%d lastack=%d", pcb->dupacks, pcb->lastack);
+#if ESP_PER_SOC_TCP_WND
+    ESP_LWIP_LOGI("per_soc_window=%d per_soc_snd_buf=%d", pcb->per_soc_tcp_wnd, pcb->per_soc_tcp_snd_buf);
+#endif
+    ESP_LWIP_LOGI("cwnd=%d ssthreash=%d", pcb->cwnd, pcb->ssthresh);
+    ESP_LWIP_LOGI("snd_next=%d snd_wl1=%d snd_wl2=%d", pcb->snd_nxt, pcb->snd_wl1, pcb->snd_wl2);
+    ESP_LWIP_LOGI("snd_lbb=%d snd_wnd=%d snd_wnd_max=%d", pcb->snd_lbb, pcb->snd_wnd, pcb->snd_wnd_max);
+    ESP_LWIP_LOGI("acked=%d", pcb->acked);
+    ESP_LWIP_LOGI("snd_buf=%d snd_queuelen=%d", pcb->snd_buf, pcb->snd_queuelen);
+    ESP_LWIP_LOGI("unsent_oversize=%d", pcb->unsent_oversize);
+    ESP_LWIP_LOGI("keep_idle=%d keep_intvl=%d keep_cnt=%d", pcb->keep_idle, pcb->keep_intvl, pcb->keep_cnt);
+    ESP_LWIP_LOGI("persist_cnt=%d persist_backoff=%d", pcb->persist_cnt, pcb->persist_backoff);
+    ESP_LWIP_LOGI("keep_cnt_sent=%d", pcb->keep_cnt_sent);
+
+    ESP_LWIP_LOGI("unsent segments:");
+    seg = pcb->unsent;
+    DBG_LWIP_SEG_SHOW(seg) 
+
+    ESP_LWIP_LOGI("unacked segments:");
+    seg = pcb->unacked;
+    DBG_LWIP_SEG_SHOW(seg);
+
+    ESP_LWIP_LOGI("ooseg semengts:");
+    seg = pcb->ooseq;
+    DBG_LWIP_SEG_SHOW(seg);
+
+    ESP_LWIP_LOGI("refused data=%p", pcb->refused_data);
+
+#if ESP_STATS_TCP
+    dbg_lwip_tcp_pcb_cnt_show(pcb);
+#endif
+}
+
+static void dbg_lwip_tcp_pcb_list_show(struct tcp_pcb* pcb)
+{
+    while(pcb){
+        dbg_lwip_tcp_pcb_one_show(pcb);
+        pcb = pcb->next;
+    }
+}
+
+extern struct tcp_pcb *tcp_bound_pcbs;
+extern struct tcp_pcb *tcp_active_pcbs;
+extern struct tcp_pcb *tcp_tw_pcbs;
+void dbg_lwip_tcp_pcb_show(void)
+{
+    ESP_LWIP_LOGI("-------------active pcbs------------");
+    dbg_lwip_tcp_pcb_list_show(tcp_active_pcbs);
+    ESP_LWIP_LOGI("-------------bound pcbs-------------");
+    dbg_lwip_tcp_pcb_list_show(tcp_bound_pcbs);
+    ESP_LWIP_LOGI("-------------tw     pcbs------------");
+    dbg_lwip_tcp_pcb_list_show(tcp_tw_pcbs);
+}
+
+void dbg_lwip_udp_pcb_one_show(struct udp_pcb *pcb)
+{
+    ESP_LWIP_LOGI("pcb=%p next=%p", pcb, (void*)pcb->next);
+    DBG_LWIP_IP_PCB_SHOW(pcb);
+    ESP_LWIP_LOGI("flags=%x", pcb->flags);
+    ESP_LWIP_LOGI("local_port=%d remote_port=%d", pcb->local_port, pcb->remote_port);
+    ESP_LWIP_LOGI("recv cb=%p recv_arg=%p", pcb->recv, pcb->recv_arg);
+}
+
+extern struct udp_pcb *udp_pcbs;
+void dbg_lwip_udp_pcb_show(void)
+{
+    struct udp_pcb *pcb = udp_pcbs;
+
+    while (pcb){
+        dbg_lwip_udp_pcb_one_show(pcb);
+        pcb = pcb->next;
+    }
+}
+
+void dbg_lwip_tcp_rxtx_show(void)
+{
+    ESP_LWIP_LOGI("TBC");
+}
+
+void dbg_lwip_udp_rxtx_show(void)
+{
+    ESP_LWIP_LOGI("TBC");
+}
+
+void dbg_lwip_stats_show(void)
+{
+    TCP_STATS_DISPLAY();
+    UDP_STATS_DISPLAY();
+    ICMP_STATS_DISPLAY();
+    IGMP_STATS_DISPLAY();
+    IP_STATS_DISPLAY();
+    IPFRAG_STATS_DISPLAY();
+    ETHARP_STATS_DISPLAY();
+    LINK_STATS_DISPLAY();
+    MEM_STATS_DISPLAY();
+    SYS_STATS_DISPLAY();
+    IP6_STATS_DISPLAY();
+    ICMP6_STATS_DISPLAY();
+    IP6_FRAG_STATS_DISPLAY();
+    MLD6_STATS_DISPLAY();
+    ND6_STATS_DISPLAY();
+    ESP_STATS_DROP_DISPLAY();
+}
+
+#if (ESP_STATS_MEM == 1)
+
+uint32_t g_lwip_mem_cnt[MEMP_MAX][2];
+extern const struct memp_desc * const memp_pools[MEMP_MAX];
+
+void dbg_lwip_cnt_show(void)
+{
+    int i=0;
+
+    ESP_LWIP_LOGI("-----lwip memory counter-----");
+    ESP_LWIP_LOGI("%6s %8s %8s", "index", "alloc", "free");
+    for (i=0; i<MEMP_MAX; i++){
+        ESP_LWIP_LOGI("%6u %8u %8u", i, g_lwip_mem_cnt[i][0], g_lwip_mem_cnt[i][1]);
+    }
+}
+
+
+#endif
+
index 9d3aca8d7ade8da5f1640ca965a03e3efd0418f4..8d7b86501b4a4c6be3f5aa8eaf8e0134354c3426 100755 (executable)
@@ -375,7 +375,7 @@ sys_mbox_free(sys_mbox_t *mbox)
     if (post_null){
       LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free: post null to mbox\n"));
       if (sys_mbox_trypost( mbox, NULL) != ERR_OK){
-        ESP_STATS_INC(esp.free_mbox_post_fail);
+        ESP_STATS_DROP_INC(esp.free_mbox_post_fail);
         LWIP_DEBUGF(ESP_THREAD_SAFE_DEBUG, ("sys_mbox_free: post null mbox fail\n"));
       } else {
         post_null = false;
index 9f454230ab2049736c23625e74f8ef78e1c3f86e..ad836421e31520684645359865c286d8b85c93b8 100644 (file)
@@ -153,7 +153,7 @@ wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb)
 #if (ESP_L2_TO_L3_COPY == 1)
   p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
   if (p == NULL) {
-    ESP_STATS_INC(esp.wlanif_input_pbuf_fail);
+    ESP_STATS_DROP_INC(esp.wlanif_input_pbuf_fail);
     esp_wifi_internal_free_rx_buffer(eb);
     return;
   }
@@ -163,7 +163,7 @@ wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb)
 #else
   p = pbuf_alloc(PBUF_RAW, len, PBUF_REF);
   if (p == NULL){
-    ESP_STATS_INC(esp.wlanif_input_pbuf_fail);
+    ESP_STATS_DROP_INC(esp.wlanif_input_pbuf_fail);
     return;
   }
   p->payload = buffer;