Merge branch 'feature/emac_start_stop_test' into 'master'

test_emac: extended Ethernet start/stop stress test

Closes IDF-4540

See merge request espressif/esp-idf!16755
This commit is contained in:
Ondrej Kosta
2022-02-15 13:23:01 +00:00
9 changed files with 282 additions and 41 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -265,7 +265,6 @@ esp_err_t esp_eth_start(esp_eth_handle_t hdl)
esp_eth_driver_t *eth_driver = (esp_eth_driver_t *)hdl;
ESP_GOTO_ON_FALSE(eth_driver, ESP_ERR_INVALID_ARG, err, TAG, "ethernet driver handle can't be null");
esp_eth_phy_t *phy = eth_driver->phy;
esp_eth_mac_t *mac = eth_driver->mac;
// check if driver has stopped
esp_eth_fsm_t expected_fsm = ESP_ETH_FSM_STOP;
ESP_GOTO_ON_FALSE(atomic_compare_exchange_strong(&eth_driver->fsm, &expected_fsm, ESP_ETH_FSM_START),
@@ -274,7 +273,6 @@ esp_err_t esp_eth_start(esp_eth_handle_t hdl)
if (eth_driver->auto_nego_en == true) {
ESP_GOTO_ON_ERROR(phy->autonego_ctrl(phy, ESP_ETH_PHY_AUTONEGO_RESTART, &eth_driver->auto_nego_en), err, TAG, "phy negotiation failed");
}
ESP_GOTO_ON_ERROR(mac->start(mac), err, TAG, "start mac failed");
ESP_GOTO_ON_ERROR(esp_event_post(ETH_EVENT, ETHERNET_EVENT_START, &eth_driver, sizeof(esp_eth_driver_t *), 0),
err, TAG, "send ETHERNET_EVENT_START event failed");
ESP_GOTO_ON_ERROR(phy->get_link(phy), err, TAG, "phy get link status failed");

View File

@@ -33,7 +33,7 @@
static const char *TAG = "esp.emac";
#define PHY_OPERATION_TIMEOUT_US (1000)
#define MAC_STOP_TIMEOUT_MS (100)
#define MAC_STOP_TIMEOUT_US (250)
#define FLOW_CONTROL_LOW_WATER_MARK (CONFIG_ETH_DMA_RX_BUFFER_NUM / 3)
#define FLOW_CONTROL_HIGH_WATER_MARK (FLOW_CONTROL_LOW_WATER_MARK * 2)
@@ -66,6 +66,8 @@ typedef struct {
static esp_err_t esp_emac_alloc_driver_obj(const eth_mac_config_t *config, emac_esp32_t **emac_out_hdl, void **out_descriptors);
static void esp_emac_free_driver_obj(emac_esp32_t *emac, void *descriptors);
static esp_err_t emac_esp32_start(esp_eth_mac_t *mac);
static esp_err_t emac_esp32_stop(esp_eth_mac_t *mac);
static esp_err_t emac_esp32_set_mediator(esp_eth_mac_t *mac, esp_eth_mediator_t *eth)
{
@@ -152,11 +154,11 @@ static esp_err_t emac_esp32_set_link(esp_eth_mac_t *mac, eth_link_t link)
switch (link) {
case ETH_LINK_UP:
ESP_GOTO_ON_ERROR(esp_intr_enable(emac->intr_hdl), err, TAG, "enable interrupt failed");
emac_hal_start(&emac->hal);
emac_esp32_start(mac);
break;
case ETH_LINK_DOWN:
ESP_GOTO_ON_ERROR(esp_intr_disable(emac->intr_hdl), err, TAG, "disable interrupt failed");
emac_hal_stop(&emac->hal);
emac_esp32_stop(mac);
break;
default:
ESP_GOTO_ON_FALSE(false, ESP_ERR_INVALID_ARG, err, TAG, "unknown link status");
@@ -389,9 +391,9 @@ static esp_err_t emac_esp32_stop(esp_eth_mac_t *mac)
if ((ret = emac_hal_stop(&emac->hal)) == ESP_OK) {
break;
}
to += 20;
vTaskDelay(pdMS_TO_TICKS(20));
} while (to < MAC_STOP_TIMEOUT_MS);
to += 25;
esp_rom_delay_us(25);
} while (to < MAC_STOP_TIMEOUT_US);
return ret;
}