esp32/lwip: some misc changes

1. Update phy to fix HT40 rx issue
2. Add code about RX_DONE/TX_DONE/Lock-free optimization
3. Fix wifi ioctl return value error
4. Add lwip statistics debug code
5. Modify TCP window size to 10 and send buffer size to 5
This commit is contained in:
Liu Zhi Fu
2016-11-28 18:36:14 +08:00
parent db1e86b3d9
commit 9a3f9af2db
9 changed files with 122 additions and 24 deletions

View File

@@ -128,6 +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);
netbuf_delete(buf);
return 0;
} else {
@@ -203,6 +204,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);
netbuf_delete(buf);
return;
} else {
@@ -262,6 +264,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);
/* don't deallocate p: it is presented to us later again from tcp_fasttmr! */
return ERR_MEM;
} else {
@@ -391,12 +394,16 @@ err_tcp(void *arg, err_t err)
/* pass NULL-message to recvmbox to wake up pending recv */
if (sys_mbox_valid(&conn->recvmbox)) {
/* use trypost to prevent deadlock */
sys_mbox_trypost(&conn->recvmbox, NULL);
if (sys_mbox_trypost(&conn->recvmbox, NULL) != ERR_OK){
ESP_STATS_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 */
sys_mbox_trypost(&conn->acceptmbox, NULL);
if (sys_mbox_trypost(&conn->acceptmbox, NULL) != ERR_OK) {
ESP_STATS_INC(esp.err_tcp_rxmbox_post_fail);
}
}
if ((old_state == NETCONN_WRITE) || (old_state == NETCONN_CLOSE) ||
@@ -476,6 +483,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);
/* When returning != ERR_OK, the pcb is aborted in tcp_process(),
so do nothing here! */
/* remove all references to this netconn from the pcb */

View File

@@ -18,6 +18,7 @@
#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"
@@ -129,6 +130,26 @@ 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];

View File

@@ -56,9 +56,6 @@
#define TCPIP_MSG_VAR_FREE(name) API_VAR_FREE(MEMP_TCPIP_MSG_API, name)
/* global variables */
#if ESP_PERF
uint32_t g_rx_post_mbox_fail_cnt = 0;
#endif
static tcpip_init_done_fn tcpip_init_done;
static void *tcpip_init_done_arg;
static sys_mbox_t mbox;
@@ -223,9 +220,7 @@ tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn)
msg->msg.inp.netif = inp;
msg->msg.inp.input_fn = input_fn;
if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
#if ESP_PERF
g_rx_post_mbox_fail_cnt ++;
#endif
ESP_STATS_INC(esp.tcpip_inpkt_post_fail);
memp_free(MEMP_TCPIP_MSG_INPKT, msg);
return ERR_MEM;
}
@@ -282,6 +277,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);
memp_free(MEMP_TCPIP_MSG_API, msg);
return ERR_MEM;
}
@@ -497,8 +493,13 @@ tcpip_init(tcpip_init_done_fn initfunc, void *arg)
#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);