From cba0160e2b73fcfa9a49f2ef2da26d2d0623f493 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 12 Jan 2024 08:17:11 +0100 Subject: [PATCH] Revert "fix(eppp_link): Per review comments" This reverts commit e97e4f8d7cae8dbcd16a49d08e040b4935fe5a96. --- components/eppp_link/README.md | 8 +++---- components/eppp_link/eppp_link.c | 23 +++++++++++++------ components/eppp_link/eppp_link_types.h | 0 .../examples/host/main/register_iperf.c | 10 +++++--- components/eppp_link/include/eppp_link.h | 4 ++-- 5 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 components/eppp_link/eppp_link_types.h diff --git a/components/eppp_link/README.md b/components/eppp_link/README.md index 2a811bfeacd..51ba0ae6d51 100644 --- a/components/eppp_link/README.md +++ b/components/eppp_link/README.md @@ -35,10 +35,10 @@ Tested with WiFi-NAPT example, no IRAM optimizations ### UART @ 3Mbauds -* TCP - 2Mbits/s -* UDP - 2Mbits/s +* TCP - 2Mbits +* UDP - 2Mbits ### SPI @ 20MHz -* TCP - 6Mbits/s -* UDP - 10Mbits/s +* TCP - 6Mbits +* UDP - 10Mbits diff --git a/components/eppp_link/eppp_link.c b/components/eppp_link/eppp_link.c index 0ac1e3c9997..73fba3ad769 100644 --- a/components/eppp_link/eppp_link.c +++ b/components/eppp_link/eppp_link.c @@ -44,7 +44,7 @@ struct eppp_handle { uart_port_t uart_port; #endif esp_netif_t *netif; - eppp_type_t role; + enum eppp_type role; bool stop; bool exited; bool netif_stop; @@ -130,7 +130,7 @@ static void netif_deinit(esp_netif_t *netif) } } -static esp_netif_t *netif_init(eppp_type_t role) +static esp_netif_t *netif_init(enum eppp_type role) { if (s_eppp_netif_count > 9) { ESP_LOGE(TAG, "Cannot create more than 10 instances"); @@ -625,6 +625,15 @@ esp_err_t eppp_perform(esp_netif_t *netif) return ESP_OK; } +static void ppp_task(void *args) +{ + esp_netif_t *netif = args; + while (eppp_perform(netif) != ESP_ERR_TIMEOUT) {} + struct eppp_handle *h = esp_netif_get_io_driver(netif); + h->exited = true; + vTaskDelete(NULL); +} + #elif CONFIG_EPPP_LINK_DEVICE_UART #define BUF_SIZE (1024) @@ -677,17 +686,17 @@ esp_err_t eppp_perform(esp_netif_t *netif) return ESP_OK; } -#endif // CONFIG_EPPP_LINK_DEVICE_SPI / UART - static void ppp_task(void *args) { esp_netif_t *netif = args; - while (eppp_perform(netif) != ESP_ERR_TIMEOUT) {} + while (eppp_perform(netif) == ESP_OK) {} struct eppp_handle *h = esp_netif_get_io_driver(netif); h->exited = true; vTaskDelete(NULL); } +#endif // CONFIG_EPPP_LINK_DEVICE_SPI / UART + static bool have_some_eppp_netif(esp_netif_t *netif, void *ctx) { return get_netif_num(netif) > 0; @@ -720,7 +729,7 @@ void eppp_deinit(esp_netif_t *netif) netif_deinit(netif); } -esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config) +esp_netif_t *eppp_init(enum eppp_type role, eppp_config_t *config) { esp_netif_t *netif = netif_init(role); if (!netif) { @@ -751,7 +760,7 @@ esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config) return netif; } -esp_netif_t *eppp_open(eppp_type_t role, eppp_config_t *config, TickType_t connect_timeout) +esp_netif_t *eppp_open(enum eppp_type role, eppp_config_t *config, TickType_t connect_timeout) { #if CONFIG_EPPP_LINK_DEVICE_UART if (config->transport != EPPP_TRANSPORT_UART) { diff --git a/components/eppp_link/eppp_link_types.h b/components/eppp_link/eppp_link_types.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/components/eppp_link/examples/host/main/register_iperf.c b/components/eppp_link/examples/host/main/register_iperf.c index 63fded10c56..d2169c3763c 100644 --- a/components/eppp_link/examples/host/main/register_iperf.c +++ b/components/eppp_link/examples/host/main/register_iperf.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -46,14 +46,18 @@ static struct { static int ppp_cmd_iperf(int argc, char **argv) { int nerrors = arg_parse(argc, argv, (void **)&iperf_args); - // ethernet iperf only support IPV4 address - iperf_cfg_t cfg = {.type = IPERF_IP_TYPE_IPV4}; + iperf_cfg_t cfg; if (nerrors != 0) { arg_print_errors(stderr, iperf_args.end, argv[0]); return 0; } + memset(&cfg, 0, sizeof(cfg)); + + // ethernet iperf only support IPV4 address + cfg.type = IPERF_IP_TYPE_IPV4; + /* iperf -a */ if (iperf_args.abort->count != 0) { iperf_stop(); diff --git a/components/eppp_link/include/eppp_link.h b/components/eppp_link/include/eppp_link.h index bb7f4989925..ad448ea7d72 100644 --- a/components/eppp_link/include/eppp_link.h +++ b/components/eppp_link/include/eppp_link.h @@ -92,11 +92,11 @@ esp_netif_t *eppp_listen(eppp_config_t *config); void eppp_close(esp_netif_t *netif); -esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config); +esp_netif_t *eppp_init(enum eppp_type role, eppp_config_t *config); void eppp_deinit(esp_netif_t *netif); -esp_netif_t *eppp_open(eppp_type_t role, eppp_config_t *config, TickType_t connect_timeout); +esp_netif_t *eppp_open(enum eppp_type role, eppp_config_t *config, TickType_t connect_timeout); esp_err_t eppp_netif_stop(esp_netif_t *netif, TickType_t stop_timeout);