From: Fuyun Liang <liangfuy...@huawei.com>

[ Upstream commit 2b39cabb2a283cea0c3d96d9370575371726164f ]

This patch fixes a bug for ethtool's get_link_ksettings().
The advertising for autoneg is always added to advertised_caps
whether autoneg is enable or disable. This patch fixes it.

Fixes: 496d03e (net: hns3: Add Ethtool support to HNS3 driver)
Signed-off-by: Fuyun Liang <liangfuy...@huawei.com>
Signed-off-by: Lipeng <lipeng...@huawei.com>
Signed-off-by: David S. Miller <da...@davemloft.net>
Signed-off-by: Sasha Levin <alexander.le...@verizon.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index d636399232fb..e590d96e434a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -375,6 +375,9 @@ static int hns3_get_link_ksettings(struct net_device 
*netdev,
                        break;
                }
 
+               if (!cmd->base.autoneg)
+                       advertised_caps &= ~HNS3_LM_AUTONEG_BIT;
+
                /* now, map driver link modes to ethtool link modes */
                hns3_driv_to_eth_caps(supported_caps, cmd, false);
                hns3_driv_to_eth_caps(advertised_caps, cmd, true);
-- 
2.11.0

Reply via email to