]> granicus.if.org Git - esp-idf/commitdiff
lwip/freertos/esp32: add throughput optimization related code
authorLiu Zhi Fu <liuzhifu@espressif.com>
Mon, 2 Jan 2017 12:03:10 +0000 (20:03 +0800)
committerLiu Zhi Fu <liuzhifu@espressif.com>
Thu, 5 Jan 2017 03:37:08 +0000 (11:37 +0800)
1. Update wifi lib which contains ampdu and other optimizations
2. Add throughput code debug code
3. Other misc modification about throughput optimization

13 files changed:
components/esp32/include/esp_wifi_types.h
components/esp32/lib
components/freertos/Kconfig
components/freertos/port.c
components/lwip/api/api_lib.c
components/lwip/api/api_msg.c
components/lwip/api/sockets.c
components/lwip/api/tcpip.c
components/lwip/include/lwip/lwip/opt.h
components/lwip/include/lwip/port/lwipopts.h
components/lwip/netif/ethernet.c
components/lwip/port/netif/ethernetif.c
components/lwip/port/netif/wlanif.c

index ac7642829fba6acd7043ef636c79b935367a9328..be3183ba5d1c557d47808c204b97c5a76dc7ca31 100755 (executable)
@@ -121,7 +121,7 @@ typedef enum {
 #define WIFI_PROTOCOL_11N         4
 
 typedef enum {
-    WIFI_BW_HT20 = 0, /* Bandwidth is HT20 */
+    WIFI_BW_HT20 = 1, /* Bandwidth is HT20 */
     WIFI_BW_HT40,     /* Bandwidth is HT40 */
 } wifi_bandwidth_t;
 
index 02232f974b0ff1568ddd6d7015a41fb4f4870994..074303d74fc9c68823adee0a38fc1e8de42943b6 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 02232f974b0ff1568ddd6d7015a41fb4f4870994
+Subproject commit 074303d74fc9c68823adee0a38fc1e8de42943b6
index fc4cf56061d4183c7037078fa7e702eee520dce4..fe7e6afd88aaec2da4be67a9be6a3b2dd49fba4b 100644 (file)
@@ -187,6 +187,7 @@ config FREERTOS_PORTMUX_DEBUG
         If enabled, debug information (including integrity checks) will be printed
         to UART for the port-specific MUX implementation.
 
+if !FREERTOS_UNICORE
 config FREERTOS_PORTMUX_DEBUG_RECURSIVE
     bool "Debug portMUX Recursion"
     depends on FREERTOS_PORTMUX_DEBUG
@@ -194,6 +195,7 @@ config FREERTOS_PORTMUX_DEBUG_RECURSIVE
     help
         If enabled, additional debug information will be printed for recursive
         portMUX usage.
+endif #FREERTOS_UNICORE
 
 endif # FREERTOS_DEBUG_INTERNALS
 
index 25480ed4756037197dd3b6beb1c61ec09b3d3839..e5898038bcb17ba3c3e467dbce44a0703386a9fb 100644 (file)
@@ -282,6 +282,7 @@ void vPortCPUAcquireMutex(portMUX_TYPE *mux, const char *fnName, int line) {
 #else
 void vPortCPUAcquireMutex(portMUX_TYPE *mux) {
 #endif
+#if !CONFIG_FREERTOS_UNICORE
        uint32_t res;
        uint32_t recCnt;
        unsigned int irqStatus;
@@ -324,6 +325,7 @@ void vPortCPUAcquireMutex(portMUX_TYPE *mux) {
        }
 #endif
        portEXIT_CRITICAL_NESTED(irqStatus);
+#endif
 }
 
 /*
@@ -335,6 +337,7 @@ portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux, const char *fnName, int li
 #else
 portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux) {
 #endif
+#if !CONFIG_FREERTOS_UNICORE
        uint32_t res=0;
        uint32_t recCnt;
        unsigned int irqStatus;
@@ -379,6 +382,9 @@ portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux) {
        }
        portEXIT_CRITICAL_NESTED(irqStatus);
        return ret;
+#else //!CONFIG_FREERTOS_UNICORE
+       return 0;
+#endif
 }
 
 #if CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG
index ecebf4f8138eb007d8e3d9994f60abda94f9558f..86ee5576aba5bd1edbf4fe34e6cc7d87fe3d84ce 100755 (executable)
@@ -508,6 +508,10 @@ netconn_recv_data(struct netconn *conn, void **new_buf)
   }
 #endif /* (LWIP_UDP || LWIP_RAW) */
 
+#ifdef ESP_PERF
+  if (len > DBG_PERF_FILTER_LEN) { DBG_PERF_PATH_SET(DBG_PERF_DIR_RX, DBG_PERF_POINT_SOC_IN); }
+#endif
+
 #if LWIP_SO_RCVBUF
   SYS_ARCH_DEC(conn->recv_avail, len);
 #endif /* LWIP_SO_RCVBUF */
index 2d98734b67d12bd6086f98a75c9a3e011109160d..87e5aeb8e5c532a413d61e9951ecd1abeba422d4 100755 (executable)
@@ -202,6 +202,10 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
 #endif /* LWIP_NETBUF_RECVINFO */
   }
 
+#ifdef ESP_PERF
+  if (p->len > DBG_PERF_FILTER_LEN) DBG_PERF_PATH_SET(DBG_PERF_DIR_RX, DBG_PERF_POINT_LWIP_OUT);
+#endif
+
   len = p->tot_len;
   if (sys_mbox_trypost(&conn->recvmbox, buf) != ERR_OK) {
     ESP_STATS_INC(esp.rx_udpmbox_post_fail);
index 4acf518cc900691fc2bedbdd2734151a6861dfd5..c163b3ac0b5ee4d92bffd2bdde84902ef4bce631 100755 (executable)
@@ -1438,6 +1438,7 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
   err = netbuf_ref(&buf, data, short_size);
 #endif /* LWIP_NETIF_TX_SINGLE_PBUF */
   if (err == ERR_OK) {
+    DBG_PERF_PATH_SET(DBG_PERF_DIR_TX, DBG_PERF_POINT_SOC_OUT);
     /* send the data */
     err = netconn_send(sock->conn, &buf);
   }
index 72de714e2a9faa2f71ef313a5ef0772877c1426f..dfb235718b38324e1c71747112ae67d60c3f96ad 100755 (executable)
@@ -219,6 +219,12 @@ tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn)
   msg->msg.inp.p = p;
   msg->msg.inp.netif = inp;
   msg->msg.inp.input_fn = input_fn;
+#ifdef ESP_PERF
+  if (p->len > DBG_PERF_FILTER_LEN) {
+    DBG_PERF_PATH_SET(DBG_PERF_DIR_RX, DBG_PERF_POINT_WIFI_OUT);
+  }
+#endif
+
   if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
     ESP_STATS_INC(esp.tcpip_inpkt_post_fail);
     memp_free(MEMP_TCPIP_MSG_INPKT, msg);
@@ -492,20 +498,11 @@ tcpip_init(tcpip_init_done_fn initfunc, void *arg)
 #endif /* LWIP_TCPIP_CORE_LOCKING */
 
 
-#if ESP_LWIP
-#if ESP_DUAL_CORE
-  sys_thread_t xLwipTaskHandle = 0;
-  xTaskCreatePinnedToCore(tcpip_thread, TCPIP_THREAD_NAME, TCPIP_THREAD_STACKSIZE, NULL, TCPIP_THREAD_PRIO, NULL, 1);
-#else
   sys_thread_t xLwipTaskHandle = sys_thread_new(TCPIP_THREAD_NAME
                 , tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
-#endif
 
   printf("tcpip_task_hdlxxx : %x, prio:%d,stack:%d\n",
                 (u32_t)xLwipTaskHandle,TCPIP_THREAD_PRIO,TCPIP_THREAD_STACKSIZE);
-#else
-  sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
-#endif
 
 }
 
index c42f3cd73505c608d32c8e6ce77f8040e390d883..4d8d6bf70c1f2f842084460c9747ce55ec1ba97f 100755 (executable)
  * LWIP_STATS==1: Enable statistics collection in lwip_stats.
  */
 #ifndef LWIP_STATS
-#define LWIP_STATS                      1
+#define LWIP_STATS                      0
 #endif
 
 #if LWIP_STATS
index 5000d63ba94f46d5d029b4477c82e47b2ea65658..933d55a510326760838bad873f7c48c433e5cc86 100755 (executable)
 #define ESP_LIGHT_SLEEP                 1
 #define ESP_L2_TO_L3_COPY               CONFIG_L2_TO_L3_COPY
 #define ESP_CNT_DEBUG                   0
-#define ESP_DUAL_CORE                   0
 
-#define TCP_WND_DEFAULT                      (4*TCP_MSS)
-#define TCP_SND_BUF_DEFAULT                  (2*TCP_MSS)
+#define TCP_WND_DEFAULT                 (4*TCP_MSS)
+#define TCP_SND_BUF_DEFAULT             (2*TCP_MSS)
 
-#if ESP_PER_SOC_TCP_WND
-#define TCP_WND(pcb)                         (pcb->per_soc_tcp_wnd)
-#define TCP_SND_BUF(pcb)                     (pcb->per_soc_tcp_snd_buf)
-#else
 #if ESP_PERF
-extern unsigned char misc_prof_get_tcpw(void);
-extern unsigned char misc_prof_get_tcp_snd_buf(void);
-#define TCP_WND(pcb)                         (misc_prof_get_tcpw()*TCP_MSS)
-#define TCP_SND_BUF(pcb)                     (misc_prof_get_tcp_snd_buf()*TCP_MSS)
+#define DBG_PERF_PATH_SET(dir, point)
+#define DBG_PERF_FILTER_LEN             1000
+
+enum {
+  DBG_PERF_DIR_RX = 0,
+  DBG_PERF_DIR_TX,
+};
+
+enum {
+  DBG_PERF_POINT_INT       = 0,
+  DBG_PERF_POINT_WIFI_IN   = 1,
+  DBG_PERF_POINT_WIFI_OUT  = 2,
+  DBG_PERF_POINT_LWIP_IN   = 3,
+  DBG_PERF_POINT_LWIP_OUT  = 4,
+  DBG_PERF_POINT_SOC_IN    = 5,
+  DBG_PERF_POINT_SOC_OUT   = 6,
+};
+
+#else
+#define DBG_PERF_PATH_SET(dir, point)   
+#define DBG_PERF_FILTER_LEN             1000
 #endif
+
+#if ESP_PER_SOC_TCP_WND
+#define TCP_WND(pcb)                    (pcb->per_soc_tcp_wnd)
+#define TCP_SND_BUF(pcb)                (pcb->per_soc_tcp_snd_buf)
 #endif
 
 /**
@@ -595,6 +611,7 @@ extern unsigned char misc_prof_get_tcp_snd_buf(void);
 #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
index 6d843913da085b436e79e3bbd828be0cc9664a80..5d618f6a3134eda0a6bb1f8d1823e801bfca068a 100755 (executable)
@@ -72,6 +72,10 @@ ethernet_input(struct pbuf *p, struct netif *netif)
   s16_t ip_hdr_offset = SIZEOF_ETH_HDR;
 #endif /* LWIP_ARP || ETHARP_SUPPORT_VLAN */
 
+#ifdef ESP_PERF
+    if (p->len > DBG_PERF_FILTER_LEN) DBG_PERF_PATH_SET(DBG_PERF_DIR_RX, DBG_PERF_POINT_LWIP_IN);
+#endif
+
   if (p->len <= SIZEOF_ETH_HDR) {
     /* a packet with only an ethernet header (or less) is not valid for us */
     ETHARP_STATS_INC(etharp.proterr);
index 79f21f6b3f71574c210d568aa8eebe1658693593..6b1245e2e6d0be1463a21001f49f96a0088ee2a8 100755 (executable)
@@ -56,9 +56,6 @@
 #define IFNAME1 'n'
 
 static char hostname[16];
-#if ESP_PERF
-uint32_t g_rx_alloc_pbuf_fail_cnt = 0;
-#endif
 
 /**
  * In this function, the hardware should be initialized.
@@ -163,7 +160,6 @@ ethernetif_input(struct netif *netif, void *buffer, uint16_t len)
 #if CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
   p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
   if (p == NULL) {
-    //g_rx_alloc_pbuf_fail_cnt++;
     return;
   }
   memcpy(p->payload, buffer, len);
index fea163f8cc36ac43fdd5e76213878cb69234d470..e114105f307c5dc36d42c6681cf7a5b732356f34 100755 (executable)
@@ -57,9 +57,6 @@
 #define IFNAME1 'n'
 
 static char hostname[16];
-#if ESP_PERF
-uint32_t g_rx_alloc_pbuf_fail_cnt = 0;
-#endif
 
 /**
  * In this function, the hardware should be initialized.