net/axgbe: add link status update
authorRavi Kumar <ravi1.kumar@amd.com>
Fri, 6 Apr 2018 12:36:45 +0000 (08:36 -0400)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 13 Apr 2018 22:41:44 +0000 (00:41 +0200)
Added support to update device link status atomically.

Signed-off-by: Ravi Kumar <ravi1.kumar@amd.com>
doc/guides/nics/features/axgbe.ini
drivers/net/axgbe/axgbe_ethdev.c

index f644128..2dbff18 100644 (file)
@@ -5,6 +5,7 @@
 ;
 [Features]
 Speed capabilities   = Y
+Link status          = Y
 Jumbo frame          = Y
 RSS hash             = Y
 CRC offload          = Y
index 5f7de9f..defe54b 100644 (file)
@@ -15,6 +15,8 @@ static int  axgbe_dev_start(struct rte_eth_dev *dev);
 static void axgbe_dev_stop(struct rte_eth_dev *dev);
 static void axgbe_dev_interrupt_handler(void *param);
 static void axgbe_dev_close(struct rte_eth_dev *dev);
+static int axgbe_dev_link_update(struct rte_eth_dev *dev,
+                                int wait_to_complete);
 static void axgbe_dev_info_get(struct rte_eth_dev *dev,
                               struct rte_eth_dev_info *dev_info);
 
@@ -71,6 +73,7 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = {
        .dev_start            = axgbe_dev_start,
        .dev_stop             = axgbe_dev_stop,
        .dev_close            = axgbe_dev_close,
+       .link_update          = axgbe_dev_link_update,
        .dev_infos_get        = axgbe_dev_info_get,
        .rx_queue_setup       = axgbe_dev_rx_queue_setup,
        .rx_queue_release     = axgbe_dev_rx_queue_release,
@@ -216,6 +219,33 @@ axgbe_dev_close(struct rte_eth_dev *dev)
        axgbe_dev_clear_queues(dev);
 }
 
+/* return 0 means link status changed, -1 means not changed */
+static int
+axgbe_dev_link_update(struct rte_eth_dev *dev,
+                     int wait_to_complete __rte_unused)
+{
+       struct axgbe_port *pdata = dev->data->dev_private;
+       struct rte_eth_link link;
+       int ret = 0;
+
+       PMD_INIT_FUNC_TRACE();
+       rte_delay_ms(800);
+
+       pdata->phy_if.phy_status(pdata);
+
+       memset(&link, 0, sizeof(struct rte_eth_link));
+       link.link_duplex = pdata->phy.duplex;
+       link.link_status = pdata->phy_link;
+       link.link_speed = pdata->phy_speed;
+       link.link_autoneg = !(dev->data->dev_conf.link_speeds &
+                             ETH_LINK_SPEED_FIXED);
+       ret = rte_eth_linkstatus_set(dev, &link);
+       if (ret == -1)
+               PMD_DRV_LOG(ERR, "No change in link status\n");
+
+       return ret;
+}
+
 static void
 axgbe_dev_info_get(struct rte_eth_dev *dev,
                   struct rte_eth_dev_info *dev_info)