From: Simon Horman <horms@kernel.org>
To: KhaiWenTan <khai.wen.tan@linux.intel.com>
Cc: anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com,
intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, faizal.abdul.rahim@intel.com,
hong.aun.looi@intel.com, khai.wen.tan@intel.com,
Faizal Rahim <faizal.abdul.rahim@linux.intel.com>,
Looi
Subject: Re: [PATCH iwl-next v3 3/3] igc: add support for forcing link speed without autonegotiation
Date: Fri, 24 Apr 2026 14:59:58 +0100 [thread overview]
Message-ID: <20260424135958.GL900403@horms.kernel.org> (raw)
In-Reply-To: <20260422155701.7420-4-khai.wen.tan@linux.intel.com>
On Wed, Apr 22, 2026 at 11:57:01PM +0800, KhaiWenTan wrote:
> From: Faizal Rahim <faizal.abdul.rahim@linux.intel.com>
>
> 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.
>
> Reviewed-by: Looi, Hong Aun <hong.aun.looi@intel.com>
> Signed-off-by: Faizal Rahim <faizal.abdul.rahim@linux.intel.com>
> Signed-off-by: KhaiWenTan <khai.wen.tan@linux.intel.com>
...
> diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
...
> @@ -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;
> + 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;
> +}
> +
> /**
> * igc_handle_autoneg_enabled - Configure autonegotiation advertisement
> * @adapter: private driver structure
> @@ -2038,6 +2086,7 @@ static void igc_handle_autoneg_enabled(struct igc_adapter *adapter,
> 10baseT_Half))
> advertised |= ADVERTISE_10_HALF;
>
> + hw->mac.autoneg_enabled = true;
> hw->phy.autoneg_advertised = advertised;
> if (adapter->fc_autoneg)
> hw->fc.requested_mode = igc_fc_default;
> @@ -2071,14 +2120,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;
> + }
The condition above verifies speed only if autoneg is AUTONEG_DISABLE.
> +
> while (test_and_set_bit(__IGC_RESETTING, &adapter->state))
> usleep_range(1000, 2000);
>
> - 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);
But here igc_handle_autoneg_disabled, which relies on speed having been
verified, is called if autoneg is not AUTONEG_ENABLE.
If autoneg is AUTONEG_DISABLE here, then all is good.
But if it is neither AUTONEG_DISABLE nor AUTONEG_ENABLE then we
are in trouble.
I suggest verifying autoneg is either AUTONEG_ENABLE or AUTONEG_DISABLE
earlier in this function.
The above is based on my analysis of review AI generated review from Sashiko.
I believe that addressing autoneg verification address the review by
Sashiko that is relevant to the progress of this patch.
...
prev parent reply other threads:[~2026-04-24 14:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 15:56 [PATCH iwl-next v3 0/3] igc: add support for forcing link speed without autonegotiation KhaiWenTan
2026-04-22 15:56 ` [PATCH iwl-next v3 1/3] igc: remove unused autoneg_failed field KhaiWenTan
2026-04-22 15:57 ` [PATCH iwl-next v3 2/3] igc: move autoneg-enabled settings into igc_handle_autoneg_enabled() KhaiWenTan
2026-04-22 15:57 ` [PATCH iwl-next v3 3/3] igc: add support for forcing link speed without autonegotiation KhaiWenTan
2026-04-24 13:59 ` Simon Horman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260424135958.GL900403@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=faizal.abdul.rahim@intel.com \
--cc=faizal.abdul.rahim@linux.intel.com \
--cc=hong.aun.looi@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=khai.wen.tan@intel.com \
--cc=khai.wen.tan@linux.intel.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox