net/mrvl: query link status using library API
authorTomasz Duszynski <tdu@semihalf.com>
Tue, 5 Dec 2017 09:39:17 +0000 (10:39 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
Up to now link status was updated unconditionally during
link_up()/link_down() calls thus one was never sure about
it's true status.

Using dedicated library API makes sure the true link status is set.

Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
Acked-by: Jianbo Liu <jianbo.liu@arm.com>
drivers/net/mrvl/mrvl_ethdev.c

index a1ae2c1..47f12b8 100644 (file)
@@ -361,8 +361,6 @@ mrvl_dev_set_link_up(struct rte_eth_dev *dev)
        if (ret)
                pp2_ppio_disable(priv->ppio);
 
-       dev->data->dev_link.link_status = ETH_LINK_UP;
-
        return ret;
 }
 
@@ -379,15 +377,8 @@ static int
 mrvl_dev_set_link_down(struct rte_eth_dev *dev)
 {
        struct mrvl_priv *priv = dev->data->dev_private;
-       int ret;
-
-       ret = pp2_ppio_disable(priv->ppio);
-       if (ret)
-               return ret;
-
-       dev->data->dev_link.link_status = ETH_LINK_DOWN;
 
-       return ret;
+       return pp2_ppio_disable(priv->ppio);
 }
 
 /**
@@ -628,9 +619,10 @@ mrvl_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
         * TODO
         * once MUSDK provides necessary API use it here
         */
+       struct mrvl_priv *priv = dev->data->dev_private;
        struct ethtool_cmd edata;
        struct ifreq req;
-       int ret, fd;
+       int ret, fd, link_up;
 
        edata.cmd = ETHTOOL_GSET;
 
@@ -670,6 +662,8 @@ mrvl_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
                                                         ETH_LINK_HALF_DUPLEX;
        dev->data->dev_link.link_autoneg = edata.autoneg ? ETH_LINK_AUTONEG :
                                                           ETH_LINK_FIXED;
+       pp2_ppio_get_link_state(priv->ppio, &link_up);
+       dev->data->dev_link.link_status = link_up ? ETH_LINK_UP : ETH_LINK_DOWN;
 
        return 0;
 }