esp_eth: added option to disable soft flow control when rx buffer is few

This commit is contained in:
morris 2021-01-28 19:10:42 +08:00
parent 932c509280
commit 006a87557b
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -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);