Skip to content
Snippets Groups Projects
Commit 1a8a560b authored by Gunar Schorcht's avatar Gunar Schorcht
Browse files

cpu/esp8266: remove timeout handling in send func

It is not necessary to realize timeout handling in send function or to disconnect from AP if lwIP packet buffer is exhausted. Waiting that the frame allocated in lwIP packet buffer is freed by MAC layer led to the complete blockage of send function on heavy network load. Disconnecting from AP is counterproductive since reconnecting usually fails on heavy network load.
parent fa5fe7e4
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,6 @@ ...@@ -65,7 +65,6 @@
#define ESP_WIFI_SOFTAP_IF (SOFTAP_IF) #define ESP_WIFI_SOFTAP_IF (SOFTAP_IF)
#define ESP_WIFI_RECONNECT_TIME (20 * US_PER_SEC) #define ESP_WIFI_RECONNECT_TIME (20 * US_PER_SEC)
#define ESP_WIFI_SEND_TIMEOUT (MS_PER_SEC)
#define MAC_STR "%02x:%02x:%02x:%02x:%02x:%02x" #define MAC_STR "%02x:%02x:%02x:%02x:%02x:%02x"
#define MAC_STR_ARG(m) m[0], m[1], m[2], m[3], m[4], m[5] #define MAC_STR_ARG(m) m[0], m[1], m[2], m[3], m[4], m[5]
...@@ -393,29 +392,17 @@ static int IRAM _send(netdev_t *netdev, const iolist_t *iolist) ...@@ -393,29 +392,17 @@ static int IRAM _send(netdev_t *netdev, const iolist_t *iolist)
#endif /* MODULE_OD */ #endif /* MODULE_OD */
#endif /* ENABLE_DEBUG */ #endif /* ENABLE_DEBUG */
int res = ieee80211_output_pbuf(sta_netif, pb); critical_exit();
err_t res = sta_netif->linkoutput(sta_netif, pb);
/*
* Attempting to send the next frame before completing the transmission
* of the previous frame may result in a complete blockage of the send
* function. To avoid this blockage, we have to wait here until the frame
* has been sent. The frame has been sent when pb->ref becomes 1.
* We wait for a maximum time of ESP_WIFI_SEND_TIMEOUT milliseconds.
*/
unsigned _timeout = ESP_WIFI_SEND_TIMEOUT;
while (pb->ref > 1 && --_timeout && dev->state == ESP_WIFI_CONNECTED) {
xtimer_usleep(US_PER_MS);
}
pbuf_free(pb); pbuf_free(pb);
if (res == ERR_OK && _timeout) { if (res == ERR_OK) {
/* There was no ieee80211_output_pbuf error and no send timeout. */ /* There was no ieee80211_output_pbuf error and no send timeout. */
#ifdef MODULE_NETSTATS_L2 #ifdef MODULE_NETSTATS_L2
netdev->stats.tx_bytes += iol_len; netdev->stats.tx_bytes += iol_len;
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE); netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
#endif #endif
_in_send = false; _in_send = false;
critical_exit();
return iol_len; return iol_len;
} }
else { else {
...@@ -424,14 +411,6 @@ static int IRAM _send(netdev_t *netdev, const iolist_t *iolist) ...@@ -424,14 +411,6 @@ static int IRAM _send(netdev_t *netdev, const iolist_t *iolist)
netdev->stats.tx_failed++; netdev->stats.tx_failed++;
#endif #endif
_in_send = false; _in_send = false;
critical_exit();
/*
* ieee80211_output_pbuf usually happens because we run into out of
* memory. We have to wait until lwIP pbuf has been flushed. For that
* purpose, we have to disconnect from AP and wait for a short time.
* The node will then reconnect to AP automatically.
*/
wifi_station_disconnect();
return -EIO; return -EIO;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment