net/txgbe: fix link status when device stopped
authorJiawen Wu <jiawenwu@trustnetic.com>
Thu, 12 Aug 2021 02:00:18 +0000 (10:00 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 18 Aug 2021 14:04:09 +0000 (16:04 +0200)
When device is stopped, the port status is not changed and only the Tx
laser is turned off by hardware design.

Fixes: 0c061eadec59 ("net/txgbe: add link status change")
Cc: stable@dpdk.org
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
drivers/net/txgbe/base/txgbe_type.h
drivers/net/txgbe/txgbe_ethdev.c
drivers/net/txgbe/txgbe_ethdev_vf.c

index 823c675..d95467f 100644 (file)
@@ -781,6 +781,7 @@ struct txgbe_hw {
        int api_version;
        bool allow_unsupported_sfp;
        bool need_crosstalk_fix;
+       bool dev_start;
        struct txgbe_devargs devarg;
 
        uint64_t isb_dma;
index e626755..0063994 100644 (file)
@@ -1664,6 +1664,7 @@ txgbe_dev_start(struct rte_eth_dev *dev)
                return -1;
        hw->mac.start_hw(hw);
        hw->mac.get_link_status = true;
+       hw->dev_start = true;
 
        /* configure PF module if SRIOV enabled */
        txgbe_pf_host_configure(dev);
@@ -1933,6 +1934,7 @@ txgbe_dev_stop(struct rte_eth_dev *dev)
 
        hw->adapter_stopped = true;
        dev->data->dev_started = 0;
+       hw->dev_start = false;
 
        return 0;
 }
@@ -2735,6 +2737,8 @@ txgbe_dev_link_update_share(struct rte_eth_dev *dev,
                                txgbe_dev_setup_link_alarm_handler, dev);
                }
                return rte_eth_linkstatus_set(dev, &link);
+       } else if (!hw->dev_start) {
+               return rte_eth_linkstatus_set(dev, &link);
        }
 
        intr->flags &= ~TXGBE_FLAG_NEED_LINK_CONFIG;
index 0bae6ff..18ed94b 100644 (file)
@@ -628,6 +628,7 @@ txgbevf_dev_start(struct rte_eth_dev *dev)
                return err;
        }
        hw->mac.get_link_status = true;
+       hw->dev_start = true;
 
        /* negotiate mailbox API version to use with the PF. */
        txgbevf_negotiate_api(hw);
@@ -749,6 +750,7 @@ txgbevf_dev_stop(struct rte_eth_dev *dev)
        }
 
        adapter->rss_reta_updated = 0;
+       hw->dev_start = false;
 
        return 0;
 }