From 932c509280cad4a4aff3e51de7b23be0401746dc Mon Sep 17 00:00:00 2001 From: morris Date: Mon, 1 Feb 2021 14:12:49 +0800 Subject: [PATCH 1/2] ethernet: not using test MAC address for EMAC example --- examples/ethernet/basic/main/ethernet_example_main.c | 2 +- examples/ethernet/eth2ap/main/ethernet_example_main.c | 2 +- examples/ethernet/iperf/main/cmd_ethernet.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/ethernet/basic/main/ethernet_example_main.c b/examples/ethernet/basic/main/ethernet_example_main.c index 73936650ea..63d82e79c3 100644 --- a/examples/ethernet/basic/main/ethernet_example_main.c +++ b/examples/ethernet/basic/main/ethernet_example_main.c @@ -145,7 +145,7 @@ void app_main(void) esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy); esp_eth_handle_t eth_handle = NULL; ESP_ERROR_CHECK(esp_eth_driver_install(&config, ð_handle)); -#if CONFIG_ETH_USE_SPI_ETHERNET +#if !CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET /* The SPI Ethernet module might doesn't have a burned factory MAC address, we cat to set it manually. 02:00:00 is a Locally Administered OUI range so should not be used except when testing on a LAN under your control. */ diff --git a/examples/ethernet/eth2ap/main/ethernet_example_main.c b/examples/ethernet/eth2ap/main/ethernet_example_main.c index a61416e0fc..ac0b36e834 100644 --- a/examples/ethernet/eth2ap/main/ethernet_example_main.c +++ b/examples/ethernet/eth2ap/main/ethernet_example_main.c @@ -218,7 +218,7 @@ static void initialize_ethernet(void) esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy); config.stack_input = pkt_eth2wifi; ESP_ERROR_CHECK(esp_eth_driver_install(&config, &s_eth_handle)); -#if CONFIG_ETH_USE_SPI_ETHERNET +#if !CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET /* The SPI Ethernet module might doesn't have a burned factory MAC address, we cat to set it manually. 02:00:00 is a Locally Administered OUI range so should not be used except when testing on a LAN under your control. */ diff --git a/examples/ethernet/iperf/main/cmd_ethernet.c b/examples/ethernet/iperf/main/cmd_ethernet.c index f8efff1e2b..d3bc7ef8bc 100644 --- a/examples/ethernet/iperf/main/cmd_ethernet.c +++ b/examples/ethernet/iperf/main/cmd_ethernet.c @@ -253,7 +253,7 @@ void register_ethernet(void) #endif // CONFIG_ETH_USE_SPI_ETHERNET esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy); ESP_ERROR_CHECK(esp_eth_driver_install(&config, ð_handle)); -#if CONFIG_ETH_USE_SPI_ETHERNET +#if !CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET /* The SPI Ethernet module might doesn't have a burned factory MAC address, we cat to set it manually. 02:00:00 is a Locally Administered OUI range so should not be used except when testing on a LAN under your control. */ From 006a87557ba326dad43011f69718d54f60a0eb19 Mon Sep 17 00:00:00 2001 From: morris Date: Thu, 28 Jan 2021 19:10:42 +0800 Subject: [PATCH 2/2] esp_eth: added option to disable soft flow control when rx buffer is few --- components/esp_eth/Kconfig | 12 ++++++++++++ components/esp_eth/src/esp_eth_mac_esp32.c | 2 ++ 2 files changed, 14 insertions(+) diff --git a/components/esp_eth/Kconfig b/components/esp_eth/Kconfig index 9780b1bf48..cba7514fd1 100644 --- a/components/esp_eth/Kconfig +++ b/components/esp_eth/Kconfig @@ -102,6 +102,18 @@ menu "Ethernet" help Number of DMA transmit buffers. Each buffer's size is ETH_DMA_BUFFER_SIZE. Larger number of buffers could increase throughput somehow. + + if ETH_DMA_RX_BUFFER_NUM > 15 + config ETH_SOFT_FLOW_CONTROL + bool "Enable software flow control" + default n + help + Ethernet MAC engine on ESP32 doesn't feature a flow control logic. + The MAC driver can perform a software flow control if you enable this option. + Note that, if the RX buffer number is small, enabling software flow control will + cause obvious performance loss. + endif + endif # ETH_USE_ESP32_EMAC menuconfig ETH_USE_SPI_ETHERNET diff --git a/components/esp_eth/src/esp_eth_mac_esp32.c b/components/esp_eth/src/esp_eth_mac_esp32.c index 47f05e68e4..45d99788d0 100644 --- a/components/esp_eth/src/esp_eth_mac_esp32.c +++ b/components/esp_eth/src/esp_eth_mac_esp32.c @@ -299,12 +299,14 @@ static void emac_esp32_rx_task(void *arg) } else { free(buffer); } +#if CONFIG_ETH_SOFT_FLOW_CONTROL // we need to do extra checking of remained frames in case there are no unhandled frames left, but pause frame is still undergoing if ((emac->free_rx_descriptor < emac->flow_control_low_water_mark) && emac->do_flow_ctrl && emac->frames_remain) { emac_hal_send_pause_frame(&emac->hal, true); } else if ((emac->free_rx_descriptor > emac->flow_control_high_water_mark) || !emac->frames_remain) { emac_hal_send_pause_frame(&emac->hal, false); } +#endif } while (emac->frames_remain); } vTaskDelete(NULL);