Merge branch 'feature/iperf_for_all_phys' into 'master'

add(examples/ethernet/iperf): capability to run iperf test on all supported phys

See merge request espressif/esp-idf!29348
pull/13550/head
Bogdan Kolendovskyy 2024-03-26 21:15:50 +08:00
commit c6002f7dfd
10 zmienionych plików z 471 dodań i 10 usunięć

Wyświetl plik

@ -68,6 +68,20 @@
#define IDF_PERFORMANCE_MIN_UDP_TX_ETH_THROUGHPUT 70
#endif
#ifndef IDF_PERFORMANCE_MIN_TCP_RX_ETH_THROUGHPUT_SPI_ETH
#define IDF_PERFORMANCE_MIN_TCP_RX_ETH_THROUGHPUT_SPI_ETH 2
#endif
#ifndef IDF_PERFORMANCE_MIN_TCP_TX_ETH_THROUGHPUT_SPI_ETH
#define IDF_PERFORMANCE_MIN_TCP_TX_ETH_THROUGHPUT_SPI_ETH 3
#endif
#ifndef IDF_PERFORMANCE_MIN_UDP_RX_ETH_THROUGHPUT_SPI_ETH
#define IDF_PERFORMANCE_MIN_UDP_RX_ETH_THROUGHPUT_SPI_ETH 5
#endif
#ifndef IDF_PERFORMANCE_MIN_UDP_TX_ETH_THROUGHPUT_SPI_ETH
#define IDF_PERFORMANCE_MIN_UDP_TX_ETH_THROUGHPUT_SPI_ETH 7
#endif
// events dispatched per second by event loop library
#if !CONFIG_FREERTOS_SMP // IDF-5112
#ifndef IDF_PERFORMANCE_MIN_EVENT_DISPATCH

Wyświetl plik

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
"""
Test case for iperf example.
@ -8,8 +8,6 @@ This test case might have problem running on Windows:
- use `sudo killall iperf` to force kill iperf, didn't implement windows version
"""
from __future__ import division, unicode_literals
import os
import subprocess
@ -19,7 +17,7 @@ from idf_iperf_test_util import IperfUtility
from pytest_embedded import Dut
try:
from typing import Any, Callable, Tuple
from typing import Any, Callable, Tuple, Optional
except ImportError:
# Only used for type annotations
pass
@ -51,12 +49,11 @@ class IperfTestUtilityEth(IperfUtility.IperfTestUtility):
return dut_ip, rssi
@pytest.mark.esp32
@pytest.mark.ethernet_router
def test_esp_eth_iperf(
dut: Dut,
log_performance: Callable[[str, object], None],
check_performance: Callable[[str, float, str], None],
spi_eth: Optional[bool] = False
) -> None:
"""
steps: |
@ -83,7 +80,11 @@ def test_esp_eth_iperf(
test_utility.run_test('tcp', 'tx', 0, NO_BANDWIDTH_LIMIT)
test_utility.run_test('tcp', 'rx', 0, NO_BANDWIDTH_LIMIT)
test_utility.run_test('udp', 'tx', 0, 80)
test_utility.run_test('udp', 'rx', 0, NO_BANDWIDTH_LIMIT)
# Limit speed to 10Mbps for SPI Ethernet PHYs
if spi_eth:
test_utility.run_test('udp', 'rx', 0, 10)
else:
test_utility.run_test('udp', 'rx', 0, NO_BANDWIDTH_LIMIT)
# 4. log performance and compare with pass standard
for throughput_type in test_result:
@ -92,6 +93,115 @@ def test_esp_eth_iperf(
# do check after logging, otherwise test will exit immediately if check fail, some performance can't be logged.
for throughput_type in test_result:
check_performance('{}_throughput'.format(throughput_type + '_eth'),
test_result[throughput_type].get_best_throughput(),
dut.target)
if spi_eth:
check_performance('{}_eth_throughput_spi_eth'.format(throughput_type),
test_result[throughput_type].get_best_throughput(),
dut.target)
else:
check_performance('{}_eth_throughput'.format(throughput_type),
test_result[throughput_type].get_best_throughput(),
dut.target)
@pytest.mark.esp32
@pytest.mark.ethernet_router
@pytest.mark.parametrize('config', [
'default_ip101',
], indirect=True)
def test_esp_eth_iperf_ip101(
dut: Dut,
log_performance: Callable[[str, object], None],
check_performance: Callable[[str, float, str], None],
) -> None:
test_esp_eth_iperf(dut, log_performance, check_performance)
@pytest.mark.esp32
@pytest.mark.eth_lan8720
@pytest.mark.parametrize('config', [
'default_lan8720',
], indirect=True)
def test_esp_eth_iperf_lan8720(
dut: Dut,
log_performance: Callable[[str, object], None],
check_performance: Callable[[str, float, str], None],
) -> None:
test_esp_eth_iperf(dut, log_performance, check_performance)
@pytest.mark.esp32
@pytest.mark.eth_rtl8201
@pytest.mark.parametrize('config', [
'default_rtl8201',
], indirect=True)
def test_esp_eth_iperf_rtl8201(
dut: Dut,
log_performance: Callable[[str, object], None],
check_performance: Callable[[str, float, str], None],
) -> None:
test_esp_eth_iperf(dut, log_performance, check_performance)
@pytest.mark.esp32
@pytest.mark.eth_dp83848
@pytest.mark.parametrize('config', [
'default_dp83848',
], indirect=True)
def test_esp_eth_iperf_dp83848(
dut: Dut,
log_performance: Callable[[str, object], None],
check_performance: Callable[[str, float, str], None],
) -> None:
test_esp_eth_iperf(dut, log_performance, check_performance)
@pytest.mark.esp32
@pytest.mark.eth_ksz8041
@pytest.mark.parametrize('config', [
'default_ksz8041',
], indirect=True)
def test_esp_eth_iperf_ksz8041(
dut: Dut,
log_performance: Callable[[str, object], None],
check_performance: Callable[[str, float, str], None],
) -> None:
test_esp_eth_iperf(dut, log_performance, check_performance)
@pytest.mark.esp32
@pytest.mark.eth_dm9051
@pytest.mark.parametrize('config', [
'default_dm9051',
], indirect=True)
def test_esp_eth_iperf_dm9051(
dut: Dut,
log_performance: Callable[[str, object], None],
check_performance: Callable[[str, float, str], None],
) -> None:
test_esp_eth_iperf(dut, log_performance, check_performance, spi_eth=True)
@pytest.mark.esp32
@pytest.mark.eth_w5500
@pytest.mark.parametrize('config', [
'default_w5500',
], indirect=True)
def test_esp_eth_iperf_w5500(
dut: Dut,
log_performance: Callable[[str, object], None],
check_performance: Callable[[str, float, str], None],
) -> None:
test_esp_eth_iperf(dut, log_performance, check_performance, spi_eth=True)
@pytest.mark.esp32
@pytest.mark.eth_ksz8851snl
@pytest.mark.parametrize('config', [
'default_ksz8851snl',
], indirect=True)
def test_esp_eth_iperf_ksz8851snl(
dut: Dut,
log_performance: Callable[[str, object], None],
check_performance: Callable[[str, float, str], None],
) -> None:
test_esp_eth_iperf(dut, log_performance, check_performance, spi_eth=True)

Wyświetl plik

@ -0,0 +1,38 @@
# Increase main task stack size
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7168
# Enable filesystem for console commands history storage
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
# Enable FreeRTOS stats formatting functions, needed for 'tasks' command
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
# --------------------------------
# Performance optimization options
# --------------------------------
# `lwIP` and `iperf` tasks have serial dependency to each other (i.e. `iperf` must wait for `lwIP`
# to process the packets). Therefore, you don't gain much performance improvement when running
# multi core mode. On the other hand, IRAM optimizations have greater effect for single core mode.
# Run FreeRTOS only on the first core
CONFIG_FREERTOS_UNICORE=y
# Disable watch dog
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT_EN=n
# Enable lwIP IRAM optimization
CONFIG_LWIP_IRAM_OPTIMIZATION=y
# Enable Ethernet IRAM optimization
CONFIG_ETH_IRAM_OPTIMIZATION=y
CONFIG_EXAMPLE_USE_SPI_ETHERNET=y
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=n
CONFIG_EXAMPLE_SPI_ETHERNETS_NUM=1
CONFIG_EXAMPLE_USE_DM9051=y
CONFIG_EXAMPLE_ETH_SPI_CLOCK_MHZ=20

Wyświetl plik

@ -0,0 +1,45 @@
# Increase main task stack size
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7168
# Enable filesystem for console commands history storage
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
# Enable FreeRTOS stats formatting functions, needed for 'tasks' command
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
# --------------------------------
# Performance optimization options
# --------------------------------
# `lwIP` and `iperf` tasks have serial dependency to each other (i.e. `iperf` must wait for `lwIP`
# to process the packets). Therefore, you don't gain much performance improvement when running
# multi core mode. On the other hand, IRAM optimizations have greater effect for single core mode.
# Run FreeRTOS only on the first core
CONFIG_FREERTOS_UNICORE=y
# Disable watch dog
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT_EN=n
# Enable lwIP IRAM optimization
CONFIG_LWIP_IRAM_OPTIMIZATION=y
# Enable Ethernet IRAM optimization
CONFIG_ETH_IRAM_OPTIMIZATION=y
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
CONFIG_EXAMPLE_ETH_PHY_DP83848=y
CONFIG_EXAMPLE_ETH_MDC_GPIO=23
CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5
CONFIG_EXAMPLE_ETH_PHY_ADDR=1
CONFIG_ETH_ENABLED=y
CONFIG_ETH_USE_ESP32_EMAC=y
CONFIG_ETH_PHY_INTERFACE_RMII=y
CONFIG_ETH_RMII_CLK_OUTPUT=y
CONFIG_ETH_RMII_CLK_OUT_GPIO=17

Wyświetl plik

@ -0,0 +1,44 @@
# Increase main task stack size
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7168
# Enable filesystem for console commands history storage
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
# Enable FreeRTOS stats formatting functions, needed for 'tasks' command
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
# --------------------------------
# Performance optimization options
# --------------------------------
# `lwIP` and `iperf` tasks have serial dependency to each other (i.e. `iperf` must wait for `lwIP`
# to process the packets). Therefore, you don't gain much performance improvement when running
# multi core mode. On the other hand, IRAM optimizations have greater effect for single core mode.
# Run FreeRTOS only on the first core
CONFIG_FREERTOS_UNICORE=y
# Disable watch dog
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT_EN=n
# Enable lwIP IRAM optimization
CONFIG_LWIP_IRAM_OPTIMIZATION=y
# Enable Ethernet IRAM optimization
CONFIG_ETH_IRAM_OPTIMIZATION=y
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
CONFIG_EXAMPLE_ETH_PHY_IP101=y
CONFIG_EXAMPLE_ETH_MDC_GPIO=23
CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5
CONFIG_EXAMPLE_ETH_PHY_ADDR=1
CONFIG_ETH_ENABLED=y
CONFIG_ETH_USE_ESP32_EMAC=y
CONFIG_ETH_PHY_INTERFACE_RMII=y
CONFIG_ETH_RMII_CLK_INPUT=y

Wyświetl plik

@ -0,0 +1,45 @@
# Increase main task stack size
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7168
# Enable filesystem for console commands history storage
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
# Enable FreeRTOS stats formatting functions, needed for 'tasks' command
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
# --------------------------------
# Performance optimization options
# --------------------------------
# `lwIP` and `iperf` tasks have serial dependency to each other (i.e. `iperf` must wait for `lwIP`
# to process the packets). Therefore, you don't gain much performance improvement when running
# multi core mode. On the other hand, IRAM optimizations have greater effect for single core mode.
# Run FreeRTOS only on the first core
CONFIG_FREERTOS_UNICORE=y
# Disable watch dog
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT_EN=n
# Enable lwIP IRAM optimization
CONFIG_LWIP_IRAM_OPTIMIZATION=y
# Enable Ethernet IRAM optimization
CONFIG_ETH_IRAM_OPTIMIZATION=y
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
CONFIG_EXAMPLE_ETH_PHY_KSZ80XX=y
CONFIG_EXAMPLE_ETH_MDC_GPIO=23
CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5
CONFIG_EXAMPLE_ETH_PHY_ADDR=1
CONFIG_ETH_ENABLED=y
CONFIG_ETH_USE_ESP32_EMAC=y
CONFIG_ETH_PHY_INTERFACE_RMII=y
CONFIG_ETH_RMII_CLK_INPUT=y
CONFIG_ETH_RMII_CLK_IN_GPIO=0

Wyświetl plik

@ -0,0 +1,38 @@
# Increase main task stack size
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7168
# Enable filesystem for console commands history storage
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
# Enable FreeRTOS stats formatting functions, needed for 'tasks' command
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
# --------------------------------
# Performance optimization options
# --------------------------------
# `lwIP` and `iperf` tasks have serial dependency to each other (i.e. `iperf` must wait for `lwIP`
# to process the packets). Therefore, you don't gain much performance improvement when running
# multi core mode. On the other hand, IRAM optimizations have greater effect for single core mode.
# Run FreeRTOS only on the first core
CONFIG_FREERTOS_UNICORE=y
# Disable watch dog
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT_EN=n
# Enable lwIP IRAM optimization
CONFIG_LWIP_IRAM_OPTIMIZATION=y
# Enable Ethernet IRAM optimization
CONFIG_ETH_IRAM_OPTIMIZATION=y
CONFIG_EXAMPLE_USE_SPI_ETHERNET=y
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=n
CONFIG_EXAMPLE_SPI_ETHERNETS_NUM=1
CONFIG_EXAMPLE_USE_KSZ8851SNL=y
CONFIG_EXAMPLE_ETH_SPI_CLOCK_MHZ=20

Wyświetl plik

@ -0,0 +1,45 @@
# Increase main task stack size
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7168
# Enable filesystem for console commands history storage
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
# Enable FreeRTOS stats formatting functions, needed for 'tasks' command
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
# --------------------------------
# Performance optimization options
# --------------------------------
# `lwIP` and `iperf` tasks have serial dependency to each other (i.e. `iperf` must wait for `lwIP`
# to process the packets). Therefore, you don't gain much performance improvement when running
# multi core mode. On the other hand, IRAM optimizations have greater effect for single core mode.
# Run FreeRTOS only on the first core
CONFIG_FREERTOS_UNICORE=y
# Disable watch dog
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT_EN=n
# Enable lwIP IRAM optimization
CONFIG_LWIP_IRAM_OPTIMIZATION=y
# Enable Ethernet IRAM optimization
CONFIG_ETH_IRAM_OPTIMIZATION=y
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
CONFIG_EXAMPLE_ETH_PHY_LAN87XX=y
CONFIG_EXAMPLE_ETH_MDC_GPIO=23
CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5
CONFIG_EXAMPLE_ETH_PHY_ADDR=0
CONFIG_ETH_ENABLED=y
CONFIG_ETH_USE_ESP32_EMAC=y
CONFIG_ETH_PHY_INTERFACE_RMII=y
CONFIG_ETH_RMII_CLK_OUTPUT=y
CONFIG_ETH_RMII_CLK_OUT_GPIO=17

Wyświetl plik

@ -0,0 +1,44 @@
# Increase main task stack size
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7168
# Enable filesystem for console commands history storage
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
# Enable FreeRTOS stats formatting functions, needed for 'tasks' command
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
# --------------------------------
# Performance optimization options
# --------------------------------
# `lwIP` and `iperf` tasks have serial dependency to each other (i.e. `iperf` must wait for `lwIP`
# to process the packets). Therefore, you don't gain much performance improvement when running
# multi core mode. On the other hand, IRAM optimizations have greater effect for single core mode.
# Run FreeRTOS only on the first core
CONFIG_FREERTOS_UNICORE=y
# Disable watch dog
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT_EN=n
# Enable lwIP IRAM optimization
CONFIG_LWIP_IRAM_OPTIMIZATION=y
# Enable Ethernet IRAM optimization
CONFIG_ETH_IRAM_OPTIMIZATION=y
CONFIG_EXAMPLE_ETH_MDC_GPIO=16
CONFIG_EXAMPLE_ETH_MDIO_GPIO=17
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=-1
CONFIG_EXAMPLE_ETH_PHY_ADDR=0
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
CONFIG_EXAMPLE_ETH_PHY_RTL8201=y
CONFIG_ETH_RMII_CLK_INPUT=y
# CONFIG_ETH_RMII_CLK_OUTPUT is not set
CONFIG_ETH_RMII_CLK_IN_GPIO=0

Wyświetl plik

@ -0,0 +1,38 @@
# Increase main task stack size
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7168
# Enable filesystem for console commands history storage
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
# Enable FreeRTOS stats formatting functions, needed for 'tasks' command
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
# --------------------------------
# Performance optimization options
# --------------------------------
# `lwIP` and `iperf` tasks have serial dependency to each other (i.e. `iperf` must wait for `lwIP`
# to process the packets). Therefore, you don't gain much performance improvement when running
# multi core mode. On the other hand, IRAM optimizations have greater effect for single core mode.
# Run FreeRTOS only on the first core
CONFIG_FREERTOS_UNICORE=y
# Disable watch dog
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT_EN=n
# Enable lwIP IRAM optimization
CONFIG_LWIP_IRAM_OPTIMIZATION=y
# Enable Ethernet IRAM optimization
CONFIG_ETH_IRAM_OPTIMIZATION=y
CONFIG_EXAMPLE_USE_SPI_ETHERNET=y
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=n
CONFIG_EXAMPLE_SPI_ETHERNETS_NUM=1
CONFIG_EXAMPLE_USE_W5500=y
CONFIG_EXAMPLE_ETH_SPI_CLOCK_MHZ=20