From ab0c5fed257551468c29dd420b6e484ecc824f9c Mon Sep 17 00:00:00 2001 From: morris Date: Thu, 17 Jun 2021 13:40:26 +0800 Subject: [PATCH] eth: dont warn nego timeout if link is down --- components/esp_eth/src/esp_eth_phy_dm9051.c | 7 ++++++- components/esp_eth/src/esp_eth_phy_dp83848.c | 8 ++++++-- components/esp_eth/src/esp_eth_phy_ip101.c | 8 ++++++-- components/esp_eth/src/esp_eth_phy_ksz80xx.c | 8 ++++++-- components/esp_eth/src/esp_eth_phy_ksz8851snl.c | 9 +++++++-- components/esp_eth/src/esp_eth_phy_lan87xx.c | 7 ++++++- components/esp_eth/src/esp_eth_phy_rtl8201.c | 8 ++++++-- 7 files changed, 43 insertions(+), 12 deletions(-) diff --git a/components/esp_eth/src/esp_eth_phy_dm9051.c b/components/esp_eth/src/esp_eth_phy_dm9051.c index 5c1c112a61..dcbc3d44fe 100644 --- a/components/esp_eth/src/esp_eth_phy_dm9051.c +++ b/components/esp_eth/src/esp_eth_phy_dm9051.c @@ -195,6 +195,11 @@ static esp_err_t dm9051_reset_hw(esp_eth_phy_t *phy) return ESP_OK; } +/** + * @note This function is responsible for restarting a new auto-negotiation, + * the result of negotiation won't be relected to uppler layers. + * Instead, the negotiation result is fetched by linker timer, see `dm9051_get_link()` + */ static esp_err_t dm9051_negotiate(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; @@ -222,7 +227,7 @@ static esp_err_t dm9051_negotiate(esp_eth_phy_t *phy) break; } } - if (to >= dm9051->autonego_timeout_ms / 100) { + if ((to >= dm9051->autonego_timeout_ms / 100) && (dm9051->link_status == ETH_LINK_UP)) { ESP_LOGW(TAG, "Ethernet PHY auto negotiation timeout"); } return ESP_OK; diff --git a/components/esp_eth/src/esp_eth_phy_dp83848.c b/components/esp_eth/src/esp_eth_phy_dp83848.c index cafef8d59c..a245a902d2 100644 --- a/components/esp_eth/src/esp_eth_phy_dp83848.c +++ b/components/esp_eth/src/esp_eth_phy_dp83848.c @@ -189,6 +189,11 @@ static esp_err_t dp83848_reset_hw(esp_eth_phy_t *phy) return ESP_OK; } +/** + * @note This function is responsible for restarting a new auto-negotiation, + * the result of negotiation won't be relected to uppler layers. + * Instead, the negotiation result is fetched by linker timer, see `dp83848_get_link()` + */ static esp_err_t dp83848_negotiate(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; @@ -216,8 +221,7 @@ static esp_err_t dp83848_negotiate(esp_eth_phy_t *phy) break; } } - /* Auto negotiation failed, maybe no network cable plugged in, so output a warning */ - if (to >= dp83848->autonego_timeout_ms / 100) { + if ((to >= dp83848->autonego_timeout_ms / 100) && (dp83848->link_status == ETH_LINK_UP)) { ESP_LOGW(TAG, "auto negotiation timeout"); } return ESP_OK; diff --git a/components/esp_eth/src/esp_eth_phy_ip101.c b/components/esp_eth/src/esp_eth_phy_ip101.c index e8424288b6..280f116a3c 100644 --- a/components/esp_eth/src/esp_eth_phy_ip101.c +++ b/components/esp_eth/src/esp_eth_phy_ip101.c @@ -230,6 +230,11 @@ static esp_err_t ip101_reset_hw(esp_eth_phy_t *phy) return ESP_OK; } +/** + * @note This function is responsible for restarting a new auto-negotiation, + * the result of negotiation won't be relected to uppler layers. + * Instead, the negotiation result is fetched by linker timer, see `ip101_get_link()` + */ static esp_err_t ip101_negotiate(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; @@ -255,8 +260,7 @@ static esp_err_t ip101_negotiate(esp_eth_phy_t *phy) break; } } - /* Auto negotiation failed, maybe no network cable plugged in, so output a warning */ - if (to >= ip101->autonego_timeout_ms / 100) { + if ((to >= ip101->autonego_timeout_ms / 100) && (ip101->link_status == ETH_LINK_UP)) { ESP_LOGW(TAG, "auto negotiation timeout"); } return ESP_OK; diff --git a/components/esp_eth/src/esp_eth_phy_ksz80xx.c b/components/esp_eth/src/esp_eth_phy_ksz80xx.c index 1674648085..638f22c2ff 100644 --- a/components/esp_eth/src/esp_eth_phy_ksz80xx.c +++ b/components/esp_eth/src/esp_eth_phy_ksz80xx.c @@ -208,6 +208,11 @@ static esp_err_t ksz80xx_reset_hw(esp_eth_phy_t *phy) return ESP_OK; } +/** + * @note This function is responsible for restarting a new auto-negotiation, + * the result of negotiation won't be relected to uppler layers. + * Instead, the negotiation result is fetched by linker timer, see `ksz80xx_get_link()` + */ static esp_err_t ksz80xx_negotiate(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; @@ -233,8 +238,7 @@ static esp_err_t ksz80xx_negotiate(esp_eth_phy_t *phy) break; } } - /* Auto negotiation failed, maybe no network cable plugged in, so output a warning */ - if (to >= ksz80xx->autonego_timeout_ms / 100) { + if ((to >= ksz80xx->autonego_timeout_ms / 100) && (ksz80xx->link_status == ETH_LINK_UP)) { ESP_LOGW(TAG, "auto negotiation timeout"); } return ESP_OK; diff --git a/components/esp_eth/src/esp_eth_phy_ksz8851snl.c b/components/esp_eth/src/esp_eth_phy_ksz8851snl.c index 2f72e6b394..3871a3e010 100644 --- a/components/esp_eth/src/esp_eth_phy_ksz8851snl.c +++ b/components/esp_eth/src/esp_eth_phy_ksz8851snl.c @@ -160,6 +160,11 @@ err: return ret; } +/** + * @note This function is responsible for restarting a new auto-negotiation, + * the result of negotiation won't be relected to uppler layers. + * Instead, the negotiation result is fetched by linker timer, see `phy_ksz8851_get_link()` + */ static esp_err_t phy_ksz8851_negotiate(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; @@ -181,8 +186,8 @@ static esp_err_t phy_ksz8851_negotiate(esp_eth_phy_t *phy) break; } } - if (to >= ksz8851->autonego_timeout_ms / 100) { - ESP_LOGW(TAG, "Ethernet PHY auto negotiation timeout"); + if ((to >= ksz8851->autonego_timeout_ms / 100) && (ksz8851->link_status == ETH_LINK_UP)) { + ESP_LOGW(TAG, "auto negotiation timeout"); } ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ksz8851->addr, KSZ8851_P1CR, control), err, TAG, "P1CR write failed"); diff --git a/components/esp_eth/src/esp_eth_phy_lan87xx.c b/components/esp_eth/src/esp_eth_phy_lan87xx.c index 6678253f65..5dc21b5c9a 100644 --- a/components/esp_eth/src/esp_eth_phy_lan87xx.c +++ b/components/esp_eth/src/esp_eth_phy_lan87xx.c @@ -343,6 +343,11 @@ static esp_err_t lan87xx_reset_hw(esp_eth_phy_t *phy) return ESP_OK; } +/** + * @note This function is responsible for restarting a new auto-negotiation, + * the result of negotiation won't be relected to uppler layers. + * Instead, the negotiation result is fetched by linker timer, see `lan87xx_get_link()` + */ static esp_err_t lan87xx_negotiate(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; @@ -371,7 +376,7 @@ static esp_err_t lan87xx_negotiate(esp_eth_phy_t *phy) } } /* Auto negotiation failed, maybe no network cable plugged in, so output a warning */ - if (to >= lan87xx->autonego_timeout_ms / 100) { + if (to >= lan87xx->autonego_timeout_ms / 100 && (lan87xx->link_status == ETH_LINK_UP)) { ESP_LOGW(TAG, "auto negotiation timeout"); } return ESP_OK; diff --git a/components/esp_eth/src/esp_eth_phy_rtl8201.c b/components/esp_eth/src/esp_eth_phy_rtl8201.c index 8ba4a35445..6733328b80 100644 --- a/components/esp_eth/src/esp_eth_phy_rtl8201.c +++ b/components/esp_eth/src/esp_eth_phy_rtl8201.c @@ -183,6 +183,11 @@ static esp_err_t rtl8201_reset_hw(esp_eth_phy_t *phy) return ESP_OK; } +/** + * @note This function is responsible for restarting a new auto-negotiation, + * the result of negotiation won't be relected to uppler layers. + * Instead, the negotiation result is fetched by linker timer, see `rtl8201_get_link()` + */ static esp_err_t rtl8201_negotiate(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; @@ -208,8 +213,7 @@ static esp_err_t rtl8201_negotiate(esp_eth_phy_t *phy) break; } } - /* Auto negotiation failed, maybe no network cable plugged in, so output a warning */ - if (to >= rtl8201->autonego_timeout_ms / 100) { + if ((to >= rtl8201->autonego_timeout_ms / 100) && (rtl8201->link_status == ETH_LINK_UP)) { ESP_LOGW(TAG, "auto negotiation timeout"); } return ESP_OK;