[riot-notifications] [RIOT-OS/RIOT] cpu/esp8266: Fixes and improvements of esp_wifi netdev driver [backport 2019.01] (#10904)

Gunar Schorcht notifications at github.com
Wed Jan 30 11:57:11 CET 2019

## Backport of #10862

### Contribution description

This PR increases the performance and the stability of the `esp_wifi` netdev driver. These are in detail:

- Since the `_esp_wifi_recv_cb` callback on frame receiption is not executed in interrupt context but in the context of the `ets` thread, it is not necessary to pass the`NETDEV_EVENT_ISR` event first. Instead, the receive function `_recv` can be called directly which leads to a much faster handling, a lower frame lost rate and more robustness.

- Since `_recv` function and `_esp_wifi_recv_cb` are called in a deterministic order, there is no need for a mutex anymore to synchronize the access to the receive buffer between the `_esp_wifi_recv_cb` and the `recv` function.

- The Espressif SDK includes its own `lwIP` version. Since `lwIP` is not required for RIOT, the `lwIP` library from Espressif SDK is not used anymore. To satisfy symbol dependencies of the SDK libraries to the `lwIP` library, a number of dummy functions are defined without real functionality. Using these dummy functions instead of real `lwIP` functions saves about 4 kbytes of RAM.

- The auto reconnect mechanism from SDK is used now since it seems to be more stable and less memory consuming.

- Removes timeout handling and disconnecting in send function when the lwIP buffer is exhausted. This PR solves problems 2 and 4 in issue #10861. 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.

- Human readable disconnect reasons.

- Generation of `NETDEV_EVENT_LINK_DOWN` and `NETDEV_EVENT_LINK_DOWN` on disconnect and connect to the AP.

### Testing procedure

With this PR, the performance of pinging an esp8266 node should be noticeably better than before.

- Compile and flash `example/gnrc_networking` to at least one ESP8266 node using your AP configuration, e.g.,
    CFLAGS='-DESP_WIFI_SSID=\"<your SSID>\" -DESP_WIFI_PASS=\"your passphrase\"' USEMODULE="esp_wifi" make BOARD=esp8266-esp-12x -C examples/gnrc_networking flash
- Stress test from LAN with `sudo ping6 fe80::<ESP_IID> -Ieth0 -s1392 -i 0` should be stable. The packet loss rate should be 0. This should be also the case, if ping is executed on two nodes or in both directions.

### Issues/PRs references

This PR solves the problems 2 and 4 as described in #10861. It improves the stability and the performance a lot.
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * cpu/esp8266: removes the mutex in esp_wifi
  * cpu/esp8266: call _recv directly in esp_wifi
  * cpu/esp8266: lwIP dummy functions added
  * cpu/esp8266: auto reconnect in esp_wifi
  * cpu/esp8266: don't disconnect on pbuf full in send
  * cpu/esp8266: remove timeout handling in send func
  * cpu/esp8266: readable disconn reasons in esp_wifi
  * cpu/esp8266: event handling for link up/down
  * cpu/esp8266: dbg msg replaced by an error msg
  * cpu/esp8266: check free heap before pbuf alloc
  * cpu/esp8266: fix compile problems
  * cpu/esp8266: avoid WiFi going into sleep mode

-- File Changes --

    M cpu/esp8266/Makefile.dep (2)
    M cpu/esp8266/esp-wifi/esp_wifi_netdev.c (178)
    M cpu/esp8266/esp-wifi/esp_wifi_netdev.h (3)
    A cpu/esp8266/sdk/lwip.c (213)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190130/25183e17/attachment.html>

More information about the notifications mailing list