Merge branch 'feature/tw8155_optimize_tx_flow_control' into 'master'

Feature/tw8155 optimize tx flow control

1. Remove TX flow control in LWIP
2. Make the return value of esp_wifi_internal_tx consistent with LWIP error code

See merge request !164
This commit is contained in:
Ivan Grokhotkov 2016-11-01 22:26:15 +08:00
commit fe64ea95b4
4 changed files with 3 additions and 38 deletions

@ -1 +1 @@
Subproject commit 9d18fd1a8f7610130e69f8be74ec68f6399221b1
Subproject commit b3090d885413fb78c86e7b88116cdb5c8c5e9e68

View file

@ -382,31 +382,6 @@ static void lwip_socket_unregister_membership(int s, const ip4_addr_t *if_addr,
static void lwip_socket_drop_registered_memberships(int s);
#endif /* LWIP_IGMP */
#if ESP_LWIP
#include "esp_wifi_internal.h"
#include "esp_system.h"
/* Please be notified that this flow control is just a workaround for fixing wifi Q full issue.
* Under UDP/TCP pressure test, we found that the sockets may cause wifi tx queue full if the socket
* sending speed is faster than the wifi sending speed, it will finally cause the packet to be dropped
* in wifi layer, it's not acceptable in some application. That's why we introdue the tx flow control here.
* However, current solution is just a workaround, we need to consider the return value of wifi tx interface,
* and feedback the return value to lwip and let lwip do the flow control itself.
*/
static inline void esp32_tx_flow_ctrl(void)
{
uint8_t _wait_delay = 1;
while ((system_get_free_heap_size() < HEAP_HIGHWAT) || esp_wifi_internal_tx_is_stop()){
vTaskDelay(_wait_delay/portTICK_RATE_MS);
if (_wait_delay < 64) _wait_delay *= 2;
}
}
#else
#define esp32_tx_flow_ctrl()
#endif
/** The global array of available sockets */
static struct lwip_sock sockets[NUM_SOCKETS];
#if ESP_THREAD_SAFE
@ -1208,8 +1183,6 @@ lwip_send(int s, const void *data, size_t size, int flags)
#endif /* (LWIP_UDP || LWIP_RAW) */
}
esp32_tx_flow_ctrl();
write_flags = NETCONN_COPY |
((flags & MSG_MORE) ? NETCONN_MORE : 0) |
((flags & MSG_DONTWAIT) ? NETCONN_DONTBLOCK : 0);
@ -1391,8 +1364,6 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
#endif /* LWIP_TCP */
}
esp32_tx_flow_ctrl();
if ((to != NULL) && !SOCK_ADDR_TYPE_MATCH(to, sock)) {
/* sockaddr does not match socket type (IPv4/IPv6) */
sock_set_errno(sock, err_to_errno(ERR_VAL));

View file

@ -523,7 +523,6 @@ extern unsigned long os_random(void);
#define ESP_IP4_ATON 1
#define ESP_LIGHT_SLEEP 1
#define TCP_WND_DEFAULT (4*TCP_MSS)
#define TCP_SND_BUF_DEFAULT (2*TCP_MSS)
@ -550,8 +549,6 @@ extern unsigned char misc_prof_get_tcp_snd_buf(void);
#define CHECKSUM_CHECK_UDP 0
#define CHECKSUM_CHECK_IP 0
#define HEAP_HIGHWAT 20*1024
#define LWIP_NETCONN_FULLDUPLEX 1
#define LWIP_NETCONN_SEM_PER_THREAD 1

View file

@ -142,16 +142,13 @@ low_level_output(struct netif *netif, struct pbuf *p)
}
}
esp_wifi_internal_tx(wifi_if, q->payload, pbuf_x_len);
return ERR_OK;
return esp_wifi_internal_tx(wifi_if, q->payload, pbuf_x_len);
#else
for(q = p; q != NULL; q = q->next) {
esp_wifi_internal_tx(wifi_if, q->payload, q->len);
}
#endif
return ERR_OK;
#endif
}
/**