Commit 16b5e501 authored by Fuyun Liang's avatar Fuyun Liang Committed by David S. Miller

net: hns3: fix for getting autoneg in hns3_get_link_ksettings

This patch fixes a bug for ethtool's get_link_ksettings().
When phy exists, we should get autoneg from phy rather than from mac.
Because the value of mac.autoneg is invalid when phy exists.

Fixes: 496d03e9 (net: hns3: Add Ethtool support to HNS3 driver)
Signed-off-by: default avatarFuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: default avatarLipeng <lipeng321@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 739c5960
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/phy.h>
#include "hns3_enet.h" #include "hns3_enet.h"
...@@ -571,26 +572,25 @@ static int hns3_get_link_ksettings(struct net_device *netdev, ...@@ -571,26 +572,25 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
u32 advertised_caps; u32 advertised_caps;
u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN; u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN;
u8 link_stat; u8 link_stat;
u8 auto_neg;
u8 duplex;
u32 speed;
if (!h->ae_algo || !h->ae_algo->ops) if (!h->ae_algo || !h->ae_algo->ops)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* 1.auto_neg & speed & duplex from cmd */ /* 1.auto_neg & speed & duplex from cmd */
if (h->ae_algo->ops->get_ksettings_an_result) { if (netdev->phydev)
h->ae_algo->ops->get_ksettings_an_result(h, &auto_neg, phy_ethtool_ksettings_get(netdev->phydev, cmd);
&speed, &duplex); else if (h->ae_algo->ops->get_ksettings_an_result)
cmd->base.autoneg = auto_neg; h->ae_algo->ops->get_ksettings_an_result(h,
cmd->base.speed = speed; &cmd->base.autoneg,
cmd->base.duplex = duplex; &cmd->base.speed,
&cmd->base.duplex);
link_stat = hns3_get_link(netdev); else
if (!link_stat) { return -EOPNOTSUPP;
cmd->base.speed = (u32)SPEED_UNKNOWN;
cmd->base.duplex = DUPLEX_UNKNOWN; link_stat = hns3_get_link(netdev);
} if (!link_stat) {
cmd->base.speed = SPEED_UNKNOWN;
cmd->base.duplex = DUPLEX_UNKNOWN;
} }
/* 2.media_type get from bios parameter block */ /* 2.media_type get from bios parameter block */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment