nvethernet: Call netif_carrier_on/off based on PHY link

Issue: When configuring loopback mode, netif_carrier_on/off
       APIs are directly used i.e, netif_carrier_on when
       loopback mode enabled, netif_carrier_off when
       loopback mode is disabled. If anyone enables/disables
       loopback mode when link is alreay up, then link is
       not restored. Stack is not sending packets due
       to netif_carrier_off.
Fix:   Check PHY link status before calling netif_carrier_*
       APIs. If link is up, then PHY framework would have
       already invoked these APIs.

Bug 200512681

Change-Id: I1e07df202a8915737be8992f838aa5bd5534c512
Signed-off-by: Srinivas Ramachandran <srinivasra@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2267401
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-by: Narayan Reddy <narayanr@nvidia.com>
Reviewed-by: Ashutosh Jha <ajha@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Srinivas Ramachandran
2019-12-22 21:53:18 -08:00
committed by Revanth Kumar Uppala
parent 4901365614
commit 20e4a2fb7a
2 changed files with 34 additions and 4 deletions

View File

@@ -598,6 +598,7 @@ static int ether_config_loopback_mode(struct net_device *ndev,
unsigned int flags)
{
struct ether_priv_data *pdata = netdev_priv(ndev);
struct phy_device *phydev = ndev->phydev;
struct osi_core_priv_data *osi_core = pdata->osi_core;
int ret = 0;
@@ -608,7 +609,14 @@ static int ether_config_loopback_mode(struct net_device *ndev,
}
if (flags) {
netif_carrier_on(ndev);
if (!phydev->link) {
/* If no phy link, then turn on carrier explicitly so
* that nw stack can send packets. If PHY link is
* present, PHY framework would have already taken care
* of netif_carrier_* status.
*/
netif_carrier_on(ndev);
}
ret = osi_config_mac_loopback(osi_core, OSI_ENABLE);
if (ret < 0) {
dev_err(pdata->dev,
@@ -618,7 +626,14 @@ static int ether_config_loopback_mode(struct net_device *ndev,
dev_info(pdata->dev, "MAC loopback enabled\n");
}
} else {
netif_carrier_off(ndev);
if (!phydev->link) {
/* If no phy link, then turn off carrier explicitly so
* that nw stack doesn't send packets. If PHY link is
* present, PHY framework would have already taken care
* of netif_carrier_* status.
*/
netif_carrier_off(ndev);
}
ret = osi_config_mac_loopback(osi_core, OSI_DISABLE);
if (ret < 0) {
dev_err(pdata->dev,