* [PATCH v1 iwl-net] igc: power up PHY before link test
@ 2025-08-30 17:06 Kohei Enju
2025-08-30 19:27 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Kohei Enju @ 2025-08-30 17:06 UTC (permalink / raw)
To: intel-wired-lan, netdev
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Vitaly Lifshits,
kohei.enju, Kohei Enju
The current implementation of igc driver doesn't power up PHY before
link test in igc_ethtool_diag_test(), causing the link test to always
report FAIL when admin state is down and PHY is consequently powered
down.
To test the link state regardless of admin state, let's power up PHY in
case of PHY down before link test.
Tested on Intel Corporation Ethernet Controller I226-V (rev 04) with
cable connected and link available.
Set device down and do ethtool test.
# ip link set dev enp0s5 down
Without patch:
# ethtool --test enp0s5
The test result is FAIL
The test extra info:
Register test (offline) 0
Eeprom test (offline) 0
Interrupt test (offline) 0
Loopback test (offline) 0
Link test (on/offline) 1
With patch:
# ethtool --test enp0s5
The test result is PASS
The test extra info:
Register test (offline) 0
Eeprom test (offline) 0
Interrupt test (offline) 0
Loopback test (offline) 0
Link test (on/offline) 0
Fixes: f026d8ca2904 ("igc: add support to eeprom, registers and link self-tests")
Signed-off-by: Kohei Enju <enjuk@amazon.com>
---
This patch uses igc_power_up_phy_copper() instead of igc_power_up_link()
to avoid PHY reset. The function only clears MII_CR_POWER_DOWN bit
without performing PHY reset, so it should not cause the autoneg
interference issue explained in the following comment:
/* Link test performed before hardware reset so autoneg doesn't
* interfere with test result
*/
---
drivers/net/ethernet/intel/igc/igc_ethtool.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index f3e7218ba6f3..ca93629b1d3a 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -2094,6 +2094,9 @@ static void igc_ethtool_diag_test(struct net_device *netdev,
netdev_info(adapter->netdev, "Offline testing starting");
set_bit(__IGC_TESTING, &adapter->state);
+ /* power up PHY for link test */
+ igc_power_up_phy_copper(&adapter->hw);
+
/* Link test performed before hardware reset so autoneg doesn't
* interfere with test result
*/
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 iwl-net] igc: power up PHY before link test
2025-08-30 17:06 [PATCH v1 iwl-net] igc: power up PHY before link test Kohei Enju
@ 2025-08-30 19:27 ` Andrew Lunn
2025-08-30 20:14 ` [Intel-wired-lan] " Kohei Enju
2025-09-01 4:36 ` Lifshits, Vitaly
2025-09-01 7:03 ` [Intel-wired-lan] " Loktionov, Aleksandr
2 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2025-08-30 19:27 UTC (permalink / raw)
To: Kohei Enju
Cc: intel-wired-lan, netdev, Tony Nguyen, Przemek Kitszel,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Vitaly Lifshits, kohei.enju
On Sun, Aug 31, 2025 at 02:06:19AM +0900, Kohei Enju wrote:
> The current implementation of igc driver doesn't power up PHY before
> link test in igc_ethtool_diag_test(), causing the link test to always
> report FAIL when admin state is down and PHY is consequently powered
> down.
>
> To test the link state regardless of admin state, let's power up PHY in
> case of PHY down before link test.
Maybe you should power the PHY down again after the test?
Alternatively, just return -ENOTDOWN is the network is admin down.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Intel-wired-lan] [PATCH v1 iwl-net] igc: power up PHY before link test
2025-08-30 19:27 ` Andrew Lunn
@ 2025-08-30 20:14 ` Kohei Enju
0 siblings, 0 replies; 5+ messages in thread
From: Kohei Enju @ 2025-08-30 20:14 UTC (permalink / raw)
To: andrew
Cc: andrew+netdev, anthony.l.nguyen, davem, edumazet, enjuk,
intel-wired-lan, kohei.enju, kuba, netdev, pabeni,
przemyslaw.kitszel, vitaly.lifshits
On Sat, 30 Aug 2025 21:27:33 +0200, Andrew Lunn wrote:
>On Sun, Aug 31, 2025 at 02:06:19AM +0900, Kohei Enju wrote:
>> The current implementation of igc driver doesn't power up PHY before
>> link test in igc_ethtool_diag_test(), causing the link test to always
>> report FAIL when admin state is down and PHY is consequently powered
>> down.
>>
>> To test the link state regardless of admin state, let's power up PHY in
>> case of PHY down before link test.
>
>Maybe you should power the PHY down again after the test?
You're right about the concern, but it's already handled by the existing
code flow:
/* power up PHY for link test */
igc_power_up_phy_copper(&adapter->hw);
/* doing link test */
if (if_running)
igc_close(netdev);
else
igc_reset(adapter);
/* other tests */
igc_reset(adapter);
igc_reset() calls igc_power_down_phy_copper_base() when !netif_running(),
so the PHY is properly powered down again.
>
>Alternatively, just return -ENOTDOWN is the network is admin down.
That would be simpler indeed. Since the callback returns void, we'd set
the test result to indicate skip/fail.
However, I think checking actual physical connectivity even when admin
down is valuable, which other Intel ethernet drivers (e.g., i40e, ixgbe,
igb) also do.
>
> Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 iwl-net] igc: power up PHY before link test
2025-08-30 17:06 [PATCH v1 iwl-net] igc: power up PHY before link test Kohei Enju
2025-08-30 19:27 ` Andrew Lunn
@ 2025-09-01 4:36 ` Lifshits, Vitaly
2025-09-01 7:03 ` [Intel-wired-lan] " Loktionov, Aleksandr
2 siblings, 0 replies; 5+ messages in thread
From: Lifshits, Vitaly @ 2025-09-01 4:36 UTC (permalink / raw)
To: Kohei Enju, intel-wired-lan, netdev
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, kohei.enju
> ---
> drivers/net/ethernet/intel/igc/igc_ethtool.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> index f3e7218ba6f3..ca93629b1d3a 100644
> --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> @@ -2094,6 +2094,9 @@ static void igc_ethtool_diag_test(struct net_device *netdev,
> netdev_info(adapter->netdev, "Offline testing starting");
> set_bit(__IGC_TESTING, &adapter->state);
>
> + /* power up PHY for link test */
> + igc_power_up_phy_copper(&adapter->hw);
I suggest moving this to igc_link_test functionn igc_diags.c as it
relates only to the link test.
> +
> /* Link test performed before hardware reset so autoneg doesn't
> * interfere with test result
> */
Thank you for this patch.
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [Intel-wired-lan] [PATCH v1 iwl-net] igc: power up PHY before link test
2025-08-30 17:06 [PATCH v1 iwl-net] igc: power up PHY before link test Kohei Enju
2025-08-30 19:27 ` Andrew Lunn
2025-09-01 4:36 ` Lifshits, Vitaly
@ 2025-09-01 7:03 ` Loktionov, Aleksandr
2 siblings, 0 replies; 5+ messages in thread
From: Loktionov, Aleksandr @ 2025-09-01 7:03 UTC (permalink / raw)
To: Kohei Enju, intel-wired-lan@lists.osuosl.org,
netdev@vger.kernel.org
Cc: Nguyen, Anthony L, Kitszel, Przemyslaw, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Lifshits, Vitaly, kohei.enju@gmail.com
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Kohei Enju
> Sent: Saturday, August 30, 2025 7:06 PM
> To: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org
> Cc: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@intel.com>; Andrew Lunn
> <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Eric
> Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo
> Abeni <pabeni@redhat.com>; Lifshits, Vitaly
> <vitaly.lifshits@intel.com>; kohei.enju@gmail.com; Kohei Enju
> <enjuk@amazon.com>
> Subject: [Intel-wired-lan] [PATCH v1 iwl-net] igc: power up PHY before
> link test
>
> The current implementation of igc driver doesn't power up PHY before
> link test in igc_ethtool_diag_test(), causing the link test to always
> report FAIL when admin state is down and PHY is consequently powered
> down.
>
> To test the link state regardless of admin state, let's power up PHY
> in
> case of PHY down before link test.
>
> Tested on Intel Corporation Ethernet Controller I226-V (rev 04) with
> cable connected and link available.
>
> Set device down and do ethtool test.
> # ip link set dev enp0s5 down
>
> Without patch:
> # ethtool --test enp0s5
> The test result is FAIL
> The test extra info:
> Register test (offline) 0
> Eeprom test (offline) 0
> Interrupt test (offline) 0
> Loopback test (offline) 0
> Link test (on/offline) 1
>
> With patch:
> # ethtool --test enp0s5
> The test result is PASS
> The test extra info:
> Register test (offline) 0
> Eeprom test (offline) 0
> Interrupt test (offline) 0
> Loopback test (offline) 0
> Link test (on/offline) 0
>
> Fixes: f026d8ca2904 ("igc: add support to eeprom, registers and link
> self-tests")
> Signed-off-by: Kohei Enju <enjuk@amazon.com>
> ---
> This patch uses igc_power_up_phy_copper() instead of
> igc_power_up_link()
> to avoid PHY reset. The function only clears MII_CR_POWER_DOWN bit
> without performing PHY reset, so it should not cause the autoneg
> interference issue explained in the following comment:
> /* Link test performed before hardware reset so autoneg doesn't
> * interfere with test result
> */
> ---
> drivers/net/ethernet/intel/igc/igc_ethtool.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> index f3e7218ba6f3..ca93629b1d3a 100644
> --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> @@ -2094,6 +2094,9 @@ static void igc_ethtool_diag_test(struct
> net_device *netdev,
> netdev_info(adapter->netdev, "Offline testing
> starting");
> set_bit(__IGC_TESTING, &adapter->state);
>
> + /* power up PHY for link test */
> + igc_power_up_phy_copper(&adapter->hw);
> +
1.You unconditionally power the PHY up but you don't restore the previous power state at the end of the test.
2. igc_power_up_phy_copper() returns a status, but you ignore it. If the MDIO access fails (e.g., bus issue), you should mark the link test as failed and continue with the rest...
n. igc is predominantly copper, but it's still best practice to guard with: if (hw->phy.media_type == igc_media_type_copper) or or check that hw->phy.type != igc_phy_none
> /* Link test performed before hardware reset so autoneg
> doesn't
> * interfere with test result
> */
> --
> 2.48.1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-01 7:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-30 17:06 [PATCH v1 iwl-net] igc: power up PHY before link test Kohei Enju
2025-08-30 19:27 ` Andrew Lunn
2025-08-30 20:14 ` [Intel-wired-lan] " Kohei Enju
2025-09-01 4:36 ` Lifshits, Vitaly
2025-09-01 7:03 ` [Intel-wired-lan] " Loktionov, Aleksandr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).