Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp724599pxb; Tue, 2 Feb 2021 16:47:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvLlbMuIxmcfQMoB8CkOqsB48++iw37t+sxslNXnf1BGfXAiLefkN9CAdB0uvSrcoHL7lU X-Received: by 2002:a17:906:ca04:: with SMTP id jt4mr629235ejb.548.1612313227945; Tue, 02 Feb 2021 16:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313227; cv=none; d=google.com; s=arc-20160816; b=iEYEmMuIxKHA5DKakv4ctdG7xS+VDXQXPcR8Y8zBqqX9TOLV23KA+Y34KlsrBAit6G zgG2x+eFXpMvi6ke7KQIf+k+xBjoNsBpgtuxuaXo9r9Q6tXdRLDZa/wx0qzG4tFAcm9G 7+dOj9zqEkszB+NjbIXTvBr4xXR7BITkYWj76jG6yboHQ/QWg5jkHFFiwuI/l0IiVmuF 3HUz496EPOGQa+LpgbNscjYE5kjvjV/woSWB5RgZy3pU/5HwZFp8MnjJQGBfS0Q5dNJv bCViZ3uDNcJHVnYUyz+F426Jx27LVcvdgID9GH3SJZTfM6Y9+nME3GsKLbWCF5V+J/V9 4g4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HtkM1RHltzSawXXfbJbqHCiWbHQcozH2QNRRyzthNzk=; b=UJ/btcxYO7cokbiXhn5O61/5WW24eAHl5Pmqhx9M875UyMfartI4Kk3+3l+0CRE+f3 suYqV5R6OH6HPnOSPoRh5+QEZiKdTCHq8uERm0q+L6ylywKoM5iYPjl3gEx5pbjZeCH7 nIEbQ/1nvNDVY2lgvQqv0SbOX4J/o/ZHOt8d2Mo81JjMgUyy2tw7njc3M3GG+Oy9tldx tD4gfKbIAv5U9eYWeQ/x7cta2SqKnoU1gF8Bm3ipHzgvTHjIKQyfhWRz0BqYTyGJSAda MBcO+xSvOHeQ3UmuEm0zDa5048EhBGmT5/T6rwr93k5xfD/6UZNeU4jHh2Bpz/awRqdE eS1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JDsc2R0L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a12si222205edn.568.2021.02.02.16.46.43; Tue, 02 Feb 2021 16:47:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JDsc2R0L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233340AbhBBTdg (ORCPT + 99 others); Tue, 2 Feb 2021 14:33:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:43136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232944AbhBBN5R (ORCPT ); Tue, 2 Feb 2021 08:57:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A899264FE7; Tue, 2 Feb 2021 13:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273541; bh=CGjqQu1nAq5BP/GMotpZSO4w6Zbgf4Zz1tLHJmwVTlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JDsc2R0LWXHavOcYNlUl0aMrLogZbAXhK52zMJmCwM4XZpdGTbjIe68wLz2tAdgqw lSBTfcoTtit7WyVW05hDABNU6j3AdknaFNBdB/mKcytEpiYdJmKArL5wjr0mYMpjfC PHNZPycbG9zQ+FCQIOLAJ/NG+heAl+6E+KkhrEYA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Corinna Vinschen , Tony Nguyen , Sasha Levin Subject: [PATCH 5.10 113/142] igc: fix link speed advertising Date: Tue, 2 Feb 2021 14:37:56 +0100 Message-Id: <20210202133002.370719228@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corinna Vinschen [ Upstream commit 329a3678ec69962aa67c91397efbd46d36635f91 ] Link speed advertising in igc has two problems: - When setting the advertisement via ethtool, the link speed is converted to the legacy 32 bit representation for the intel PHY code. This inadvertently drops ETHTOOL_LINK_MODE_2500baseT_Full_BIT (being beyond bit 31). As a result, any call to `ethtool -s ...' drops the 2500Mbit/s link speed from the PHY settings. Only reloading the driver alleviates that problem. Fix this by converting the ETHTOOL_LINK_MODE_2500baseT_Full_BIT to the Intel PHY ADVERTISE_2500_FULL bit explicitly. - Rather than checking the actual PHY setting, the .get_link_ksettings function always fills link_modes.advertising with all link speeds the device is capable of. Fix this by checking the PHY autoneg_advertised settings and report only the actually advertised speeds up to ethtool. Fixes: 8c5ad0dae93c ("igc: Add ethtool support") Signed-off-by: Corinna Vinschen Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igc/igc_ethtool.c | 24 +++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c index 61d331ce38cdd..831f2f09de5fb 100644 --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c @@ -1675,12 +1675,18 @@ static int igc_ethtool_get_link_ksettings(struct net_device *netdev, cmd->base.phy_address = hw->phy.addr; /* advertising link modes */ - ethtool_link_ksettings_add_link_mode(cmd, advertising, 10baseT_Half); - ethtool_link_ksettings_add_link_mode(cmd, advertising, 10baseT_Full); - ethtool_link_ksettings_add_link_mode(cmd, advertising, 100baseT_Half); - ethtool_link_ksettings_add_link_mode(cmd, advertising, 100baseT_Full); - ethtool_link_ksettings_add_link_mode(cmd, advertising, 1000baseT_Full); - ethtool_link_ksettings_add_link_mode(cmd, advertising, 2500baseT_Full); + if (hw->phy.autoneg_advertised & ADVERTISE_10_HALF) + ethtool_link_ksettings_add_link_mode(cmd, advertising, 10baseT_Half); + if (hw->phy.autoneg_advertised & ADVERTISE_10_FULL) + ethtool_link_ksettings_add_link_mode(cmd, advertising, 10baseT_Full); + if (hw->phy.autoneg_advertised & ADVERTISE_100_HALF) + ethtool_link_ksettings_add_link_mode(cmd, advertising, 100baseT_Half); + if (hw->phy.autoneg_advertised & ADVERTISE_100_FULL) + ethtool_link_ksettings_add_link_mode(cmd, advertising, 100baseT_Full); + if (hw->phy.autoneg_advertised & ADVERTISE_1000_FULL) + ethtool_link_ksettings_add_link_mode(cmd, advertising, 1000baseT_Full); + if (hw->phy.autoneg_advertised & ADVERTISE_2500_FULL) + ethtool_link_ksettings_add_link_mode(cmd, advertising, 2500baseT_Full); /* set autoneg settings */ if (hw->mac.autoneg == 1) { @@ -1792,6 +1798,12 @@ igc_ethtool_set_link_ksettings(struct net_device *netdev, ethtool_convert_link_mode_to_legacy_u32(&advertising, cmd->link_modes.advertising); + /* Converting to legacy u32 drops ETHTOOL_LINK_MODE_2500baseT_Full_BIT. + * We have to check this and convert it to ADVERTISE_2500_FULL + * (aka ETHTOOL_LINK_MODE_2500baseX_Full_BIT) explicitly. + */ + if (ethtool_link_ksettings_test_link_mode(cmd, advertising, 2500baseT_Full)) + advertising |= ADVERTISE_2500_FULL; if (cmd->base.autoneg == AUTONEG_ENABLE) { hw->mac.autoneg = 1; -- 2.27.0