lwip/freertos/esp32: add throughput optimization related code

1. Update wifi lib which contains ampdu and other optimizations
2. Add throughput code debug code
3. Other misc modification about throughput optimization
This commit is contained in:
Liu Zhi Fu 2017-01-02 20:03:10 +08:00
parent 370cf5493f
commit 0fb2ab9f5c
13 changed files with 59 additions and 31 deletions

View File

@ -121,7 +121,7 @@ typedef enum {
#define WIFI_PROTOCOL_11N 4 #define WIFI_PROTOCOL_11N 4
typedef enum { typedef enum {
WIFI_BW_HT20 = 0, /* Bandwidth is HT20 */ WIFI_BW_HT20 = 1, /* Bandwidth is HT20 */
WIFI_BW_HT40, /* Bandwidth is HT40 */ WIFI_BW_HT40, /* Bandwidth is HT40 */
} wifi_bandwidth_t; } wifi_bandwidth_t;

@ -1 +1 @@
Subproject commit 02232f974b0ff1568ddd6d7015a41fb4f4870994 Subproject commit 074303d74fc9c68823adee0a38fc1e8de42943b6

View File

@ -187,6 +187,7 @@ config FREERTOS_PORTMUX_DEBUG
If enabled, debug information (including integrity checks) will be printed If enabled, debug information (including integrity checks) will be printed
to UART for the port-specific MUX implementation. to UART for the port-specific MUX implementation.
if !FREERTOS_UNICORE
config FREERTOS_PORTMUX_DEBUG_RECURSIVE config FREERTOS_PORTMUX_DEBUG_RECURSIVE
bool "Debug portMUX Recursion" bool "Debug portMUX Recursion"
depends on FREERTOS_PORTMUX_DEBUG depends on FREERTOS_PORTMUX_DEBUG
@ -194,6 +195,7 @@ config FREERTOS_PORTMUX_DEBUG_RECURSIVE
help help
If enabled, additional debug information will be printed for recursive If enabled, additional debug information will be printed for recursive
portMUX usage. portMUX usage.
endif #FREERTOS_UNICORE
endif # FREERTOS_DEBUG_INTERNALS endif # FREERTOS_DEBUG_INTERNALS

View File

@ -282,6 +282,7 @@ void vPortCPUAcquireMutex(portMUX_TYPE *mux, const char *fnName, int line) {
#else #else
void vPortCPUAcquireMutex(portMUX_TYPE *mux) { void vPortCPUAcquireMutex(portMUX_TYPE *mux) {
#endif #endif
#if !CONFIG_FREERTOS_UNICORE
uint32_t res; uint32_t res;
uint32_t recCnt; uint32_t recCnt;
unsigned int irqStatus; unsigned int irqStatus;
@ -324,6 +325,7 @@ void vPortCPUAcquireMutex(portMUX_TYPE *mux) {
} }
#endif #endif
portEXIT_CRITICAL_NESTED(irqStatus); portEXIT_CRITICAL_NESTED(irqStatus);
#endif
} }
/* /*
@ -335,6 +337,7 @@ portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux, const char *fnName, int li
#else #else
portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux) { portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux) {
#endif #endif
#if !CONFIG_FREERTOS_UNICORE
uint32_t res=0; uint32_t res=0;
uint32_t recCnt; uint32_t recCnt;
unsigned int irqStatus; unsigned int irqStatus;
@ -379,6 +382,9 @@ portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux) {
} }
portEXIT_CRITICAL_NESTED(irqStatus); portEXIT_CRITICAL_NESTED(irqStatus);
return ret; return ret;
#else //!CONFIG_FREERTOS_UNICORE
return 0;
#endif
} }
#if CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG #if CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG

View File

@ -508,6 +508,10 @@ netconn_recv_data(struct netconn *conn, void **new_buf)
} }
#endif /* (LWIP_UDP || LWIP_RAW) */ #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 #if LWIP_SO_RCVBUF
SYS_ARCH_DEC(conn->recv_avail, len); SYS_ARCH_DEC(conn->recv_avail, len);
#endif /* LWIP_SO_RCVBUF */ #endif /* LWIP_SO_RCVBUF */

View File

@ -202,6 +202,10 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
#endif /* LWIP_NETBUF_RECVINFO */ #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; len = p->tot_len;
if (sys_mbox_trypost(&conn->recvmbox, buf) != ERR_OK) { if (sys_mbox_trypost(&conn->recvmbox, buf) != ERR_OK) {
ESP_STATS_INC(esp.rx_udpmbox_post_fail); ESP_STATS_INC(esp.rx_udpmbox_post_fail);

View File

@ -1438,6 +1438,7 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
err = netbuf_ref(&buf, data, short_size); err = netbuf_ref(&buf, data, short_size);
#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ #endif /* LWIP_NETIF_TX_SINGLE_PBUF */
if (err == ERR_OK) { if (err == ERR_OK) {
DBG_PERF_PATH_SET(DBG_PERF_DIR_TX, DBG_PERF_POINT_SOC_OUT);
/* send the data */ /* send the data */
err = netconn_send(sock->conn, &buf); err = netconn_send(sock->conn, &buf);
} }

View File

@ -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.p = p;
msg->msg.inp.netif = inp; msg->msg.inp.netif = inp;
msg->msg.inp.input_fn = input_fn; 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) { if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
ESP_STATS_INC(esp.tcpip_inpkt_post_fail); ESP_STATS_INC(esp.tcpip_inpkt_post_fail);
memp_free(MEMP_TCPIP_MSG_INPKT, msg); 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 */ #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 sys_thread_t xLwipTaskHandle = sys_thread_new(TCPIP_THREAD_NAME
, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO); , tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
#endif
printf("tcpip_task_hdlxxx : %x, prio:%d,stack:%d\n", printf("tcpip_task_hdlxxx : %x, prio:%d,stack:%d\n",
(u32_t)xLwipTaskHandle,TCPIP_THREAD_PRIO,TCPIP_THREAD_STACKSIZE); (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
} }

View File

@ -1665,7 +1665,7 @@
* LWIP_STATS==1: Enable statistics collection in lwip_stats. * LWIP_STATS==1: Enable statistics collection in lwip_stats.
*/ */
#ifndef LWIP_STATS #ifndef LWIP_STATS
#define LWIP_STATS 1 #define LWIP_STATS 0
#endif #endif
#if LWIP_STATS #if LWIP_STATS

View File

@ -572,21 +572,37 @@
#define ESP_LIGHT_SLEEP 1 #define ESP_LIGHT_SLEEP 1
#define ESP_L2_TO_L3_COPY CONFIG_L2_TO_L3_COPY #define ESP_L2_TO_L3_COPY CONFIG_L2_TO_L3_COPY
#define ESP_CNT_DEBUG 0 #define ESP_CNT_DEBUG 0
#define ESP_DUAL_CORE 0
#define TCP_WND_DEFAULT (4*TCP_MSS) #define TCP_WND_DEFAULT (4*TCP_MSS)
#define TCP_SND_BUF_DEFAULT (2*TCP_MSS) #define TCP_SND_BUF_DEFAULT (2*TCP_MSS)
#if ESP_PERF
#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 #if ESP_PER_SOC_TCP_WND
#define TCP_WND(pcb) (pcb->per_soc_tcp_wnd) #define TCP_WND(pcb) (pcb->per_soc_tcp_wnd)
#define TCP_SND_BUF(pcb) (pcb->per_soc_tcp_snd_buf) #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)
#endif
#endif #endif
/** /**
@ -595,6 +611,7 @@ extern unsigned char misc_prof_get_tcp_snd_buf(void);
#define DHCP_DEBUG LWIP_DBG_OFF #define DHCP_DEBUG LWIP_DBG_OFF
#define LWIP_DEBUG LWIP_DBG_OFF #define LWIP_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF #define TCP_DEBUG LWIP_DBG_OFF
#define ESP_STATS 0
#define CHECKSUM_CHECK_UDP 0 #define CHECKSUM_CHECK_UDP 0
#define CHECKSUM_CHECK_IP 0 #define CHECKSUM_CHECK_IP 0

View File

@ -72,6 +72,10 @@ ethernet_input(struct pbuf *p, struct netif *netif)
s16_t ip_hdr_offset = SIZEOF_ETH_HDR; s16_t ip_hdr_offset = SIZEOF_ETH_HDR;
#endif /* LWIP_ARP || ETHARP_SUPPORT_VLAN */ #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) { if (p->len <= SIZEOF_ETH_HDR) {
/* a packet with only an ethernet header (or less) is not valid for us */ /* a packet with only an ethernet header (or less) is not valid for us */
ETHARP_STATS_INC(etharp.proterr); ETHARP_STATS_INC(etharp.proterr);

View File

@ -56,9 +56,6 @@
#define IFNAME1 'n' #define IFNAME1 'n'
static char hostname[16]; 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. * 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 #if CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM); p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
if (p == NULL) { if (p == NULL) {
//g_rx_alloc_pbuf_fail_cnt++;
return; return;
} }
memcpy(p->payload, buffer, len); memcpy(p->payload, buffer, len);

View File

@ -57,9 +57,6 @@
#define IFNAME1 'n' #define IFNAME1 'n'
static char hostname[16]; 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. * In this function, the hardware should be initialized.