igc: add support for forcing link speed without autonegotiation
Subsystems (3)
v4 cover igc: add support for forcing link speed without autonegotiation
From: Faizal Rahim <[email protected]>
This series adds support for forcing 10/100 Mb/s link speed via ethtool when autonegotiation is disabled on the igc driver.
Changes in v4:
- Validate that autoneg is AUTONEG_ENABLE or AUTONEG_DISABLE early in igc_ethtool_set_link_ksettings() to avoid passing unexpected values to igc_handle_autoneg_disabled(). (Simon Horman)
Changes in v3:
- Modify condition from "if (duplex == DUPLEX_HALF)" to "if (duplex != DUPLEX_FULL)". (Simon Horman)
Changes in v2:
- When forcing half-duplex, set hw->fc.requested_mode = igc_fc_none, since half-duplex cannot support flow control per IEEE 802.3. (Simon Horman)
- Split the original single patch into three patches for clarity:
patches 1 and 2 are preparatory cleanups; patch 3 carries the functional change.
v3 at:
https://patchwork.ozlabs.org/project/intel-wired-lan/cover/[email protected]/
v2 at:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
v1 at:
https://patchwork.ozlabs.org/project/intel-wired-lan/patch/[email protected]/
Faizal Rahim (3):
igc: remove unused autoneg_failed field
igc: move autoneg-enabled settings into igc_handle_autoneg_enabled()
igc: add support for forcing link speed without autonegotiation
drivers/net/ethernet/intel/igc/igc_base.c | 35 +++- drivers/net/ethernet/intel/igc/igc_defines.h | 9 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 209 +++++++++++++------ drivers/net/ethernet/intel/igc/igc_hw.h | 10 +- drivers/net/ethernet/intel/igc/igc_mac.c | 16 +- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- drivers/net/ethernet/intel/igc/igc_phy.c | 65 +++++- drivers/net/ethernet/intel/igc/igc_phy.h | 1 + 8 files changed, 257 insertions(+), 90 deletions(-)
--
2.43.0
PATCH v4 1/3 igc: remove unused autoneg_failed field
From: Faizal Rahim <[email protected]>
autoneg_failed in struct igc_mac_info is never set in the igc driver. Remove the field and the dead code checking it in igc_config_fc_after_link_up().
--- drivers/net/ethernet/intel/igc/igc_hw.h | 1 - drivers/net/ethernet/intel/igc/igc_mac.c | 16 +--------------- 2 files changed, 1 insertion(+), 16 deletions(-)
drivers/net/ethernet/intel/igc/igc_hw.h +0 -1
@@ -92,7 +92,6 @@ struct igc_mac_info {bool asf_firmware_present;bool arc_subsystem_valid; -bool autoneg_failed;bool get_link_status; };
drivers/net/ethernet/intel/igc/igc_mac.c +1 -15
@@ -438,28 +438,14 @@ void igc_config_collision_dist(struct igc_hw *hw)* Checks the status of auto-negotiation after link up to ensure that the * speed and duplex were not forced. If the link needed to be forced, then * flow control needs to be forced also. If auto-negotiation is enabled -* and did not fail, then we configure flow control based on our link -* partner. +* then we configure flow control based on our link partner. */ s32 igc_config_fc_after_link_up (struct igc_hw *hw) {u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg; -struct igc_mac_info *mac = &hw->mac;u16 speed, duplex;s32 ret_val =0 ; -/* Check for the case where we have fiber media and auto-neg failed -* so we had to force link. In this case, we need to force the -* configuration of the MAC to match the "fc" parameter. -*/ -if (mac->autoneg_failed) - ret_val =igc_force_mac_fc (hw); - -if (ret_val) { -hw_dbg ("Error forcing flow control settings\n" ); - goto out; - } -/* In auto-neg, we need to check and see if Auto-Neg has completed, * and if so, how the PHY and link partner has flow control * configured.
--
2.43.0
Re: [Intel-wired-lan] [PATCH iwl-next v4 1/3] igc: remove unused autoneg_failed field
[Cc: Removed stray *Looi*]
Dear Khai Wen Tan,
Thank you for your patch.
Am 28.04.26 um 08:00 schrieb KhaiWenTan:
(Should spaces be added in your name?)
Quoted 5 lines
From: Faizal Rahim <[email protected]>
autoneg_failedin structigc_mac_infois never set in the igc driver. Remove the field and the dead code checking it inigc_config_fc_after_link_up().
Could you please elaborate. Why is removal the correct fix, and it’s not an incomplete feature? Does auto-negotiation always succeed?
Quoted 1 line
Reviewed-by Looi, Hong Aun <[email protected]>
Please order it to not use the comma: Hong Aun Looi
Quoted 44 lines
Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Faizal Rahim <[email protected]>Signed-off-by KhaiWenTan <[email protected]>--- drivers/net/ethernet/intel/igc/igc_hw.h | 1 - drivers/net/ethernet/intel/igc/igc_mac.c | 16 +--------------- 2 files changed, 1 insertion(+), 16 deletions(-)drivers/net/ethernet/intel/igc/igc_hw.h +0
-1@@ -92,7 +92,6 @@ struct igc_mac_info {bool asf_firmware_present;bool arc_subsystem_valid; -bool autoneg_failed;bool get_link_status; };drivers/net/ethernet/intel/igc/igc_mac.c +1
-8@@ -438,28 +438,14 @@ void igc_config_collision_dist(struct igc_hw *hw)* Checks the status of auto-negotiation after link up to ensure that the * speed and duplex were not forced. If the link needed to be forced, then * flow control needs to be forced also. If auto-negotiation is enabled -* and did not fail, then we configure flow control based on our link -* partner. +* then we configure flow control based on our link partner. */ s32 igc_config_fc_after_link_up (struct igc_hw *hw) {u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg; -struct igc_mac_info *mac = &hw->mac;u16 speed, duplex;s32 ret_val =0 ; -/* Check for the case where we have fiber media and auto-neg failed -* so we had to force link. In this case, we need to force the -* configuration of the MAC to match the "fc" parameter. -*/ -if (mac->autoneg_failed)
drivers/net/ethernet/intel/igc/igc_mac.c void igc_config_collision_dist(struct igc_hw *hw) · line 451
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_mac.c +0
-7- ret_val =igc_force_mac_fc (hw); - -if (ret_val) { -hw_dbg ("Error forcing flow control settings\n" ); - goto out; - } -/* In auto-neg, we need to check and see if Auto-Neg has completed, * and if so, how the PHY and link partner has flow control * configured.
Kind regards,
Paul
Re: [Intel-wired-lan] [PATCH iwl-next v4 1/3] igc: remove unused autoneg_failed field
Hi Paul,
Thank you for your review.
Quoted 12 lines · Paul Menzel
[Cc: Removed stray *Looi*]
Dear Khai Wen Tan,
Thank you for your patch.
Am 28.04.26 um 08:00 schrieb KhaiWenTan:
(Should spaces be added in your name?)
Quoted 8 lines
Quoted 5 lines
From: Faizal Rahim <[email protected]>
autoneg_failedin structigc_mac_infois never set in the igc driver. Remove the field and the dead code checking it inigc_config_fc_after_link_up().Could you please elaborate. Why is removal the correct fix, and it’s not an incomplete feature? Does auto-negotiation always succeed?
Auto-negotiation does not always succeed, but igc does not use autoneg_failed to handle that case, the field was never set anywhere in the igc driver.
Before this patch, the only igc references to autoneg_failed were the struct member declaration and the read in igc_config_fc_after_link_up(). No igc code ever assigned it to true, and git history shows no commit that added a setter since the code creation in 2018.
The field originates from the e1000/e1000e fiber/serdes forced-link
path: when MAC-level auto-negotiation on fiber times out, the driver forces link up and sets autoneg_failed so the flow-control code knows pause was not negotiated and must be forced. igc has no fiber or serdes media, it only supports copper (igc_media_type_copper), so the code that sets autoneg_failed was never ported.
On copper, PHY auto-negotiation failure is handled differently:
- No link at all: igc_check_for_copper_link() returns before reaching flow-control configuration, there's nothing to configure FC on.
- Link present but autoneg not yet complete:
igc_config_fc_after_link_up() checks MII_SR_AUTONEG_COMPLETE and returns early without resolving pause. The next link-status event re-triggers the check.
- Autoneg completes (including via parallel detection fallback when the link partner doesn't autoneg): the PHY still sets AUTONEG_COMPLETE but LP_ABILITY won't have PAUSE bits since the partner never sent autoneg pages. The existing flow-control logic in igc_config_fc_after_link_up() handles that correctly, it falls through to igc_fc_none or igc_fc_rx_pause based on requested_mode.
None of these paths need autoneg_failed. Keeping the field would be misleading to reader.
Quoted 4 lines
Quoted 1 line
Reviewed-by Looi, Hong Aun <[email protected]>Please order it to not use the comma: Hong Aun Looi
Will do, thanks.
Quoted 60 lines
Quoted 44 lines
Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Faizal Rahim <[email protected]>Signed-off-by KhaiWenTan <[email protected]>---
drivers/net/ethernet/intel/igc/igc_hw.h | 1 -drivers/net/ethernet/intel/igc/igc_mac.c| 16 +---------------2 files changed, 1 insertion(+), 16 deletions(-)drivers/net/ethernet/intel/igc/igc_hw.h +0
-1@@ -92,7 +92,6 @@ struct igc_mac_info { bool asf_firmware_present; bool arc_subsystem_valid; - bool autoneg_failed; bool get_link_status; };drivers/net/ethernet/intel/igc/igc_mac.c +1
-8@@ -438,28 +438,14 @@ void igc_config_collision_dist(struct igc_hw *hw)* Checks the status of auto-negotiation after link up to ensure that the * speed and duplex were not forced. If the link needed to be forced, then * flow control needs to be forced also. If auto-negotiation is enabled -* and did not fail, then we configure flow control based on our link -* partner. +* then we configure flow control based on our link partner. */ s32 igc_config_fc_after_link_up(struct igc_hw *hw) { u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg; - struct igc_mac_info *mac = &hw->mac; u16 speed, duplex; s32 ret_val = 0; - /* Check for the case where we have fiber media and auto-neg failed - * so we had to force link. In this case, we need to force the - * configuration of the MAC to match the "fc" parameter. - */ - if (mac->autoneg_failed)drivers/net/ethernet/intel/igc/igc_mac.c void igc_config_collision_dist(struct igc_hw *hw) · line 451
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_mac.c +0
-7- ret_val = igc_force_mac_fc(hw); - - if (ret_val) { - hw_dbg("Error forcing flow control settings\n"); - goto out; - } - /* In auto-neg, we need to check and see if Auto-Neg has completed,* and if so, how the PHY and link partner has flow control * configured. Kind regards,
Paul
Re: [Intel-wired-lan] [PATCH iwl-next v4 1/3] igc: remove unused autoneg_failed field
Dear Faizal,
Am 28.04.26 um 12:39 schrieb Abdul Rahim, Faizal:
Quoted 45 lines · Paul Menzel
Quoted 5 lines
Am 28.04.26 um 08:00 schrieb KhaiWenTan:
(Should spaces be added in your name?)
Quoted 7 lines
Quoted 5 lines
From: Faizal Rahim <[email protected]>
autoneg_failedin structigc_mac_infois never set in the igc driver. Remove the field and the dead code checking it inigc_config_fc_after_link_up().Could you please elaborate. Why is removal the correct fix, and it’s not an incomplete feature? Does auto-negotiation always succeed?
Auto-negotiation does not always succeed, but igc does not use
autoneg_failedto handle that case, the field was never set anywhere in the igc driver.Before this patch, the only igc references to
autoneg_failedwere the struct member declaration and the read inigc_config_fc_after_link_up(). No igc code ever assigned it to true, and git history shows no commit that added a setter since the code creation in 2018.The field originates from the e1000/e1000e fiber/serdes forced-link
path: when MAC-level auto-negotiation on fiber times out, the driver forces link up and setsautoneg_failedso the flow-control code knows pause was not negotiated and must be forced. igc has no fiber or serdes media, it only supports copper (igc_media_type_copper), so the code that setsautoneg_failedwas never ported.On copper, PHY auto-negotiation failure is handled differently:
- No link at all:igc_check_for_copper_link()returns before reaching flow-control configuration, there's nothing to configure FC on.
- Link present but autoneg not yet complete:
igc_config_fc_after_link_up()checksMII_SR_AUTONEG_COMPLETEand returns early without resolving pause. The next link-status event re-triggers the check.
- Autoneg completes (including via parallel detection fallback when the link partner doesn't autoneg): the PHY still setsAUTONEG_COMPLETEbutLP_ABILITYwon't have PAUSE bits since the partner never sent autoneg pages. The existing flow-control logic inigc_config_fc_after_link_up()handles that correctly, it falls through toigc_fc_noneorigc_fc_rx_pausebased onrequested_mode.
Quoted 1 line
None of these paths need
autoneg_failed. Keeping the field would be misleading to reader.
Thank you. For me the information about just supporting copper would be great to have in the commit message.
Quoted 26 lines
Quoted 3 lines
Quoted 1 line
Reviewed-by Looi, Hong Aun <[email protected]>Please order it to not use the comma: Hong Aun Looi
Will do, thanks.
Quoted 20 lines
Quoted 20 lines
Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Faizal Rahim <[email protected]>Signed-off-by KhaiWenTan <[email protected]>---
drivers/net/ethernet/intel/igc/igc_hw.h | 1 -drivers/net/ethernet/intel/igc/igc_mac.c| 16 +---------------2 files changed, 1 insertion(+), 16 deletions(-)drivers/net/ethernet/intel/igc/igc_hw.h +0
-1@@ -92,7 +92,6 @@ struct igc_mac_info { bool asf_firmware_present; bool arc_subsystem_valid; - bool autoneg_failed; bool get_link_status; };
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_mac.c void igc_config_collision_dist(struct igc_hw *hw) · line 438
Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_mac.c +0
-0@@ -438,28 +438,14 @@ void igc_config_collision_dist(struct igc_hw *hw) * Checks the status of auto-negotiation after link up to ensure that the
Just for your information, that your mailer wraps the lines of the quotes.
[…]
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/net/ethernet/intel/igc/igc_mac.c +1
-3* speed and duplex were not forced. If the link needed to be forced, then * flow control needs to be forced also. If auto-negotiation is enabled -* and did not fail, then we configure flow control based on our link -* partner. +* then we configure flow control based on our link partner. */ s32 igc_config_fc_after_link_up(struct igc_hw *hw) { u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg; - struct igc_mac_info *mac = &hw->mac; u16 speed, duplex; s32 ret_val = 0;
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/igc/igc_mac.c +0
-7- /* Check for the case where we have fiber media and auto-neg failed - * so we had to force link. In this case, we need to force the - * configuration of the MAC to match the "fc" parameter. - */ - if (mac->autoneg_failed) - ret_val = igc_force_mac_fc(hw); -Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_mac.c void igc_config_collision_dist(struct igc_hw *hw) · line 451
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_mac.c +0
-5- if (ret_val) { - hw_dbg("Error forcing flow control settings\n"); - goto out; - } - /* In auto-neg, we need to check and see if Auto-Neg has completed,* and if so, how the PHY and link partner has flow control * configured.
Kind regards,
Paul
Re: [Intel-wired-lan] [PATCH iwl-next v4 1/3] igc: remove unused autoneg_failed field
Quoted 51 lines · Paul Menzel
Dear Faizal,
Am 28.04.26 um 12:39 schrieb Abdul Rahim, Faizal:
Quoted 46 lines · Paul Menzel
Quoted 5 lines
Am 28.04.26 um 08:00 schrieb KhaiWenTan:
(Should spaces be added in your name?)
Quoted 8 lines
Quoted 5 lines
From: Faizal Rahim <[email protected]>
autoneg_failedin structigc_mac_infois never set in the igc driver. Remove the field and the dead code checking it inigc_config_fc_after_link_up().Could you please elaborate. Why is removal the correct fix, and it’s not an incomplete feature? Does auto-negotiation always succeed?
Auto-negotiation does not always succeed, but igc does not use
autoneg_failedto handle that case, the field was never set anywhere in the igc driver.Before this patch, the only igc references to
autoneg_failedwere the struct member declaration and the read inigc_config_fc_after_link_up(). No igc code ever assigned it to true, and git history shows no commit that added a setter since the code creation in 2018.The field originates from the e1000/e1000e fiber/serdes forced-link
path: when MAC-level auto-negotiation on fiber times out, the driver forces link up and setsautoneg_failedso the flow-control code knows pause was not negotiated and must be forced. igc has no fiber or serdes media, it only supports copper (igc_media_type_copper), so the code that setsautoneg_failedwas never ported.On copper, PHY auto-negotiation failure is handled differently:
- No link at all:igc_check_for_copper_link()returns before reaching flow-control configuration, there's nothing to configure FC on.
- Link present but autoneg not yet complete:
igc_config_fc_after_link_up()checksMII_SR_AUTONEG_COMPLETEand returns early without resolving pause. The next link-status event re-triggers the check.
- Autoneg completes (including via parallel detection fallback when the link partner doesn't autoneg): the PHY still setsAUTONEG_COMPLETEbutLP_ABILITYwon't have PAUSE bits since the partner never sent autoneg pages. The existing flow-control logic inigc_config_fc_after_link_up()handles that correctly, it falls through toigc_fc_noneorigc_fc_rx_pausebased onrequested_mode.
Quoted 5 lines
Quoted 2 lines
None of these paths need
autoneg_failed. Keeping the field would be misleading to reader.Thank you. For me the information about just supporting copper would be great to have in the commit message.
Will update.
Quoted 28 lines
Quoted 28 lines
Quoted 4 lines
Quoted 2 lines
Reviewed-by Looi, Hong Aun <[email protected]>Please order it to not use the comma: Hong Aun Looi
Will do, thanks.
Quoted 21 lines
Quoted 21 lines
Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Faizal Rahim <[email protected]>Signed-off-by KhaiWenTan <[email protected]>---
drivers/net/ethernet/intel/igc/igc_hw.h | 1 -drivers/net/ethernet/intel/igc/igc_mac.c| 16 +---------------2 files changed, 1 insertion(+), 16 deletions(-)drivers/net/ renamed from drivers/net/ethernet/intel/igc/igc_hw.h +0
-0
ethernet/intel/igc/igc_hw.h
indexbe8a49a86d09..86ab8f566f44100644drivers/net/ethernet/intel/igc/igc_hw.h +0
-1@@ -92,7 +92,6 @@ struct igc_mac_info { bool asf_firmware_present; bool arc_subsystem_valid; - bool autoneg_failed; bool get_link_status; };
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/ renamed from drivers/net/ethernet/intel/igc/igc_mac.c +0
-0
ethernet/intel/igc/igc_mac.c
index7ac6637f8db7..142beb9ae557100644drivers/net/ethernet/intel/igc/igc_mac.c +0
-0@@ -438,28 +438,14 @@ void igc_config_collision_dist(struct igc_hw *hw) * Checks the status of auto-negotiation after link up to ensure thatthe
Just for your information, that your mailer wraps the lines of the quotes.
Ohh okay, let me check, thanks!
Quoted 36 lines
[…]
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
* speed and duplex were not forced. If the link needed to be forced, then
* flow control needs to be forced also. If auto-negotiation is enabled
- * and did not fail, then we configure flow control based on our link
- * partner.
+ * then we configure flow control based on our link partner. */
s32igc_config_fc_after_link_up(struct igc_hw *hw)
{
u16mii_status_reg,mii_nway_adv_reg,mii_nway_lp_ability_reg; - structigc_mac_info*mac =&hw->mac;
u16 speed, duplex;
s32ret_val= 0;Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
- /* Check for the case where we have fiber media and auto-neg failed - * so we had to force link. In this case, we need to force the - * configuration of the MAC to match the "fc" parameter. - */
- if (mac->autoneg_failed)
-ret_val=igc_force_mac_fc(hw);
-Quoted 8 lines
Quoted 8 lines
- if (
ret_val) {
-hw_dbg("Error forcing flow control settings\n");
- goto out;
- }
-
/* In auto-neg, we need to check and see if Auto-Neg has completed,
* and if so, how the PHY and link partner has flow control
* configured.Kind regards,
Paul
PATCH v4 2/3 igc: move autoneg-enabled settings into igc_handle_autoneg_enabled()
In reply to KhaiWenTanFrom: Faizal Rahim <[email protected]>
Move the advertised link modes and flow control configuration from igc_ethtool_set_link_ksettings() into igc_handle_autoneg_enabled().
No functional change.
--- drivers/net/ethernet/intel/igc/igc_ethtool.c | 72 ++++++++++++-------- 1 file changed, 44 insertions(+), 28 deletions(-)
drivers/net/ethernet/intel/igc/igc_ethtool.c +44 -28
@@ -2000,6 +2000,49 @@ static int igc_ethtool_get_link_ksettings(struct net_device *netdev,return 0 ; } +/** +* igc_handle_autoneg_enabled - Configure autonegotiation advertisement +* @adapter: private driver structure +* @cmd: ethtool link ksettings from user +* +* Records advertised speeds and flow control settings when autoneg +* is enabled. +*/ +static void igc_handle_autoneg_enabled (struct igc_adapter *adapter, +const struct ethtool_link_ksettings *cmd) +{ +struct igc_hw *hw = &adapter->hw; +u16 advertised =0 ; + +if (ethtool_link_ksettings_test_link_mode (cmd, advertising, + 2500baseT_Full)) + advertised |=ADVERTISE_2500_FULL ; + +if (ethtool_link_ksettings_test_link_mode (cmd, advertising, + 1000baseT_Full)) + advertised |=ADVERTISE_1000_FULL ; + +if (ethtool_link_ksettings_test_link_mode (cmd, advertising, + 100baseT_Full)) + advertised |=ADVERTISE_100_FULL ; + +if (ethtool_link_ksettings_test_link_mode (cmd, advertising, + 100baseT_Half)) + advertised |=ADVERTISE_100_HALF ; + +if (ethtool_link_ksettings_test_link_mode (cmd, advertising, + 10baseT_Full)) + advertised |=ADVERTISE_10_FULL ; + +if (ethtool_link_ksettings_test_link_mode (cmd, advertising, + 10baseT_Half)) + advertised |=ADVERTISE_10_HALF ; + + hw->phy.autoneg_advertised = advertised; +if (adapter->fc_autoneg) + hw->fc.requested_mode = igc_fc_default; +} +static int igc_ethtool_set_link_ksettings (struct net_device *netdev,const struct ethtool_link_ksettings *cmd)
@@ -2007,7 +2050,6 @@ igc_ethtool_set_link_ksettings(struct net_device *netdev,struct igc_adapter *adapter =netdev_priv (netdev);struct net_device *dev = adapter->netdev;struct igc_hw *hw = &adapter->hw; -u16 advertised =0 ;/* When adapter in resetting mode, autoneg/speed/duplex * cannot be changed
@@ -2032,34 +2074,8 @@ igc_ethtool_set_link_ksettings(struct net_device *netdev,while (test_and_set_bit (__IGC_RESETTING, &adapter->state))usleep_range (1000 ,2000 ); -if (ethtool_link_ksettings_test_link_mode (cmd, advertising, - 2500baseT_Full)) - advertised |=ADVERTISE_2500_FULL ; - -if (ethtool_link_ksettings_test_link_mode (cmd, advertising, - 1000baseT_Full)) - advertised |=ADVERTISE_1000_FULL ; - -if (ethtool_link_ksettings_test_link_mode (cmd, advertising, - 100baseT_Full)) - advertised |=ADVERTISE_100_FULL ; - -if (ethtool_link_ksettings_test_link_mode (cmd, advertising, - 100baseT_Half)) - advertised |=ADVERTISE_100_HALF ; - -if (ethtool_link_ksettings_test_link_mode (cmd, advertising, - 10baseT_Full)) - advertised |=ADVERTISE_10_FULL ; - -if (ethtool_link_ksettings_test_link_mode (cmd, advertising, - 10baseT_Half)) - advertised |=ADVERTISE_10_HALF ; -if (cmd->base.autoneg ==AUTONEG_ENABLE ) { - hw->phy.autoneg_advertised = advertised; -if (adapter->fc_autoneg) - hw->fc.requested_mode = igc_fc_default; +igc_handle_autoneg_enabled (adapter, cmd); }else {netdev_info (dev,"Force mode currently not supported\n" ); }
--
2.43.0
PATCH v4 3/3 igc: add support for forcing link speed without autonegotiation
In reply to KhaiWenTanFrom: Faizal Rahim <[email protected]>
Allow users to force 10/100 Mb/s link speed and duplex via ethtool when autonegotiation is disabled. Previously, the driver rejected these requests with "Force mode currently not supported.".
Forcing at 1000 Mb/s and 2500 Mb/s is not supported.
--- drivers/net/ethernet/intel/igc/igc_base.c | 35 ++++- drivers/net/ethernet/intel/igc/igc_defines.h | 9 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 137 ++++++++++++++----- drivers/net/ethernet/intel/igc/igc_hw.h | 9 ++ drivers/net/ethernet/intel/igc/igc_mac.c | 10 ++ drivers/net/ethernet/intel/igc/igc_main.c | 2 +- drivers/net/ethernet/intel/igc/igc_phy.c | 65 ++++++++- drivers/net/ethernet/intel/igc/igc_phy.h | 1 + 8 files changed, 217 insertions(+), 51 deletions(-)
drivers/net/ethernet/intel/igc/igc_base.c +30 -5
@@ -114,11 +114,35 @@ static s32 igc_setup_copper_link_base(struct igc_hw *hw)u32 ctrl; ctrl =rd32 (IGC_CTRL ); - ctrl |=IGC_CTRL_SLU ; - ctrl &= ~(IGC_CTRL_FRCSPD |IGC_CTRL_FRCDPX ); -wr32 (IGC_CTRL , ctrl); - - ret_val =igc_setup_copper_link (hw); + ctrl &= ~(IGC_CTRL_FRCSPD |IGC_CTRL_FRCDPX | +IGC_CTRL_SPEED_MASK |IGC_CTRL_FD ); + +if (hw->mac.autoneg_enabled) { + ctrl |=IGC_CTRL_SLU ; +wr32 (IGC_CTRL , ctrl); + ret_val =igc_setup_copper_link (hw); + }else { + ctrl |=IGC_CTRL_SLU |IGC_CTRL_FRCSPD |IGC_CTRL_FRCDPX ; + +switch (hw->mac.forced_speed_duplex) { +case IGC_FORCED_10H : + ctrl |=IGC_CTRL_SPEED_10 ; +break ; +case IGC_FORCED_10F : + ctrl |=IGC_CTRL_SPEED_10 |IGC_CTRL_FD ; +break ; +case IGC_FORCED_100H : + ctrl |=IGC_CTRL_SPEED_100 ; +break ; +case IGC_FORCED_100F : + ctrl |=IGC_CTRL_SPEED_100 |IGC_CTRL_FD ; +break ; +default : +return -IGC_ERR_CONFIG ; + } +wr32 (IGC_CTRL , ctrl); + ret_val =igc_setup_copper_link (hw); + }return ret_val; }
@@ -443,6 +467,7 @@ static const struct igc_phy_operations igc_phy_ops_base = { .reset = igc_phy_hw_reset, .read_reg = igc_read_phy_reg_gpy, .write_reg = igc_write_phy_reg_gpy, + .force_speed_duplex = igc_force_speed_duplex, };const struct igc_info igc_base_info = {
drivers/net/ethernet/intel/igc/igc_defines.h +8 -1
@@ -129,10 +129,13 @@#define IGC_ERR_SWFW_SYNC 13/* Device Control */ +#define IGC_CTRL_FD BIT(0)/* Full Duplex */ #define IGC_CTRL_RST 0x04000000/* Global reset */ -#define IGC_CTRL_PHY_RST 0x80000000/* PHY Reset */ #define IGC_CTRL_SLU 0x00000040/* Set link up (Force Link) */ +#define IGC_CTRL_SPEED_MASK GENMASK(10, 8) +#define IGC_CTRL_SPEED_10 FIELD_PREP(IGC_CTRL_SPEED_MASK, 0) +#define IGC_CTRL_SPEED_100 FIELD_PREP(IGC_CTRL_SPEED_MASK, 1)#define IGC_CTRL_FRCSPD 0x00000800/* Force Speed */ #define IGC_CTRL_FRCDPX 0x00001000/* Force Duplex */ #define IGC_CTRL_VME 0x40000000/* IEEE VLAN mode enable */
@@ -673,6 +676,10 @@#define IGC_GEN_POLL_TIMEOUT 1920/* PHY Control Register */ +#define MII_CR_SPEED_MASK (BIT(6) | BIT(13)) +#define MII_CR_SPEED_10 0x0000/* SSM=0, SSL=0: 10 Mb/s */ +#define MII_CR_SPEED_100 BIT(13)/* SSM=0, SSL=1: 100 Mb/s */ +#define MII_CR_DUPLEX_EN BIT(8)/* 0 = Half Duplex, 1 = Full Duplex */ #define MII_CR_RESTART_AUTO_NEG 0x0200/* Restart auto negotiation */ #define MII_CR_POWER_DOWN 0x0800/* Power down */ #define MII_CR_AUTO_NEG_EN 0x1000/* Auto Neg Enable */
drivers/net/ethernet/intel/igc/igc_ethtool.c +99 -38
182 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_hw.h +9 -0
@@ -73,6 +73,13 @@ struct igc_info {extern const struct igc_info igc_base_info; +enum igc_forced_speed_duplex { +IGC_FORCED_10H , +IGC_FORCED_10F , +IGC_FORCED_100H , +IGC_FORCED_100F , +}; +struct igc_mac_info {struct igc_mac_operations ops;
@@ -93,6 +100,8 @@ struct igc_mac_info {bool arc_subsystem_valid;bool get_link_status; +bool autoneg_enabled; +enum igc_forced_speed_duplex forced_speed_duplex; };struct igc_nvm_operations {
drivers/net/ethernet/intel/igc/igc_mac.c +10 -0
@@ -446,6 +446,16 @@ s32 igc_config_fc_after_link_up(struct igc_hw *hw)u16 speed, duplex;s32 ret_val =0 ; +/* When autoneg is disabled, force the MAC flow control settings +* to match the "fc" parameter. +*/ +if (!hw->mac.autoneg_enabled) { + ret_val =igc_force_mac_fc (hw); +if (ret_val) +hw_dbg ("Error forcing flow control settings\n" ); + goto out; + } +/* In auto-neg, we need to check and see if Auto-Neg has completed, * and if so, how the PHY and link partner has flow control * configured.
drivers/net/ethernet/intel/igc/igc_main.c +1 -1
@@ -7298,7 +7298,7 @@ static int igc_probe(struct pci_dev *pdev,/* Initialize link properties that are user-changeable */ adapter->fc_autoneg = true; hw->phy.autoneg_advertised =0xaf ; - + hw->mac.autoneg_enabled = true; hw->fc.requested_mode = igc_fc_default; hw->fc.current_mode = igc_fc_default;
drivers/net/ethernet/intel/igc/igc_phy.c +59 -6
74 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_phy.h +1 -0
@@ -18,5 +18,6 @@ void igc_power_down_phy_copper(struct igc_hw *hw);s32 igc_write_phy_reg_gpy (struct igc_hw *hw,u32 offset,u16 data);s32 igc_read_phy_reg_gpy (struct igc_hw *hw,u32 offset,u16 *data);u16 igc_read_phy_fw_version (struct igc_hw *hw); +s32 igc_force_speed_duplex (struct igc_hw *hw);#endif
Signature · 1 line
2.43.0
Simon Horman
reviewerFrom: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
igc: add support for forcing link speed without autonegotiation
This commit allows users to force 10/100 Mb/s link speed and duplex via ethtool when autonegotiation is disabled. Previously, the driver rejected these requests.
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0
[ ... ]
Quoted 27 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +23
-0@@ -2000,6 +2013,41 @@ static int igc_ethtool_get_link_ksettings(struct net_device *netdev,return 0 ; } +/** +* igc_handle_autoneg_disabled - Configure forced speed/duplex settings +* @adapter: private driver structure +* @speed: requested speed (must be SPEED_10 or SPEED_100) +* @duplex: requested duplex +* +* Records forced speed/duplex when autoneg is disabled. +* Caller must validate speed before calling this function. +*/ +static void igc_handle_autoneg_disabled (struct igc_adapter *adapter,u32 speed, +u8 duplex) +{ +struct igc_mac_info *mac = &adapter->hw.mac; + +switch (speed) { +case SPEED_10 : + mac->forced_speed_duplex = (duplex ==DUPLEX_FULL ) ? +IGC_FORCED_10F :IGC_FORCED_10H ; +break ; +case SPEED_100 : + mac->forced_speed_duplex = (duplex ==DUPLEX_FULL ) ? +IGC_FORCED_100F :IGC_FORCED_100H ; +break ;
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_get_link_ksettings(struct net_device *netdev, · line 2048
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +10
-0+default : +WARN_ONCE (1 ,"Unsupported speed %u\n" , speed); +return ; + } + + mac->autoneg_enabled = false; + +/* Half-duplex cannot support flow control per IEEE 802.3 */ +if (duplex !=DUPLEX_FULL ) + adapter->hw.fc.requested_mode = igc_fc_none;
Does this permanently overwrite the user's flow control preference?
If half-duplex is requested, requested_mode is set to igc_fc_none. Because requested_mode represents the persistent state for the user's flow control preference, the user might permanently lose their configuration. If they later switch back to full-duplex, requested_mode remains igc_fc_none, and flow control stays disabled.
Would it be better to dynamically override hw->fc.current_mode to igc_fc_none during link configuration instead of mutating requested_mode?
Quoted 1 line
drivers/net/ethernet/intel/igc/igc_ethtool.c +1
-0+}
[ ... ]
drivers/net/ethernet/intel/igc/igc_ethtool.c igc_ethtool_set_link_ksettings(struct net_device *netdev, · line 2134
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +6
-0@@ -2071,14 +2126,20 @@ igc_ethtool_set_link_ksettings(struct net_device *netdev, } } +if (cmd->base.autoneg ==AUTONEG_DISABLE && + cmd->base.speed !=SPEED_10 && cmd->base.speed !=SPEED_100 ) { +netdev_info (dev,"Unsupported speed for forced link\n" ); +return -EINVAL ; + } +
Should we also validate cmd->base.duplex here to prevent a fallback to half-duplex?
If a user runs a command like "ethtool -s eth0 speed 100 autoneg off" while the link is down, ethtool queries and preserves the current duplex value, which is DUPLEX_UNKNOWN (0xff).
In igc_handle_autoneg_disabled(), the code checks if duplex == DUPLEX_FULL, which evaluates to false, and forces the interface to 100 Mbps half-duplex.
Could we explicitly check that cmd->base.duplex is either DUPLEX_HALF or DUPLEX_FULL and return -EINVAL otherwise?
drivers/net/ethernet/intel/igc/igc_ethtool.c igc_ethtool_set_link_ksettings(struct net_device *netdev, · line 2136
Quoted 2 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0while (test_and_set_bit (__IGC_RESETTING, &adapter->state))usleep_range (1000 ,2000 );
This isn't a bug introduced by this patch, but does this ad-hoc synchronization loop reimplement locking without fairness or lockdep support?
According to the Networking Subsystem Guidelines, using bit operations as a substitute for real locks violates core kernel locking rules and introduces potential races.
Could this be replaced with a proper concurrency mechanism such as a mutex?
Quoted 13 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +4
-4-if (cmd->base.autoneg ==AUTONEG_ENABLE ) { +if (cmd->base.autoneg ==AUTONEG_ENABLE )igc_handle_autoneg_enabled (adapter, cmd); - }else { -netdev_info (dev,"Force mode currently not supported\n" ); - } +else +igc_handle_autoneg_disabled (adapter, cmd->base.speed, + cmd->base.duplex);/* MDI-X => 2; MDI => 1; Auto => 3 */ if (cmd->base.eth_tp_mdix_ctrl) {
Quoted 57 lines · Simon Horman
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
igc: add support for forcing link speed without autonegotiationThis commit allows users to force 10/100 Mb/s link speed and duplex via ethtool when autonegotiation is disabled. Previously, the driver rejected these requests.
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0[ ... ]
Quoted 27 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +23
-0@@ -2000,6 +2013,41 @@ static int igc_ethtool_get_link_ksettings(struct net_device *netdev,return 0 ; } +/** +* igc_handle_autoneg_disabled - Configure forced speed/duplex settings +* @adapter: private driver structure +* @speed: requested speed (must be SPEED_10 or SPEED_100) +* @duplex: requested duplex +* +* Records forced speed/duplex when autoneg is disabled. +* Caller must validate speed before calling this function. +*/ +static void igc_handle_autoneg_disabled (struct igc_adapter *adapter,u32 speed, +u8 duplex) +{ +struct igc_mac_info *mac = &adapter->hw.mac; + +switch (speed) { +case SPEED_10 : + mac->forced_speed_duplex = (duplex ==DUPLEX_FULL ) ? +IGC_FORCED_10F :IGC_FORCED_10H ; +break ; +case SPEED_100 : + mac->forced_speed_duplex = (duplex ==DUPLEX_FULL ) ? +IGC_FORCED_100F :IGC_FORCED_100H ; +break ;drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_get_link_ksettings(struct net_device *netdev, · line 2048
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +10
-0+default : +WARN_ONCE (1 ,"Unsupported speed %u\n" , speed); +return ; + } + + mac->autoneg_enabled = false; + +/* Half-duplex cannot support flow control per IEEE 802.3 */ +if (duplex !=DUPLEX_FULL ) + adapter->hw.fc.requested_mode = igc_fc_none;Does this permanently overwrite the user's flow control preference?
Quoted 9 lines
If half-duplex is requested,
requested_modeis set toigc_fc_none. Becauserequested_moderepresents the persistent state for the user's flow control preference, the user might permanently lose their configuration. If they later switch back to full-duplex,requested_moderemainsigc_fc_none, and flow control stays disabled.Would it be better to dynamically override
hw->fc.current_modetoigc_fc_noneduring link configuration instead of mutatingrequested_mode?
Yes you're right, thanks, will update.
Quoted 20 lines
Quoted 1 line
drivers/net/ethernet/intel/igc/igc_ethtool.c +1
-0+}[ ... ]
drivers/net/ethernet/intel/igc/igc_ethtool.c igc_ethtool_set_link_ksettings(struct net_device *netdev, · line 2134
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +6
-0@@ -2071,14 +2126,20 @@ igc_ethtool_set_link_ksettings(struct net_device *netdev, } } +if (cmd->base.autoneg ==AUTONEG_DISABLE && + cmd->base.speed !=SPEED_10 && cmd->base.speed !=SPEED_100 ) { +netdev_info (dev,"Unsupported speed for forced link\n" ); +return -EINVAL ; + } +Should we also validate
cmd->base.duplexhere to prevent a fallback to half-duplex?If a user runs a command like "ethtool -s eth0 speed 100 autoneg off" while the link is down, ethtool queries and preserves the current duplex value, which is
DUPLEX_UNKNOWN(0xff).
Quoted 5 lines
In
igc_handle_autoneg_disabled(), the code checks if duplex ==DUPLEX_FULL, which evaluates to false, and forces the interface to 100 Mbps half-duplex.Could we explicitly check that
cmd->base.duplexis eitherDUPLEX_HALForDUPLEX_FULLand return-EINVALotherwise?
Will update.
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c igc_ethtool_set_link_ksettings(struct net_device *netdev, · line 2136
Quoted 3 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0while (test_and_set_bit (__IGC_RESETTING, &adapter->state))usleep_range (1000 ,2000 );
Quoted 9 lines
This isn't a bug introduced by this patch, but does this ad-hoc synchronization loop reimplement locking without fairness or lockdep support?
According to the Networking Subsystem Guidelines, using bit operations as a substitute for real locks violates core kernel locking rules and introduces potential races.
Could this be replaced with a proper concurrency mechanism such as a mutex?
Hi Simon, you've raised this issue in v2, and after discussion, you've agreed that this change doesn't belong in this patch series.
Not sure if I missed anything?
Quoted 14 lines
Quoted 13 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +4
-4-if (cmd->base.autoneg ==AUTONEG_ENABLE ) { +if (cmd->base.autoneg ==AUTONEG_ENABLE )igc_handle_autoneg_enabled (adapter, cmd); - }else { -netdev_info (dev,"Force mode currently not supported\n" ); - } +else +igc_handle_autoneg_disabled (adapter, cmd->base.speed, + cmd->base.duplex);/* MDI-X => 2; MDI => 1; Auto => 3 */ if (cmd->base.eth_tp_mdix_ctrl) {
Simon Horman
reviewerQuoted 111 lines · Faizal
Quoted 57 lines · Simon Horman
From: 'Simon Horman' <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://sashiko.dev
---
igc: add support for forcing link speed without autonegotiationThis commit allows users to force 10/100 Mb/s link speed and duplex via ethtool when autonegotiation is disabled. Previously, the driver rejected these requests.
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0[ ... ]
Quoted 27 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +23
-0@@ -2000,6 +2013,41 @@ static int igc_ethtool_get_link_ksettings(struct net_device *netdev,return 0 ; } +/** +* igc_handle_autoneg_disabled - Configure forced speed/duplex settings +* @adapter: private driver structure +* @speed: requested speed (must be SPEED_10 or SPEED_100) +* @duplex: requested duplex +* +* Records forced speed/duplex when autoneg is disabled. +* Caller must validate speed before calling this function. +*/ +static void igc_handle_autoneg_disabled (struct igc_adapter *adapter,u32 speed, +u8 duplex) +{ +struct igc_mac_info *mac = &adapter->hw.mac; + +switch (speed) { +case SPEED_10 : + mac->forced_speed_duplex = (duplex ==DUPLEX_FULL ) ? +IGC_FORCED_10F :IGC_FORCED_10H ; +break ; +case SPEED_100 : + mac->forced_speed_duplex = (duplex ==DUPLEX_FULL ) ? +IGC_FORCED_100F :IGC_FORCED_100H ; +break ;drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_get_link_ksettings(struct net_device *netdev, · line 2048
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +10
-0+default : +WARN_ONCE (1 ,"Unsupported speed %u\n" , speed); +return ; + } + + mac->autoneg_enabled = false; + +/* Half-duplex cannot support flow control per IEEE 802.3 */ +if (duplex !=DUPLEX_FULL ) + adapter->hw.fc.requested_mode = igc_fc_none;Does this permanently overwrite the user's flow control preference?
Quoted 9 lines
If half-duplex is requested,
requested_modeis set toigc_fc_none. Becauserequested_moderepresents the persistent state for the user's flow control preference, the user might permanently lose their configuration. If they later switch back to full-duplex,requested_moderemainsigc_fc_none, and flow control stays disabled.Would it be better to dynamically override
hw->fc.current_modetoigc_fc_noneduring link configuration instead of mutatingrequested_mode?Yes you're right, thanks, will update.
Quoted 20 lines
Quoted 1 line
drivers/net/ethernet/intel/igc/igc_ethtool.c +1
-0+}[ ... ]
drivers/net/ethernet/intel/igc/igc_ethtool.c igc_ethtool_set_link_ksettings(struct net_device *netdev, · line 2134
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +6
-0@@ -2071,14 +2126,20 @@ igc_ethtool_set_link_ksettings(struct net_device *netdev, } } +if (cmd->base.autoneg ==AUTONEG_DISABLE && + cmd->base.speed !=SPEED_10 && cmd->base.speed !=SPEED_100 ) { +netdev_info (dev,"Unsupported speed for forced link\n" ); +return -EINVAL ; + } +Should we also validate
cmd->base.duplexhere to prevent a fallback to half-duplex?If a user runs a command like "ethtool -s eth0 speed 100 autoneg off" while the link is down, ethtool queries and preserves the current duplex value, which is
DUPLEX_UNKNOWN(0xff).Quoted 5 lines
In
igc_handle_autoneg_disabled(), the code checks if duplex ==DUPLEX_FULL, which evaluates to false, and forces the interface to 100 Mbps half-duplex.Could we explicitly check that
cmd->base.duplexis eitherDUPLEX_HALForDUPLEX_FULLand return-EINVALotherwise?Will update.
Quoted 11 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c igc_ethtool_set_link_ksettings(struct net_device *netdev, · line 2136
Quoted 3 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0while (test_and_set_bit (__IGC_RESETTING, &adapter->state))usleep_range (1000 ,2000 );This isn't a bug introduced by this patch, but does this ad-hoc synchronization loop reimplement locking without fairness or lockdep support?
According to the Networking Subsystem Guidelines, using bit operations as a substitute for real locks violates core kernel locking rules and introduces potential races.
Quoted 7 lines
Quoted 2 lines
Could this be replaced with a proper concurrency mechanism such as a mutex?
Hi Simon, you've raised this issue in v2, and after discussion, you've agreed that this change doesn't belong in this patch series.
Not sure if I missed anything?
Sorry, my bad. I missed that we'd already covered this one.
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Forcing half-duplex permanently clobbers the user's flow control preference. - [High] Missing…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Forcing half-duplex permanently clobbers the user's flow control preference.
- [High] Missing validation for DUPLEX_UNKNOWN causes silent fallback to half-duplex.
- [High] Ad-hoc synchronization loop using bit flags instead of a proper lock. --
commit 8d7b28f68d024d026b38dde450a1a1adfbbf8daf
Author: Faizal Rahim <[email protected]>
igc: add support for forcing link speed without autonegotiation
This commit allows users to force 10/100 Mb/s link speed and duplex via ethtool when autonegotiation is disabled. Previously, the driver rejected these requests.
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0
[ ... ]
Quoted 27 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +23
-0@@ -2000,6 +2013,41 @@ static int igc_ethtool_get_link_ksettings(struct net_device *netdev,return 0 ; } +/** +* igc_handle_autoneg_disabled - Configure forced speed/duplex settings +* @adapter: private driver structure +* @speed: requested speed (must be SPEED_10 or SPEED_100) +* @duplex: requested duplex +* +* Records forced speed/duplex when autoneg is disabled. +* Caller must validate speed before calling this function. +*/ +static void igc_handle_autoneg_disabled (struct igc_adapter *adapter,u32 speed, +u8 duplex) +{ +struct igc_mac_info *mac = &adapter->hw.mac; + +switch (speed) { +case SPEED_10 : + mac->forced_speed_duplex = (duplex ==DUPLEX_FULL ) ? +IGC_FORCED_10F :IGC_FORCED_10H ; +break ; +case SPEED_100 : + mac->forced_speed_duplex = (duplex ==DUPLEX_FULL ) ? +IGC_FORCED_100F :IGC_FORCED_100H ; +break ;
drivers/net/ethernet/intel/igc/igc_ethtool.c static int igc_ethtool_get_link_ksettings(struct net_device *netdev, · line 2048
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +10
-0+default : +WARN_ONCE (1 ,"Unsupported speed %u\n" , speed); +return ; + } + + mac->autoneg_enabled = false; + +/* Half-duplex cannot support flow control per IEEE 802.3 */ +if (duplex !=DUPLEX_FULL ) + adapter->hw.fc.requested_mode = igc_fc_none;
Does this permanently overwrite the user's flow control preference?
If half-duplex is requested, requested_mode is set to igc_fc_none. Because requested_mode represents the persistent state for the user's flow control preference, the user might permanently lose their configuration. If they later switch back to full-duplex, requested_mode remains igc_fc_none, and flow control stays disabled.
Would it be better to dynamically override hw->fc.current_mode to igc_fc_none during link configuration instead of mutating requested_mode?
Quoted 1 line
drivers/net/ethernet/intel/igc/igc_ethtool.c +1
-0+}
[ ... ]
drivers/net/ethernet/intel/igc/igc_ethtool.c igc_ethtool_set_link_ksettings(struct net_device *netdev, · line 2134
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +6
-0@@ -2071,14 +2126,20 @@ igc_ethtool_set_link_ksettings(struct net_device *netdev, } } +if (cmd->base.autoneg ==AUTONEG_DISABLE && + cmd->base.speed !=SPEED_10 && cmd->base.speed !=SPEED_100 ) { +netdev_info (dev,"Unsupported speed for forced link\n" ); +return -EINVAL ; + } +
Should we also validate cmd->base.duplex here to prevent a fallback to half-duplex?
If a user runs a command like "ethtool -s eth0 speed 100 autoneg off" while the link is down, ethtool queries and preserves the current duplex value, which is DUPLEX_UNKNOWN (0xff).
In igc_handle_autoneg_disabled(), the code checks if duplex == DUPLEX_FULL, which evaluates to false, and forces the interface to 100 Mbps half-duplex.
Could we explicitly check that cmd->base.duplex is either DUPLEX_HALF or DUPLEX_FULL and return -EINVAL otherwise?
drivers/net/ethernet/intel/igc/igc_ethtool.c igc_ethtool_set_link_ksettings(struct net_device *netdev, · line 2136
Quoted 2 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +0
-0while (test_and_set_bit (__IGC_RESETTING, &adapter->state))usleep_range (1000 ,2000 );
This isn't a bug introduced by this patch, but does this ad-hoc synchronization loop reimplement locking without fairness or lockdep support?
According to the Networking Subsystem Guidelines, using bit operations as a substitute for real locks violates core kernel locking rules and introduces potential races.
Could this be replaced with a proper concurrency mechanism such as a mutex?
Quoted 13 lines
drivers/net/ethernet/intel/igc/igc_ethtool.c +4
-4-if (cmd->base.autoneg ==AUTONEG_ENABLE ) { +if (cmd->base.autoneg ==AUTONEG_ENABLE )igc_handle_autoneg_enabled (adapter, cmd); - }else { -netdev_info (dev,"Force mode currently not supported\n" ); - } +else +igc_handle_autoneg_disabled (adapter, cmd->base.speed, + cmd->base.duplex);/* MDI-X => 2; MDI => 1; Auto => 3 */ if (cmd->base.eth_tp_mdix_ctrl) {
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Quoted 4 lines · On Tue, 28 Apr 2026 14:00:06 +0800 KhaiWenTan <[email protected]>…
From: Faizal Rahim <[email protected]>
This series adds support for forcing 10/100 Mb/s link speed via ethtool when autonegotiation is disabled on the igc driver.
I'll ask 'why' ?
In particular forcing half/full duplex has always been a very good way of 'breaking' a network connection.
It really is much better to restrict the advertised link modes and let the autodetect/autonegotiation logic in the phy/mac do its job.
About the only think I can think of is to force 10M HDX when connected to a remote system that supports 10M/100M HDX.
In that case you need to send out single link test pulses, not the burst used to identify 100M HDX, or the pattern encoded on the burst used by autonegotiation.
But you need to got back to the mid 1990s to find such systems. Anything that supports FDX will do autonegotiation.
David
Quoted 46 lines
Changes in v4:
- Validate that autoneg isAUTONEG_ENABLEorAUTONEG_DISABLEearly inigc_ethtool_set_link_ksettings()to avoid passing unexpected values toigc_handle_autoneg_disabled(). (Simon Horman)Changes in v3:
- Modify condition from "if (duplex ==DUPLEX_HALF)" to "if (duplex !=DUPLEX_FULL)". (Simon Horman)Changes in v2:
- When forcing half-duplex, sethw->fc.requested_mode=igc_fc_none, since half-duplex cannot support flow control per IEEE 802.3. (Simon Horman)
- Split the original single patch into three patches for clarity:
patches 1 and 2 are preparatory cleanups; patch 3 carries the functional change.v3 at:
https://patchwork.ozlabs.org/project/intel-wired-lan/cover/[email protected]/v2 at:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/v1 at:
https://patchwork.ozlabs.org/project/intel-wired-lan/patch/[email protected]/Faizal Rahim (3):
igc: remove unusedautoneg_failedfield
igc: move autoneg-enabled settings intoigc_handle_autoneg_enabled()
igc: add support for forcing link speed without autonegotiationdrivers/net/ethernet/intel/igc/igc_base.c | 35 +++- drivers/net/ethernet/intel/igc/igc_defines.h | 9 +- drivers/net/ethernet/intel/igc/igc_ethtool.c | 209 +++++++++++++------ drivers/net/ethernet/intel/igc/igc_hw.h | 10 +- drivers/net/ethernet/intel/igc/igc_mac.c | 16 +- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- drivers/net/ethernet/intel/igc/igc_phy.c | 65 +++++- drivers/net/ethernet/intel/igc/igc_phy.h | 1 + 8 files changed, 257 insertions(+), 90 deletions(-)--
2.43.0
Quoted 24 lines · David Laight
Quoted 4 lines · On Tue, 28 Apr 2026 14:00:06 +0800 KhaiWenTan <[email protected]>…
From: Faizal Rahim <[email protected]>
This series adds support for forcing 10/100 Mb/s link speed via ethtool when autonegotiation is disabled on the igc driver.
I'll ask 'why' ?
In particular forcing half/full duplex has always been a very good way of 'breaking' a network connection.
It really is much better to restrict the advertised link modes and let the autodetect/autonegotiation logic in the phy/mac do its job.
About the only think I can think of is to force 10M HDX when connected to a remote system that supports 10M/100M HDX.
In that case you need to send out single link test pulses, not the burst used to identify 100M HDX, or the pattern encoded on the burst used by autonegotiation.
But you need to got back to the mid 1990s to find such systems. Anything that supports FDX will do autonegotiation.
Quoted 2 lines
David
There's a use case requested:
Profinet Certification tool reports that forcing a link speed without auto-negotiation is not working.
Forcing the link speed is a critical feature for the industrial automation "fast-start" use case. When there is a connection lost, the system must come back up as fast as possible. In PROFINET, that means to force the speed and rejoin the controller loops. Without supporting forcing the speed to 100M in Foxville, the certification tool would not be able to certify the availability of this feature.
I'm hoping this context is enough to justify the need?
Quoted 39 lines · Faizal
Quoted 24 lines · David Laight
Quoted 4 lines · On Tue, 28 Apr 2026 14:00:06 +0800 KhaiWenTan <[email protected]>…
From: Faizal Rahim <[email protected]>
This series adds support for forcing 10/100 Mb/s link speed via ethtool when autonegotiation is disabled on the igc driver.
I'll ask 'why' ?
In particular forcing half/full duplex has always been a very good way of 'breaking' a network connection.
It really is much better to restrict the advertised link modes and let the autodetect/autonegotiation logic in the phy/mac do its job.
About the only think I can think of is to force 10M HDX when connected to a remote system that supports 10M/100M HDX.
In that case you need to send out single link test pulses, not the burst used to identify 100M HDX, or the pattern encoded on the burst used by autonegotiation.
But you need to got back to the mid 1990s to find such systems. Anything that supports FDX will do autonegotiation.Quoted 2 lines
David
There's a use case requested:
Profinet Certification tool reports that forcing a link speed without auto-negotiation is not working.
Forcing the link speed is a critical feature for the industrial automation "fast-start" use case. When there is a connection lost, the system must come back up as fast as possible. In PROFINET, that means to force the speed and rejoin the controller loops. Without supporting forcing the speed to 100M in Foxville, the certification tool would not be able to certify the availability of this feature.
Quoted 1 line
I'm hoping this context is enough to justify the need?
Is auto-negotiation of the 'low' speed actually that slow?
IIRC detecting 10G and above requires a lot of signal processing. But 10/100 and hdx/fdx just uses the ANAR register value sent in the link test pulses.
(IIRC 1G uses the ANAR pattern, but requires extra signal processing as well. The higher speeds didn't exist when I was writing ethernet drivers.)
I've been on the 'wrong end' of hdx/fdx mismatches - you really don't want to let people get there, it is terribly confusing.
There actually ought to be a way of setting the auto-negotiation registers to 100M (HDX and/or FDX) and then transmitting as (say) 100M HDX even before negotiation completes.
Then correcting hdx/fdx based on the received ANAR register. Or, at least, sending out an ANAR that only contains what you are using.
The problem I always had was that the actual operating mode of the phy wasn't in one of the standard registers.
So if you connected to a system that didn't do auto-negotiation the phy would be using (say) 10M HDX, but the received ANAR register would still contain a value from an earlier connection.
If the driver read that register from the phy it used the wrong duplex mode. (The speed for 10/100 doesn't matter, the phy clocks the interface to the mac at the right speed and the mac doesn't care.)
David
+ Hector
Quoted 51 lines · David Laight
Quoted 39 lines · Faizal
Quoted 24 lines · David Laight
Quoted 4 lines · On Tue, 28 Apr 2026 14:00:06 +0800 KhaiWenTan <[email protected]>…
From: Faizal Rahim <[email protected]>
This series adds support for forcing 10/100 Mb/s link speed via ethtool when autonegotiation is disabled on the igc driver.
I'll ask 'why' ?
In particular forcing half/full duplex has always been a very good way of 'breaking' a network connection.
It really is much better to restrict the advertised link modes and let the autodetect/autonegotiation logic in the phy/mac do its job.
About the only think I can think of is to force 10M HDX when connected to a remote system that supports 10M/100M HDX.
In that case you need to send out single link test pulses, not the burst used to identify 100M HDX, or the pattern encoded on the burst used by autonegotiation.
But you need to got back to the mid 1990s to find such systems. Anything that supports FDX will do autonegotiation.Quoted 2 lines
David
There's a use case requested:
Profinet Certification tool reports that forcing a link speed without auto-negotiation is not working.
Forcing the link speed is a critical feature for the industrial automation "fast-start" use case. When there is a connection lost, the system must come back up as fast as possible. In PROFINET, that means to force the speed and rejoin the controller loops. Without supporting forcing the speed to 100M in Foxville, the certification tool would not be able to certify the availability of this feature.Quoted 1 line
I'm hoping this context is enough to justify the need?
Is auto-negotiation of the 'low' speed actually that slow?
IIRC detecting 10G and above requires a lot of signal processing. But 10/100 and hdx/fdx just uses the ANAR register value sent in the link test pulses.
(IIRC 1G uses the ANAR pattern, but requires extra signal processing as well. The higher speeds didn't exist when I was writing ethernet drivers.)
Quoted 3 lines
I've been on the 'wrong end' of hdx/fdx mismatches - you really don't want to let people get there, it is terribly confusing.
Thanks for the information.
I agree that for normal Ethernet use, auto-negotiation on both link partners is safer and avoids the issues you mentioned.
The reason for this patch is the more specific PROFINET Fast Start Up (FSU) use case. For FSU, the requirement is different from normal Ethernet use. It is intended for deterministic startup, for example in industrial robot/tool-change applications.
One of the startup optimizations is to use "fixed transmission parameters" instead of automatic detection in the profinet specification:
https://us.profinet.com/profinet_tech/fast-start-up/
I understand your point that 10/100 auto-negotiation is faster than higher-speed link training. I don't have a detailed timing breakdown for the FSU case comparing 10/100 startup with auto-negotiation enabled versus disabled, or enough visibility into the certification criteria to comment on additional determinism requirements.
But keeping AutoNeg enabled, even with only specific speed advertised, would not cover the same requirement.
This is only meant as an explicit link configuration for controlled industrial deployments where both link partners are configured consistently. It's not intended as a recommended default for general networking.
Also, ethtool already allows users to request speed/duplex configuration with auto-negotiation disabled, and some drivers already support this, for example igb. This patch just reuses that existing interface and enables igc to support the forced modes supported by this hardware.
Quoted 21 lines
There actually ought to be a way of setting the auto-negotiation registers to 100M (HDX and/or FDX) and then transmitting as (say) 100M HDX even before negotiation completes.
Then correcting hdx/fdx based on the received ANAR register. Or, at least, sending out an ANAR that only contains what you are using.The problem I always had was that the actual operating mode of the phy wasn't in one of the standard registers.
So if you connected to a system that didn't do auto-negotiation the phy would be using (say) 10M HDX, but the received ANAR register would still contain a value from an earlier connection.
If the driver read that register from the phy it used the wrong duplex mode. (The speed for 10/100 doesn't matter, the phy clocks the interface to the mac at the right speed and the mac doesn't care.)David
Quoted 11 lines
I agree that for normal Ethernet use, auto-negotiation on both link partners is safer and avoids the issues you mentioned.
The reason for this patch is the more specific PROFINET Fast Start Up (FSU) use case. For FSU, the requirement is different from normal Ethernet use. It is intended for deterministic startup, for example in industrial robot/tool-change applications.
One of the startup optimizations is to use "fixed transmission parameters" instead of automatic detection in the profinet specification:
https://us.profinet.com/profinet_tech/fast-start-up/
Automotive also have similar requirements. For them, Autoneg is slow, takes around 1 second, where as a fixed link is operative very fast. There are even some automotive ethernet devices which don't even support autoneg.
So this use case makes sense to me, for embedded systems. If the hardware can do it, any most PHYs can, i see no reason not to support it. And anything using phylib gets it for free.
Andrew