Commit bb7189dc authored by Qianqian Xie's avatar Qianqian Xie Committed by David S. Miller

net: hns: fix the wrong speed for bond

For debug-ports,there are two non-synchronized processes:
Speed-Auto-Negotiation and Link-Update-Status. The two
processes are towed by two different state machines.
Bond reads the speed when link up, but the speed maybe
not update the right value at that time.That make for bond's
wrong speed. Thus only one state machine should be used and
if phy_state_machine is used, it does not need to do
hns_nic_update_link_status().
Signed-off-by: default avatarQianqian Xie <xieqianqian@huawei.com>
Signed-off-by: default avatarYisen Zhuang <Yisen.Zhuang@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cba80bde
...@@ -991,8 +991,26 @@ static void hns_nic_adjust_link(struct net_device *ndev) ...@@ -991,8 +991,26 @@ static void hns_nic_adjust_link(struct net_device *ndev)
{ {
struct hns_nic_priv *priv = netdev_priv(ndev); struct hns_nic_priv *priv = netdev_priv(ndev);
struct hnae_handle *h = priv->ae_handle; struct hnae_handle *h = priv->ae_handle;
int state = 1;
if (priv->phy) {
h->dev->ops->adjust_link(h, ndev->phydev->speed,
ndev->phydev->duplex);
state = priv->phy->link;
}
state = state && h->dev->ops->get_status(h);
h->dev->ops->adjust_link(h, ndev->phydev->speed, ndev->phydev->duplex); if (state != priv->link) {
if (state) {
netif_carrier_on(ndev);
netif_tx_wake_all_queues(ndev);
netdev_info(ndev, "link up\n");
} else {
netif_carrier_off(ndev);
netdev_info(ndev, "link down\n");
}
priv->link = state;
}
} }
/** /**
...@@ -1577,27 +1595,14 @@ static void hns_nic_update_link_status(struct net_device *netdev) ...@@ -1577,27 +1595,14 @@ static void hns_nic_update_link_status(struct net_device *netdev)
struct hns_nic_priv *priv = netdev_priv(netdev); struct hns_nic_priv *priv = netdev_priv(netdev);
struct hnae_handle *h = priv->ae_handle; struct hnae_handle *h = priv->ae_handle;
int state = 1;
if (priv->phy) { if (h->phy_dev) {
if (!genphy_update_link(priv->phy)) if (h->phy_if != PHY_INTERFACE_MODE_XGMII)
state = priv->phy->link; return;
else
state = 0;
}
state = state && h->dev->ops->get_status(h);
if (state != priv->link) { (void)genphy_read_status(h->phy_dev);
if (state) {
netif_carrier_on(netdev);
netif_tx_wake_all_queues(netdev);
netdev_info(netdev, "link up\n");
} else {
netif_carrier_off(netdev);
netdev_info(netdev, "link down\n");
}
priv->link = state;
} }
hns_nic_adjust_link(netdev);
} }
/* for dumping key regs*/ /* for dumping key regs*/
......
...@@ -49,7 +49,7 @@ static u32 hns_nic_get_link(struct net_device *net_dev) ...@@ -49,7 +49,7 @@ static u32 hns_nic_get_link(struct net_device *net_dev)
h = priv->ae_handle; h = priv->ae_handle;
if (priv->phy) { if (priv->phy) {
if (!genphy_update_link(priv->phy)) if (!genphy_read_status(priv->phy))
link_stat = priv->phy->link; link_stat = priv->phy->link;
else else
link_stat = 0; link_stat = 0;
......
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